diff --git a/src/@seed/api/postoffice/index.ts b/src/@seed/api/postoffice/index.ts new file mode 100644 index 00000000..531d8116 --- /dev/null +++ b/src/@seed/api/postoffice/index.ts @@ -0,0 +1,2 @@ +export * from './postoffice.service' +export * from './postoffice.types' diff --git a/src/@seed/api/postoffice/postoffice.service.ts b/src/@seed/api/postoffice/postoffice.service.ts new file mode 100644 index 00000000..b7529cc1 --- /dev/null +++ b/src/@seed/api/postoffice/postoffice.service.ts @@ -0,0 +1,33 @@ +import { HttpClient } from '@angular/common/http' +import { inject, Injectable } from '@angular/core' +import { BehaviorSubject, map } from 'rxjs' +import { OrganizationService } from '@seed/api/organization' +import type { EmailTemplate, ListTemplatesResponse } from './postoffice.types' + +@Injectable({ providedIn: 'root' }) +export class PostofficeService { + private _httpClient = inject(HttpClient) + private _organizationService = inject(OrganizationService) + private _templates = new BehaviorSubject([]) + + templates$ = this._templates.asObservable() + + get(): void { + // fetch current organization + this._organizationService.currentOrganization$.subscribe(({ org_id }) => { + const url = `/api/v3/cycles/?organization_id=${org_id}` + // fetch templates + this._httpClient + .get(url) + .pipe(map((response) => response.templates)) + .subscribe({ + next: (templates) => { + this._templates.next(templates) + }, + error: (error) => { + console.error('Error fetching templates:', error) + }, + }) + }) + } +} diff --git a/src/@seed/api/postoffice/postoffice.types.ts b/src/@seed/api/postoffice/postoffice.types.ts new file mode 100644 index 00000000..5e5d18e1 --- /dev/null +++ b/src/@seed/api/postoffice/postoffice.types.ts @@ -0,0 +1,13 @@ +export type EmailTemplate = { + id: number; + name: string; + description: string; + subject: string; + content: string; + html_content: string; +} + +export type ListTemplatesResponse = { + status: string; + cycles: EmailTemplate[]; +} diff --git a/src/app/modules/organizations/organizations-cycles/organizations-cycles.component.html b/src/app/modules/organizations/organizations-cycles/organizations-cycles.component.html index ea0c07bb..15d80e5c 100644 --- a/src/app/modules/organizations/organizations-cycles/organizations-cycles.component.html +++ b/src/app/modules/organizations/organizations-cycles/organizations-cycles.component.html @@ -3,7 +3,10 @@ class="bg-card flex flex-0 flex-col border-b p-6 sm:flex-row sm:items-center sm:justify-between sm:px-10 sm:py-8 dark:bg-transparent" >
-

Cycles

+

+ + Cycles +

diff --git a/src/app/modules/organizations/organizations-email-templates/organizations-email-templates.component.html b/src/app/modules/organizations/organizations-email-templates/organizations-email-templates.component.html index ebb90af1..7d87e904 100644 --- a/src/app/modules/organizations/organizations-email-templates/organizations-email-templates.component.html +++ b/src/app/modules/organizations/organizations-email-templates/organizations-email-templates.component.html @@ -1 +1,58 @@ -
Email Templates Content
+
+
+
+

+ + {{ t('Email Templates') }} +

+
+
+ +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ID{{ cycle.id }}Name{{ cycle.name }}From Date{{ cycle.start }}To Date{{ cycle.end }}Actions + Actions here +
+
+
+
+
+
+
diff --git a/src/app/modules/organizations/organizations-email-templates/organizations-email-templates.component.ts b/src/app/modules/organizations/organizations-email-templates/organizations-email-templates.component.ts index 0d766d31..31bbddec 100644 --- a/src/app/modules/organizations/organizations-email-templates/organizations-email-templates.component.ts +++ b/src/app/modules/organizations/organizations-email-templates/organizations-email-templates.component.ts @@ -1,9 +1,14 @@ import type { OnInit } from '@angular/core' import { Component } from '@angular/core' - +import { MatButtonModule } from '@angular/material/button' +import { MatDialogModule, MatDialog } from '@angular/material/dialog' +import { MatIconModule } from '@angular/material/icon' +import { MatTableDataSource, MatTableModule } from '@angular/material/table' +import { SharedImports } from '@seed/directives' @Component({ selector: 'seed-organizations-email-templates', templateUrl: './organizations-email-templates.component.html', + imports: [MatButtonModule, MatDialogModule, MatIconModule, MatTableModule, CommonModule, SharedImports], }) export class OrganizationsEmailTemplatesComponent implements OnInit { ngOnInit(): void {