@huloglobal/vendure-plugin-quotations 0.1.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 +20 -0
- package/LICENSE +685 -0
- package/README.md +48 -0
- package/dist/crons.d.ts +15 -0
- package/dist/crons.d.ts.map +1 -0
- package/dist/crons.js +63 -0
- package/dist/crons.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/plugin.d.ts +63 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +177 -0
- package/dist/plugin.js.map +1 -0
- package/dist/pricing.d.ts +22 -0
- package/dist/pricing.d.ts.map +1 -0
- package/dist/pricing.js +46 -0
- package/dist/pricing.js.map +1 -0
- package/dist/quotation.controller.d.ts +36 -0
- package/dist/quotation.controller.d.ts.map +1 -0
- package/dist/quotation.controller.js +453 -0
- package/dist/quotation.controller.js.map +1 -0
- package/dist/quotation.service.d.ts +79 -0
- package/dist/quotation.service.d.ts.map +1 -0
- package/dist/quotation.service.js +676 -0
- package/dist/quotation.service.js.map +1 -0
- package/dist/templates.d.ts +10 -0
- package/dist/templates.d.ts.map +1 -0
- package/dist/templates.js +164 -0
- package/dist/templates.js.map +1 -0
- package/dist/types.d.ts +72 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +25 -0
- package/dist/types.js.map +1 -0
- package/package.json +39 -0
- package/ui/components/quotations.component.ts +804 -0
- package/ui/quotations.module.ts +17 -0
|
@@ -0,0 +1,804 @@
|
|
|
1
|
+
import { Component, OnInit, ChangeDetectorRef } from '@angular/core';
|
|
2
|
+
import { HttpClient } from '@angular/common/http';
|
|
3
|
+
import { NotificationService } from '@vendure/admin-ui/core';
|
|
4
|
+
|
|
5
|
+
type Tab = 'quotes' | 'editor' | 'settings';
|
|
6
|
+
|
|
7
|
+
interface QuoteLine {
|
|
8
|
+
productVariantId?: number | null; sku?: string; description: string;
|
|
9
|
+
quantity: number; unitPricePence: number; lineDiscountPercent: number;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
@Component({
|
|
13
|
+
selector: 'ees-quotations',
|
|
14
|
+
standalone: false,
|
|
15
|
+
template: `
|
|
16
|
+
<vdr-page-block>
|
|
17
|
+
<div class="hulo-hero">
|
|
18
|
+
<div class="hulo-hero-logo" aria-hidden="true">
|
|
19
|
+
<svg viewBox="0 0 64 64" xmlns="http://www.w3.org/2000/svg">
|
|
20
|
+
<rect width="64" height="64" rx="14" fill="#0f1419"/>
|
|
21
|
+
<rect x="15" y="12" width="34" height="40" rx="4" fill="none" stroke="#fff" stroke-width="2.4"/>
|
|
22
|
+
<path d="M21 22 h22 M21 29 h22 M21 36 h12" stroke="#fff" stroke-width="2.4" stroke-linecap="round"/>
|
|
23
|
+
<circle cx="44" cy="44" r="11" fill="#0f1419"/>
|
|
24
|
+
<path d="M39 44 l3.5 3.5 L50 40" fill="none" stroke="#f59e0b" stroke-width="2.8" stroke-linecap="round" stroke-linejoin="round"/>
|
|
25
|
+
</svg>
|
|
26
|
+
</div>
|
|
27
|
+
<div class="hulo-hero-text">
|
|
28
|
+
<h2 class="hulo-hero-title">Quotations</h2>
|
|
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
|
+
</div>
|
|
31
|
+
<div class="hulo-hero-actions">
|
|
32
|
+
<button class="gbtn gbtn-hero" (click)="newQuote()"><clr-icon shape="plus"></clr-icon> New quote</button>
|
|
33
|
+
<button class="gbtn gbtn-hero" (click)="reloadAll()" [disabled]="loading"><clr-icon shape="refresh"></clr-icon> Refresh</button>
|
|
34
|
+
</div>
|
|
35
|
+
</div>
|
|
36
|
+
</vdr-page-block>
|
|
37
|
+
|
|
38
|
+
<vdr-page-block *ngIf="meta?.update?.updateAvailable && !updateDismissed">
|
|
39
|
+
<div class="update-banner">
|
|
40
|
+
<div>
|
|
41
|
+
<strong>⬆️ Update available</strong> —
|
|
42
|
+
<!--email_off-->v{{ meta.update.current }} → <strong>v{{ meta.update.latest }}</strong><!--/email_off-->.
|
|
43
|
+
Run <code class="upd-cmd">npm install @huloglobal/vendure-plugin-quotations@{{ meta.update.latest }}</code> and restart.
|
|
44
|
+
</div>
|
|
45
|
+
<div class="actions">
|
|
46
|
+
<button class="gbtn gbtn-primary gbtn-sm" *ngIf="meta?.selfUpdate?.allowed" (click)="runSelfUpdate()" [disabled]="updating">{{ updating ? updateProgress : 'Update now' }}</button>
|
|
47
|
+
<button class="gbtn gbtn-outline gbtn-sm" (click)="copyUpdateCmd()">{{ cmdCopied ? 'Copied ✓' : 'Copy command' }}</button>
|
|
48
|
+
<a href="https://huloglobal.com/vendure-plugins/quotations/changelog/" target="_blank" class="gbtn gbtn-outline gbtn-sm">What’s new ↗</a>
|
|
49
|
+
<button class="gbtn gbtn-outline gbtn-sm" (click)="updateDismissed = true">Dismiss</button>
|
|
50
|
+
</div>
|
|
51
|
+
</div>
|
|
52
|
+
</vdr-page-block>
|
|
53
|
+
|
|
54
|
+
<vdr-page-block *ngIf="meta && !meta.licensed">
|
|
55
|
+
<div class="update-banner major" *ngIf="meta.tier === 'trial'">
|
|
56
|
+
<div>
|
|
57
|
+
<strong>⏳ Full-featured evaluation</strong> —
|
|
58
|
+
<ng-container *ngIf="meta.eval?.daysRemaining != null; else evalNoClock">
|
|
59
|
+
<strong>{{ meta.eval.daysRemaining }} day{{ meta.eval.daysRemaining === 1 ? '' : 's' }} left</strong> with everything enabled — sending, chasers and order conversion included.
|
|
60
|
+
</ng-container>
|
|
61
|
+
<ng-template #evalNoClock>everything is enabled — sending, chasers and order conversion included.</ng-template>
|
|
62
|
+
Afterwards the plugin drops to the free tier (draft + preview only).
|
|
63
|
+
</div>
|
|
64
|
+
<div class="actions eval-actions">
|
|
65
|
+
<ng-container *ngIf="!remindMeSent">
|
|
66
|
+
<input class="eval-email" type="email" placeholder="you@company.com" [(ngModel)]="remindEmail" [disabled]="remindMeSending">
|
|
67
|
+
<button class="gbtn gbtn-outline gbtn-sm" (click)="sendRemindMe()" [disabled]="remindMeSending || !remindEmail">{{ remindMeSending ? 'Saving…' : 'Email me before it ends' }}</button>
|
|
68
|
+
</ng-container>
|
|
69
|
+
<span *ngIf="remindMeSent" class="eval-ok">✓ We'll email you before it ends</span>
|
|
70
|
+
<a href="https://huloglobal.com/vendure-plugins/quotations/" target="_blank" class="gbtn gbtn-primary gbtn-sm">Keep it — get a licence ↗</a>
|
|
71
|
+
</div>
|
|
72
|
+
</div>
|
|
73
|
+
<div class="update-banner major" *ngIf="meta.tier !== 'trial'">
|
|
74
|
+
<div><strong>🔓 Free tier</strong> — your evaluation has ended. 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.</div>
|
|
75
|
+
<div class="actions"><a href="https://huloglobal.com/vendure-plugins/quotations/" target="_blank" class="gbtn gbtn-primary gbtn-sm">Get a licence ↗</a></div>
|
|
76
|
+
</div>
|
|
77
|
+
<div class="update-banner" style="margin-top:8px">
|
|
78
|
+
<div><strong>🔑 Already have a licence key?</strong> Paste it from your purchase email to activate instantly — no .env edit, no redeploy.</div>
|
|
79
|
+
<div class="actions eval-actions">
|
|
80
|
+
<input class="eval-email" style="min-width:280px" type="text" placeholder="eyJhbGciOi…" [(ngModel)]="licenceKeyInput" [disabled]="activating">
|
|
81
|
+
<button class="gbtn gbtn-primary gbtn-sm" (click)="activateLicence()" [disabled]="activating || !licenceKeyInput">{{ activating ? 'Verifying…' : 'Activate' }}</button>
|
|
82
|
+
</div>
|
|
83
|
+
</div>
|
|
84
|
+
</vdr-page-block>
|
|
85
|
+
|
|
86
|
+
<vdr-page-block *ngIf="!loading">
|
|
87
|
+
<div class="card top-bar"><div class="card-block">
|
|
88
|
+
<div class="tabs" role="tablist">
|
|
89
|
+
<button class="tab" role="tab" [class.active]="tab==='quotes'" (click)="go('quotes')">Quotes<span class="tab-count" *ngIf="list?.totalItems">{{ list.totalItems }}</span></button>
|
|
90
|
+
<button class="tab" role="tab" [class.active]="tab==='editor'" (click)="go('editor')">{{ editing?.id ? 'Edit ' + editing.reference : 'New quote' }}</button>
|
|
91
|
+
<button class="tab" role="tab" [class.active]="tab==='settings'" (click)="go('settings')">Settings</button>
|
|
92
|
+
</div>
|
|
93
|
+
</div></div>
|
|
94
|
+
</vdr-page-block>
|
|
95
|
+
|
|
96
|
+
<!-- QUOTES LIST -->
|
|
97
|
+
<ng-container *ngIf="!loading && tab==='quotes'">
|
|
98
|
+
<vdr-page-block>
|
|
99
|
+
<div class="kpi-row">
|
|
100
|
+
<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>
|
|
101
|
+
<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>
|
|
102
|
+
<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>
|
|
103
|
+
<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>
|
|
104
|
+
</div>
|
|
105
|
+
</vdr-page-block>
|
|
106
|
+
<vdr-page-block>
|
|
107
|
+
<div class="card"><div class="card-block">
|
|
108
|
+
<div class="row-between" style="margin-bottom:10px">
|
|
109
|
+
<div class="picker">
|
|
110
|
+
<select class="form-select" [(ngModel)]="filterStatus" (ngModelChange)="loadList()">
|
|
111
|
+
<option value="all">All statuses</option>
|
|
112
|
+
<option *ngFor="let s of statuses" [value]="s">{{ s }}</option>
|
|
113
|
+
</select>
|
|
114
|
+
<input class="form-input" style="min-width:240px" placeholder="Search ref / customer / company" [(ngModel)]="search" (keyup.enter)="loadList()">
|
|
115
|
+
<button class="gbtn gbtn-outline gbtn-sm" (click)="loadList()">Search</button>
|
|
116
|
+
</div>
|
|
117
|
+
<button class="gbtn gbtn-primary gbtn-sm" (click)="newQuote()">+ New quote</button>
|
|
118
|
+
</div>
|
|
119
|
+
<table class="table" *ngIf="list?.items?.length; else noQuotes">
|
|
120
|
+
<thead><tr><th>Ref</th><th>Customer</th><th>Total</th><th>Status</th><th>Valid until</th><th>Updated</th></tr></thead>
|
|
121
|
+
<tbody>
|
|
122
|
+
<tr *ngFor="let r of list.items" class="row-click" (click)="openQuote(r.id)">
|
|
123
|
+
<td><strong>{{ r.reference }}</strong></td>
|
|
124
|
+
<td>{{ r.customerName }}<span class="hint" *ngIf="r.customerCompany"> · {{ r.customerCompany }}</span><div class="hint">{{ r.customerEmail }}</div></td>
|
|
125
|
+
<td>{{ money(r.totalPence, r.currency) }}</td>
|
|
126
|
+
<td><span class="pill" [ngClass]="'st-' + r.status">{{ r.status }}</span></td>
|
|
127
|
+
<td class="hint">{{ r.validUntil | date:'d MMM y' }}</td>
|
|
128
|
+
<td class="hint">{{ r.updatedAt | date:'d MMM HH:mm' }}</td>
|
|
129
|
+
</tr>
|
|
130
|
+
</tbody>
|
|
131
|
+
</table>
|
|
132
|
+
<ng-template #noQuotes><p class="hint">No quotes yet — click <strong>New quote</strong> to build your first one.</p></ng-template>
|
|
133
|
+
<div class="picker" *ngIf="list && list.totalItems > list.perPage" style="margin-top:10px">
|
|
134
|
+
<button class="gbtn gbtn-outline gbtn-sm" (click)="page = page - 1; loadList()" [disabled]="page <= 1">‹ Prev</button>
|
|
135
|
+
<span class="hint">page {{ page }} / {{ maxPage() }}</span>
|
|
136
|
+
<button class="gbtn gbtn-outline gbtn-sm" (click)="page = page + 1; loadList()" [disabled]="page >= maxPage()">Next ›</button>
|
|
137
|
+
</div>
|
|
138
|
+
</div></div>
|
|
139
|
+
</vdr-page-block>
|
|
140
|
+
|
|
141
|
+
<!-- DETAIL -->
|
|
142
|
+
<vdr-page-block *ngIf="detail">
|
|
143
|
+
<div class="card"><div class="card-block">
|
|
144
|
+
<div class="row-between">
|
|
145
|
+
<h3 class="step-title" style="margin:0">{{ detail.reference }} — {{ money(detail.totalPence, detail.currency) }} <span class="pill" [ngClass]="'st-' + detail.status" style="margin-left:8px">{{ detail.status }}</span></h3>
|
|
146
|
+
<div class="picker">
|
|
147
|
+
<button class="gbtn gbtn-primary gbtn-sm" *ngIf="canSend(detail)" (click)="send(detail)" [disabled]="busy">{{ detail.sentAt ? 'Re-send' : 'Send to customer' }}</button>
|
|
148
|
+
<button class="gbtn gbtn-primary gbtn-sm" *ngIf="detail.status==='accepted'" (click)="convert(detail)" [disabled]="busy">Convert to order</button>
|
|
149
|
+
<button class="gbtn gbtn-outline gbtn-sm" *ngIf="isEditable(detail)" (click)="edit(detail)">Edit</button>
|
|
150
|
+
<button class="gbtn gbtn-outline gbtn-sm" (click)="duplicate(detail)" [disabled]="busy">Duplicate</button>
|
|
151
|
+
<button class="gbtn gbtn-outline gbtn-sm" *ngIf="detail.status==='draft'" (click)="removeQuote(detail)" [disabled]="busy">Delete</button>
|
|
152
|
+
<button class="gbtn gbtn-outline gbtn-sm" *ngIf="!['accepted','converted','cancelled','draft'].includes(detail.status)" (click)="cancel(detail)" [disabled]="busy">Withdraw</button>
|
|
153
|
+
<button class="gbtn gbtn-outline gbtn-sm" (click)="detail = null">Close</button>
|
|
154
|
+
</div>
|
|
155
|
+
</div>
|
|
156
|
+
<p class="hint" *ngIf="detail.status !== 'draft'">
|
|
157
|
+
Customer link: <a [href]="detail.publicUrl" target="_blank">{{ detail.publicUrl }}</a>
|
|
158
|
+
<button class="gbtn gbtn-outline gbtn-sm" style="margin-left:6px" (click)="copyLink(detail)">{{ linkCopied ? 'Copied ✓' : 'Copy' }}</button>
|
|
159
|
+
</p>
|
|
160
|
+
<p class="hint" *ngIf="detail.convertedOrderId">Converted to draft order <a [routerLink]="['/orders', 'draft', detail.convertedOrderId]">#{{ detail.convertedOrderId }}</a> — open it in Orders to complete.</p>
|
|
161
|
+
<table class="table">
|
|
162
|
+
<thead><tr><th>Item</th><th class="num">Qty</th><th class="num">Unit</th><th class="num">Disc.</th><th class="num">Total</th></tr></thead>
|
|
163
|
+
<tbody>
|
|
164
|
+
<tr *ngFor="let l of detail.lines">
|
|
165
|
+
<td>{{ l.description }}<div class="hint" *ngIf="l.sku">{{ l.sku }}</div></td>
|
|
166
|
+
<td class="num">{{ l.quantity }}</td>
|
|
167
|
+
<td class="num">{{ money(l.unitPricePence, detail.currency) }}</td>
|
|
168
|
+
<td class="num">{{ l.lineDiscountPercent > 0 ? l.lineDiscountPercent + '%' : '—' }}</td>
|
|
169
|
+
<td class="num">{{ money(l.totalPence, detail.currency) }}</td>
|
|
170
|
+
</tr>
|
|
171
|
+
<tr><td colspan="4" class="num hint">Subtotal</td><td class="num">{{ money(detail.subTotalPence, detail.currency) }}</td></tr>
|
|
172
|
+
<tr *ngIf="detail.discountPence > 0"><td colspan="4" class="num hint">Discount</td><td class="num">−{{ money(detail.discountPence, detail.currency) }}</td></tr>
|
|
173
|
+
<tr><td colspan="4" class="num hint">VAT ({{ detail.vatRate }}%)</td><td class="num">{{ money(detail.vatPence, detail.currency) }}</td></tr>
|
|
174
|
+
<tr><td colspan="4" class="num"><strong>Total</strong></td><td class="num"><strong>{{ money(detail.totalPence, detail.currency) }}</strong></td></tr>
|
|
175
|
+
</tbody>
|
|
176
|
+
</table>
|
|
177
|
+
<div *ngIf="detail.acceptedBy" class="hint" style="margin-top:8px">Signed: <strong>{{ detail.acceptedBy }}</strong><span *ngIf="detail.responseComment"> — “{{ detail.responseComment }}”</span></div>
|
|
178
|
+
<h4 class="step-title" style="margin-top:16px">Activity</h4>
|
|
179
|
+
<table class="table">
|
|
180
|
+
<tbody><tr *ngFor="let e of detail.events">
|
|
181
|
+
<td class="hint" style="white-space:nowrap">{{ e.createdAt | date:'d MMM HH:mm' }}</td>
|
|
182
|
+
<td><span class="pill" [ngClass]="'st-' + e.type">{{ e.type }}</span></td>
|
|
183
|
+
<td>{{ e.detail }}<span class="hint" *ngIf="e.actor"> · {{ e.actor }}</span></td>
|
|
184
|
+
</tr></tbody>
|
|
185
|
+
</table>
|
|
186
|
+
</div></div>
|
|
187
|
+
</vdr-page-block>
|
|
188
|
+
</ng-container>
|
|
189
|
+
|
|
190
|
+
<!-- EDITOR -->
|
|
191
|
+
<ng-container *ngIf="!loading && tab==='editor'">
|
|
192
|
+
<vdr-page-block>
|
|
193
|
+
<div class="card"><div class="card-block">
|
|
194
|
+
<h3 class="step-title">{{ editing.id ? 'Edit ' + editing.reference : 'New quote' }}</h3>
|
|
195
|
+
<div class="form-grid">
|
|
196
|
+
<div class="form-row" *ngIf="configs.length > 1"><label>Channel</label>
|
|
197
|
+
<select class="form-select" [(ngModel)]="editing.channelId" [disabled]="!!editing.id">
|
|
198
|
+
<option *ngFor="let c of configs" [ngValue]="c.channelId">{{ c.channelCode }}</option>
|
|
199
|
+
</select></div>
|
|
200
|
+
<div class="form-row"><label>Customer name *</label><input class="form-input" [(ngModel)]="editing.customerName" placeholder="Jane Smith"></div>
|
|
201
|
+
<div class="form-row"><label>Customer email *</label><input class="form-input" [(ngModel)]="editing.customerEmail" placeholder="jane@company.com"></div>
|
|
202
|
+
<div class="form-row"><label>Company</label><input class="form-input" [(ngModel)]="editing.customerCompany"></div>
|
|
203
|
+
<div class="form-row"><label>Phone</label><input class="form-input" [(ngModel)]="editing.customerPhone"></div>
|
|
204
|
+
</div>
|
|
205
|
+
|
|
206
|
+
<h4 class="step-title" style="margin-top:14px">Lines</h4>
|
|
207
|
+
<div class="picker" style="position:relative">
|
|
208
|
+
<input class="form-input" style="min-width:320px" placeholder="Search catalogue by name or SKU…" [(ngModel)]="variantSearch" (ngModelChange)="searchVariants()">
|
|
209
|
+
<button class="gbtn gbtn-outline gbtn-sm" (click)="addCustomLine()">+ Custom line</button>
|
|
210
|
+
<div class="dropdown" *ngIf="variantResults.length">
|
|
211
|
+
<div class="dropdown-item" *ngFor="let v of variantResults" (click)="addVariantLine(v)">
|
|
212
|
+
{{ v.name }} <span class="hint">{{ v.sku }} · {{ money(v.pricePence) }}</span>
|
|
213
|
+
</div>
|
|
214
|
+
</div>
|
|
215
|
+
</div>
|
|
216
|
+
<table class="table" *ngIf="editing.lines.length">
|
|
217
|
+
<thead><tr><th style="min-width:260px">Description</th><th>Qty</th><th>Unit £ (ex VAT)</th><th>Disc %</th><th class="num">Total</th><th></th></tr></thead>
|
|
218
|
+
<tbody>
|
|
219
|
+
<tr *ngFor="let l of editing.lines; let i = index">
|
|
220
|
+
<td><input class="form-input" [(ngModel)]="l.description"><div class="hint" *ngIf="l.sku">{{ l.sku }}</div></td>
|
|
221
|
+
<td><input class="form-input num-in" type="number" min="1" [(ngModel)]="l.quantity"></td>
|
|
222
|
+
<td><input class="form-input num-in" type="number" min="0" step="0.01" [ngModel]="l.unitPricePence / 100" (ngModelChange)="l.unitPricePence = toPence($event)"></td>
|
|
223
|
+
<td><input class="form-input num-in" type="number" min="0" max="100" [(ngModel)]="l.lineDiscountPercent"></td>
|
|
224
|
+
<td class="num">{{ money(lineTotal(l)) }}</td>
|
|
225
|
+
<td><button class="gbtn gbtn-outline gbtn-sm" (click)="editing.lines.splice(i, 1)">✕</button></td>
|
|
226
|
+
</tr>
|
|
227
|
+
</tbody>
|
|
228
|
+
</table>
|
|
229
|
+
<p class="hint" *ngIf="!editing.lines.length">Search the catalogue above, or add a custom line.</p>
|
|
230
|
+
|
|
231
|
+
<div class="form-grid" style="margin-top:12px">
|
|
232
|
+
<div class="form-row"><label>Quote discount</label>
|
|
233
|
+
<div class="picker">
|
|
234
|
+
<select class="form-select" [(ngModel)]="editing.discountType">
|
|
235
|
+
<option value="none">None</option><option value="percent">Percent</option><option value="fixed">Fixed £</option>
|
|
236
|
+
</select>
|
|
237
|
+
<input class="form-input num-in" type="number" min="0" [disabled]="editing.discountType==='none'"
|
|
238
|
+
[ngModel]="editing.discountType==='fixed' ? editing.discountValue / 100 : editing.discountValue"
|
|
239
|
+
(ngModelChange)="editing.discountValue = editing.discountType==='fixed' ? toPence($event) : $event">
|
|
240
|
+
</div></div>
|
|
241
|
+
<div class="form-row"><label>VAT rate %</label><input class="form-input num-in" type="number" min="0" max="100" [(ngModel)]="editing.vatRate"></div>
|
|
242
|
+
<div class="form-row"><label>Valid for (days)</label><input class="form-input num-in" type="number" min="1" [(ngModel)]="editing.validityDays"></div>
|
|
243
|
+
</div>
|
|
244
|
+
<div class="totals-preview">
|
|
245
|
+
<span>Subtotal {{ money(preview().subTotalPence) }}</span>
|
|
246
|
+
<span *ngIf="preview().discountPence">− {{ money(preview().discountPence) }}</span>
|
|
247
|
+
<span>VAT {{ money(preview().vatPence) }}</span>
|
|
248
|
+
<strong>Total {{ money(preview().totalPence) }}</strong>
|
|
249
|
+
</div>
|
|
250
|
+
|
|
251
|
+
<div class="form-grid" style="margin-top:12px">
|
|
252
|
+
<div class="form-row wide"><label>Notes (customer-visible)</label><textarea class="form-input" rows="2" [(ngModel)]="editing.notes"></textarea></div>
|
|
253
|
+
<div class="form-row wide"><label>Terms</label><textarea class="form-input" rows="3" [(ngModel)]="editing.terms"></textarea></div>
|
|
254
|
+
<div class="form-row wide"><label>Internal notes (never shown to the customer)</label><textarea class="form-input" rows="2" [(ngModel)]="editing.internalNotes"></textarea></div>
|
|
255
|
+
</div>
|
|
256
|
+
<div class="picker" style="margin-top:14px">
|
|
257
|
+
<button class="gbtn gbtn-primary" (click)="save(false)" [disabled]="busy || !valid()">{{ busy ? 'Saving…' : 'Save draft' }}</button>
|
|
258
|
+
<button class="gbtn gbtn-primary" (click)="save(true)" [disabled]="busy || !valid()">Save & send</button>
|
|
259
|
+
<button class="gbtn gbtn-outline" (click)="go('quotes')">Cancel</button>
|
|
260
|
+
</div>
|
|
261
|
+
</div></div>
|
|
262
|
+
</vdr-page-block>
|
|
263
|
+
</ng-container>
|
|
264
|
+
|
|
265
|
+
<!-- SETTINGS -->
|
|
266
|
+
<ng-container *ngIf="!loading && tab==='settings' && cfg">
|
|
267
|
+
<vdr-page-block>
|
|
268
|
+
<div class="card"><div class="card-block">
|
|
269
|
+
<div class="chan-row" *ngIf="configs.length > 1">
|
|
270
|
+
<label class="lbl">Channel</label>
|
|
271
|
+
<select class="form-select" [(ngModel)]="cfgIdx" (ngModelChange)="cfg = configs[cfgIdx]">
|
|
272
|
+
<option *ngFor="let c of configs; let i = index" [ngValue]="i">{{ c.channelCode }}</option>
|
|
273
|
+
</select>
|
|
274
|
+
</div>
|
|
275
|
+
<h3 class="step-title">Branding & contact</h3>
|
|
276
|
+
<div class="form-grid">
|
|
277
|
+
<div class="form-row"><label>Business name</label><input class="form-input" [(ngModel)]="cfg.businessName" placeholder="ELITE"></div>
|
|
278
|
+
<div class="form-row"><label>Reply-to email</label><input class="form-input" [(ngModel)]="cfg.replyTo" placeholder="sales@company.com"></div>
|
|
279
|
+
<div class="form-row"><label>Notify on accept/decline</label><input class="form-input" [(ngModel)]="cfg.notifyEmail" placeholder="sales@company.com"></div>
|
|
280
|
+
<div class="form-row"><label>Logo URL</label><input class="form-input" [(ngModel)]="cfg.logoUrl" placeholder="https://…/logo.png"></div>
|
|
281
|
+
<div class="form-row"><label>Accent colour</label><input class="form-input" [(ngModel)]="cfg.accentColor" placeholder="#1d4ed8"></div>
|
|
282
|
+
<div class="form-row"><label>Currency</label><input class="form-input" [(ngModel)]="cfg.currency" placeholder="GBP"></div>
|
|
283
|
+
</div>
|
|
284
|
+
<h3 class="step-title" style="margin-top:14px">Defaults & numbering</h3>
|
|
285
|
+
<div class="form-grid">
|
|
286
|
+
<div class="form-row"><label>Reference prefix</label><input class="form-input" [(ngModel)]="cfg.numberPrefix" placeholder="Q-"></div>
|
|
287
|
+
<div class="form-row"><label>Default validity (days)</label><input class="form-input num-in" type="number" min="1" [(ngModel)]="cfg.defaultValidityDays"></div>
|
|
288
|
+
<div class="form-row"><label>Default VAT rate %</label><input class="form-input num-in" type="number" min="0" [(ngModel)]="cfg.defaultVatRate"></div>
|
|
289
|
+
<div class="form-row wide"><label>Default terms</label><textarea class="form-input" rows="3" [(ngModel)]="cfg.defaultTerms"></textarea></div>
|
|
290
|
+
</div>
|
|
291
|
+
<h3 class="step-title" style="margin-top:14px">Follow-ups</h3>
|
|
292
|
+
<div class="form-grid">
|
|
293
|
+
<div class="form-row"><label>Chase unopened quotes</label>
|
|
294
|
+
<span class="gb-switch-group">
|
|
295
|
+
<button class="gb-switch" role="switch" [attr.aria-checked]="cfg.chaserEnabled" [class.on]="cfg.chaserEnabled" (click)="cfg.chaserEnabled = !cfg.chaserEnabled"><span class="gb-switch-knob"></span></button>
|
|
296
|
+
<span class="gb-switch-label">{{ cfg.chaserEnabled ? 'One reminder if unopened' : 'Off' }}</span>
|
|
297
|
+
</span></div>
|
|
298
|
+
<div class="form-row"><label>Chase after (days)</label><input class="form-input num-in" type="number" min="1" [(ngModel)]="cfg.chaserAfterDays" [disabled]="!cfg.chaserEnabled"></div>
|
|
299
|
+
<div class="form-row"><label>Expiry reminder (days before, 0 = off)</label><input class="form-input num-in" type="number" min="0" [(ngModel)]="cfg.expiryReminderDays"></div>
|
|
300
|
+
</div>
|
|
301
|
+
<h3 class="step-title" style="margin-top:14px">Quote email</h3>
|
|
302
|
+
<div class="form-grid">
|
|
303
|
+
<div class="form-row wide"><label>Subject</label><input class="form-input" [(ngModel)]="cfg.emailSubject"></div>
|
|
304
|
+
<div class="form-row wide"><label>Body</label><textarea class="form-input" rows="7" [(ngModel)]="cfg.emailBody"></textarea>
|
|
305
|
+
<div class="hint" style="margin-top:4px">Variables: {{ '{' }}{{ '{' }}reference{{ '}' }}{{ '}' }}, {{ '{' }}{{ '{' }}customerName{{ '}' }}{{ '}' }}, {{ '{' }}{{ '{' }}businessName{{ '}' }}{{ '}' }}, {{ '{' }}{{ '{' }}total{{ '}' }}{{ '}' }}, {{ '{' }}{{ '{' }}validUntil{{ '}' }}{{ '}' }}, {{ '{' }}{{ '{' }}quoteUrl{{ '}' }}{{ '}' }}</div></div>
|
|
306
|
+
</div>
|
|
307
|
+
<div class="picker" style="margin-top:14px">
|
|
308
|
+
<button class="gbtn gbtn-primary" (click)="saveConfig()" [disabled]="busy">{{ busy ? 'Saving…' : 'Save settings' }}</button>
|
|
309
|
+
</div>
|
|
310
|
+
</div></div>
|
|
311
|
+
</vdr-page-block>
|
|
312
|
+
</ng-container>
|
|
313
|
+
|
|
314
|
+
<vdr-page-block *ngIf="loading"><div class="card"><div class="card-block"><p class="hint">Loading…</p></div></div></vdr-page-block>
|
|
315
|
+
`,
|
|
316
|
+
styles: [` :host { display:block; color:var(--gb-strong); }
|
|
317
|
+
:host {
|
|
318
|
+
--gb-surface:var(--color-component-bg-100,#fafafa); --gb-surface-2:var(--color-component-bg-200,#f2f3f5);
|
|
319
|
+
--gb-line:var(--color-component-border-200,#d5d8de); --gb-line-soft:var(--color-component-border-100,#e8eaee);
|
|
320
|
+
--gb-strong:#3d4147; --gb-muted:#5d6470; --gb-ui-border:#79818f;
|
|
321
|
+
--gb-amber:#f59e0b; --gb-amber-hover:#e18f06; --gb-amber-edge:#b45309; --gb-amber-ink:#231602;
|
|
322
|
+
--gb-danger-ink:#b91c1c; --gb-ok:#10b981; --gb-warn:#f59e0b; --gb-bad:#ef4444; --gb-info:#3b82f6;
|
|
323
|
+
--gb-tint-ok:color-mix(in srgb,var(--gb-ok) 10%,var(--gb-surface)); --gb-tint-warn:color-mix(in srgb,var(--gb-warn) 12%,var(--gb-surface));
|
|
324
|
+
--gb-tint-bad:color-mix(in srgb,var(--gb-bad) 10%,var(--gb-surface)); --gb-tint-info:color-mix(in srgb,var(--gb-info) 10%,var(--gb-surface));
|
|
325
|
+
--gb-line-ok:color-mix(in srgb,var(--gb-ok) 45%,transparent); --gb-line-warn:color-mix(in srgb,var(--gb-warn) 50%,transparent);
|
|
326
|
+
--gb-line-bad:color-mix(in srgb,var(--gb-bad) 45%,transparent); --gb-line-info:color-mix(in srgb,var(--gb-info) 45%,transparent);
|
|
327
|
+
--gb-shadow-1:0 1px 2px rgba(15,23,42,.06);
|
|
328
|
+
}
|
|
329
|
+
:host-context([data-theme='dark']) { --gb-strong:var(--color-text-100,hsl(210,16%,93%)); --gb-muted:hsl(205,14%,74%); --gb-ui-border:hsl(203,12%,50%); --gb-amber-edge:#f59e0b; --gb-danger-ink:#f87171; --gb-shadow-1:0 1px 2px rgba(0,0,0,.35); }
|
|
330
|
+
.gbtn { display:inline-flex; align-items:center; justify-content:center; gap:6px; min-height:36px; padding:0 16px; border-radius:8px; font-size:13px; font-weight:600; border:1px solid transparent; background:none; cursor:pointer; color:var(--gb-strong); text-decoration:none; transition:background .12s,border-color .12s,color .12s; }
|
|
331
|
+
.gbtn:disabled { opacity:.45; cursor:not-allowed; }
|
|
332
|
+
.gbtn-sm { min-height:30px; padding:0 12px; font-size:12px; }
|
|
333
|
+
.gbtn-primary { background:var(--gb-amber); border-color:var(--gb-amber-edge); color:var(--gb-amber-ink); box-shadow:var(--gb-shadow-1); }
|
|
334
|
+
.gbtn-primary:hover:not(:disabled){ background:var(--gb-amber-hover); }
|
|
335
|
+
.gbtn-outline { border-color:var(--gb-ui-border); background:var(--gb-surface); }
|
|
336
|
+
.gbtn-outline:hover:not(:disabled){ border-color:var(--gb-amber-edge); background:var(--gb-surface-2); }
|
|
337
|
+
.gbtn-ghost { color:var(--gb-muted); } .gbtn-ghost:hover:not(:disabled){ color:var(--gb-strong); background:var(--gb-surface-2); }
|
|
338
|
+
.gbtn-hero { color:#e2e8f0; } .gbtn-hero:hover:not(:disabled){ color:#fff; background:rgba(255,255,255,.12); }
|
|
339
|
+
.hulo-hero { display:flex; align-items:center; gap:18px; padding:20px 22px; border-radius:14px; background:linear-gradient(135deg,#0f1419,#1e293b); color:#fff; box-shadow:0 1px 3px rgba(15,23,42,.15),0 8px 24px rgba(15,23,42,.08); }
|
|
340
|
+
.hulo-hero-logo { flex:0 0 auto; width:56px; height:56px; } .hulo-hero-logo svg { width:100%; height:100%; display:block; }
|
|
341
|
+
.hulo-hero-text { flex:1; min-width:0; } .hulo-hero-title { color:#fff; font-size:22px; font-weight:700; margin:0; }
|
|
342
|
+
.hulo-hero-sub { color:#cbd5e1; font-size:13px; line-height:1.5; margin:4px 0 0; max-width:720px; }
|
|
343
|
+
.hulo-hero-actions { display:flex; gap:6px; }
|
|
344
|
+
.card { background:var(--gb-surface); border:1px solid var(--gb-line); border-radius:12px; box-shadow:var(--gb-shadow-1); margin-bottom:16px; }
|
|
345
|
+
.card-block { padding:18px 20px; }
|
|
346
|
+
.row-between { display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; margin-bottom:8px; }
|
|
347
|
+
.step-title { font-size:15px; font-weight:700; color:var(--gb-strong); margin:0 0 4px; } .step-title small { font-weight:500; font-size:12px; color:var(--gb-muted); }
|
|
348
|
+
.subsection-title { margin:20px 0 10px; font-size:11px; font-weight:700; letter-spacing:.06em; text-transform:uppercase; color:var(--gb-muted); }
|
|
349
|
+
.hint { font-size:12px; color:var(--gb-muted); margin:2px 0 12px; } .hint.inline { display:inline; margin:0; }
|
|
350
|
+
.mono { font-family:ui-monospace,monospace; }
|
|
351
|
+
.top-bar { border-left:4px solid var(--gb-amber); }
|
|
352
|
+
.chan-row { display:flex; gap:12px; align-items:center; flex-wrap:wrap; }
|
|
353
|
+
.lbl { font-size:11px; font-weight:700; letter-spacing:.06em; text-transform:uppercase; color:var(--gb-muted); }
|
|
354
|
+
.form-select, .form-input { padding:7px 10px; border-radius:8px; min-height:36px; border:1px solid var(--gb-ui-border); background:var(--gb-surface); color:var(--gb-strong); font-size:13px; }
|
|
355
|
+
.form-select:focus, .form-input:focus { outline:none; border-color:var(--gb-amber-edge); box-shadow:0 0 0 3px color-mix(in srgb,var(--gb-amber) 30%,transparent); }
|
|
356
|
+
.form-select { min-width:180px; }
|
|
357
|
+
.gb-switch-group { display:inline-flex; align-items:center; gap:8px; }
|
|
358
|
+
.gb-switch { position:relative; width:44px; height:24px; border-radius:999px; border:1px solid transparent; padding:0; background:var(--gb-ui-border); cursor:pointer; }
|
|
359
|
+
.gb-switch.on { background:var(--gb-amber); border-color:var(--gb-amber-edge); }
|
|
360
|
+
.gb-switch-knob { position:absolute; top:2px; left:2px; width:18px; height:18px; border-radius:50%; background:#fff; box-shadow:0 1px 2px rgba(15,23,42,.35); transition:transform .15s; }
|
|
361
|
+
.gb-switch.on .gb-switch-knob { transform:translateX(20px); }
|
|
362
|
+
.gb-switch-label { font-size:13px; font-weight:700; }
|
|
363
|
+
.dirty-flag { font-size:12px; font-weight:700; color:var(--gb-amber-edge); }
|
|
364
|
+
.status-sentence { margin:12px 0 0; padding:10px 14px; border-radius:8px; font-size:13px; line-height:1.5; background:var(--gb-tint-ok); border:1px solid var(--gb-line-ok); border-left-width:4px; }
|
|
365
|
+
.status-sentence.status-off { background:var(--gb-surface-2); border-color:var(--gb-line); color:var(--gb-muted); }
|
|
366
|
+
.tabs { display:flex; gap:4px; margin-top:14px; flex-wrap:wrap; border-top:1px solid var(--gb-line-soft); padding-top:12px; }
|
|
367
|
+
.tab { display:inline-flex; align-items:center; gap:6px; padding:7px 14px; min-height:34px; border-radius:999px; border:1px solid transparent; background:none; cursor:pointer; font-size:13px; font-weight:600; color:var(--gb-muted); }
|
|
368
|
+
.tab:hover { color:var(--gb-strong); background:var(--gb-surface-2); } .tab.active { background:var(--gb-amber); border-color:var(--gb-amber-edge); color:var(--gb-amber-ink); }
|
|
369
|
+
.tab-count { font-size:10px; font-weight:800; min-width:16px; height:16px; padding:0 4px; border-radius:999px; display:inline-grid; place-items:center; background:color-mix(in srgb,currentColor 18%,transparent); }
|
|
370
|
+
.kpi-row { display:grid; grid-template-columns:repeat(auto-fit,minmax(160px,1fr)); gap:12px; }
|
|
371
|
+
.kpi { background:var(--gb-surface); border:1px solid var(--gb-line); border-radius:12px; padding:16px 18px; }
|
|
372
|
+
.kpi-alert { border-color:var(--gb-line-warn); border-left:4px solid var(--gb-amber); }
|
|
373
|
+
.kpi-label { font-size:11px; font-weight:700; letter-spacing:.06em; text-transform:uppercase; color:var(--gb-muted); }
|
|
374
|
+
.kpi-num { margin-top:6px; font-size:26px; font-weight:700; color:var(--gb-strong); font-variant-numeric:tabular-nums; }
|
|
375
|
+
.kpi-sub { margin-top:4px; font-size:12px; color:var(--gb-muted); }
|
|
376
|
+
.form-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(240px,1fr)); gap:12px 18px; }
|
|
377
|
+
.form-row label { display:block; font-size:12px; font-weight:700; color:var(--gb-strong); margin-bottom:4px; } .form-row label small { font-weight:500; color:var(--gb-muted); }
|
|
378
|
+
.form-row .form-input, .form-row .form-select { width:100%; }
|
|
379
|
+
.rating-box { display:flex; align-items:center; gap:16px; flex-wrap:wrap; }
|
|
380
|
+
.stars { font-size:22px; letter-spacing:2px; } .star { color:#dcdce6; } .star.on { color:#00b67a; }
|
|
381
|
+
.table { width:100%; border-collapse:collapse; font-size:13px; }
|
|
382
|
+
.table th { text-align:left; font-size:11px; font-weight:700; letter-spacing:.05em; text-transform:uppercase; color:var(--gb-muted); padding:8px 10px; border-bottom:1px solid var(--gb-line); }
|
|
383
|
+
.table td { padding:9px 10px; border-bottom:1px solid var(--gb-line-soft); color:var(--gb-strong); }
|
|
384
|
+
.table .num-col { text-align:right; }
|
|
385
|
+
.pill { font-size:11px; font-weight:700; padding:2px 9px; border-radius:999px; border:1px solid var(--gb-line); background:var(--gb-surface-2); }
|
|
386
|
+
.st-sent { background:var(--gb-tint-ok); border-color:var(--gb-line-ok); } .st-skipped { background:var(--gb-tint-info); border-color:var(--gb-line-info); } .st-failed { background:var(--gb-tint-bad); border-color:var(--gb-line-bad); }
|
|
387
|
+
.picker { display:flex; gap:8px; align-items:center; flex-wrap:wrap; margin-bottom:12px; }
|
|
388
|
+
.form-row { margin-bottom:14px; }
|
|
389
|
+
.mini-chip { font-size:11px; font-weight:600; padding:2px 7px; border-radius:5px; background:var(--gb-surface); border:1px solid var(--gb-line-warn); color:var(--gb-strong); }
|
|
390
|
+
.mini-chip.custom { border-color:var(--gb-line-info); }
|
|
391
|
+
.chip-x { display:inline-grid; place-items:center; min-width:22px; min-height:22px; border-radius:999px; background:none; border:0; cursor:pointer; font-size:15px; color:var(--gb-muted); }
|
|
392
|
+
.chip-x:hover { color:var(--gb-danger-ink); background:var(--gb-tint-bad); }
|
|
393
|
+
.rte { border:1px solid var(--gb-line); border-radius:10px; overflow:hidden; background:var(--gb-surface); }
|
|
394
|
+
.rte-head { display:flex; align-items:center; justify-content:space-between; gap:8px; padding:6px 8px; background:var(--gb-surface-2); border-bottom:1px solid var(--gb-line); flex-wrap:wrap; }
|
|
395
|
+
.rte-toolbar { display:flex; gap:2px; flex-wrap:wrap; }
|
|
396
|
+
.rte-btn { min-width:30px; height:30px; padding:0 8px; border:1px solid transparent; background:none; border-radius:6px; cursor:pointer; color:var(--gb-strong); font-size:14px; }
|
|
397
|
+
.rte-btn:hover { background:var(--gb-surface); border-color:var(--gb-line); }
|
|
398
|
+
.rte-viewtoggle { display:inline-flex; border:1px solid var(--gb-ui-border); border-radius:999px; overflow:hidden; }
|
|
399
|
+
.rte-tab { padding:4px 12px; border:0; background:none; cursor:pointer; font-size:11px; font-weight:700; color:var(--gb-muted); }
|
|
400
|
+
.rte-tab.active { background:var(--gb-amber); color:var(--gb-amber-ink); }
|
|
401
|
+
.rte-vars { display:flex; align-items:center; gap:6px; flex-wrap:wrap; padding:8px 10px; border-bottom:1px solid var(--gb-line-soft); background:var(--gb-surface); }
|
|
402
|
+
.rte-varlabel { font-size:11px; font-weight:700; color:var(--gb-muted); text-transform:uppercase; letter-spacing:.05em; }
|
|
403
|
+
.rte-chip { font-size:12px; font-weight:600; padding:3px 10px; border-radius:999px; background:var(--gb-tint-info); border:1px solid var(--gb-line-info); color:var(--gb-strong); cursor:grab; user-select:none; }
|
|
404
|
+
.rte-chip:hover { border-color:var(--gb-amber-edge); }
|
|
405
|
+
.rte-editor { min-height:240px; max-height:520px; overflow:auto; margin:12px; padding:16px 18px; background:#fff; color:#0f172a; caret-color:#0f172a; border-radius:8px; box-shadow:0 1px 3px rgba(15,23,42,.14); font-family:Arial,Helvetica,sans-serif; font-size:14px; line-height:1.6; outline:none; }
|
|
406
|
+
:host-context([data-theme='dark']) .rte-editor { box-shadow:0 2px 14px rgba(0,0,0,.5); }
|
|
407
|
+
.rte-editor ::selection { background:#b3d4fc; color:#0f172a; }
|
|
408
|
+
.rte-editor:focus { box-shadow:inset 0 0 0 2px color-mix(in srgb,var(--gb-amber) 30%,transparent); }
|
|
409
|
+
.rte-editor p, .rte-editor li, .rte-editor h1, .rte-editor h2, .rte-editor h3, .rte-editor h4, .rte-editor div, .rte-editor span, .rte-editor strong, .rte-editor em, .rte-editor td, .rte-editor th, .rte-editor blockquote, .rte-editor ul, .rte-editor ol { color: inherit; }
|
|
410
|
+
.rte-editor img { max-width:100%; height:auto; }
|
|
411
|
+
.rte-editor blockquote { border-left:3px solid #cbd5e1; margin:0 0 12px; padding:2px 0 2px 14px; color:#475569; }
|
|
412
|
+
.rte-sep { display:inline-block; width:1px; height:20px; background:var(--gb-line); margin:0 3px; vertical-align:middle; }
|
|
413
|
+
.rte-select { height:30px; border:1px solid var(--gb-line); border-radius:6px; background:var(--gb-surface); color:var(--gb-strong); font-size:12px; padding:0 4px; cursor:pointer; }
|
|
414
|
+
.rte-color { position:relative; overflow:hidden; display:inline-grid; place-items:center; }
|
|
415
|
+
.rte-color input[type=color] { position:absolute; inset:0; width:100%; height:100%; opacity:0; cursor:pointer; border:0; padding:0; }
|
|
416
|
+
.rte-editor h2 { font-size:18px; margin:0 0 8px; } .rte-editor a { color:#00b67a; }
|
|
417
|
+
.rte-source { width:100%; border:0; padding:14px 16px; background:var(--gb-surface); color:var(--gb-strong); font-family:ui-monospace,monospace; font-size:12px; line-height:1.5; outline:none; resize:vertical; }
|
|
418
|
+
.tpl-preview { margin-top:14px; padding:16px 18px; border-radius:10px; border:1px dashed var(--gb-ui-border); background:#fff; color:#0f172a; font-size:13px; }
|
|
419
|
+
.tpl-preview-subject { font-weight:700; margin-bottom:10px; padding-bottom:8px; border-bottom:1px solid var(--gb-line); }
|
|
420
|
+
.save-bar { position:sticky; bottom:12px; z-index:5; display:flex; align-items:center; gap:10px; padding:12px 16px; border-radius:12px; background:var(--gb-surface); border:1px solid var(--gb-line); box-shadow:var(--gb-shadow-1); }
|
|
421
|
+
.save-bar.is-dirty { border-color:var(--gb-amber-edge); box-shadow:0 8px 24px rgba(15,23,42,.18); }
|
|
422
|
+
.save-msg { display:inline-flex; align-items:center; gap:8px; font-size:13px; font-weight:600; } .save-msg.quiet { color:var(--gb-muted); font-weight:500; }
|
|
423
|
+
.save-dot { width:8px; height:8px; border-radius:50%; background:var(--gb-amber); box-shadow:0 0 0 3px color-mix(in srgb,var(--gb-amber) 25%,transparent); }
|
|
424
|
+
.save-spacer { flex:1; }
|
|
425
|
+
.cust-results { border:1px solid var(--gb-line); border-radius:10px; overflow:hidden; margin-bottom:12px; }
|
|
426
|
+
.cust-row { display:flex; align-items:center; gap:12px; padding:10px 14px; }
|
|
427
|
+
.cust-row + .cust-row { border-top:1px solid var(--gb-line-soft); }
|
|
428
|
+
.cust-row:hover { background:var(--gb-surface-2); }
|
|
429
|
+
.cust-info { flex:1; display:flex; flex-direction:column; gap:2px; min-width:0; }
|
|
430
|
+
.cust-info strong { font-size:13px; } .cust-info .hint { margin:0; }
|
|
431
|
+
.update-banner { display:flex; gap:12px; align-items:center; justify-content:space-between; flex-wrap:wrap; padding:12px 16px; border-radius:10px; font-size:13px; background:var(--gb-tint-warn); border:1px solid var(--gb-line-warn); }
|
|
432
|
+
.update-banner .actions { display:flex; gap:6px; }
|
|
433
|
+
.upd-cmd { font-family: monospace; font-size: 12px; background: rgba(0,0,0,.06); padding: 2px 6px; border-radius: 5px; }
|
|
434
|
+
:host-context([data-theme='dark']) .upd-cmd { background: rgba(255,255,255,.1); }
|
|
435
|
+
.eval-actions { align-items:center; }
|
|
436
|
+
.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; }
|
|
437
|
+
.eval-ok { font-size:12.5px; color:var(--gb-strong); font-weight:600; }
|
|
438
|
+
|
|
439
|
+
.row-click { cursor: pointer; }
|
|
440
|
+
.row-click:hover td { background: var(--color-component-bg-200, #f8fafc); }
|
|
441
|
+
.num { text-align: right; white-space: nowrap; }
|
|
442
|
+
.num-in { max-width: 110px; }
|
|
443
|
+
.form-row.wide { grid-column: 1 / -1; }
|
|
444
|
+
.dropdown { position: absolute; top: 100%; left: 0; z-index: 30; min-width: 380px; background: var(--color-component-bg-100, #fff); border: 1px solid var(--color-component-border-200, #e5e7eb); border-radius: 8px; box-shadow: 0 8px 22px rgba(15,20,25,.12); max-height: 300px; overflow-y: auto; }
|
|
445
|
+
.dropdown-item { padding: 9px 13px; cursor: pointer; }
|
|
446
|
+
.dropdown-item:hover { background: var(--color-component-bg-200, #f1f5f9); }
|
|
447
|
+
.totals-preview { display: flex; gap: 18px; justify-content: flex-end; align-items: baseline; padding: 10px 4px; font-size: 14px; }
|
|
448
|
+
.totals-preview strong { font-size: 17px; }
|
|
449
|
+
.st-accepted, .st-converted { background: #ecfdf5; color: #047857; }
|
|
450
|
+
.st-sent, .st-viewed { background: #eff6ff; color: #1d4ed8; }
|
|
451
|
+
.st-draft { background: #f1f5f9; color: #475569; }
|
|
452
|
+
.st-declined, .st-expired, .st-cancelled { background: #fef2f2; color: #b91c1c; }
|
|
453
|
+
`],
|
|
454
|
+
})
|
|
455
|
+
export class QuotationsComponent implements OnInit {
|
|
456
|
+
loading = true;
|
|
457
|
+
busy = false;
|
|
458
|
+
meta: any = null;
|
|
459
|
+
tab: Tab = 'quotes';
|
|
460
|
+
|
|
461
|
+
configs: any[] = [];
|
|
462
|
+
cfg: any = null;
|
|
463
|
+
cfgIdx = 0;
|
|
464
|
+
|
|
465
|
+
list: any = null;
|
|
466
|
+
stats: any = null;
|
|
467
|
+
detail: any = null;
|
|
468
|
+
filterStatus = 'all';
|
|
469
|
+
search = '';
|
|
470
|
+
page = 1;
|
|
471
|
+
statuses = ['draft', 'sent', 'viewed', 'accepted', 'declined', 'expired', 'converted', 'cancelled'];
|
|
472
|
+
|
|
473
|
+
editing: any = this.blankQuote();
|
|
474
|
+
variantSearch = '';
|
|
475
|
+
variantResults: any[] = [];
|
|
476
|
+
private searchTimer: any = null;
|
|
477
|
+
|
|
478
|
+
updateDismissed = false;
|
|
479
|
+
updating = false;
|
|
480
|
+
updateProgress = 'Updating…';
|
|
481
|
+
cmdCopied = false;
|
|
482
|
+
linkCopied = false;
|
|
483
|
+
remindEmail = '';
|
|
484
|
+
remindMeSending = false;
|
|
485
|
+
remindMeSent = false;
|
|
486
|
+
licenceKeyInput = '';
|
|
487
|
+
activating = false;
|
|
488
|
+
|
|
489
|
+
constructor(private http: HttpClient, private notify: NotificationService, private cdr: ChangeDetectorRef) {}
|
|
490
|
+
|
|
491
|
+
ngOnInit() { this.reloadAll(); }
|
|
492
|
+
|
|
493
|
+
reloadAll() {
|
|
494
|
+
this.loading = true;
|
|
495
|
+
this.http.get<any>('/quotations/meta').subscribe({ next: m => { this.meta = m; this.cdr.markForCheck(); }, error: () => undefined });
|
|
496
|
+
this.http.get<any[]>('/quotations/config').subscribe({
|
|
497
|
+
next: cs => {
|
|
498
|
+
this.configs = cs || [];
|
|
499
|
+
this.cfg = this.configs[this.cfgIdx] || this.configs[0] || null;
|
|
500
|
+
this.loading = false;
|
|
501
|
+
this.loadList();
|
|
502
|
+
this.loadStats();
|
|
503
|
+
this.cdr.markForCheck();
|
|
504
|
+
},
|
|
505
|
+
error: () => { this.loading = false; this.notify.error('Could not load quotation config'); this.cdr.markForCheck(); },
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
go(t: Tab) { this.tab = t; }
|
|
510
|
+
|
|
511
|
+
// ── list / detail ───────────────────────────────────────────────────
|
|
512
|
+
loadList() {
|
|
513
|
+
const params: any = { status: this.filterStatus, page: this.page };
|
|
514
|
+
if (this.search) params.q = this.search;
|
|
515
|
+
this.http.get<any>('/quotations/quotes', { params }).subscribe({
|
|
516
|
+
next: l => { this.list = l; this.cdr.markForCheck(); },
|
|
517
|
+
error: () => undefined,
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
loadStats() {
|
|
522
|
+
this.http.get<any>('/quotations/stats').subscribe({ next: s => { this.stats = s; this.cdr.markForCheck(); }, error: () => undefined });
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
maxPage() { return this.list ? Math.max(1, Math.ceil(this.list.totalItems / this.list.perPage)) : 1; }
|
|
526
|
+
|
|
527
|
+
openPipeline(): number {
|
|
528
|
+
const rows = this.stats?.byStatus || [];
|
|
529
|
+
return rows.filter((r: any) => r.status === 'sent' || r.status === 'viewed')
|
|
530
|
+
.reduce((s: number, r: any) => s + Number(r.value || 0), 0);
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
openQuote(id: number) {
|
|
534
|
+
this.http.get<any>(`/quotations/quotes/${id}`).subscribe({
|
|
535
|
+
next: q => { this.detail = q; this.cdr.markForCheck(); },
|
|
536
|
+
error: () => this.notify.error('Could not load the quote'),
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
isEditable(q: any) { return ['draft', 'sent', 'viewed'].includes(q.status); }
|
|
541
|
+
canSend(q: any) { return ['draft', 'sent', 'viewed'].includes(q.status) && q.customerEmail; }
|
|
542
|
+
|
|
543
|
+
send(q: any) {
|
|
544
|
+
this.busy = true;
|
|
545
|
+
this.http.post<any>(`/quotations/quotes/${q.id}/send`, {}).subscribe({
|
|
546
|
+
next: () => { this.busy = false; this.notify.success(`Quote ${q.reference} sent to ${q.customerEmail}`); this.openQuote(q.id); this.loadList(); },
|
|
547
|
+
error: e => { this.busy = false; this.notify.error(e?.error?.message || e?.error?.reason || 'Send failed'); this.cdr.markForCheck(); },
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
convert(q: any) {
|
|
552
|
+
this.busy = true;
|
|
553
|
+
this.http.post<any>(`/quotations/quotes/${q.id}/convert`, {}).subscribe({
|
|
554
|
+
next: r => { this.busy = false; this.notify.success(`Draft order ${r.orderCode || r.orderId} created`); this.openQuote(q.id); this.loadList(); },
|
|
555
|
+
error: e => { this.busy = false; this.notify.error(e?.error?.message || e?.error?.reason || 'Conversion failed'); this.cdr.markForCheck(); },
|
|
556
|
+
});
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
cancel(q: any) {
|
|
560
|
+
if (!confirm(`Withdraw quote ${q.reference}? The customer link stops working.`)) return;
|
|
561
|
+
this.busy = true;
|
|
562
|
+
this.http.post<any>(`/quotations/quotes/${q.id}/cancel`, {}).subscribe({
|
|
563
|
+
next: () => { this.busy = false; this.openQuote(q.id); this.loadList(); },
|
|
564
|
+
error: e => { this.busy = false; this.notify.error(e?.error?.error || 'Could not withdraw'); },
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
removeQuote(q: any) {
|
|
569
|
+
if (!confirm(`Delete draft ${q.reference}? This cannot be undone.`)) return;
|
|
570
|
+
this.busy = true;
|
|
571
|
+
this.http.delete<any>(`/quotations/quotes/${q.id}`).subscribe({
|
|
572
|
+
next: () => { this.busy = false; this.detail = null; this.loadList(); },
|
|
573
|
+
error: e => { this.busy = false; this.notify.error(e?.error?.error || 'Could not delete'); },
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
duplicate(q: any) {
|
|
578
|
+
this.busy = true;
|
|
579
|
+
this.http.post<any>(`/quotations/quotes/${q.id}/duplicate`, {}).subscribe({
|
|
580
|
+
next: d => { this.busy = false; this.notify.success(`Duplicated as ${d.reference}`); this.loadList(); this.openQuote(d.id); },
|
|
581
|
+
error: () => { this.busy = false; this.notify.error('Could not duplicate'); },
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
copyLink(q: any) {
|
|
586
|
+
navigator.clipboard?.writeText(q.publicUrl).then(() => {
|
|
587
|
+
this.linkCopied = true; this.cdr.markForCheck();
|
|
588
|
+
setTimeout(() => { this.linkCopied = false; this.cdr.markForCheck(); }, 2000);
|
|
589
|
+
});
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
// ── editor ──────────────────────────────────────────────────────────
|
|
593
|
+
blankQuote(): any {
|
|
594
|
+
return {
|
|
595
|
+
channelId: 1, customerName: '', customerEmail: '', customerCompany: '', customerPhone: '',
|
|
596
|
+
notes: '', internalNotes: '', terms: '', vatRate: 20, discountType: 'none', discountValue: 0,
|
|
597
|
+
validityDays: 30, lines: [] as QuoteLine[],
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
newQuote() {
|
|
602
|
+
this.editing = this.blankQuote();
|
|
603
|
+
const c = this.cfg || this.configs[0];
|
|
604
|
+
if (c) {
|
|
605
|
+
this.editing.channelId = c.channelId;
|
|
606
|
+
this.editing.vatRate = c.defaultVatRate;
|
|
607
|
+
this.editing.terms = c.defaultTerms;
|
|
608
|
+
this.editing.validityDays = c.defaultValidityDays;
|
|
609
|
+
}
|
|
610
|
+
this.tab = 'editor';
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
edit(q: any) {
|
|
614
|
+
this.editing = {
|
|
615
|
+
id: q.id, reference: q.reference, channelId: q.channelId,
|
|
616
|
+
customerName: q.customerName, customerEmail: q.customerEmail,
|
|
617
|
+
customerCompany: q.customerCompany, customerPhone: q.customerPhone,
|
|
618
|
+
notes: q.notes || '', internalNotes: q.internalNotes || '', terms: q.terms || '',
|
|
619
|
+
vatRate: Number(q.vatRate), discountType: q.discountType, discountValue: Number(q.discountValue),
|
|
620
|
+
validityDays: 30,
|
|
621
|
+
lines: (q.lines || []).map((l: any) => ({
|
|
622
|
+
productVariantId: l.productVariantId, sku: l.sku, description: l.description,
|
|
623
|
+
quantity: l.quantity, unitPricePence: l.unitPricePence, lineDiscountPercent: Number(l.lineDiscountPercent),
|
|
624
|
+
})),
|
|
625
|
+
};
|
|
626
|
+
this.tab = 'editor';
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
searchVariants() {
|
|
630
|
+
clearTimeout(this.searchTimer);
|
|
631
|
+
if (!this.variantSearch || this.variantSearch.length < 2) { this.variantResults = []; return; }
|
|
632
|
+
this.searchTimer = setTimeout(() => {
|
|
633
|
+
this.http.get<any[]>('/quotations/variants/search', { params: { channelId: this.editing.channelId, q: this.variantSearch } })
|
|
634
|
+
.subscribe({ next: r => { this.variantResults = r || []; this.cdr.markForCheck(); }, error: () => undefined });
|
|
635
|
+
}, 250);
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
addVariantLine(v: any) {
|
|
639
|
+
this.editing.lines.push({
|
|
640
|
+
productVariantId: v.productVariantId, sku: v.sku, description: v.name,
|
|
641
|
+
quantity: 1, unitPricePence: Number(v.pricePence) || 0, lineDiscountPercent: 0,
|
|
642
|
+
});
|
|
643
|
+
this.variantSearch = '';
|
|
644
|
+
this.variantResults = [];
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
addCustomLine() {
|
|
648
|
+
this.editing.lines.push({ productVariantId: null, sku: '', description: '', quantity: 1, unitPricePence: 0, lineDiscountPercent: 0 });
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
toPence(v: any): number { return Math.max(0, Math.round(Number(v || 0) * 100)); }
|
|
652
|
+
|
|
653
|
+
lineTotal(l: QuoteLine): number {
|
|
654
|
+
const disc = Math.min(100, Math.max(0, Number(l.lineDiscountPercent || 0)));
|
|
655
|
+
return Math.round(Math.max(0, l.quantity) * Math.max(0, l.unitPricePence) * (1 - disc / 100));
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
preview() {
|
|
659
|
+
const sub = this.editing.lines.reduce((s: number, l: QuoteLine) => s + this.lineTotal(l), 0);
|
|
660
|
+
let disc = 0;
|
|
661
|
+
if (this.editing.discountType === 'percent') disc = Math.round((sub * Math.min(100, Math.max(0, this.editing.discountValue))) / 100);
|
|
662
|
+
if (this.editing.discountType === 'fixed') disc = Math.min(sub, Math.max(0, Math.floor(this.editing.discountValue)));
|
|
663
|
+
const vat = Math.round(((sub - disc) * Math.min(100, Math.max(0, this.editing.vatRate))) / 100);
|
|
664
|
+
return { subTotalPence: sub, discountPence: disc, vatPence: vat, totalPence: sub - disc + vat };
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
valid(): boolean {
|
|
668
|
+
return !!(this.editing.customerName && /.+@.+\..+/.test(this.editing.customerEmail || '') && this.editing.lines.length);
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
save(andSend: boolean) {
|
|
672
|
+
this.busy = true;
|
|
673
|
+
const req = this.editing.id
|
|
674
|
+
? this.http.put<any>(`/quotations/quotes/${this.editing.id}`, this.editing)
|
|
675
|
+
: this.http.post<any>('/quotations/quotes', this.editing);
|
|
676
|
+
req.subscribe({
|
|
677
|
+
next: q => {
|
|
678
|
+
if (andSend) {
|
|
679
|
+
this.http.post<any>(`/quotations/quotes/${q.id}/send`, {}).subscribe({
|
|
680
|
+
next: () => { this.busy = false; this.notify.success(`Quote ${q.reference} sent`); this.finishEdit(q.id); },
|
|
681
|
+
error: e => { this.busy = false; this.notify.error(e?.error?.message || e?.error?.reason || 'Saved, but sending failed'); this.finishEdit(q.id); },
|
|
682
|
+
});
|
|
683
|
+
} else {
|
|
684
|
+
this.busy = false;
|
|
685
|
+
this.notify.success(`Quote ${q.reference} saved`);
|
|
686
|
+
this.finishEdit(q.id);
|
|
687
|
+
}
|
|
688
|
+
},
|
|
689
|
+
error: e => { this.busy = false; this.notify.error(e?.error?.error || 'Save failed'); this.cdr.markForCheck(); },
|
|
690
|
+
});
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
private finishEdit(id: number) {
|
|
694
|
+
this.editing = this.blankQuote();
|
|
695
|
+
this.tab = 'quotes';
|
|
696
|
+
this.loadList();
|
|
697
|
+
this.loadStats();
|
|
698
|
+
this.openQuote(id);
|
|
699
|
+
this.cdr.markForCheck();
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
// ── settings ────────────────────────────────────────────────────────
|
|
703
|
+
saveConfig() {
|
|
704
|
+
if (!this.cfg) return;
|
|
705
|
+
this.busy = true;
|
|
706
|
+
this.http.post<any>('/quotations/config', this.cfg).subscribe({
|
|
707
|
+
next: () => { this.busy = false; this.notify.success('Settings saved'); this.cdr.markForCheck(); },
|
|
708
|
+
error: () => { this.busy = false; this.notify.error('Could not save settings'); this.cdr.markForCheck(); },
|
|
709
|
+
});
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
// ── shared helpers ──────────────────────────────────────────────────
|
|
713
|
+
money(pence: number, currency = 'GBP'): string {
|
|
714
|
+
const sym: any = { GBP: '£', USD: '$', EUR: '€', AUD: 'A$', CAD: 'C$' };
|
|
715
|
+
return `${sym[currency] ?? currency + ' '}${((Number(pence) || 0) / 100).toFixed(2)}`;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
copyUpdateCmd() {
|
|
719
|
+
const cmd = `npm install @huloglobal/vendure-plugin-quotations@${this.meta?.update?.latest || 'latest'}`;
|
|
720
|
+
navigator.clipboard?.writeText(cmd).then(() => {
|
|
721
|
+
this.cmdCopied = true; this.cdr.markForCheck();
|
|
722
|
+
setTimeout(() => { this.cmdCopied = false; this.cdr.markForCheck(); }, 2000);
|
|
723
|
+
});
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
runSelfUpdate() {
|
|
727
|
+
const target = this.meta?.update?.latest;
|
|
728
|
+
if (!target || this.updating) return;
|
|
729
|
+
this.updating = true;
|
|
730
|
+
this.updateProgress = 'Installing…';
|
|
731
|
+
this.cdr.markForCheck();
|
|
732
|
+
this.http.post<any>('/quotations/update/run', { version: target }).subscribe({
|
|
733
|
+
next: r => {
|
|
734
|
+
if (r?.restartScheduled) {
|
|
735
|
+
this.updateProgress = 'Restarting…';
|
|
736
|
+
this.notify.success(r.message || 'Updated — server restarting');
|
|
737
|
+
this.pollAfterRestart(target);
|
|
738
|
+
} else {
|
|
739
|
+
this.updating = false;
|
|
740
|
+
this.notify.success(r?.message || 'Installed — restart the server to load it');
|
|
741
|
+
}
|
|
742
|
+
this.cdr.markForCheck();
|
|
743
|
+
},
|
|
744
|
+
error: e => {
|
|
745
|
+
this.updating = false;
|
|
746
|
+
this.notify.error(e?.error?.message || 'Update failed — nothing was changed');
|
|
747
|
+
this.cdr.markForCheck();
|
|
748
|
+
},
|
|
749
|
+
});
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
private pollAfterRestart(target: string, attempt = 0) {
|
|
753
|
+
if (attempt > 40) {
|
|
754
|
+
this.updating = false;
|
|
755
|
+
this.notify.error('The server has not come back yet — check your process manager');
|
|
756
|
+
this.cdr.markForCheck();
|
|
757
|
+
return;
|
|
758
|
+
}
|
|
759
|
+
setTimeout(() => {
|
|
760
|
+
this.http.get<any>('/quotations/meta').subscribe({
|
|
761
|
+
next: m => {
|
|
762
|
+
const v = m?.version || m?.update?.current;
|
|
763
|
+
if (v === target) {
|
|
764
|
+
this.updating = false;
|
|
765
|
+
this.meta = m;
|
|
766
|
+
this.notify.success(`Now running v${target}`);
|
|
767
|
+
this.cdr.markForCheck();
|
|
768
|
+
} else {
|
|
769
|
+
this.pollAfterRestart(target, attempt + 1);
|
|
770
|
+
}
|
|
771
|
+
},
|
|
772
|
+
error: () => this.pollAfterRestart(target, attempt + 1),
|
|
773
|
+
});
|
|
774
|
+
}, 3000);
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
sendRemindMe() {
|
|
778
|
+
if (!this.remindEmail) return;
|
|
779
|
+
this.remindMeSending = true;
|
|
780
|
+
this.http.post<any>('/quotations/eval/remind-me', { email: this.remindEmail }).subscribe({
|
|
781
|
+
next: () => { this.remindMeSending = false; this.remindMeSent = true; this.cdr.markForCheck(); },
|
|
782
|
+
error: () => { this.remindMeSending = false; this.notify.error('Could not save the reminder — try again'); this.cdr.markForCheck(); },
|
|
783
|
+
});
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
activateLicence() {
|
|
787
|
+
const key = (this.licenceKeyInput || '').trim();
|
|
788
|
+
if (!key) return;
|
|
789
|
+
this.activating = true;
|
|
790
|
+
this.http.post<any>('/quotations/licence/activate', { key }).subscribe({
|
|
791
|
+
next: r => {
|
|
792
|
+
this.activating = false;
|
|
793
|
+
this.notify.success(r?.message || 'Licence activated');
|
|
794
|
+
this.licenceKeyInput = '';
|
|
795
|
+
this.reloadAll();
|
|
796
|
+
},
|
|
797
|
+
error: e => {
|
|
798
|
+
this.activating = false;
|
|
799
|
+
this.notify.error(e?.error?.message || 'That key could not be verified');
|
|
800
|
+
this.cdr.markForCheck();
|
|
801
|
+
},
|
|
802
|
+
});
|
|
803
|
+
}
|
|
804
|
+
}
|