Skip to content

Commit dc619c1

Browse files
authored
Merge pull request #65 from sourcefuse/GH-63
feat(arc-saas): Enable tenant registration via super admin
2 parents e36bfe1 + a254193 commit dc619c1

21 files changed

+1266
-118
lines changed

projects/arc-lib/src/lib/core/validators.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,33 @@ export class CustomValidators {
1212
};
1313
}
1414
}
15+
16+
export function keyValidator(): ValidatorFn {
17+
return (control: AbstractControl): {[key: string]: any} | null => {
18+
const key = control.value;
19+
const maxLength = 10;
20+
const isValid = /^[A-Za-z][A-Za-z0-9]{0,9}$/.test(key);
21+
return isValid ? null : {keyInvalid: true};
22+
};
23+
}
24+
25+
export function domainMatchValidator(
26+
emailControl: AbstractControl,
27+
domainControl: AbstractControl,
28+
): ValidatorFn {
29+
return (control: AbstractControl): ValidationErrors | null => {
30+
const emailValue = emailControl.value;
31+
const domainValue = domainControl.value;
32+
33+
if (!emailValue || !domainValue) {
34+
return null;
35+
}
36+
37+
const emailDomain = emailValue.split('@')[1];
38+
if (emailDomain !== domainValue) {
39+
return {domainMismatch: true};
40+
}
41+
42+
return null;
43+
};
44+
}

projects/saas-ui/src/app/main/commands/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ export * from './get-total-lead.command';
1515
export * from './get-total-tenant.command';
1616
export * from './get-total-plan.command';
1717
export * from './get-total-billing-plan.command';
18+
export * from './register-tenant.command';
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import {
2+
ApiService,
3+
GetListAPICommand,
4+
IAdapter,
5+
PostAPICommand,
6+
} from '@project-lib/core/api';
7+
import {Lead} from '../../shared/models';
8+
9+
import {IAnyObject} from '@project-lib/core/i-any-object';
10+
import {TenantLead} from '../../shared/models/tenantLead.model';
11+
12+
export class RegisterTenantCommand<T> extends PostAPICommand<TenantLead> {
13+
constructor(
14+
apiService: ApiService,
15+
adapter: IAdapter<TenantLead>,
16+
appConfig: IAnyObject,
17+
) {
18+
super(
19+
apiService,
20+
adapter,
21+
`${appConfig.baseApiUrl}${appConfig.tenantMgmtFacadeUrl}/tenants`,
22+
);
23+
}
24+
}

projects/saas-ui/src/app/main/components/onboarding-tenant-list/onboarding-tenant-list.component.html

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,26 @@
11
<div>
22
<nb-card accent="danger" class="card-style">
33
<nb-card-body>
4-
<h2 class="heading">Onboarded Tenant List</h2>
4+
<div class="header-wrapper">
5+
<h2 class="heading">Onboarded Tenant List</h2>
6+
<!-- signup button -->
7+
<div class="regbtn">
8+
<button
9+
nbButton
10+
size="medium"
11+
status="danger"
12+
(click)="registerTenantPage()"
13+
>
14+
Add tenant
15+
</button>
16+
</div>
17+
</div>
18+
19+
<!-- loader -->
20+
<!-- <div *ngIf="loading" class="loader-overlay">
21+
<div class="loader"></div>
22+
</div> -->
23+
524
<!-- ag-grid -->
625
<div class="grid">
726
<ag-grid-angular

projects/saas-ui/src/app/main/components/onboarding-tenant-list/onboarding-tenant-list.component.scss

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,48 @@
44
width: 100%;
55
height: 400;
66
}
7+
8+
.header-wrapper{
9+
display: flex;
10+
justify-content: space-between;
11+
align-items: center;
12+
}
13+
14+
.a {
15+
text-decoration: none;
16+
color: #19a5ff;
17+
}
18+
19+
// for test
20+
.loader-overlay {
21+
position: fixed;
22+
top: 0;
23+
left: 0;
24+
width: 100%;
25+
height: 100%;
26+
background: rgba(255, 255, 255, 0.8);
27+
display: flex;
28+
justify-content: center;
29+
align-items: center;
30+
z-index: 1000;
31+
}
32+
33+
.loader {
34+
border: 8px solid #f3f3f3;
35+
border-top: 8px solid #3498db;
36+
border-radius: 50%;
37+
width: 60px;
38+
height: 60px;
39+
-webkit-animation: spin 2s linear infinite;
40+
animation: spin 2s linear infinite;
41+
}
42+
43+
@-webkit-keyframes spin {
44+
0% { transform: rotate(0deg); }
45+
100% { transform: rotate(360deg); }
46+
}
47+
48+
@keyframes spin {
49+
0% { transform: rotate(0deg); }
50+
100% { transform: rotate(360deg); }
51+
}

projects/saas-ui/src/app/main/components/onboarding-tenant-list/onboarding-tenant-list.component.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Component, Inject, OnInit} from '@angular/core';
2-
import {ActivatedRoute} from '@angular/router';
2+
import {ActivatedRoute, Router} from '@angular/router';
33
import {RouteComponentBaseDirective} from '@project-lib/core/route-component-base';
44
import {
55
ColDef,
@@ -35,8 +35,10 @@ export class OnboardingTenantListComponent extends RouteComponentBaseDirective {
3535
floatingFilter: true,
3636
resizable: true,
3737
};
38+
3839
constructor(
3940
protected override readonly location: Location,
41+
private readonly router: Router,
4042
protected override readonly route: ActivatedRoute,
4143
private readonly tenantFacade: TenantFacadeService,
4244
private http: HttpClient,
@@ -106,6 +108,7 @@ export class OnboardingTenantListComponent extends RouteComponentBaseDirective {
106108
combineLatest([paginatedLeads, totalLead]).subscribe(
107109
([data, count]) => {
108110
params.successCallback(data, count.count);
111+
// for test
109112
},
110113

111114
err => {
@@ -126,7 +129,8 @@ export class OnboardingTenantListComponent extends RouteComponentBaseDirective {
126129
return this.tenantFacade.getTenantList(filter).pipe(
127130
map(res => {
128131
return res.map(item => {
129-
const addressString = `${item.address.city}, ${item.address.state}, ${item.address.zip}, ${item.address.country}`;
132+
const addressString = ` ${item.address.zip}, ${item.address.country}`;
133+
// ${item.address.city}, ${item.address.state},
130134
return {
131135
name: item.name,
132136
key: item.key,
@@ -152,4 +156,8 @@ export class OnboardingTenantListComponent extends RouteComponentBaseDirective {
152156
getTotal() {
153157
return this.tenantFacade.getTotalTenant();
154158
}
159+
160+
registerTenantPage() {
161+
this.router.navigate(['main/create-tenant']);
162+
}
155163
}

0 commit comments

Comments
 (0)