Skip to content

Commit 34d84ce

Browse files
committed
fix(arc-saas): key validation changes
key validation changes
1 parent 03a73a3 commit 34d84ce

File tree

8 files changed

+75
-34
lines changed

8 files changed

+75
-34
lines changed

projects/saas-ui/src/app/main/styles/grid-styles.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,13 @@
1414
width: 100%;
1515
overflow: auto;
1616
height: calc(100vh - 120px);
17+
border-radius: 15px;
1718
}
1819
.ag-theme-quartz {
1920
width: 100%;
2021
height: 650px;
22+
--ag-font-family: sans-serif;
23+
--ag-font-size: 16px;
2124
}
2225

2326
.regbtn {

projects/saas-ui/src/app/on-boarding/commands/get-all-tenant-command.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ export class GetAllTenantKeysCommand<T> extends GetAPICommand<T> {
1010
constructor(
1111
apiService: IApiService,
1212
adapter: IAdapter<T>,
13+
key: string,
1314
appConfig: IAnyObject,
1415
) {
1516
super(
1617
apiService,
1718
adapter,
18-
`${appConfig.baseApiUrl}${appConfig.tenantmgmtServiceUrl}/tenant/keys`,
19+
`${appConfig.baseApiUrl}${appConfig.tenantmgmtServiceUrl}/verify-key/${key}`,
1920
);
2021
}
2122
}

projects/saas-ui/src/app/on-boarding/components/add-subscriber/add-subscriber.component.html

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -223,13 +223,14 @@ <h2 class="title">Marketplace Registration</h2>
223223
Application Sub-Domain <span class="required">*</span>
224224
</span>
225225
</div>
226+
226227
<div class="input">
227228
<div class="input-container">
228229
<input
229-
placeholder="Enter the subdomain of your application"
230+
placeholder="Enter the key of your application"
230231
fieldSize="medium"
231232
status="info"
232-
formControlName="subdomain"
233+
formControlName="key"
233234
nbInput
234235
/>
235236
<nb-icon
@@ -238,26 +239,40 @@ <h2 class="title">Marketplace Registration</h2>
238239
nbTooltip="Enter a unique key starting with an alphabet. This field is required and has a maximum length of 20 characters. Special characters are not allowed."
239240
></nb-icon>
240241
</div>
242+
241243
<div>
242244
<div
243245
*ngIf="
244-
marketSubsForm.get('subdomain').valid &&
245-
keyVerificationMessage &&
246-
marketSubsForm.get('subdomain').touched
246+
marketSubsForm.get('key').hasError('keyExists') &&
247+
marketSubsForm.get('key').touched
247248
"
248-
class="message"
249+
class="error-msg"
249250
>
250251
{{ keyVerificationMessage }}
251252
</div>
253+
254+
<div
255+
*ngIf="
256+
marketSubsForm.get('key').valid &&
257+
marketSubsForm.get('key').touched
258+
"
259+
class="success-msg"
260+
>
261+
<nb-icon
262+
icon="checkmark-circle-2-outline"
263+
class="success-icon"
264+
></nb-icon>
265+
{{ keyVerificationSuccess }}
266+
</div>
252267
<div
253268
*ngIf="
254-
marketSubsForm.get('subdomain').hasError('pattern') &&
255-
marketSubsForm.get('subdomain').touched
269+
marketSubsForm.get('key').hasError('pattern') &&
270+
marketSubsForm.get('key').touched
256271
"
257272
class="error-msg"
258273
>
259274
Subdomain must start with a letter and can include numbers
260-
and hyphens and has maximum length 20.
275+
and hyphens and has a maximum length of 20.
261276
</div>
262277
</div>
263278
</div>

projects/saas-ui/src/app/on-boarding/components/add-subscriber/add-subscriber.component.scss

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,19 @@
2525
color: #007bff;
2626
}
2727

