@huloglobal/vendure-plugin-quotations 0.7.3 → 0.8.0
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/CHANGELOG.md +16 -0
- package/README.md +49 -2
- package/dist/plugin.d.ts +7 -3
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +43 -15
- package/dist/plugin.js.map +1 -1
- package/dist/quotation.controller.d.ts +12 -0
- package/dist/quotation.controller.d.ts.map +1 -1
- package/dist/quotation.controller.js +150 -5
- package/dist/quotation.controller.js.map +1 -1
- package/dist/quotation.service.d.ts +70 -2
- package/dist/quotation.service.d.ts.map +1 -1
- package/dist/quotation.service.js +231 -12
- package/dist/quotation.service.js.map +1 -1
- package/package.json +2 -2
- package/ui/components/quotations-widget.component.ts +55 -0
- package/ui/components/quotations.component.ts +198 -7
- package/ui/quotations-nav.module.ts +9 -2
|
@@ -29,12 +29,41 @@ interface QuoteLine {
|
|
|
29
29
|
<p class="hulo-hero-sub">Build quotes from your catalogue, email a signed accept/decline link, chase automatically, and convert wins to draft orders at the exact quoted total.</p>
|
|
30
30
|
</div>
|
|
31
31
|
<div class="hulo-hero-actions">
|
|
32
|
+
<button class="gbtn gbtn-hero hulo-help-btn" (click)="helpOpen = !helpOpen" [attr.aria-expanded]="helpOpen"><clr-icon shape="help"></clr-icon> Help</button>
|
|
32
33
|
<button class="gbtn gbtn-hero" (click)="newQuote()"><clr-icon shape="plus"></clr-icon> New quote</button>
|
|
33
34
|
<button class="gbtn gbtn-hero" (click)="reloadAll()" [disabled]="loading"><clr-icon shape="refresh"></clr-icon> Refresh</button>
|
|
34
35
|
</div>
|
|
35
36
|
</div>
|
|
36
37
|
</vdr-page-block>
|
|
37
38
|
|
|
39
|
+
<!-- Help drawer — collapsed by default: the three steps of a quote. -->
|
|
40
|
+
<vdr-page-block *ngIf="helpOpen">
|
|
41
|
+
<div class="hulo-help-drawer">
|
|
42
|
+
<div class="hulo-help-grid">
|
|
43
|
+
<div class="hulo-help-card">
|
|
44
|
+
<div class="hulo-help-num">1</div>
|
|
45
|
+
<h4>New quote</h4>
|
|
46
|
+
<p>Pick a customer (or type their details), search your catalogue for the lines — current prices fill in — and add custom lines for services. Discounts, VAT and validity come from your channel defaults.</p>
|
|
47
|
+
</div>
|
|
48
|
+
<div class="hulo-help-card">
|
|
49
|
+
<div class="hulo-help-num">2</div>
|
|
50
|
+
<h4>Send</h4>
|
|
51
|
+
<p>The customer gets a branded email with a signed link to accept or decline online. You see when it is opened; an unopened quote is chased once and an expiring one gets a reminder.</p>
|
|
52
|
+
</div>
|
|
53
|
+
<div class="hulo-help-card">
|
|
54
|
+
<div class="hulo-help-num">3</div>
|
|
55
|
+
<h4>Convert</h4>
|
|
56
|
+
<p>An accepted quote converts to a Vendure draft order at the exact quoted total — a pricing surcharge reconciles any difference to the catalogue — and you complete it in Orders as usual.</p>
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
<div class="hulo-help-links">
|
|
60
|
+
<a href="https://huloglobal.com/vendure-plugins/quotations/" target="_blank">Full docs ↗</a>
|
|
61
|
+
<a href="https://huloglobal.com/vendure-plugins/quotations/changelog/" target="_blank">Changelog ↗</a>
|
|
62
|
+
<a href="mailto:support@huloglobal.com">Support</a>
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
</vdr-page-block>
|
|
66
|
+
|
|
38
67
|
<vdr-page-block *ngIf="meta?.update?.updateAvailable && !updateDismissed">
|
|
39
68
|
<div class="update-banner">
|
|
40
69
|
<div>
|
|
@@ -63,6 +92,7 @@ interface QuoteLine {
|
|
|
63
92
|
<a href="https://huloglobal.com/vendure-plugins/quotations/" target="_blank" class="gbtn gbtn-outline gbtn-sm">Details ↗</a>
|
|
64
93
|
</div>
|
|
65
94
|
</div>
|
|
95
|
+
<div class="licence-notice" *ngIf="meta.notice?.message">{{ meta.notice.message }}</div>
|
|
66
96
|
</vdr-page-block>
|
|
67
97
|
<vdr-page-block *ngIf="meta && !meta.licensed">
|
|
68
98
|
<div class="update-banner major" *ngIf="meta.tier === 'trial'">
|
|
@@ -73,6 +103,8 @@ interface QuoteLine {
|
|
|
73
103
|
</ng-container>
|
|
74
104
|
<ng-template #evalNoClock>everything is enabled — sending, chasers and order conversion included.</ng-template>
|
|
75
105
|
Afterwards the plugin drops to the free tier (draft + preview only).
|
|
106
|
+
<div class="premium-line" *ngIf="meta.premiumFeatures?.length">Included now: {{ meta.premiumFeatures.join(' · ') }}</div>
|
|
107
|
+
<div class="sofar-line" *ngIf="meta.recentStats?.length">So far: {{ soFarLine() }}</div>
|
|
76
108
|
</div>
|
|
77
109
|
<div class="actions eval-actions">
|
|
78
110
|
<ng-container *ngIf="!remindMeSent">
|
|
@@ -87,12 +119,16 @@ interface QuoteLine {
|
|
|
87
119
|
</div>
|
|
88
120
|
</div>
|
|
89
121
|
<div class="update-banner major" *ngIf="meta.tier !== 'trial'">
|
|
90
|
-
<div><strong>🔓 Free tier</strong> — premium features need a licence. Start your <strong>14-day free trial</strong> below (card required, nothing charged until day 15, cancel any time) or buy a lifetime licence. Drafting, pricing and previews stay active; sending, chasers and order conversion need a licence. Everything you built is saved and reactivates instantly with a key
|
|
122
|
+
<div><strong>🔓 Free tier</strong> — premium features need a licence. Start your <strong>14-day free trial</strong> below (card required, nothing charged until day 15, cancel any time) or buy a lifetime licence. Drafting, pricing and previews stay active; sending, chasers and order conversion need a licence. Everything you built is saved and reactivates instantly with a key.
|
|
123
|
+
<div class="premium-line" *ngIf="meta.premiumFeatures?.length">With a licence: {{ meta.premiumFeatures.join(' · ') }}</div>
|
|
124
|
+
<div class="sofar-line" *ngIf="meta.recentStats?.length">{{ meta.eval?.source === 'server' ? 'During your evaluation' : 'So far' }}: {{ soFarLine() }}</div>
|
|
125
|
+
</div>
|
|
91
126
|
<div class="actions"><select [(ngModel)]="buyPlan" [disabled]="buying" style="padding:5px 9px;border:1px solid #d1d5db;border-radius:7px;font-size:12.5px;background:#fff;color:inherit"><option value="monthly">Monthly</option><option value="annual">Annual (2 months free)</option><option value="lifetime">Lifetime</option></select>
|
|
92
127
|
<button class="gbtn gbtn-primary gbtn-sm" (click)="buyLicence()" [disabled]="buying">{{ buying ? 'Opening checkout…' : 'Buy licence →' }}</button>
|
|
93
128
|
<span *ngIf="claim?.state === 'pending'" style="font-size:12.5px;font-weight:600">⏳ Waiting for checkout to finish — the licence installs itself. <a (click)="checkClaim(true)" style="cursor:pointer;text-decoration:underline">Check now</a></span>
|
|
94
129
|
<a href="https://huloglobal.com/vendure-plugins/quotations/" target="_blank" class="gbtn gbtn-outline gbtn-sm">Details ↗</a></div>
|
|
95
130
|
</div>
|
|
131
|
+
<div class="licence-notice" *ngIf="meta.notice?.message">{{ meta.notice.message }}</div>
|
|
96
132
|
<div class="update-banner" style="margin-top:8px">
|
|
97
133
|
<div><strong>🔑 Already have a licence key?</strong> Paste it from your purchase email to activate instantly — no .env edit, no redeploy.</div>
|
|
98
134
|
<div class="actions eval-actions">
|
|
@@ -114,11 +150,32 @@ interface QuoteLine {
|
|
|
114
150
|
|
|
115
151
|
<!-- QUOTES LIST -->
|
|
116
152
|
<ng-container *ngIf="!loading && tab==='quotes'">
|
|
153
|
+
<vdr-page-block *ngIf="setupVisible()">
|
|
154
|
+
<div class="card setup-card"><div class="card-block">
|
|
155
|
+
<div class="row-between" style="margin-bottom:6px">
|
|
156
|
+
<h3 class="step-title" style="margin:0">Set-up checklist <span class="hint inline">· {{ setupDone() }} of {{ setup.items.length }} done</span></h3>
|
|
157
|
+
<a class="setup-hide" (click)="hideSetup()">Hide</a>
|
|
158
|
+
</div>
|
|
159
|
+
<div class="setup-item" *ngFor="let it of setup.items">
|
|
160
|
+
<span class="setup-dot" [class.on]="it.done" aria-hidden="true"></span>
|
|
161
|
+
<div class="setup-text">
|
|
162
|
+
<strong>{{ it.label }}</strong>
|
|
163
|
+
<div class="hint" style="margin:2px 0 0">{{ it.hint }}</div>
|
|
164
|
+
</div>
|
|
165
|
+
<div class="setup-actions" *ngIf="!it.done">
|
|
166
|
+
<a class="setup-link" *ngIf="it.tab" (click)="setupGo(it)">{{ it.tab === 'editor' ? 'New quote' : 'Open settings' }}</a>
|
|
167
|
+
<a class="setup-link" *ngIf="it.url && !it.tab" [href]="it.url" target="_blank">Read how ↗</a>
|
|
168
|
+
<a class="setup-link" *ngIf="it.dismissible" (click)="dismissSetup(it)">Dismiss</a>
|
|
169
|
+
</div>
|
|
170
|
+
</div>
|
|
171
|
+
</div></div>
|
|
172
|
+
</vdr-page-block>
|
|
117
173
|
<vdr-page-block>
|
|
118
174
|
<div class="kpi-row">
|
|
119
175
|
<div class="kpi" [class.kpi-alert]="openRequests() > 0" (click)="showRequests()" title="Show requests awaiting a quote"><div class="kpi-label">Requests</div><div class="kpi-num">{{ openRequests() }}</div><div class="kpi-sub">{{ openRequests() ? 'waiting for a price' : 'inbox clear' }}</div></div>
|
|
120
176
|
<div class="kpi"><div class="kpi-label">Sent · 30d</div><div class="kpi-num">{{ stats?.last30?.sent || 0 }}</div><div class="kpi-sub">quotes emailed</div></div>
|
|
121
177
|
<div class="kpi"><div class="kpi-label">Win rate · 30d</div><div class="kpi-num">{{ stats?.last30?.winRate == null ? '—' : stats.last30.winRate + '%' }}</div><div class="kpi-sub">{{ stats?.last30?.won || 0 }} accepted</div></div>
|
|
178
|
+
<div class="kpi"><div class="kpi-label">Value won · 30d</div><div class="kpi-num">{{ money(stats?.last30?.valueWonPence || 0, cfg?.currency || 'GBP') }}</div><div class="kpi-sub">{{ stats?.last30?.accepted || 0 }} accepted this month</div></div>
|
|
122
179
|
<div class="kpi"><div class="kpi-label">Open pipeline</div><div class="kpi-num">{{ money(openPipeline()) }}</div><div class="kpi-sub">sent + viewed</div></div>
|
|
123
180
|
<div class="kpi"><div class="kpi-label">Avg response</div><div class="kpi-num">{{ stats?.avgResponseHours == null ? '—' : stats.avgResponseHours + 'h' }}</div><div class="kpi-sub">send → decision</div></div>
|
|
124
181
|
</div>
|
|
@@ -457,6 +514,32 @@ interface QuoteLine {
|
|
|
457
514
|
</div>
|
|
458
515
|
</div></div>
|
|
459
516
|
</vdr-page-block>
|
|
517
|
+
<vdr-page-block>
|
|
518
|
+
<div class="card"><div class="card-block">
|
|
519
|
+
<h3 class="step-title">Weekly report</h3>
|
|
520
|
+
<p class="hint">Every Monday at 08:00 (server time) Quotations emails a short report: quotes created, sent and accepted, value won, storefront requests and win rate for the week against the week before, plus the next set-up step. Needs the same SMTP settings as quote emails.</p>
|
|
521
|
+
<div class="form-grid" *ngIf="digest; else digestLoading">
|
|
522
|
+
<div class="form-row"><label>Send the weekly report</label>
|
|
523
|
+
<span class="gb-switch-group">
|
|
524
|
+
<button class="gb-switch" role="switch" [attr.aria-checked]="digest.enabled" [class.on]="digest.enabled" (click)="toggleDigest()" [disabled]="digestBusy"><span class="gb-switch-knob"></span></button>
|
|
525
|
+
<span class="gb-switch-label">{{ digest.enabled ? 'On — Monday 08:00' : 'Off' }}</span>
|
|
526
|
+
</span></div>
|
|
527
|
+
<div class="form-row"><label>Recipient</label>
|
|
528
|
+
<div class="picker" style="margin:0">
|
|
529
|
+
<input class="form-input" type="email" style="min-width:260px" [(ngModel)]="digestRecipient" [placeholder]="digest.defaultRecipient ? 'Defaults to ' + digest.defaultRecipient : 'No default yet — add a notify address above'">
|
|
530
|
+
<button class="gbtn gbtn-outline gbtn-sm" (click)="saveDigestRecipient()" [disabled]="digestBusy">Save</button>
|
|
531
|
+
</div></div>
|
|
532
|
+
<div class="form-row wide">
|
|
533
|
+
<div class="hint" style="margin:0 0 8px">Last sent {{ digest.lastSentAt ? (digest.lastSentAt | date:'d MMM y HH:mm') : 'never' }} · next {{ digest.nextDueAt ? (digest.nextDueAt | date:'d MMM y HH:mm') : '—' }}</div>
|
|
534
|
+
<div class="picker" style="margin:0">
|
|
535
|
+
<button class="gbtn gbtn-primary gbtn-sm" (click)="sendDigestTest()" [disabled]="digestBusy">{{ digestBusy ? 'Working…' : 'Send me a test' }}</button>
|
|
536
|
+
<button class="gbtn gbtn-outline gbtn-sm" (click)="previewDigest()">Preview</button>
|
|
537
|
+
</div>
|
|
538
|
+
</div>
|
|
539
|
+
</div>
|
|
540
|
+
<ng-template #digestLoading><p class="hint">Loading…</p></ng-template>
|
|
541
|
+
</div></div>
|
|
542
|
+
</vdr-page-block>
|
|
460
543
|
</ng-container>
|
|
461
544
|
|
|
462
545
|
<vdr-page-block *ngIf="loading"><div class="card"><div class="card-block"><p class="hint">Loading…</p></div></div></vdr-page-block>
|
|
@@ -583,6 +666,27 @@ interface QuoteLine {
|
|
|
583
666
|
.eval-actions { align-items:center; }
|
|
584
667
|
.eval-email { padding:5px 9px; border:1px solid var(--gb-ui-border); border-radius:7px; font-size:12.5px; min-width:190px; background:#fff; color:#0f172a; }
|
|
585
668
|
.eval-ok { font-size:12.5px; color:var(--gb-strong); font-weight:600; }
|
|
669
|
+
.premium-line { margin-top:6px; font-size:12px; color:var(--gb-muted); }
|
|
670
|
+
.sofar-line { margin-top:4px; font-size:12.5px; font-weight:600; color:var(--gb-strong); }
|
|
671
|
+
.licence-notice { margin-top:8px; padding:10px 14px; border-radius:8px; font-size:13px; line-height:1.5; background:var(--gb-tint-warn); border:1px solid var(--gb-line-warn); border-left:4px solid var(--gb-amber); color:var(--gb-strong); }
|
|
672
|
+
.setup-card { border-left:4px solid var(--gb-amber); }
|
|
673
|
+
.setup-hide { font-size:12px; color:var(--gb-muted); cursor:pointer; text-decoration:underline; text-underline-offset:2px; }
|
|
674
|
+
.setup-item { display:flex; align-items:flex-start; gap:12px; padding:9px 0; border-top:1px solid var(--gb-line-soft); }
|
|
675
|
+
.setup-item:first-of-type { border-top:0; }
|
|
676
|
+
.setup-dot { flex:0 0 auto; width:12px; height:12px; margin-top:4px; border-radius:50%; background:var(--gb-ui-border); }
|
|
677
|
+
.setup-dot.on { background:var(--gb-ok); box-shadow:0 0 0 3px color-mix(in srgb,var(--gb-ok) 25%,transparent); }
|
|
678
|
+
.setup-text { flex:1; min-width:0; font-size:13px; } .setup-text .hint { margin-bottom:0; }
|
|
679
|
+
.setup-actions { display:flex; gap:12px; flex-wrap:wrap; align-items:center; }
|
|
680
|
+
.setup-link { font-size:12.5px; font-weight:600; color:var(--gb-strong); cursor:pointer; text-decoration:underline; text-underline-offset:2px; white-space:nowrap; }
|
|
681
|
+
.hulo-help-btn clr-icon { margin-right:2px; }
|
|
682
|
+
.hulo-help-drawer { background:var(--gb-tint-warn); border:1px solid var(--gb-line-warn); border-radius:12px; padding:20px 22px; color:var(--gb-strong); }
|
|
683
|
+
.hulo-help-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(220px,1fr)); gap:16px; }
|
|
684
|
+
.hulo-help-card { background:var(--gb-surface); border-radius:10px; padding:16px; border:1px solid var(--gb-line); }
|
|
685
|
+
.hulo-help-num { width:24px; height:24px; border-radius:999px; background:var(--gb-amber); color:var(--gb-amber-ink); font-weight:800; font-size:13px; display:grid; place-items:center; margin-bottom:8px; }
|
|
686
|
+
.hulo-help-card h4 { margin:0 0 4px; font-size:14px; color:var(--gb-strong); }
|
|
687
|
+
.hulo-help-card p { margin:0; font-size:13px; line-height:1.5; color:var(--gb-muted); }
|
|
688
|
+
.hulo-help-links { margin-top:16px; padding-top:14px; border-top:1px solid var(--gb-line-warn); display:flex; gap:18px; flex-wrap:wrap; font-size:13px; }
|
|
689
|
+
.hulo-help-links a { color:var(--gb-strong); text-decoration:underline; text-underline-offset:2px; font-weight:600; }
|
|
586
690
|
|
|
587
691
|
.row-click { cursor: pointer; }
|
|
588
692
|
.row-click:hover td { background: var(--color-component-bg-200, #f8fafc); }
|
|
@@ -693,6 +797,20 @@ export class QuotationsComponent implements OnInit, OnDestroy {
|
|
|
693
797
|
licenceKeyInput = '';
|
|
694
798
|
activating = false;
|
|
695
799
|
|
|
800
|
+
/** Help drawer toggle. Rendered right under the hero when true. */
|
|
801
|
+
helpOpen = false;
|
|
802
|
+
|
|
803
|
+
// Set-up checklist (GET /quotations/setup) — hidden via localStorage once complete.
|
|
804
|
+
setup: any = null;
|
|
805
|
+
/** "Hide" collapses the card for this visit; the stored flag only keeps it
|
|
806
|
+
* away while every item stays done — an undone item brings it back. */
|
|
807
|
+
private setupHiddenNow = false;
|
|
808
|
+
|
|
809
|
+
// Weekly report card (Settings tab).
|
|
810
|
+
digest: any = null;
|
|
811
|
+
digestRecipient = '';
|
|
812
|
+
digestBusy = false;
|
|
813
|
+
|
|
696
814
|
constructor(private http: HttpClient, private notify: NotificationService, private cdr: ChangeDetectorRef) {}
|
|
697
815
|
|
|
698
816
|
ngOnInit() {
|
|
@@ -711,6 +829,8 @@ export class QuotationsComponent implements OnInit, OnDestroy {
|
|
|
711
829
|
this.loading = false;
|
|
712
830
|
this.loadList();
|
|
713
831
|
this.loadStats();
|
|
832
|
+
this.loadSetup();
|
|
833
|
+
this.loadDigest();
|
|
714
834
|
this.cdr.markForCheck();
|
|
715
835
|
},
|
|
716
836
|
error: () => { this.loading = false; this.notify.error('Could not load quotation config'); this.cdr.markForCheck(); },
|
|
@@ -719,6 +839,76 @@ export class QuotationsComponent implements OnInit, OnDestroy {
|
|
|
719
839
|
|
|
720
840
|
go(t: Tab) { this.tab = t; }
|
|
721
841
|
|
|
842
|
+
/** 402 / licence errors read as one sentence; everything else as the server's message. */
|
|
843
|
+
errMsg(e: any, what: string): string {
|
|
844
|
+
const code = e?.error?.error;
|
|
845
|
+
if (e?.status === 402 || ['licence-required', 'licence_required', 'premium-feature'].includes(code)) {
|
|
846
|
+
return `${what} needs a licence — start the free trial or activate a key at the top of this page.`;
|
|
847
|
+
}
|
|
848
|
+
return e?.error?.message || e?.error?.reason || (typeof code === 'string' ? code : '') || `${what} failed`;
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
soFarLine(): string {
|
|
852
|
+
return (this.meta?.recentStats || []).map((s: any) => `${s.value} ${s.label}`).join(' · ');
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
// ── set-up checklist ────────────────────────────────────────────────
|
|
856
|
+
loadSetup() {
|
|
857
|
+
this.http.get<any>('/quotations/setup').subscribe({ next: s => { this.setup = s; this.cdr.markForCheck(); }, error: () => undefined });
|
|
858
|
+
}
|
|
859
|
+
setupDone(): number { return (this.setup?.items || []).filter((i: any) => i.done).length; }
|
|
860
|
+
/** Shown while an item is open (even if hidden earlier); gone once complete. */
|
|
861
|
+
setupVisible(): boolean {
|
|
862
|
+
if (!this.setup?.items?.length || this.setup.complete) return false;
|
|
863
|
+
return !this.setupHiddenNow;
|
|
864
|
+
}
|
|
865
|
+
hideSetup() {
|
|
866
|
+
this.setupHiddenNow = true;
|
|
867
|
+
try { localStorage.setItem('hulo-vendure-plugin-quotations-setup-hidden', '1'); } catch { /* private mode */ }
|
|
868
|
+
}
|
|
869
|
+
setupGo(it: any) {
|
|
870
|
+
if (it.tab === 'editor') { this.newQuote(); return; }
|
|
871
|
+
if (it.tab === 'settings') { this.go('settings'); return; }
|
|
872
|
+
if (it.url) window.open(it.url, '_blank', 'noopener');
|
|
873
|
+
}
|
|
874
|
+
dismissSetup(it: any) {
|
|
875
|
+
this.http.post<any>('/quotations/setup/dismiss', { key: it.key }).subscribe({
|
|
876
|
+
next: s => { this.setup = s; this.cdr.markForCheck(); },
|
|
877
|
+
error: e => { this.notify.error(this.errMsg(e, 'Dismissing the item')); this.cdr.markForCheck(); },
|
|
878
|
+
});
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
// ── weekly report ───────────────────────────────────────────────────
|
|
882
|
+
loadDigest() {
|
|
883
|
+
this.http.get<any>('/quotations/digest/settings').subscribe({
|
|
884
|
+
next: d => { this.digest = d; this.digestRecipient = d?.recipient || ''; this.cdr.markForCheck(); },
|
|
885
|
+
error: () => undefined,
|
|
886
|
+
});
|
|
887
|
+
}
|
|
888
|
+
private saveDigest(patch: any) {
|
|
889
|
+
this.digestBusy = true;
|
|
890
|
+
this.http.post<any>('/quotations/digest/settings', patch).subscribe({
|
|
891
|
+
next: d => { this.digestBusy = false; this.digest = d; this.digestRecipient = d?.recipient || ''; this.notify.success('Weekly report settings saved'); this.cdr.markForCheck(); },
|
|
892
|
+
error: e => { this.digestBusy = false; this.notify.error(this.errMsg(e, 'Saving the weekly report settings')); this.cdr.markForCheck(); },
|
|
893
|
+
});
|
|
894
|
+
}
|
|
895
|
+
toggleDigest() { if (this.digest) this.saveDigest({ enabled: !this.digest.enabled }); }
|
|
896
|
+
saveDigestRecipient() { this.saveDigest({ recipient: (this.digestRecipient || '').trim() || null }); }
|
|
897
|
+
sendDigestTest() {
|
|
898
|
+
this.digestBusy = true;
|
|
899
|
+
const to = (this.digestRecipient || '').trim() || this.me?.email || '';
|
|
900
|
+
this.http.post<any>('/quotations/digest/send-test', to ? { to } : {}).subscribe({
|
|
901
|
+
next: r => {
|
|
902
|
+
this.digestBusy = false;
|
|
903
|
+
if (r?.sent) this.notify.success(`Test report sent to ${r.to}`);
|
|
904
|
+
else this.notify.error(r?.reason === 'no-recipient' ? 'No recipient — enter an address or add a notify address above' : (r?.reason || 'Could not send the test report'));
|
|
905
|
+
this.cdr.markForCheck();
|
|
906
|
+
},
|
|
907
|
+
error: e => { this.digestBusy = false; this.notify.error(this.errMsg(e, 'Sending the test report')); this.cdr.markForCheck(); },
|
|
908
|
+
});
|
|
909
|
+
}
|
|
910
|
+
previewDigest() { window.open('/quotations/digest/preview', '_blank'); }
|
|
911
|
+
|
|
722
912
|
// ── list / detail ───────────────────────────────────────────────────
|
|
723
913
|
loadList() {
|
|
724
914
|
const params: any = { status: this.filterStatus, page: this.page };
|
|
@@ -757,8 +947,8 @@ export class QuotationsComponent implements OnInit, OnDestroy {
|
|
|
757
947
|
send(q: any) {
|
|
758
948
|
this.busy = true;
|
|
759
949
|
this.http.post<any>(`/quotations/quotes/${q.id}/send`, {}).subscribe({
|
|
760
|
-
next: () => { this.busy = false; this.notify.success(`Quote ${q.reference} sent to ${q.customerEmail}`); this.openQuote(q.id); this.loadList(); },
|
|
761
|
-
error: e => { this.busy = false; this.notify.error(e
|
|
950
|
+
next: () => { this.busy = false; this.notify.success(`Quote ${q.reference} sent to ${q.customerEmail}`); this.openQuote(q.id); this.loadList(); this.loadStats(); this.loadSetup(); },
|
|
951
|
+
error: e => { this.busy = false; this.notify.error(this.errMsg(e, 'Sending the quote')); this.cdr.markForCheck(); },
|
|
762
952
|
});
|
|
763
953
|
}
|
|
764
954
|
|
|
@@ -766,7 +956,7 @@ export class QuotationsComponent implements OnInit, OnDestroy {
|
|
|
766
956
|
this.busy = true;
|
|
767
957
|
this.http.post<any>(`/quotations/quotes/${q.id}/convert`, {}).subscribe({
|
|
768
958
|
next: r => { this.busy = false; this.notify.success(`Draft order ${r.orderCode || r.orderId} created`); this.openQuote(q.id); this.loadList(); },
|
|
769
|
-
error: e => { this.busy = false; this.notify.error(e
|
|
959
|
+
error: e => { this.busy = false; this.notify.error(this.errMsg(e, 'Converting the quote to an order')); this.cdr.markForCheck(); },
|
|
770
960
|
});
|
|
771
961
|
}
|
|
772
962
|
|
|
@@ -934,7 +1124,7 @@ export class QuotationsComponent implements OnInit, OnDestroy {
|
|
|
934
1124
|
this.busy = true;
|
|
935
1125
|
this.http.post<any>(`/quotations/quotes/${q.id}/test-send`, { to }).subscribe({
|
|
936
1126
|
next: () => { this.busy = false; this.notify.success(`Test sent to ${to}`); this.cdr.markForCheck(); },
|
|
937
|
-
error: e => { this.busy = false; this.notify.error(e
|
|
1127
|
+
error: e => { this.busy = false; this.notify.error(this.errMsg(e, 'The test send')); this.cdr.markForCheck(); },
|
|
938
1128
|
});
|
|
939
1129
|
}
|
|
940
1130
|
|
|
@@ -987,7 +1177,7 @@ export class QuotationsComponent implements OnInit, OnDestroy {
|
|
|
987
1177
|
if (andSend) {
|
|
988
1178
|
this.http.post<any>(`/quotations/quotes/${q.id}/send`, {}).subscribe({
|
|
989
1179
|
next: () => { this.busy = false; this.notify.success(`Quote ${q.reference} sent`); this.finishEdit(q.id); },
|
|
990
|
-
error: e => { this.busy = false; this.notify.error(
|
|
1180
|
+
error: e => { this.busy = false; this.notify.error('Saved as a draft, but ' + this.errMsg(e, 'sending it').replace(/^./, c => c.toLowerCase())); this.finishEdit(q.id); },
|
|
991
1181
|
});
|
|
992
1182
|
} else {
|
|
993
1183
|
this.busy = false;
|
|
@@ -1004,6 +1194,7 @@ export class QuotationsComponent implements OnInit, OnDestroy {
|
|
|
1004
1194
|
this.tab = 'quotes';
|
|
1005
1195
|
this.loadList();
|
|
1006
1196
|
this.loadStats();
|
|
1197
|
+
this.loadSetup();
|
|
1007
1198
|
this.openQuote(id);
|
|
1008
1199
|
this.cdr.markForCheck();
|
|
1009
1200
|
}
|
|
@@ -1013,7 +1204,7 @@ export class QuotationsComponent implements OnInit, OnDestroy {
|
|
|
1013
1204
|
if (!this.cfg) return;
|
|
1014
1205
|
this.busy = true;
|
|
1015
1206
|
this.http.post<any>('/quotations/config', this.cfg).subscribe({
|
|
1016
|
-
next: () => { this.busy = false; this.notify.success('Settings saved'); this.cdr.markForCheck(); },
|
|
1207
|
+
next: () => { this.busy = false; this.notify.success('Settings saved'); this.loadSetup(); this.loadDigest(); this.cdr.markForCheck(); },
|
|
1017
1208
|
error: () => { this.busy = false; this.notify.error('Could not save settings'); this.cdr.markForCheck(); },
|
|
1018
1209
|
});
|
|
1019
1210
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { NgModule } from '@angular/core';
|
|
2
|
-
import { SharedModule, addNavMenuItem } from '@vendure/admin-ui/core';
|
|
2
|
+
import { SharedModule, addNavMenuItem, registerDashboardWidget } from '@vendure/admin-ui/core';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Registers the "Quotations" entry in the admin nav under Sales —
|
|
6
|
-
* quoting lives where orders live
|
|
6
|
+
* quoting lives where orders live — and the Quotations dashboard widget
|
|
7
|
+
* (Dashboard → Add widget → Quotations).
|
|
7
8
|
*/
|
|
8
9
|
@NgModule({
|
|
9
10
|
imports: [SharedModule],
|
|
@@ -18,6 +19,12 @@ import { SharedModule, addNavMenuItem } from '@vendure/admin-ui/core';
|
|
|
18
19
|
},
|
|
19
20
|
'sales',
|
|
20
21
|
),
|
|
22
|
+
registerDashboardWidget('hulo-vendure-plugin-quotations', {
|
|
23
|
+
title: 'Quotations',
|
|
24
|
+
supportedWidths: [4, 6, 8],
|
|
25
|
+
requiresPermissions: ['ReadSettings'],
|
|
26
|
+
loadComponent: () => import('./components/quotations-widget.component').then(m => m.QuotationsWidgetComponent),
|
|
27
|
+
}),
|
|
21
28
|
],
|
|
22
29
|
})
|
|
23
30
|
export class QuotationsNavModule {}
|