diff --git a/projects/saas-ui/src/app/main/commands/resend-email-by-leadid.command.ts b/projects/saas-ui/src/app/main/commands/resend-email-by-leadid.command.ts new file mode 100644 index 0000000..06dd573 --- /dev/null +++ b/projects/saas-ui/src/app/main/commands/resend-email-by-leadid.command.ts @@ -0,0 +1,24 @@ +import { + ApiService, + IAdapter, + PatchAPICommand, + PostAPICommand, +} from '@project-lib/core/api'; + +import {Inject} from '@angular/core'; +import {APP_CONFIG} from '@project-lib/app-config'; +import {IAnyObject} from '@project-lib/core/i-any-object'; +export class ResendEmailByLeadIdCommand extends PostAPICommand { + constructor( + apiService: ApiService, + adapter: IAdapter, + leadId: string, + appConfig: IAnyObject, + ) { + super( + apiService, + adapter, + `${appConfig.baseApiUrl}${appConfig.tenantMgmtFacadeUrl}/leads/${leadId}/reminder`, + ); + } +} diff --git a/projects/saas-ui/src/app/main/components/lead-list/lead-list.component.ts b/projects/saas-ui/src/app/main/components/lead-list/lead-list.component.ts index 664a11f..5781f2c 100644 --- a/projects/saas-ui/src/app/main/components/lead-list/lead-list.component.ts +++ b/projects/saas-ui/src/app/main/components/lead-list/lead-list.component.ts @@ -14,6 +14,7 @@ import {OnBoardingService} from '../../../shared/services/on-boarding-service'; import {Lead} from '../../../shared/models'; import {AnyObject, BackendFilter, Count} from '@project-lib/core/index'; import {HttpClient} from '@angular/common/http'; +import {ResendReminderButtonComponent} from '../resend-reminder-button/resend-reminder-button.component'; @Component({ selector: 'app-lead', @@ -33,6 +34,12 @@ export class LeadListComponent extends RouteComponentBaseDirective { {field: 'companyName', width: 250, minWidth: 20}, {field: 'email', width: 300, minWidth: 20}, {field: 'country', width: 250, minWidth: 20}, + { + field: 'actions', + headerName: 'Actions', + cellRenderer: ResendReminderButtonComponent, + width: 200, + }, ]; rowData = []; @@ -93,6 +100,7 @@ export class LeadListComponent extends RouteComponentBaseDirective { return this.onboardingService.getLeadList(filter).pipe( map(res => { const rows = res.map(item => ({ + id: item.id, firstName: item.firstName, lastName: item.lastName, companyName: item.companyName, diff --git a/projects/saas-ui/src/app/main/components/resend-reminder-button/resend-reminder-button.component.html b/projects/saas-ui/src/app/main/components/resend-reminder-button/resend-reminder-button.component.html new file mode 100644 index 0000000..6f110ff --- /dev/null +++ b/projects/saas-ui/src/app/main/components/resend-reminder-button/resend-reminder-button.component.html @@ -0,0 +1,10 @@ +
+ +
diff --git a/projects/saas-ui/src/app/main/components/resend-reminder-button/resend-reminder-button.component.scss b/projects/saas-ui/src/app/main/components/resend-reminder-button/resend-reminder-button.component.scss new file mode 100644 index 0000000..6fd3082 --- /dev/null +++ b/projects/saas-ui/src/app/main/components/resend-reminder-button/resend-reminder-button.component.scss @@ -0,0 +1,4 @@ +.email-icon { + color: #ef0b16; + + } \ No newline at end of file diff --git a/projects/saas-ui/src/app/main/components/resend-reminder-button/resend-reminder-button.component.spec.ts b/projects/saas-ui/src/app/main/components/resend-reminder-button/resend-reminder-button.component.spec.ts new file mode 100644 index 0000000..0216130 --- /dev/null +++ b/projects/saas-ui/src/app/main/components/resend-reminder-button/resend-reminder-button.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ResendReminderButtonComponent } from './resend-reminder-button.component'; + +describe('ResendReminderButtonComponent', () => { + let component: ResendReminderButtonComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ ResendReminderButtonComponent ] + }) + .compileComponents(); + + fixture = TestBed.createComponent(ResendReminderButtonComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/projects/saas-ui/src/app/main/components/resend-reminder-button/resend-reminder-button.component.ts b/projects/saas-ui/src/app/main/components/resend-reminder-button/resend-reminder-button.component.ts new file mode 100644 index 0000000..6195ea1 --- /dev/null +++ b/projects/saas-ui/src/app/main/components/resend-reminder-button/resend-reminder-button.component.ts @@ -0,0 +1,48 @@ +import {Component} from '@angular/core'; +import {ActivatedRoute, Router} from '@angular/router'; +import {AnyObject} from '@project-lib/core/api'; +import {ToasterService} from '@project-lib/theme/toaster'; +import {ICellRendererAngularComp} from 'ag-grid-angular'; +import {GridApi, ICellRendererParams} from 'ag-grid-community'; +import {BillingPlanService, OnBoardingService} from '../../../shared/services'; +import {Location} from '@angular/common'; + +@Component({ + selector: 'app-resend-reminder-button', + templateUrl: './resend-reminder-button.component.html', + styleUrls: ['./resend-reminder-button.component.scss'], +}) +export class ResendReminderButtonComponent implements ICellRendererAngularComp { + params: AnyObject; + gridApi: GridApi; + + constructor( + private router: Router, + private toastrService: ToasterService, + private billingPlanService: BillingPlanService, + private location: Location, + private route: ActivatedRoute, + private readonly onBoardingService: OnBoardingService, + ) {} + refresh(params: ICellRendererParams) { + return true; + } + + agInit(params: ICellRendererParams): void { + this.params = params; + } + resendEmail(e) { + // const rowDataId = this.route.snapshot.paramMap.get('id')!; + const rowDataId = this.params.node.data.id; + console.log(rowDataId); + this.onBoardingService + .resendValidateEmail(rowDataId) + .subscribe(respLead => { + console.log(respLead); + }); + this.toastrService.show('The email has been sent successfully.'); + } + onGridReady(params) { + this.gridApi = params.api; + } +} diff --git a/projects/saas-ui/src/app/main/main.module.ts b/projects/saas-ui/src/app/main/main.module.ts index 606307b..5c702d5 100644 --- a/projects/saas-ui/src/app/main/main.module.ts +++ b/projects/saas-ui/src/app/main/main.module.ts @@ -22,6 +22,7 @@ import {ButtonRendererComponent} from './components/button-renderer/button-rende import {TenantRegistrationComponent} from './components/tenant-registration/tenant-registration.component'; import { TenantDetailComponent } from './components/tenant-detail/tenant-detail.component'; import { EyeIconRendererComponent } from './components/eye-icon-renderer/eye-icon-renderer.component'; +import { ResendReminderButtonComponent } from './components/resend-reminder-button/resend-reminder-button.component'; @NgModule({ declarations: [ @@ -35,6 +36,7 @@ import { EyeIconRendererComponent } from './components/eye-icon-renderer/eye-ico TenantRegistrationComponent, TenantDetailComponent, EyeIconRendererComponent, + ResendReminderButtonComponent, ], imports: [ CommonModule, diff --git a/projects/saas-ui/src/app/shared/services/on-boarding-service.ts b/projects/saas-ui/src/app/shared/services/on-boarding-service.ts index 9ac5acd..de58f54 100644 --- a/projects/saas-ui/src/app/shared/services/on-boarding-service.ts +++ b/projects/saas-ui/src/app/shared/services/on-boarding-service.ts @@ -26,6 +26,7 @@ import {GetTotalLeadCommand} from '../../main/commands/get-total-lead.command'; import {TenantLead} from '../models/tenantLead.model'; import {RegisterTenantCommand} from '../../main/commands/register-tenant.command'; +import {ResendEmailByLeadIdCommand} from '../../main/commands/resend-email-by-leadid.command'; interface BackendFilter { where?: Where; @@ -66,6 +67,21 @@ export class OnBoardingService { return command.execute(); } + public resendValidateEmail(leadId: string) { + const command: ResendEmailByLeadIdCommand<{leadId: string}> = + new ResendEmailByLeadIdCommand( + this.apiService, + this.anyAdapter, + leadId, + this.appConfig, + ); + // sonarignore:end + command.parameters = { + data: {}, + }; + return command.execute(); + } + getLeadDetails(leadId: string): Observable { const command: GetLeadByIdCommand = new GetLeadByIdCommand( this.apiService,