Skip to content

Commit 4054f2b

Browse files
GET /licenses/hubPOST /licenses/hub/prod
1 parent 3078b9f commit 4054f2b

File tree

2 files changed

+76
-53
lines changed

2 files changed

+76
-53
lines changed

assets/js/hubce.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// requires newsletter.js
44
const VERIFY_EMAIL_URL = API_BASE_URL + '/connect/email/verify';
5-
const GET_LICENSE_URL = API_BASE_URL + '/licenses/hub';
5+
const CLAIM_LICENSE_URL = API_BASE_URL + '/licenses/hub/prod';
66

77
class HubCE {
88

@@ -17,6 +17,15 @@ class HubCE {
1717
if (searchParams.get('verifiedEmail')) {
1818
feedbackData.currentStep = 2;
1919
feedbackData.success = true;
20+
}
21+
}
22+
23+
submit() {
24+
if (this._feedbackData.currentStep === 0) {
25+
this.validateEmail();
26+
} else if (this._feedbackData.currentStep === 1) {
27+
this.sendConfirmationEmail();
28+
} else if (this._feedbackData.currentStep === 2) {
2029
this.getHubLicense();
2130
}
2231
}
@@ -73,10 +82,11 @@ class HubCE {
7382

7483
getHubLicense() {
7584
$.ajax({
76-
url: GET_LICENSE_URL,
77-
type: 'GET',
85+
url: CLAIM_LICENSE_URL,
86+
type: 'POST',
7887
data: {
79-
hubId: this._submitData.hubId
88+
hubId: this._submitData.hubId,
89+
captcha: this._submitData.captcha
8090
}
8191
}).done(response => {
8292
this._feedbackData.licenseText = response;

layouts/hub-register/single.html

Lines changed: 62 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -8,59 +8,70 @@ <h1 class="font-h1 mb-8">{{ .Title }}</h1>
88
<p class="lead">{{ i18n "hub_ce_registration_description" }}</p>
99
</header>
1010

11-
<form x-ref="form" @submit.prevent="hubCE.sendConfirmationEmail(); $refs.captcha.reset()">
12-
<section class="white-box md:min-h-110 px-4 py-5 md:p-6 md:grid md:grid-cols-3 md:gap-6">
13-
<header class="mb-8 md:col-span-1 md:mt-4">
14-
<nav class="flex items-center justify-center gap-6" aria-label="Progress">
15-
<p class="font-p text-sm text-gray-500 md:hidden">
16-
{{ i18n "hub_ce_registration_steps_title" | safeHTML }}
17-
</p>
18-
<ol role="list" class="flex items-center gap-3 md:flex-col md:items-start md:gap-6">
19-
<template x-for="(step, index) in steps" :key="index">
20-
<li>
21-
<!-- Complete Step -->
22-
<template x-if="index < feedbackData.currentStep">
23-
<a href="#" class="group" @click.prevent="feedbackData.currentStep = index" :data-umami-event="`hub-managed-nav-step-${index + 1}`">
24-
<span class="flex items-center gap-3">
25-
<div class="relative flex w-5 h-5 shrink-0 items-center justify-center">
26-
<svg class="w-full h-full text-primary group-hover:text-secondary" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
27-
<path fill-rule="evenodd" d="M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16Zm3.857-9.809a.75.75 0 0 0-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 1 0-1.06 1.061l2.5 2.5a.75.75 0 0 0 1.137-.089l4-5.5Z" clip-rule="evenodd" />
28-
</svg>
29-
</div>
30-
<p class="hidden md:block font-p text-sm text-gray-500 group-hover:text-gray-900" x-text="step"></p>
31-
</span>
32-
</a>
33-
</template>
3411

35-
<!-- Current Step -->
36-
<template x-if="index === feedbackData.currentStep">
37-
<div class="flex items-center gap-3" aria-current="step">
38-
<div class="relative flex w-5 h-5 shrink-0 items-center justify-center" aria-hidden="true">
39-
<span class="absolute w-4 h-4 rounded-full bg-primary-l2"></span>
40-
<span class="relative block w-2 h-2 rounded-full bg-primary"></span>
12+
<section class="white-box md:min-h-110 px-4 py-5 md:p-6 md:grid md:grid-cols-3 md:gap-6">
13+
<header class="mb-8 md:col-span-1 md:mt-4">
14+
<nav class="flex items-center justify-center gap-6" aria-label="Progress">
15+
<p class="font-p text-sm text-gray-500 md:hidden">
16+
{{ i18n "hub_ce_registration_steps_title" | safeHTML }}
17+
</p>
18+
<ol role="list" class="flex items-center gap-3 md:flex-col md:items-start md:gap-6">
19+
<template x-for="(step, index) in steps" :key="index">
20+
<li>
21+
<!-- Complete Step -->
22+
<template x-if="index < feedbackData.currentStep &amp;&amp; !feedbackData.success">
23+
<a href="#" class="group" @click.prevent="feedbackData.currentStep = index" :data-umami-event="`hub-managed-nav-step-${index + 1}`">
24+
<span class="flex items-center gap-3">
25+
<div class="relative flex w-5 h-5 shrink-0 items-center justify-center">
26+
<svg class="w-full h-full text-primary group-hover:text-secondary" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
27+
<path fill-rule="evenodd" d="M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16Zm3.857-9.809a.75.75 0 0 0-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 1 0-1.06 1.061l2.5 2.5a.75.75 0 0 0 1.137-.089l4-5.5Z" clip-rule="evenodd" />
28+
</svg>
4129
</div>
42-
<p class="hidden md:block font-p text-sm font-medium text-primary" x-text="step"></p>
30+
<p class="hidden md:block font-p text-sm text-gray-500 group-hover:text-gray-900" x-text="step"></p>
31+
</span>
32+
</a>
33+
</template>
34+
<template x-if="index < feedbackData.currentStep &amp;&amp; feedbackData.success">
35+
<span class="flex items-center gap-3">
36+
<div class="relative flex w-5 h-5 shrink-0 items-center justify-center">
37+
<svg class="w-full h-full text-primary group-hover:text-secondary" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
38+
<path fill-rule="evenodd" d="M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16Zm3.857-9.809a.75.75 0 0 0-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 1 0-1.06 1.061l2.5 2.5a.75.75 0 0 0 1.137-.089l4-5.5Z" clip-rule="evenodd" />
39+
</svg>
4340
</div>
44-
</template>
41+
<p class="hidden md:block font-p text-sm text-gray-500 group-hover:text-gray-900" x-text="step"></p>
42+
</span>
43+
</template>
4544

46-
<!-- Upcoming Step -->
47-
<template x-if="index > feedbackData.currentStep">
48-
<div class="flex items-center gap-3">
49-
<div class="relative flex w-5 h-5 shrink-0 items-center justify-center" aria-hidden="true">
50-
<div class="w-2 h-2 rounded-full bg-gray-300"></div>
51-
</div>
52-
<p class="hidden md:block font-p text-sm text-gray-500" x-text="step"></p>
45+
<!-- Current Step -->
46+
<template x-if="index === feedbackData.currentStep">
47+
<div class="flex items-center gap-3" aria-current="step">
48+
<div class="relative flex w-5 h-5 shrink-0 items-center justify-center" aria-hidden="true">
49+
<span class="absolute w-4 h-4 rounded-full bg-primary-l2"></span>
50+
<span class="relative block w-2 h-2 rounded-full bg-primary"></span>
51+
</div>
52+
<p class="hidden md:block font-p text-sm font-medium text-primary" x-text="step"></p>
53+
</div>
54+
</template>
55+
56+
<!-- Upcoming Step -->
57+
<template x-if="index > feedbackData.currentStep">
58+
<div class="flex items-center gap-3">
59+
<div class="relative flex w-5 h-5 shrink-0 items-center justify-center" aria-hidden="true">
60+
<div class="w-2 h-2 rounded-full bg-gray-300"></div>
5361
</div>
54-
</template>
55-
</li>
56-
</template>
57-
</ol>
58-
</nav>
59-
</header>
62+
<p class="hidden md:block font-p text-sm text-gray-500" x-text="step"></p>
63+
</div>
64+
</template>
65+
</li>
66+
</template>
67+
</ol>
68+
</nav>
69+
</header>
6070

71+
<form x-ref="form" class="md:col-span-2" @submit.prevent="hubCE.submit(); $refs.captcha.reset()">
6172
<!-- Step 1: Email Address -->
6273
<template x-if="feedbackData.currentStep == 0">
63-
<div class="md:col-span-2 grid grid-cols-6 gap-6">
74+
<div class="grid grid-cols-6 gap-6">
6475
<div class="flex flex-col col-span-6 lg:col-span-4">
6576
<p class="hidden md:block font-p text-sm text-gray-500 mb-2">
6677
{{ i18n "hub_managed_steps_title" | safeHTML }}
@@ -110,7 +121,7 @@ <h2 class="font-h2 mb-6">
110121
</div>
111122
</template>
112123

113-
<!-- Step 3: License Key (loading...) -->
124+
<!-- Step 3a: License Key (loading...) -->
114125
<template x-if="feedbackData.currentStep == 2 &amp;&amp; !feedbackData.success">
115126
<div class="md:col-span-2 grid grid-cols-6 gap-6">
116127
<div class="flex flex-col col-span-6 lg:col-span-4">
@@ -125,7 +136,7 @@ <h2 class="font-h2 mb-6">
125136
</div>
126137
</template>
127138

128-
<!-- Step 3: License Key (success) -->
139+
<!-- Step 3b: License Key (success) -->
129140
<template x-if="feedbackData.currentStep == 2 &amp;&amp; feedbackData.success">
130141
<div class="md:col-span-2 grid grid-cols-6 gap-6">
131142
<div class="flex flex-col col-span-6 lg:col-span-4">
@@ -136,6 +147,8 @@ <h2 class="font-h2 mb-6">
136147
{{ i18n "hub_ce_registration_step_3_license_title" }}
137148
</h2>
138149
<p>Todo: return URL</p>
150+
{{ $challengeUrl := printf "%s/licenses/hub/challenge" .Site.Params.apiBaseUrl }}
151+
{{ partial "captcha.html" (dict "challengeUrl" $challengeUrl "captchaPayload" "submitData.captcha" "captchaState" "captchaState") }}
139152
<textarea class="block input-box w-full h-48 mb-8" x-text="feedbackData.licenseText" readonly></textarea>
140153

141154
<div class="mt-auto">
@@ -148,8 +161,8 @@ <h2 class="font-h2 mb-6">
148161
</div>
149162
</div>
150163
</template>
151-
</section>
152-
</form>
164+
</form>
165+
</section>
153166
</section>
154167
{{ end }}
155168
{{ define "script" }}

0 commit comments

Comments
 (0)