highcourt-affidavit 1.0.4 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,46 +1,46 @@
1
- # Federal High Court Affidavit Library for Angular
1
+ # Federal High Court Affidavit Library
2
+ ## Angular Library & Web Components – Complete Integration Guide
2
3
 
3
- [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)
4
- [![npm version](https://img.shields.io/npm/v/highcourt-affidavit.svg)](https://www.npmjs.com/package/highcourt-affidavit)
5
- [![Angular](https://img.shields.io/badge/Angular-17+-red.svg)](https://angular.io/)
4
+ ![License](https://img.shields.io/badge/license-MIT-blue.svg)
5
+ ![Angular](https://img.shields.io/badge/Angular-16%2B-red.svg)
6
+ ![Web Components](https://img.shields.io/badge/Web%20Components-3-success)
7
+ ![Elements Version](https://img.shields.io/badge/Elements-0.2.19-orange)
6
8
 
7
- ## Introduction
9
+ ---
8
10
 
9
- This library simplifies the integration of the Federal High Court's Affidavit Library into your Angular applications. It provides a user-friendly Angular component (`highcourt-affidavit`) that can be easily customized and integrated to manage the creation of affidavits.
11
+ ## 1. Overview
10
12
 
11
- ## Features
13
+ The **Federal High Court Affidavit Library** is delivered in **two complementary integration models**:
12
14
 
13
- - **Effortless Integration:** Seamlessly integrate affidavit creation into your Angular application with minimal setup
14
- - **Customizable Component:** Tailor the `highcourt-affidavit` component to match your specific requirements and workflows
15
- - **Bulk Operations:** Create multiple affidavits at once using the bulk creation component
16
- - **Service-based API:** Use the service directly for programmatic affidavit creation
17
- - **Clear Documentation:** Comprehensive documentation and examples to guide you through the library's usage
18
- - **Error Handling:** Built-in error handling mechanisms to address potential issues during affidavit creation
19
- - **TypeScript Support:** Full TypeScript support with type definitions
15
+ 1. **Angular Library (`highcourt-affidavit`)**
16
+ Designed for internal Angular applications that require:
17
+ - Tight framework integration
18
+ - Service-based API access
19
+ - Full TypeScript support
20
20
 
21
- ## Prerequisites
21
+ 2. **Web Components (`highcourt-affidavit-elements`)**
22
+ Framework-agnostic custom elements for:
23
+ - Partner portals and MDAs
24
+ - Angular, React, Vue, or plain HTML
25
+ - CDN-based, copy‑paste integration
22
26
 
23
- - Angular 16 or higher
24
- - Node.js 18 or higher
25
- - npm or yarn package manager
27
+ This document provides **complete documentation** for **both the Angular library and all Web Components**, including **all callback events**.
26
28
 
27
- ## Installation
29
+ ---
28
30
 
29
- 1. **Install using npm:**
31
+ # PART A — ANGULAR LIBRARY (`highcourt-affidavit`)
30
32
 
31
- ```bash
32
- npm install highcourt-affidavit
33
- ```
33
+ ## 2. Installation
34
34
 
35
- Or using yarn:
36
-
37
- ```bash
38
- yarn add highcourt-affidavit
39
- ```
35
+ ```bash
36
+ npm install highcourt-affidavit
37
+ # or
38
+ yarn add highcourt-affidavit
39
+ ```
40
40
 
41
- ## 2. Import the Module
41
+ ---
42
42
 
43
- In your Angular app, import the `HighcourtAffidavitModule` in your app module or any other relevant module where you want to use the affidavit functionality. Pass your API keys from the environment configuration:
43
+ ## 3. Module Setup
44
44
 
45
45
  ```ts
46
46
  import { NgModule } from "@angular/core";
@@ -49,318 +49,428 @@ import { environment } from "../environments/environment";
49
49
 
50
50
  @NgModule({
51
51
  imports: [
52
- HighcourtAffidavitModule.forRoot(environment.affidavit_api_secret_key, environment.mode), // Both token and mode arguments are optional
52
+ HighcourtAffidavitModule.forRoot(
53
+ environment.affidavit_api_secret_key,
54
+ environment.mode //(in: 'development', 'production')
55
+ ),
53
56
  ],
54
- // ...
55
57
  })
56
58
  export class AppModule {}
57
59
  ```
58
60
 
59
- > **Note:** Make sure to set the `affidavit_api_secret_key` and `affidavit_api_public_key` in your environment files.
61
+ > Ensure `affidavit_api_secret_key` and `affidavit_api_public_key` are defined in your environment files.
62
+
63
+ ---
60
64
 
61
- ## 3. Integration Methods
65
+ ## 4. Angular Components
62
66
 
63
- You can integrate the affidavit functionality using either the component-based approach or the service-based approach.
67
+ ### 4.1 `<highcourt-affidavit>` – Single Affidavit
68
+
69
+ ```html
70
+ <highcourt-affidavit [templateId]="template_id"
71
+ (callBack)="handleAffidavitCallback($event)">
72
+ </highcourt-affidavit>
73
+ ```
64
74
 
65
- ### Option 1: Component-based Integration
75
+ **Events**
76
+ - `callBack` – affidavit application completed
77
+ - `paymentSuccess` – payment completed (if applicable)
78
+ - `overlayClose` – overlay closed by user/system
66
79
 
67
- #### Single Affidavit Creation
80
+ ---
68
81
 
69
- Integrate the `highcourt-affidavit` component into your HTML template, optionally configuring it with `token` and `mode` properties. Capture its output using the event callback for further processing.
82
+ ### 4.2 `<e-affidavit-bulk-create-applications>` – Bulk Affidavits
70
83
 
71
84
  ```html
72
- <highcourt-affidavit (callBack)="getApp($event)" [token]="'FHC_sk_xxxxxxxx-xxxxxx'" [mode]="'production'"> </highcourt-affidavit>
85
+ <e-affidavit-bulk-create-applications
86
+ [payload]="bulkPayload"
87
+ [affidavitTemplateId]="templateId"
88
+ [client_ref]="clientRef"
89
+ (callBack)="handleBulkCallback($event)">
90
+ </e-affidavit-bulk-create-applications>
73
91
  ```
74
92
 
75
- ```ts
76
- export class MyComponent {
77
- getApp(data: any) {
78
- console.log("Application", data);
79
- // Handle the affidavit creation response
80
- }
81
- }
93
+ **Events**
94
+ - `callBack` – bulk workflow completed
95
+ - `overlayClose` – bulk workspace closed
96
+
97
+ ---
98
+ ### 4.3 `<e-affidavit-applications-details-page>` – Bulk Affidavits
99
+
100
+ ```html
101
+ <e-affidavit-applications-details-page
102
+ [client_ref]="clientRef"
103
+ (handlePayment)="handlePaymentSuccess($event)">
104
+ </e-affidavit-applications-details-page>
82
105
  ```
83
106
 
84
- #### Bulk Affidavit Creation
107
+ **Events**
108
+ - `handlePayment` – payment completed
109
+ - `overlayClose` – bulk workspace closed
85
110
 
86
- To create multiple affidavits at once, use the `e-affidavit-bulk-create-applications` component. Provide a `payload`, `affidavitTemplateId`, and a unique `client_ref`.
111
+ ---
87
112
 
88
- ```html
89
- <e-affidavit-bulk-create-applications [payload]="affidavitPayload" [affidavitTemplateId]="55" [client_ref]="'POSSAP-0023-2343243212211'" (callBack)="getApp($event)"> </e-affidavit-bulk-create-applications>
113
+ ## 5. Angular Services
114
+
115
+ ### `HighcourtAffidavitLibraryService`
116
+
117
+ ```ts
118
+ this.affidavitService.create(data).subscribe(...)
119
+ this.affidavitService.createBulk(data).subscribe(...)
120
+ ...
90
121
  ```
91
122
 
123
+ Used for **headless / backend-driven** affidavit creation.
124
+
125
+ ---
126
+
127
+ ## 6. Angular Callback Contract
128
+
92
129
  ```ts
93
- export class MyComponent {
94
- affidavitPayload = [
95
- {
96
- deponent_name: "John Doe",
97
- deponent_nin: 12345678912,
98
- // ... other required fields
99
- },
100
- ];
101
-
102
- getApp(data: any) {
103
- console.log("Bulk Application", data);
104
- // Handle the bulk affidavit creation response
105
- }
130
+ interface AngularAffidavitCallback {
131
+ status: "success" | "error";
132
+ reference?: string;
133
+ data: any;
106
134
  }
107
135
  ```
108
136
 
109
- #### View Application Details
137
+ ---
110
138
 
111
- You can also navigate directly to the details of an affidavit application using the `client_ref` and `page` parameters:
139
+ # PART B — WEB COMPONENTS (`highcourt-affidavit-elements`)
112
140
 
113
- ```html
114
- <e-affidavit-bulk-create-applications [page]="'details'" [client_ref]="'POSSAP-0023-2343243212211'"> </e-affidavit-bulk-create-applications>
115
- ```
141
+ ## 7. What Are the Web Components?
116
142
 
117
- ### Option 2: Service-based Integration
143
+ Web Components are **native browser custom elements** built with Angular Elements.
144
+ They encapsulate:
145
+ - UI & validation
146
+ - Workflow orchestration
147
+ - Payment initiation
148
+ - Secure API calls
149
+ - Event emission
118
150
 
119
- If you prefer a programmatic approach, use the `HighcourtAffidavitLibraryService` to create affidavits via a service call:
151
+ They **do not require Angular/React/Vuejs** in the consuming app.
120
152
 
121
- ```ts
122
- import { Component } from "@angular/core";
123
- import { HighcourtAffidavitLibraryService } from "highcourt-affidavit";
153
+ ---
124
154
 
125
- @Component({
126
- selector: "app-create-affidavit",
127
- templateUrl: "./create-affidavit.component.html",
128
- })
129
- export class CreateAffidavitComponent {
130
- constructor(private affidavitService: HighcourtAffidavitLibraryService) {}
131
-
132
- createAffidavit() {
133
- const affidavitData = {
134
- affidavit_type_name: "Affidavit of Ownership",
135
- deponent_name: "Ahmad Ibrahim",
136
- deponent_nin: 12345678912,
137
- town_native: "Gusau",
138
- town_resident: "Gusau",
139
- occupation: "Software Developer",
140
- gender: "Male",
141
- religion: "Islam",
142
- signature_file: "signature.png", // Should be provided in binary format
143
- passport_photo_file: "passport.jpg", // Should be provided in binary format
144
- identity_photo_file: "id-card.jpeg", // Should be provided in binary format
145
- applicant_email: "applicant@mail.com",
146
- applicant_phone: "07066666666",
147
- adult_minor: "adult",
148
- affidavit_template_id: 1,
149
- lga_id: 1,
150
- court_id: 1,
151
- formEntries: [
152
- {
153
- placeholder: "fullName",
154
- label: "Full Name",
155
- provided_value: "Ahmad Ibrahim",
156
- },
157
- ],
158
- clauseEntries: [{ entry: "Affidavit Clause" }],
159
- };
160
-
161
- this.affidavitService.create(affidavitData).subscribe({
162
- next: (response) => {
163
- console.log("Affidavit Created:", response);
164
- // Handle successful creation
165
- },
166
- error: (error) => {
167
- console.error("Affidavit Creation Failed:", error);
168
- // Handle error
169
- },
170
- });
171
- }
155
+ ## 8. Available Web Components
172
156
 
173
- createBulkAffidavit() {
174
- const affidavitData = {
175
- affidavit_type_name: "Affidavit of Ownership",
176
- affidavit_template_id: 1,
177
- applicant_email: "applicant@mail.com",
178
- applicant_phone: "07066666666",
179
- court_id: 1,
180
- applications: [
181
- {
182
- deponent_name: "Ahmad Ibrahim",
183
- deponent_nin: 12345678912,
184
- town_native: "Gusau",
185
- town_resident: "Gusau",
186
- occupation: "Software Developer",
187
- gender: "Male",
188
- religion: "Islam",
189
- signature_file: "signature.png", // Should be provided in binary format
190
- passport_photo_file: "passport.jpg", // Should be provided in binary format
191
- identity_photo_file: "id-card.jpeg", // Should be provided in binary format
192
- lga_id: 1,
193
- court_id: 1,
194
- formEntries: [
195
- {
196
- placeholder: "fullName",
197
- label: "Full Name",
198
- provided_value: "Ahmad Ibrahim",
199
- },
200
- ],
201
- clauseEntries: [{ entry: "Affidavit Clause" }],
202
- },
203
- ],
204
- };
205
-
206
- this.affidavitService.createBulk(affidavitData).subscribe({
207
- next: (response) => {
208
- console.log("Affidavits Created:", response);
209
- // Handle successful bulk creation
210
- },
211
- error: (error) => {
212
- console.error("Affidavits Creation Failed:", error);
213
- // Handle error
214
- },
215
- });
216
- }
217
- }
218
- ```
157
+ | Component | Tag | Purpose |
158
+ |--------|-----|--------|
159
+ | Affidavit Application | `<highcourt-affidavit>` | Create & submit affidavits |
160
+ | Payment | `<pay-affidavit>` | Pay for an existing affidavit |
161
+ | Bulk Workspace | `<bulk-create-applications>` | Manage multiple affidavits |
162
+ | Bulk Applications Details | `<e-affidavit-applications-details-page>` | Manage multiple affidavits Payment |
219
163
 
220
- > **Note:** Make sure to set the `affidavit_api_secret_key` and `affidavit_api_public_key` in your environment files.
164
+ ---
221
165
 
222
- ## 4. Add Styles
166
+ ## 9. Distribution (CDN – Recommended)
223
167
 
224
- To ensure your application uses the correct styles for PrimeNG components and the affidavit library, import the following styles in your global `styles.scss` file:
168
+ ```html
169
+ <link rel="stylesheet"
170
+ href="https://cdn.jsdelivr.net/npm/highcourt-affidavit-elements@0.x.x/dist/affidavit-library/browser/styles.css" />
225
171
 
226
- ```scss
227
- @import "~primeng/resources/primeng.min.css";
228
- @import "~primeflex/primeflex.scss";
229
- @import "~primeicons/primeicons.css";
230
- @import "~highcourt-affidavit/src/lib/styles.scss";
231
- @import url("https://fonts.googleapis.com/css?family=Comfortaa");
172
+ <script src="https://cdn.jsdelivr.net/npm/highcourt-affidavit-elements@0.x.x/dist/affidavit-library/browser/polyfills.js" type="module"></script>
173
+ <script src="https://cdn.jsdelivr.net/npm/highcourt-affidavit-elements@0.x.x/dist/affidavit-library/browser/scripts.js" defer></script>
174
+ <script src="https://cdn.jsdelivr.net/npm/highcourt-affidavit-elements@0.x.x/dist/affidavit-library/browser/main.js" type="module"></script>
232
175
  ```
233
176
 
234
- ## 5. Environment Configuration
235
-
236
- Ensure you have set your API keys in the environment files. These keys are required for the affidavit service to function correctly:
177
+ ### Alternatively
178
+ ```html
179
+ <script src="https://cdn.jsdelivr.net/npm/highcourt-affidavit-elements@0.x.x/dist/affidavit-library/browser/loader.js" ></script>
237
180
 
238
- ```ts
239
- export const environment = {
240
- production: false,
241
- affidavit_api_secret_key: "your_secret_key",
242
- affidavit_api_public_key: "your_public_key",
243
- mode: "test", // Can be either 'production' or 'test'
244
- };
245
181
  ```
182
+ ---
183
+
184
+ ## 10. `<highcourt-affidavit>` – Web Component
185
+
186
+ ### Attributes
246
187
 
247
- ## 6. API Reference
188
+ | Attribute | Required | Description |
189
+ |--------|----------|-------------|
190
+ | `token` | ❌ | API key |
191
+ | `mode` | ❌ | `development` or `production` |
192
+ | `template-id` | ❌ | Affidavit template |
193
+ | `templateId` | ❌ | Affidavit template |
194
+ | `client-ref` | ❌ | Client reference |
195
+ | `clientRef` | ❌ | Client reference |
196
+ | `payload` | ❌ | Prefilled data |
248
197
 
249
- ### Components
198
+ ### Callbacks
250
199
 
251
- #### `highcourt-affidavit`
200
+ | Event | Description |
201
+ |-----|------------|
202
+ | `callBack` | Application submitted |
203
+ | `on-payment-success` / `paymentSuccess` | Payment completed |
204
+ | `overlay-close` / `overlayClose` | Overlay closed |
252
205
 
253
- The main component for creating single affidavits.
206
+ ---
254
207
 
255
- **Properties:**
208
+ ## 11. `<pay-affidavit>` – Web Component
256
209
 
257
- - `token` (optional): Your API secret key
258
- - `mode` (optional): Environment mode ('production' or 'test')
210
+ ### Attributes
259
211
 
260
- **Events:**
212
+ | Attribute | Required | Description |
213
+ |--------|----------|-------------|
214
+ | `token` | ✅ | API key |
215
+ | `app-no` | ✅ | Application number |
216
+ | `should-display-details` | ❌ | Show payment breakdown |
261
217
 
262
- - `callBack`: Emitted when affidavit creation is completed
218
+ ### Callbacks
263
219
 
264
- #### `e-affidavit-bulk-create-applications`
220
+ | Event | Description |
221
+ |-----|------------|
222
+ | `handlePayment` | Payment processed (success/failure) |
223
+ | `overlayClose` | Payment overlay closed |
224
+
225
+ ```js
226
+ payElement.addEventListener("handlePayment", (e) => {
227
+ console.log("Payment status:", e.detail.status);
228
+ });
229
+ ```
265
230
 
266
- Component for creating multiple affidavits at once.
231
+ ---
267
232
 
268
- **Properties:**
233
+ ## 12. `<bulk-create-applications>` – Web Component
269
234
 
270
- - `payload`: Array of affidavit data objects
271
- - `affidavitTemplateId`: Template ID for the affidavits
272
- - `client_ref`: Unique reference for the bulk operation
273
- - `page` (optional): Set to 'details' to view application details
274
- - `token` (optional): Your API secret key
275
- - `mode` (optional): Environment mode
235
+ ### Attributes
276
236
 
277
- **Events:**
237
+ | Attribute | Required | Description |
238
+ |--------|----------|-------------|
239
+ | `token` | ❌ | API key |
240
+ | `mode` | ❌ | Environment |
241
+ | `affidavit-template-id` | ✅ | Template ID |
242
+ | `client-ref` | ❌ | Bulk session reference |
243
+ | `page` | ❌ | new | review | details | summary |
278
244
 
279
- - `callBack`: Emitted when bulk affidavit creation is completed
245
+ ### Callbacks
280
246
 
281
- ### Services
247
+ | Event | Description |
248
+ |-----|------------|
249
+ | `callBack` | Bulk submission completed |
250
+ | `overlayClose` | Workspace closed |
282
251
 
283
- #### `HighcourtAffidavitLibraryService`
252
+ ---
253
+ ## 13. `<e-affidavit-applications-details-page>` – Web Component
284
254
 
285
- Service for programmatic affidavit creation.
255
+ ### Attributes
286
256
 
287
- **Methods:**
257
+ | Attribute | Required | Description |
258
+ |--------|----------|-------------|
259
+ | `token` | ❌ | API key |
260
+ | `mode` | ❌ | Environment |
261
+ | `client_ref` | ✅ | Bulk session reference |
288
262
 
289
- - `create(affidavitData)`: Create a single affidavit
290
- - `createBulk(affidavitData)`: Create multiple affidavits
263
+ ### Callbacks
291
264
 
292
- ## 7. Data Models
265
+ | Event | Description |
266
+ |-----|------------|
267
+ | `handlePayment` | Bulk submission completed |
268
+ | `overlayClose` | Workspace closed |
293
269
 
294
- ### Affidavit Data Structure
270
+ ---
271
+
272
+ ## 14. Unified Web Component Callback Contract
295
273
 
296
274
  ```ts
297
- interface AffidavitData {
298
- affidavit_type_name: string;
299
- deponent_name: string;
300
- deponent_nin: number;
301
- town_native: string;
302
- town_resident: string;
303
- occupation: string;
304
- gender: string;
305
- religion: string;
306
- signature_file: string; // Binary format
307
- passport_photo_file: string; // Binary format
308
- identity_photo_file: string; // Binary format
309
- applicant_email: string;
310
- applicant_phone: string;
311
- adult_minor: "adult" | "minor";
312
- affidavit_template_id: number;
313
- lga_id: number;
314
- court_id: number;
315
- formEntries: FormEntry[];
316
- clauseEntries: ClauseEntry[];
275
+ interface WebComponentCallback {
276
+ component: "highcourt-affidavit" | "pay-affidavit" | "bulk-create-applications";
277
+ action:
278
+ | "application_submitted"
279
+ | "payment_completed"
280
+ | "bulk_completed"
281
+ | "overlay_closed"
282
+ status: "success" | "pending" | "failed" | "cancelled";
283
+ reference?: string;
284
+ data: any;
285
+ timestamp: string;
317
286
  }
287
+ ```
318
288
 
319
- interface FormEntry {
320
- placeholder: string;
321
- label: string;
322
- provided_value: string;
323
- }
289
+ ---
324
290
 
325
- interface ClauseEntry {
326
- entry: string;
327
- }
291
+ ## 15. Global Callback Listener
292
+
293
+ ```js
294
+ document.addEventListener("callBack", (event) => {
295
+ console.log("Global callback:", event.detail);
296
+ });
297
+ ```
298
+
299
+ ---
300
+
301
+ ## 16. Using Web Components in Angular Apps
302
+
303
+ ```ts
304
+ import { CUSTOM_ELEMENTS_SCHEMA } from "@angular/core";
305
+
306
+ @NgModule({
307
+ schemas: [CUSTOM_ELEMENTS_SCHEMA],
308
+ })
309
+ export class AppModule {}
310
+ ```
311
+
312
+ ```html
313
+ <div class="mb-4" *ngIf="showAffidavitOverlay">
314
+ <h4>📝 Affidavit Application Component</h4>
315
+ <highcourt-affidavit [appNo]="appNo" [templateId]="templateId"
316
+ [payload]="payload" [appNo]="appNo"
317
+ (callBack)="handleAffidavitCallback($event)" [clientRef]="clientRef"
318
+ (overlayClose)="handleAffidavitOverlayClose($event)"
319
+ (paymentSuccess)="handleAffidavitPaymentSuccess($event)">
320
+ </highcourt-affidavit>
321
+ </div>
328
322
  ```
329
323
 
330
- ## 8. Troubleshooting
324
+ ```ts
325
+ import { Component, OnInit } from '@angular/core';
326
+
327
+
328
+ @Component({
329
+ selector: 'app-root',
330
+ templateUrl: './app.component.html',
331
+ styleUrl: './app.component.scss',
332
+ standalone: false
333
+ })
334
+ export class AppComponent implements OnInit {
335
+ // Configuration
336
+ token = 'FHC-INTEG-pk_f0a01636119a45d218c2016758e368be';
337
+ mode = 'test';
338
+ templateId = 96;
339
+ appNo = 'APP-1768501941-0004';
340
+ clientRef = 'APP-SESSION-01';
341
+ showAffidavitOverlay = true;
342
+
343
+ // Payload data for pre-filling the affidavit form
344
+ payload = {
345
+ affidavit_type_name: 'Affidavit of Ownership',
346
+ deponent_name: 'Ahmad Ibrahim',
347
+ deponent_nin: 12345678912,
348
+ town_native: 'Gusau',
349
+ town_resident: 'Gusau',
350
+ occupation: 'Software Developer',
351
+ gender: 'Male',
352
+ religion: 'Islam',
353
+ applicant_email: 'applicant@mail.com',
354
+ applicant_phone: '07066666666',
355
+ adult_minor: 'adult',
356
+ affidavit_template_id: 96,
357
+ state_id: 1,
358
+ court_id: 1,
359
+ formEntries: [
360
+ {
361
+ placeholder: "deponent_company_position",
362
+ provided_value: "CEO"
363
+ },
364
+ {
365
+ placeholder: "contractor_company_name",
366
+ provided_value: "Centaur Info Systems",
367
+ },
368
+ {
369
+ placeholder: "mda_authority_name",
370
+ provided_value: "FGN",
371
+ },
372
+ {
373
+ placeholder: "rc_number",
374
+ provided_value: "343434",
375
+ },
376
+ {
377
+ placeholder: "lot_number",
378
+ provided_value: "343434",
379
+ },
380
+ {
381
+ placeholder: "lot_title",
382
+ provided_value: "Purchase of 50 CNG Buses",
383
+ },
384
+ ],
385
+ clauseEntries: [],
386
+ };
387
+
388
+ constructor() { }
389
+
390
+ ngOnInit(): void {
391
+ this.ensureAffidavitWebComponentLoaded();
392
+ }
393
+
394
+ private ensureAffidavitWebComponentLoaded(): Promise<void> {
395
+ try {
396
+ // Already registered
397
+ if (typeof window !== 'undefined' && window.customElements?.get('highcourt-affidavit')) {
398
+ return Promise.resolve();
399
+ }
400
+
401
+ // Loader already injected
402
+ const existing = document.getElementById('highcourt-affidavit-loader');
403
+ if (existing) return Promise.resolve();
404
+
405
+ return new Promise<void>((resolve, reject) => {
406
+ const script = document.createElement('script');
407
+ script.id = 'highcourt-affidavit-loader';
408
+ script.src =
409
+ 'https://cdn.jsdelivr.net/npm/highcourt-affidavit-elements@0.2.18/dist/affidavit-library/browser/loader.js';
410
+ script.async = true;
411
+ script.onload = () => resolve();
412
+ script.onerror = () => reject(new Error('Failed to load highcourt-affidavit web component loader'));
413
+ document.head.appendChild(script);
414
+ });
415
+ } catch {
416
+ // If we can't access DOM (edge case), just no-op.
417
+ return Promise.resolve();
418
+ }
419
+ }
420
+
421
+ ngOnDestroy(): void {
422
+ // Clean up any injected loader script so it can't leak global CSS/JS across routes.
423
+ try {
424
+ const loader = document.getElementById('highcourt-affidavit-loader');
425
+ loader?.remove();
426
+ } catch {
427
+ // no-op
428
+ }
429
+ }
331
430
 
332
- ### Common Issues
431
+ // Highcourt Affidavit Component Event Handlers
432
+ handleAffidavitCallback(evt: any) {
433
+ const anyEvt = evt as any;
434
+ const detail = anyEvt?.detail ?? null;
333
435
 
334
- 1. **Module not found error**: Ensure you have installed the package correctly using npm or yarn.
436
+ console.log('[highcourt-affidavit] event received:', evt);
437
+ }
335
438
 
336
- 2. **API key errors**: Verify that your API keys are correctly set in the environment files.
439
+ handleAffidavitPaymentSuccess(data: any) {
440
+ console.log('APP Affidavit Payment Success:', data);
337
441
 
338
- 3. **Styling issues**: Make sure you have imported all required styles in your global styles file.
442
+ // Handle payment success - e.g., update application status, show success message, etc.
443
+ }
339
444
 
340
- 4. **File upload issues**: Ensure that file uploads are in binary format as required by the API.
445
+ handleAffidavitOverlayClose(data: boolean) {
446
+ console.log('APP Affidavit Overlay Closed:', data);
447
+ if (data) {
448
+ this.showAffidavitOverlay = false;
449
+ }
450
+ }
341
451
 
342
- ### Getting Help
452
+ }
453
+ ```
343
454
 
344
- If you encounter any issues or need assistance:
455
+ ---
345
456
 
346
- 1. Check the [NPM](https://www.npmjs.com/package/highcourt-affidavit) page
347
- 2. Review the API documentation
348
- 3. Contact support at [tech@centuryinformationsystems.com](mailto:tech@centuryinformationsystems.com) or visit [Century Information Systems Contact](https://centuryinformationsystems.com/contact-us)
457
+ ## 17. Security & Compliance
349
458
 
350
- ## 9. Contributing
459
+ - Never expose live API keys
460
+ - Always validate payments server-side
461
+ - Enforce HTTPS
462
+ - Rotate credentials periodically
463
+ - Do not trust client-only callbacks
351
464
 
352
- We welcome contributions! For more information about contributing to this project, please contact us at [tech@centuryinformationsystems.com](mailto:tech@centuryinformationsystems.com) or visit [Century Information Systems](https://centuryinformationsystems.com/contact-us).
465
+ ---
353
466
 
354
- <!-- ## 10. License
467
+ ## 18. Support
355
468
 
356
- This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. -->
469
+ 📧 support@centuryinformationsystems.com
357
470
 
358
- ## 11. Changelog
471
+ ---
359
472
 
360
- ### Version 1.0.0
473
+ ## 19. License
361
474
 
362
- - Initial release
363
- - Single affidavit creation
364
- - Bulk affidavit creation
365
- - Service-based integration
366
- - Component-based integration
475
+ MIT License
476
+ © 2026 ECMS