28+
29+
.success-msg {
30+
color: green;
31+
font-size: 14px;
32+
display: flex;
33+
align-items: center;
34+
}
35+
36+
.success-icon {
37+
color: green;
38+
margin-right: 5px;
39+
}
40+
2841
.input-box {
2942
.input {
3043
select {

projects/saas-ui/src/app/on-boarding/components/add-subscriber/add-subscriber.component.ts

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export class AddSubscriberComponent {
3737
address: [''],
3838
country: ['', Validators.required],
3939
zip: ['', [Validators.required, Validators.pattern('^[0-9]*$')]],
40-
subdomain: [
40+
key: [
4141
'',
4242
[
4343
Validators.required,
@@ -64,34 +64,39 @@ export class AddSubscriberComponent {
6464
});
6565

6666
this.marketSubsForm
67-
.get('subdomain')
67+
.get('key')
6868
?.valueChanges.pipe(debounceTime(1500), distinctUntilChanged())
69-
.subscribe(subdomain => {
70-
const subdomainControl = this.marketSubsForm.get('subdomain');
69+
.subscribe(key => {
70+
const subdomainControl = this.marketSubsForm.get('key');
7171
if (subdomainControl && subdomainControl.valid) {
72-
this.verifyKey(subdomain);
72+
this.verifyKey(key);
7373
} else {
7474
this.keyVerificationMessage = '';
7575
}
7676
});
7777
}
7878

79-
verifyKey(subdomain: string) {
80-
this.onBoardingService.getAllTenantKeys().subscribe(
81-
(response: string[]) => {
82-
if (response.includes(subdomain)) {
83-
this.marketSubsForm.get('subdomain')?.setErrors({keyExists: true});
84-
this.keyVerificationMessage =
85-
'Subdomain already exists. Please choose another one.';
86-
} else {
87-
this.marketSubsForm.get('subdomain')?.setErrors(null);
88-
this.keyVerificationMessage = 'Subdomain is available.';
89-
}
90-
},
91-
error => {
92-
this.keyVerificationMessage = 'Error verifying subdomain';
93-
},
94-
);
79+
verifyKey(key: string) {
80+
this.onBoardingService
81+
.getAllTenantKeys(this.marketSubsForm.get('key')?.value)
82+
.subscribe(
83+
response => {
84+
if (response.exists) {
85+
this.marketSubsForm.get('key')?.setErrors({keyExists: true});
86+
this.keyVerificationMessage =
87+
'Subdomain already exists. Please choose another one.';
88+
this.keyVerificationSuccess = '';
89+
} else {
90+
this.marketSubsForm.get('key')?.setErrors(null);
91+
this.keyVerificationSuccess = 'Subdomain is available.';
92+
this.keyVerificationMessage = '';
93+
}
94+
},
95+
error => {
96+
this.keyVerificationMessage = 'Error verifying subdomain';
97+
this.keyVerificationSuccess = '';
98+
},
99+
);
95100
}
96101

97102
showToastr(status: string, message: string) {
@@ -113,7 +118,7 @@ export class AddSubscriberComponent {
113118
address: userData.address,
114119
country: userData.country,
115120
zip: userData.zip,
116-
subdomain: userData.subdomain,
121+
key: userData.key,
117122
regToken: this.regToken,
118123
};
119124
console.log(user);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export class KeyResponse {
2+
exists: boolean;
3+
}

projects/saas-ui/src/app/shared/models/subscriber.model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ export interface Subscriber {
77
address?: string;
88
country: string;
99
zip?: string;
10-
subdomain: string;
10+
key: string;
1111
regToken: string;
1212
}

projects/saas-ui/src/app/shared/services/on-boarding-service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,11 @@ export class OnBoardingService {
4848
private readonly getPlanAdapter: GetPlanAdapter,
4949
@Inject(APP_CONFIG) private readonly appConfig: IAnyObject,
5050
) {}
51-
public getAllTenantKeys() {
51+
public getAllTenantKeys(key: string) {
5252
const command: GetAllTenantKeysCommand<any> = new GetAllTenantKeysCommand(
5353
this.apiService,
5454
this.anyAdapter,
55+
key,
5556
this.appConfig,
5657
);
5758

0 commit comments

Comments
 (0)