@isaiahiroko/tilmart-ngx-apps-buyer 0.2.3 → 0.2.4
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/fesm2022/{isaiahiroko-tilmart-ngx-apps-buyer-account.module-NwaAXgVS.mjs → isaiahiroko-tilmart-ngx-apps-buyer-account.module-BTRypX8P.mjs} +28 -5
- package/fesm2022/isaiahiroko-tilmart-ngx-apps-buyer-account.module-BTRypX8P.mjs.map +1 -0
- package/fesm2022/isaiahiroko-tilmart-ngx-apps-buyer-checkout.module-C3Ncr5fc.mjs +453 -0
- package/fesm2022/isaiahiroko-tilmart-ngx-apps-buyer-checkout.module-C3Ncr5fc.mjs.map +1 -0
- package/fesm2022/isaiahiroko-tilmart-ngx-apps-buyer.mjs +77 -21
- package/fesm2022/isaiahiroko-tilmart-ngx-apps-buyer.mjs.map +1 -1
- package/package.json +1 -1
- package/types/isaiahiroko-tilmart-ngx-apps-buyer.d.ts +21 -4
- package/fesm2022/isaiahiroko-tilmart-ngx-apps-buyer-account.module-NwaAXgVS.mjs.map +0 -1
- package/fesm2022/isaiahiroko-tilmart-ngx-apps-buyer-checkout.module-8gkn9duj.mjs +0 -426
- package/fesm2022/isaiahiroko-tilmart-ngx-apps-buyer-checkout.module-8gkn9duj.mjs.map +0 -1
|
@@ -4,7 +4,7 @@ import * as i1 from '@angular/router';
|
|
|
4
4
|
import { ActivatedRoute, RouterModule } from '@angular/router';
|
|
5
5
|
import { ApiService, ControlService, BaseDirective, using, notify, SharedModule } from '@thescaffold/ngx-core';
|
|
6
6
|
import { ReplaySubject, firstValueFrom, map, catchError, of, takeUntil, switchMap, forkJoin } from 'rxjs';
|
|
7
|
-
import {
|
|
7
|
+
import { StaticListService, CartStoreService } from './isaiahiroko-tilmart-ngx-apps-buyer.mjs';
|
|
8
8
|
import * as i1$1 from '@angular/forms';
|
|
9
9
|
import * as i2 from '@angular/common';
|
|
10
10
|
import { ThemeService } from '@thescaffold/ngx-common';
|
|
@@ -128,7 +128,10 @@ class AccountAddressesComponent extends BaseDirective {
|
|
|
128
128
|
constructor() {
|
|
129
129
|
super(...arguments);
|
|
130
130
|
this.store = inject(AccountStoreService);
|
|
131
|
-
this.
|
|
131
|
+
this.staticList = inject(StaticListService);
|
|
132
|
+
this.states = [];
|
|
133
|
+
this.lgas = [];
|
|
134
|
+
this.lgasLoading = false;
|
|
132
135
|
this.loading = true;
|
|
133
136
|
this.customerId = '';
|
|
134
137
|
this.addresses = [];
|
|
@@ -137,6 +140,7 @@ class AccountAddressesComponent extends BaseDirective {
|
|
|
137
140
|
this.form = blankForm();
|
|
138
141
|
this.formError = '';
|
|
139
142
|
this.init = () => {
|
|
143
|
+
void this.staticList.getStates().then((states) => (this.states = states));
|
|
140
144
|
this.store
|
|
141
145
|
.customer()
|
|
142
146
|
.pipe(takeUntil(this.$))
|
|
@@ -150,6 +154,23 @@ class AccountAddressesComponent extends BaseDirective {
|
|
|
150
154
|
}));
|
|
151
155
|
};
|
|
152
156
|
}
|
|
157
|
+
async onFormStateChange() {
|
|
158
|
+
this.form.lga = '';
|
|
159
|
+
await this.loadLgas(this.form.state);
|
|
160
|
+
}
|
|
161
|
+
async loadLgas(state) {
|
|
162
|
+
if (!state) {
|
|
163
|
+
this.lgas = [];
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
this.lgasLoading = true;
|
|
167
|
+
try {
|
|
168
|
+
this.lgas = await this.staticList.getLgas(state).catch(() => []);
|
|
169
|
+
}
|
|
170
|
+
finally {
|
|
171
|
+
this.lgasLoading = false;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
153
174
|
async load() {
|
|
154
175
|
const res = await firstValueFrom(this.apiService
|
|
155
176
|
.on('apps/commerce/address')
|
|
@@ -174,11 +195,13 @@ class AccountAddressesComponent extends BaseDirective {
|
|
|
174
195
|
this.form = blankForm();
|
|
175
196
|
this.formError = '';
|
|
176
197
|
this.editing = true;
|
|
198
|
+
this.lgas = [];
|
|
177
199
|
}
|
|
178
200
|
startEdit(a) {
|
|
179
201
|
this.form = { ...a };
|
|
180
202
|
this.formError = '';
|
|
181
203
|
this.editing = true;
|
|
204
|
+
void this.loadLgas(this.form.state);
|
|
182
205
|
}
|
|
183
206
|
cancel() {
|
|
184
207
|
this.editing = false;
|
|
@@ -251,11 +274,11 @@ class AccountAddressesComponent extends BaseDirective {
|
|
|
251
274
|
}
|
|
252
275
|
}
|
|
253
276
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: AccountAddressesComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
254
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.16", type: AccountAddressesComponent, isStandalone: false, selector: "x-account-addresses", usesInheritance: true, ngImport: i0, template: "<h2 class=\"x-acct-h2\">Addresses</h2>\n<p class=\"x-acct-sub\">Used for delivery and, later, installation visits.</p>\n\n@if (loading) {\n <div class=\"x-acct-empty\">Loading\u2026</div>\n} @else {\n @if (editing) {\n <div class=\"x-acct-card\">\n <strong>{{ form.id ? 'Edit address' : 'New address' }}</strong>\n <div style=\"margin-top: 14px\">\n <div class=\"x-acct-field\">\n <label>Label</label>\n <input [(ngModel)]=\"form.label\" placeholder=\"Home, Office, Site\u2026\" />\n </div>\n <div class=\"x-acct-field\">\n <label>State</label>\n <select aria-label=\"State\" [(ngModel)]=\"form.state\">\n <option value=\"\">Select a state</option>\n @for (s of states; track s) {\n <option [value]=\"s\">{{ s }}</option>\n }\n </select>\n </div>\n <div class=\"x-acct-field\">\n <label>LGA / area</label>\n <
|
|
277
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.16", type: AccountAddressesComponent, isStandalone: false, selector: "x-account-addresses", usesInheritance: true, ngImport: i0, template: "<h2 class=\"x-acct-h2\">Addresses</h2>\n<p class=\"x-acct-sub\">Used for delivery and, later, installation visits.</p>\n\n@if (loading) {\n <div class=\"x-acct-empty\">Loading\u2026</div>\n} @else {\n @if (editing) {\n <div class=\"x-acct-card\">\n <strong>{{ form.id ? 'Edit address' : 'New address' }}</strong>\n <div style=\"margin-top: 14px\">\n <div class=\"x-acct-field\">\n <label>Label</label>\n <input [(ngModel)]=\"form.label\" placeholder=\"Home, Office, Site\u2026\" />\n </div>\n <div class=\"x-acct-field\">\n <label>State</label>\n <select aria-label=\"State\" data-testid=\"address-state\" [(ngModel)]=\"form.state\" (ngModelChange)=\"onFormStateChange()\">\n <option value=\"\">Select a state</option>\n @for (s of states; track s.value) {\n <option [value]=\"s.value\">{{ s.label }}</option>\n }\n </select>\n </div>\n <div class=\"x-acct-field\">\n <label>LGA / area</label>\n <select aria-label=\"LGA\" data-testid=\"address-lga\" [(ngModel)]=\"form.lga\" [disabled]=\"!form.state || lgasLoading\">\n <option value=\"\">{{ form.state ? 'Select an LGA' : 'Select a state first' }}</option>\n @for (l of lgas; track l.value) {\n <option [value]=\"l.value\">{{ l.label }}</option>\n }\n </select>\n </div>\n <div class=\"x-acct-field\">\n <label>Street</label>\n <input [(ngModel)]=\"form.street\" />\n </div>\n <div class=\"x-acct-field\">\n <label>Nearest landmark</label>\n <input [(ngModel)]=\"form.landmark\" placeholder=\"e.g. opposite Zenith Bank\" />\n </div>\n <div class=\"x-acct-field\">\n <label>Building / flat info</label>\n <input [(ngModel)]=\"form.buildingInfo\" />\n </div>\n <div class=\"x-acct-field\">\n <label>Delivery notes</label>\n <input [(ngModel)]=\"form.notes\" />\n </div>\n @if (formError) {\n <div class=\"x-acct-err\">{{ formError }}</div>\n }\n <button type=\"button\" class=\"x-acct-btn\" [disabled]=\"saving\" (click)=\"save()\">\n {{ saving ? 'Saving\u2026' : 'Save address' }}\n </button>\n <button type=\"button\" class=\"x-acct-btn-ghost\" (click)=\"cancel()\" style=\"margin-left: 8px\">\n Cancel\n </button>\n </div>\n </div>\n } @else {\n <button type=\"button\" class=\"x-acct-btn\" (click)=\"startAdd()\">Add an address</button>\n }\n\n @for (a of addresses; track a.id) {\n <div class=\"x-acct-card\">\n <div class=\"x-acct-row\" style=\"border-bottom: 0; padding-top: 0\">\n <strong>\n {{ a.label }}\n @if (a.isDefault) {\n <span class=\"x-acct-pill x-acct-pill-ok\" style=\"margin-left: 6px\">Default</span>\n }\n </strong>\n <span>\n <button type=\"button\" class=\"x-acct-btn-ghost\" (click)=\"startEdit(a)\">Edit</button>\n <button type=\"button\" class=\"x-acct-btn-ghost\" (click)=\"remove(a)\" style=\"margin-left: 6px\">\n Delete\n </button>\n </span>\n </div>\n <p class=\"x-acct-sub\" style=\"margin: 0\">\n {{ a.street }}@if (a.landmark) {, near {{ a.landmark }}}<br />\n {{ a.lga ? a.lga + ', ' : '' }}{{ a.state }}\n </p>\n @if (!a.isDefault) {\n <button\n type=\"button\"\n class=\"x-acct-btn-ghost\"\n style=\"margin-top: 10px\"\n (click)=\"makeDefault(a)\"\n >\n Make default\n </button>\n }\n </div>\n } @empty {\n @if (!editing) {\n <div class=\"x-acct-empty\">No saved addresses yet.</div>\n }\n }\n}\n", dependencies: [{ kind: "directive", type: i1$1.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i1$1.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i1$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1$1.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { kind: "directive", type: i1$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }] }); }
|
|
255
278
|
}
|
|
256
279
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: AccountAddressesComponent, decorators: [{
|
|
257
280
|
type: Component,
|
|
258
|
-
args: [{ standalone: false, selector: 'x-account-addresses', template: "<h2 class=\"x-acct-h2\">Addresses</h2>\n<p class=\"x-acct-sub\">Used for delivery and, later, installation visits.</p>\n\n@if (loading) {\n <div class=\"x-acct-empty\">Loading\u2026</div>\n} @else {\n @if (editing) {\n <div class=\"x-acct-card\">\n <strong>{{ form.id ? 'Edit address' : 'New address' }}</strong>\n <div style=\"margin-top: 14px\">\n <div class=\"x-acct-field\">\n <label>Label</label>\n <input [(ngModel)]=\"form.label\" placeholder=\"Home, Office, Site\u2026\" />\n </div>\n <div class=\"x-acct-field\">\n <label>State</label>\n <select aria-label=\"State\" [(ngModel)]=\"form.state\">\n <option value=\"\">Select a state</option>\n @for (s of states; track s) {\n <option [value]=\"s\">{{ s }}</option>\n }\n </select>\n </div>\n <div class=\"x-acct-field\">\n <label>LGA / area</label>\n <
|
|
281
|
+
args: [{ standalone: false, selector: 'x-account-addresses', template: "<h2 class=\"x-acct-h2\">Addresses</h2>\n<p class=\"x-acct-sub\">Used for delivery and, later, installation visits.</p>\n\n@if (loading) {\n <div class=\"x-acct-empty\">Loading\u2026</div>\n} @else {\n @if (editing) {\n <div class=\"x-acct-card\">\n <strong>{{ form.id ? 'Edit address' : 'New address' }}</strong>\n <div style=\"margin-top: 14px\">\n <div class=\"x-acct-field\">\n <label>Label</label>\n <input [(ngModel)]=\"form.label\" placeholder=\"Home, Office, Site\u2026\" />\n </div>\n <div class=\"x-acct-field\">\n <label>State</label>\n <select aria-label=\"State\" data-testid=\"address-state\" [(ngModel)]=\"form.state\" (ngModelChange)=\"onFormStateChange()\">\n <option value=\"\">Select a state</option>\n @for (s of states; track s.value) {\n <option [value]=\"s.value\">{{ s.label }}</option>\n }\n </select>\n </div>\n <div class=\"x-acct-field\">\n <label>LGA / area</label>\n <select aria-label=\"LGA\" data-testid=\"address-lga\" [(ngModel)]=\"form.lga\" [disabled]=\"!form.state || lgasLoading\">\n <option value=\"\">{{ form.state ? 'Select an LGA' : 'Select a state first' }}</option>\n @for (l of lgas; track l.value) {\n <option [value]=\"l.value\">{{ l.label }}</option>\n }\n </select>\n </div>\n <div class=\"x-acct-field\">\n <label>Street</label>\n <input [(ngModel)]=\"form.street\" />\n </div>\n <div class=\"x-acct-field\">\n <label>Nearest landmark</label>\n <input [(ngModel)]=\"form.landmark\" placeholder=\"e.g. opposite Zenith Bank\" />\n </div>\n <div class=\"x-acct-field\">\n <label>Building / flat info</label>\n <input [(ngModel)]=\"form.buildingInfo\" />\n </div>\n <div class=\"x-acct-field\">\n <label>Delivery notes</label>\n <input [(ngModel)]=\"form.notes\" />\n </div>\n @if (formError) {\n <div class=\"x-acct-err\">{{ formError }}</div>\n }\n <button type=\"button\" class=\"x-acct-btn\" [disabled]=\"saving\" (click)=\"save()\">\n {{ saving ? 'Saving\u2026' : 'Save address' }}\n </button>\n <button type=\"button\" class=\"x-acct-btn-ghost\" (click)=\"cancel()\" style=\"margin-left: 8px\">\n Cancel\n </button>\n </div>\n </div>\n } @else {\n <button type=\"button\" class=\"x-acct-btn\" (click)=\"startAdd()\">Add an address</button>\n }\n\n @for (a of addresses; track a.id) {\n <div class=\"x-acct-card\">\n <div class=\"x-acct-row\" style=\"border-bottom: 0; padding-top: 0\">\n <strong>\n {{ a.label }}\n @if (a.isDefault) {\n <span class=\"x-acct-pill x-acct-pill-ok\" style=\"margin-left: 6px\">Default</span>\n }\n </strong>\n <span>\n <button type=\"button\" class=\"x-acct-btn-ghost\" (click)=\"startEdit(a)\">Edit</button>\n <button type=\"button\" class=\"x-acct-btn-ghost\" (click)=\"remove(a)\" style=\"margin-left: 6px\">\n Delete\n </button>\n </span>\n </div>\n <p class=\"x-acct-sub\" style=\"margin: 0\">\n {{ a.street }}@if (a.landmark) {, near {{ a.landmark }}}<br />\n {{ a.lga ? a.lga + ', ' : '' }}{{ a.state }}\n </p>\n @if (!a.isDefault) {\n <button\n type=\"button\"\n class=\"x-acct-btn-ghost\"\n style=\"margin-top: 10px\"\n (click)=\"makeDefault(a)\"\n >\n Make default\n </button>\n }\n </div>\n } @empty {\n @if (!editing) {\n <div class=\"x-acct-empty\">No saved addresses yet.</div>\n }\n }\n}\n" }]
|
|
259
282
|
}] });
|
|
260
283
|
|
|
261
284
|
// PRD Appendix B — the 17 order states, buyer-friendly labels. Shared by
|
|
@@ -1749,4 +1772,4 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImpo
|
|
|
1749
1772
|
}] });
|
|
1750
1773
|
|
|
1751
1774
|
export { AccountModule };
|
|
1752
|
-
//# sourceMappingURL=isaiahiroko-tilmart-ngx-apps-buyer-account.module-
|
|
1775
|
+
//# sourceMappingURL=isaiahiroko-tilmart-ngx-apps-buyer-account.module-BTRypX8P.mjs.map
|