@aglyn/plugins-commerce 1.15.2 → 1.16.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/README.md +1 -1
- package/package.json +13 -13
- package/src/lib/components/cart.js +2 -1
- package/src/lib/components/cart.js.map +1 -1
- package/src/lib/components/console/payments-settings-card.component.js +6 -1
- package/src/lib/components/console/payments-settings-card.component.js.map +1 -1
- package/src/lib/components/console/pos/pos-api.d.ts +5 -0
- package/src/lib/components/console/pos/pos-api.js.map +1 -1
- package/src/lib/components/console/pos/pos-tender-dialogs.component.d.ts +2 -0
- package/src/lib/components/console/pos/pos-tender-dialogs.component.js +13 -6
- package/src/lib/components/console/pos/pos-tender-dialogs.component.js.map +1 -1
- package/src/lib/components/console/pos/pos-tender-panel.component.js +7 -4
- package/src/lib/components/console/pos/pos-tender-panel.component.js.map +1 -1
- package/src/lib/components/console/product-add-ons-fields.component.d.ts +13 -0
- package/src/lib/components/console/product-add-ons-fields.component.js +96 -3
- package/src/lib/components/console/product-add-ons-fields.component.js.map +1 -1
- package/src/lib/components/console/product-builder-fields.component.d.ts +39 -0
- package/src/lib/components/console/product-builder-fields.component.js +195 -0
- package/src/lib/components/console/product-builder-fields.component.js.map +1 -0
- package/src/lib/components/console/product-editor-dialog.component.js +35 -2
- package/src/lib/components/console/product-editor-dialog.component.js.map +1 -1
- package/src/lib/components/console/quote-editor-dialog.component.js +43 -6
- package/src/lib/components/console/quote-editor-dialog.component.js.map +1 -1
- package/src/lib/components/console/quote-messages.component.d.ts +21 -0
- package/src/lib/components/console/quote-messages.component.js +185 -0
- package/src/lib/components/console/quote-messages.component.js.map +1 -0
- package/src/lib/components/console/quote-pay-link.component.js +1 -1
- package/src/lib/components/console/quote-pay-link.component.js.map +1 -1
- package/src/lib/components/console/quote-proofs.component.js +30 -3
- package/src/lib/components/console/quote-proofs.component.js.map +1 -1
- package/src/lib/components/console/quote-settings-card.component.d.ts +7 -3
- package/src/lib/components/console/quote-settings-card.component.js +154 -24
- package/src/lib/components/console/quote-settings-card.component.js.map +1 -1
- package/src/lib/components/product-builder-context.d.ts +22 -0
- package/src/lib/components/product-builder-context.js +21 -0
- package/src/lib/components/product-builder-context.js.map +1 -0
- package/src/lib/components/product-builder-mockup.d.ts +42 -0
- package/src/lib/components/product-builder-mockup.js +120 -0
- package/src/lib/components/product-builder-mockup.js.map +1 -0
- package/src/lib/components/product-builder-sample.d.ts +63 -0
- package/src/lib/components/product-builder-sample.js +96 -0
- package/src/lib/components/product-builder-sample.js.map +1 -0
- package/src/lib/components/product-choice-cards.d.ts +51 -0
- package/src/lib/components/product-choice-cards.js +311 -0
- package/src/lib/components/product-choice-cards.js.map +1 -0
- package/src/lib/components/product-detail-panels.d.ts +42 -0
- package/src/lib/components/product-detail-panels.js +185 -0
- package/src/lib/components/product-detail-panels.js.map +1 -0
- package/src/lib/components/product-detail.d.ts +20 -12
- package/src/lib/components/product-detail.js +136 -221
- package/src/lib/components/product-detail.js.map +1 -1
- package/src/lib/components/product-grid.d.ts +7 -0
- package/src/lib/components/product-grid.js +11 -8
- package/src/lib/components/product-grid.js.map +1 -1
- package/src/lib/components/product-options-field-body.d.ts +9 -8
- package/src/lib/components/product-options-field-body.js +152 -3
- package/src/lib/components/product-options-field-body.js.map +1 -1
- package/src/lib/components/product-options-field.js +1 -1
- package/src/lib/components/product-options-field.js.map +1 -1
- package/src/lib/components/product-photo-fit.d.ts +49 -0
- package/src/lib/components/product-photo-fit.js +58 -0
- package/src/lib/components/product-photo-fit.js.map +1 -0
- package/src/lib/components/product-restock-notify.d.ts +12 -0
- package/src/lib/components/product-restock-notify.js +86 -0
- package/src/lib/components/product-restock-notify.js.map +1 -0
- package/src/lib/components/quote-messages-panel.d.ts +21 -0
- package/src/lib/components/quote-messages-panel.js +191 -0
- package/src/lib/components/quote-messages-panel.js.map +1 -0
- package/src/lib/components/quote-page-body.js +15 -1
- package/src/lib/components/quote-page-body.js.map +1 -1
- package/src/lib/components/quote-proof-panel.d.ts +6 -3
- package/src/lib/components/quote-proof-panel.js +139 -14
- package/src/lib/components/quote-proof-panel.js.map +1 -1
- package/src/lib/components/related-products.d.ts +7 -0
- package/src/lib/components/related-products.js +8 -6
- package/src/lib/components/related-products.js.map +1 -1
- package/src/lib/constants/quote-page.d.ts +8 -0
- package/src/lib/constants/quote-page.js +11 -0
- package/src/lib/constants/quote-page.js.map +1 -1
- package/src/lib/model/commerce-cart.d.ts +6 -1
- package/src/lib/model/commerce-cart.js +5 -1
- package/src/lib/model/commerce-cart.js.map +1 -1
- package/src/lib/model/commerce-invoices.js +5 -1
- package/src/lib/model/commerce-invoices.js.map +1 -1
- package/src/lib/model/commerce-pos-ops.d.ts +3 -0
- package/src/lib/model/commerce-pos-ops.js +3 -0
- package/src/lib/model/commerce-pos-ops.js.map +1 -1
- package/src/lib/model/commerce-pos.d.ts +8 -0
- package/src/lib/model/commerce-pos.js.map +1 -1
- package/src/lib/model/commerce-quote-messages.d.ts +106 -0
- package/src/lib/model/commerce-quote-messages.js +146 -0
- package/src/lib/model/commerce-quote-messages.js.map +1 -0
- package/src/lib/model/commerce-quote-pay.d.ts +31 -2
- package/src/lib/model/commerce-quote-pay.js +31 -7
- package/src/lib/model/commerce-quote-pay.js.map +1 -1
- package/src/lib/model/commerce-quote-proofs.d.ts +47 -8
- package/src/lib/model/commerce-quote-proofs.js +73 -18
- package/src/lib/model/commerce-quote-proofs.js.map +1 -1
- package/src/lib/model/commerce-quote-request.d.ts +14 -4
- package/src/lib/model/commerce-quote-request.js +25 -2
- package/src/lib/model/commerce-quote-request.js.map +1 -1
- package/src/lib/model/commerce-quotes.d.ts +56 -3
- package/src/lib/model/commerce-quotes.js +47 -2
- package/src/lib/model/commerce-quotes.js.map +1 -1
- package/src/lib/model/commerce.d.ts +12 -1
- package/src/lib/model/commerce.js.map +1 -1
- package/src/lib/model/index.d.ts +1 -0
- package/src/lib/model/index.js +1 -0
- package/src/lib/model/index.js.map +1 -1
- package/src/lib/model/pos-cellular.d.ts +5 -0
- package/src/lib/model/pos-cellular.js.map +1 -1
- package/src/lib/model/product-card-rules.d.ts +41 -0
- package/src/lib/model/product-card-rules.js +90 -0
- package/src/lib/model/product-card-rules.js.map +1 -0
- package/src/lib/model/product-modifiers.d.ts +11 -0
- package/src/lib/model/product-modifiers.js +10 -0
- package/src/lib/model/product-modifiers.js.map +1 -1
- package/src/lib/model/product-write.d.ts +3 -0
- package/src/lib/server/billing-webhook.js +6 -2
- package/src/lib/server/billing-webhook.js.map +1 -1
- package/src/lib/server/cancel-order.js +15 -0
- package/src/lib/server/cancel-order.js.map +1 -1
- package/src/lib/server/channel-order-updates.js +15 -1
- package/src/lib/server/channel-order-updates.js.map +1 -1
- package/src/lib/server/channel-orders.js +20 -0
- package/src/lib/server/channel-orders.js.map +1 -1
- package/src/lib/server/checkout.js +1 -1
- package/src/lib/server/checkout.js.map +1 -1
- package/src/lib/server/local-fulfillment.js +1 -1
- package/src/lib/server/local-fulfillment.js.map +1 -1
- package/src/lib/server/pos-cellular-billing.d.ts +1 -1
- package/src/lib/server/pos-cellular-billing.js +2 -1
- package/src/lib/server/pos-cellular-billing.js.map +1 -1
- package/src/lib/server/pos-cellular.d.ts +3 -1
- package/src/lib/server/pos-cellular.js +15 -8
- package/src/lib/server/pos-cellular.js.map +1 -1
- package/src/lib/server/pos-offline-sync.d.ts +3 -3
- package/src/lib/server/pos-offline-sync.js +17 -4
- package/src/lib/server/pos-offline-sync.js.map +1 -1
- package/src/lib/server/pos-order.js +17 -6
- package/src/lib/server/pos-order.js.map +1 -1
- package/src/lib/server/pos-payment.js +27 -11
- package/src/lib/server/pos-payment.js.map +1 -1
- package/src/lib/server/pos-reader-splash.js +10 -5
- package/src/lib/server/pos-reader-splash.js.map +1 -1
- package/src/lib/server/pos-readers.js +34 -10
- package/src/lib/server/pos-readers.js.map +1 -1
- package/src/lib/server/pos-return.js +19 -3
- package/src/lib/server/pos-return.js.map +1 -1
- package/src/lib/server/pos-stripe.d.ts +14 -0
- package/src/lib/server/pos-stripe.js +6 -2
- package/src/lib/server/pos-stripe.js.map +1 -1
- package/src/lib/server/pos-terminal-connection-token.js +23 -9
- package/src/lib/server/pos-terminal-connection-token.js.map +1 -1
- package/src/lib/server/pos-terminal.d.ts +80 -14
- package/src/lib/server/pos-terminal.js +393 -123
- package/src/lib/server/pos-terminal.js.map +1 -1
- package/src/lib/server/product-drafts.d.ts +1 -1
- package/src/lib/server/product-drafts.js +4 -3
- package/src/lib/server/product-drafts.js.map +1 -1
- package/src/lib/server/product-writer.js +5 -4
- package/src/lib/server/product-writer.js.map +1 -1
- package/src/lib/server/product.d.ts +11 -0
- package/src/lib/server/product.js +18 -3
- package/src/lib/server/product.js.map +1 -1
- package/src/lib/server/products-write.js +4 -3
- package/src/lib/server/products-write.js.map +1 -1
- package/src/lib/server/quote-email.d.ts +26 -0
- package/src/lib/server/quote-email.js +73 -7
- package/src/lib/server/quote-email.js.map +1 -1
- package/src/lib/server/quote-messages.d.ts +72 -0
- package/src/lib/server/quote-messages.js +356 -0
- package/src/lib/server/quote-messages.js.map +1 -0
- package/src/lib/server/quote-pay.d.ts +42 -0
- package/src/lib/server/quote-pay.js +81 -4
- package/src/lib/server/quote-pay.js.map +1 -1
- package/src/lib/server/quote-proofs.d.ts +1 -1
- package/src/lib/server/quote-proofs.js +63 -19
- package/src/lib/server/quote-proofs.js.map +1 -1
- package/src/lib/server/quote.d.ts +12 -0
- package/src/lib/server/quote.js +44 -14
- package/src/lib/server/quote.js.map +1 -1
- package/src/lib/server/refund.js +3 -1
- package/src/lib/server/refund.js.map +1 -1
- package/src/lib/server/reserve-stock.js +9 -0
- package/src/lib/server/reserve-stock.js.map +1 -1
- package/src/lib/server/returns.js +15 -1
- package/src/lib/server/returns.js.map +1 -1
- package/src/lib/server/reviews.js +15 -0
- package/src/lib/server/reviews.js.map +1 -1
- package/src/lib/server/sold-out-drop.d.ts +58 -0
- package/src/lib/server/sold-out-drop.js +81 -0
- package/src/lib/server/sold-out-drop.js.map +1 -0
- package/src/lib/server/stock-levels.js +9 -0
- package/src/lib/server/stock-levels.js.map +1 -1
- package/src/lib/server/stripe-refund.d.ts +7 -0
- package/src/lib/server/stripe-refund.js +26 -7
- package/src/lib/server/stripe-refund.js.map +1 -1
- package/src/lib/server.js +2 -0
- package/src/lib/server.js.map +1 -1
- package/src/lib/tenant-emails.js +85 -2
- package/src/lib/tenant-emails.js.map +1 -1
- package/src/lib/testing/fake-seller-payment-account.d.ts +29 -0
- package/src/lib/testing/fake-seller-payment-account.js +40 -0
- package/src/lib/testing/fake-seller-payment-account.js.map +1 -0
- package/src/lib/transfer/product-transfer.js +6 -5
- package/src/lib/transfer/product-transfer.js.map +1 -1
- package/src/lib/transfer/products.server.js +4 -3
- package/src/lib/transfer/products.server.js.map +1 -1
- package/src/lib/utils/quote-email-content.d.ts +6 -0
- package/src/lib/utils/quote-email-content.js +6 -3
- package/src/lib/utils/quote-email-content.js.map +1 -1
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/ 'use client';
|
|
17
|
+
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
18
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
|
+
import * as CommerceModel from "../../model/index.js";
|
|
20
|
+
import { commerceSitePermissionRefusal } from "../../model/plugin-permissions.js";
|
|
21
|
+
import { ReplyComposer, ReplyThread } from "@aglyn/shared-ui-jsx/components/reply-composer.component";
|
|
22
|
+
import { useSnackbar } from "@aglyn/shared-ui-snackstack";
|
|
23
|
+
import { authorizedFetch } from "@aglyn/shared-util-http/authorized-token";
|
|
24
|
+
import { useUser } from "@aglyn/tenant-feature-instance";
|
|
25
|
+
import { Alert, Stack, Typography } from "@mui/material";
|
|
26
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
27
|
+
const SEND_REFUSAL = commerceSitePermissionRefusal('commerce.quotes.send');
|
|
28
|
+
const newKey = ()=>{
|
|
29
|
+
var _ref;
|
|
30
|
+
var _globalThis_crypto_randomUUID, _globalThis_crypto;
|
|
31
|
+
return (_ref = (_globalThis_crypto = globalThis.crypto) == null ? void 0 : (_globalThis_crypto_randomUUID = _globalThis_crypto.randomUUID) == null ? void 0 : _globalThis_crypto_randomUUID.call(_globalThis_crypto)) != null ? _ref : `${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* The quote's conversation with its customer (AGL-4207), in the quote's
|
|
35
|
+
* dialog: every reply sent from here and everything the customer wrote on
|
|
36
|
+
* the quote page, oldest first, and a reply box. The same composer as the
|
|
37
|
+
* Inbox's reply. A reply goes by email in the quote's own conversation in
|
|
38
|
+
* the customer's mailbox, and their email answer reaches the site's contact
|
|
39
|
+
* email (or the sender's), not this list: nothing here receives mail.
|
|
40
|
+
*/ export function QuoteMessagesSection(props) {
|
|
41
|
+
const { hostId, quoteId, quote, canSend } = props;
|
|
42
|
+
const { data: user } = useUser();
|
|
43
|
+
const { enqueueSnackbar } = useSnackbar();
|
|
44
|
+
const [messages, setMessages] = useState([]);
|
|
45
|
+
const [loadError, setLoadError] = useState('');
|
|
46
|
+
const [message, setMessage] = useState('');
|
|
47
|
+
const [busy, setBusy] = useState(false);
|
|
48
|
+
const attempt = useRef('');
|
|
49
|
+
const refused = CommerceModel.quoteReplyRefusal({
|
|
50
|
+
channel: 'quote',
|
|
51
|
+
quote: quote.quote
|
|
52
|
+
});
|
|
53
|
+
const to = CommerceModel.quoteReplyRecipient(quote);
|
|
54
|
+
const post = useCallback(async (body, headers = {})=>{
|
|
55
|
+
const response = await authorizedFetch(user, '/api/commerce/quote', {
|
|
56
|
+
method: 'POST',
|
|
57
|
+
headers: _extends({
|
|
58
|
+
'Content-Type': 'application/json'
|
|
59
|
+
}, headers),
|
|
60
|
+
body: JSON.stringify(_extends({
|
|
61
|
+
hostId,
|
|
62
|
+
quoteId
|
|
63
|
+
}, body))
|
|
64
|
+
});
|
|
65
|
+
return {
|
|
66
|
+
ok: response.ok,
|
|
67
|
+
payload: await response.json().catch(()=>({}))
|
|
68
|
+
};
|
|
69
|
+
}, [
|
|
70
|
+
user,
|
|
71
|
+
hostId,
|
|
72
|
+
quoteId
|
|
73
|
+
]);
|
|
74
|
+
const load = useCallback(async ()=>{
|
|
75
|
+
if (!user) return;
|
|
76
|
+
try {
|
|
77
|
+
var _payload_error;
|
|
78
|
+
const { ok, payload } = await post({
|
|
79
|
+
action: 'messages'
|
|
80
|
+
});
|
|
81
|
+
if (!ok) return void setLoadError(String((_payload_error = payload['error']) != null ? _payload_error : 'The messages could not be loaded.'));
|
|
82
|
+
setLoadError('');
|
|
83
|
+
setMessages(Array.isArray(payload['messages']) ? payload['messages'] : []);
|
|
84
|
+
} catch (unused) {
|
|
85
|
+
setLoadError('The messages could not be loaded.');
|
|
86
|
+
}
|
|
87
|
+
}, [
|
|
88
|
+
user,
|
|
89
|
+
post
|
|
90
|
+
]);
|
|
91
|
+
useEffect(()=>{
|
|
92
|
+
void load();
|
|
93
|
+
}, [
|
|
94
|
+
load
|
|
95
|
+
]);
|
|
96
|
+
const send = useCallback(async ()=>{
|
|
97
|
+
if (busy || !message.trim()) return;
|
|
98
|
+
setBusy(true);
|
|
99
|
+
// One key per reply: a retry of the same press is answered from the first.
|
|
100
|
+
if (!attempt.current) attempt.current = newKey();
|
|
101
|
+
try {
|
|
102
|
+
var _payload_to;
|
|
103
|
+
const { ok, payload } = await post({
|
|
104
|
+
action: 'reply',
|
|
105
|
+
message: message.trim()
|
|
106
|
+
}, {
|
|
107
|
+
'Idempotency-Key': attempt.current
|
|
108
|
+
});
|
|
109
|
+
attempt.current = '';
|
|
110
|
+
if (!ok) {
|
|
111
|
+
var _payload_error;
|
|
112
|
+
return void enqueueSnackbar((_payload_error = payload['error']) != null ? _payload_error : 'The reply was not sent', {
|
|
113
|
+
variant: 'warning',
|
|
114
|
+
allowDuplicate: true
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
setMessage('');
|
|
118
|
+
enqueueSnackbar(`Reply sent to ${(_payload_to = payload['to']) != null ? _payload_to : to}`, {
|
|
119
|
+
variant: 'success',
|
|
120
|
+
persist: false
|
|
121
|
+
});
|
|
122
|
+
await load();
|
|
123
|
+
} catch (unused) {
|
|
124
|
+
enqueueSnackbar('The reply was not sent', {
|
|
125
|
+
variant: 'warning',
|
|
126
|
+
allowDuplicate: true
|
|
127
|
+
});
|
|
128
|
+
} finally{
|
|
129
|
+
setBusy(false);
|
|
130
|
+
}
|
|
131
|
+
}, [
|
|
132
|
+
busy,
|
|
133
|
+
message,
|
|
134
|
+
post,
|
|
135
|
+
enqueueSnackbar,
|
|
136
|
+
to,
|
|
137
|
+
load
|
|
138
|
+
]);
|
|
139
|
+
return /*#__PURE__*/ _jsxs(Stack, {
|
|
140
|
+
spacing: 1.5,
|
|
141
|
+
"data-quote-messages": "",
|
|
142
|
+
children: [
|
|
143
|
+
/*#__PURE__*/ _jsxs(Stack, {
|
|
144
|
+
spacing: 0.5,
|
|
145
|
+
children: [
|
|
146
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
147
|
+
variant: "subtitle2",
|
|
148
|
+
children: 'Messages'
|
|
149
|
+
}),
|
|
150
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
151
|
+
variant: "body2",
|
|
152
|
+
color: "text.secondary",
|
|
153
|
+
children: 'Write to your customer about this quote. They can answer by email or on the quote page; what they write on the page shows here, and you’re notified of it.'
|
|
154
|
+
})
|
|
155
|
+
]
|
|
156
|
+
}),
|
|
157
|
+
loadError ? /*#__PURE__*/ _jsx(Alert, {
|
|
158
|
+
severity: "warning",
|
|
159
|
+
children: loadError
|
|
160
|
+
}) : null,
|
|
161
|
+
/*#__PURE__*/ _jsx(ReplyThread, {
|
|
162
|
+
title: "Conversation",
|
|
163
|
+
messages: messages.map((entry)=>_extends({}, entry))
|
|
164
|
+
}),
|
|
165
|
+
refused ? /*#__PURE__*/ _jsx(Alert, {
|
|
166
|
+
severity: "info",
|
|
167
|
+
children: CommerceModel.quoteReplyRefusalMessage(refused)
|
|
168
|
+
}) : /*#__PURE__*/ _jsx(ReplyComposer, {
|
|
169
|
+
to: to,
|
|
170
|
+
message: message,
|
|
171
|
+
onMessageChange: setMessage,
|
|
172
|
+
messageMax: CommerceModel.QUOTE_MESSAGE_MAX,
|
|
173
|
+
messagePlaceholder: "Write your reply.",
|
|
174
|
+
note: canSend ? 'Sent from your site in the same email conversation as the quote. When your customer replies by email, it goes to your site’s contact email (or yours, if the site has none), not here.' : SEND_REFUSAL,
|
|
175
|
+
busy: busy,
|
|
176
|
+
canSend: canSend,
|
|
177
|
+
onSend: ()=>void send()
|
|
178
|
+
})
|
|
179
|
+
]
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
QuoteMessagesSection.displayName = 'QuoteMessagesSection';
|
|
183
|
+
export default QuoteMessagesSection;
|
|
184
|
+
|
|
185
|
+
//# sourceMappingURL=quote-messages.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/quote-messages.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport * as CommerceModel from '../../model'\nimport { commerceSitePermissionRefusal } from '../../model/plugin-permissions'\nimport { ReplyComposer, ReplyThread } from '@aglyn/shared-ui-jsx/components/reply-composer.component'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport { authorizedFetch } from '@aglyn/shared-util-http/authorized-token'\nimport { useUser } from '@aglyn/tenant-feature-instance'\nimport { Alert, Stack, Typography } from '@mui/material'\nimport { useCallback, useEffect, useRef, useState } from 'react'\n\nconst SEND_REFUSAL = commerceSitePermissionRefusal('commerce.quotes.send')\n\nconst newKey = () => globalThis.crypto?.randomUUID?.() ?? `${Date.now()}-${Math.random().toString(36).slice(2)}`\n\nexport interface QuoteMessagesSectionProps {\n hostId: string\n quoteId: string\n quote: CommerceModel.HostOrder\n /** Holds \"Send quotes and invoices to customers\" (`commerce.quotes.send`): a reply emails the customer. */\n canSend: boolean\n}\n\n/**\n * The quote's conversation with its customer (AGL-4207), in the quote's\n * dialog: every reply sent from here and everything the customer wrote on\n * the quote page, oldest first, and a reply box. The same composer as the\n * Inbox's reply. A reply goes by email in the quote's own conversation in\n * the customer's mailbox, and their email answer reaches the site's contact\n * email (or the sender's), not this list: nothing here receives mail.\n */\nexport function QuoteMessagesSection(props: QuoteMessagesSectionProps) {\n const { hostId, quoteId, quote, canSend } = props\n const { data: user } = useUser()\n const { enqueueSnackbar } = useSnackbar()\n const [messages, setMessages] = useState<CommerceModel.QuoteConsoleMessage[]>([])\n const [loadError, setLoadError] = useState('')\n const [message, setMessage] = useState('')\n const [busy, setBusy] = useState(false)\n const attempt = useRef('')\n const refused = CommerceModel.quoteReplyRefusal({ channel: 'quote', quote: quote.quote })\n const to = CommerceModel.quoteReplyRecipient(quote)\n\n const post = useCallback(\n async (body: Record<string, unknown>, headers: Record<string, string> = {}) => {\n const response = await authorizedFetch(user, '/api/commerce/quote', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json', ...headers },\n body: JSON.stringify({ hostId, quoteId, ...body }),\n })\n return { ok: response.ok, payload: (await response.json().catch(() => ({}))) as Record<string, any> }\n },\n [user, hostId, quoteId],\n )\n\n const load = useCallback(async () => {\n if (!user) return\n try {\n const { ok, payload } = await post({ action: 'messages' })\n if (!ok) return void setLoadError(String(payload['error'] ?? 'The messages could not be loaded.'))\n setLoadError('')\n setMessages(Array.isArray(payload['messages']) ? payload['messages'] : [])\n } catch {\n setLoadError('The messages could not be loaded.')\n }\n }, [user, post])\n\n useEffect(() => {\n void load()\n }, [load])\n\n const send = useCallback(async () => {\n if (busy || !message.trim()) return\n setBusy(true)\n // One key per reply: a retry of the same press is answered from the first.\n if (!attempt.current) attempt.current = newKey()\n try {\n const { ok, payload } = await post({ action: 'reply', message: message.trim() }, { 'Idempotency-Key': attempt.current })\n attempt.current = ''\n if (!ok) {\n return void enqueueSnackbar(payload['error'] ?? 'The reply was not sent', { variant: 'warning', allowDuplicate: true })\n }\n setMessage('')\n enqueueSnackbar(`Reply sent to ${payload['to'] ?? to}`, { variant: 'success', persist: false })\n await load()\n } catch {\n enqueueSnackbar('The reply was not sent', { variant: 'warning', allowDuplicate: true })\n } finally {\n setBusy(false)\n }\n }, [busy, message, post, enqueueSnackbar, to, load])\n\n return (\n <Stack spacing={1.5} data-quote-messages=\"\">\n <Stack spacing={0.5}>\n <Typography variant=\"subtitle2\">{'Messages'}</Typography>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Write to your customer about this quote. They can answer by email or on the quote page; what they write on the page shows here, and you’re notified of it.'}\n </Typography>\n </Stack>\n {loadError ? <Alert severity=\"warning\">{loadError}</Alert> : null}\n <ReplyThread\n title=\"Conversation\"\n messages={messages.map((entry) => ({ ...entry }))}\n />\n {refused ? (\n <Alert severity=\"info\">{CommerceModel.quoteReplyRefusalMessage(refused)}</Alert>\n ) : (\n <ReplyComposer\n to={to}\n message={message}\n onMessageChange={setMessage}\n messageMax={CommerceModel.QUOTE_MESSAGE_MAX}\n messagePlaceholder=\"Write your reply.\"\n note={\n canSend\n ? 'Sent from your site in the same email conversation as the quote. When your customer replies by email, it goes to your site’s contact email (or yours, if the site has none), not here.'\n : SEND_REFUSAL\n }\n busy={busy}\n canSend={canSend}\n onSend={() => void send()}\n />\n )}\n </Stack>\n )\n}\nQuoteMessagesSection.displayName = 'QuoteMessagesSection'\n\nexport default QuoteMessagesSection\n"],"names":["CommerceModel","commerceSitePermissionRefusal","ReplyComposer","ReplyThread","useSnackbar","authorizedFetch","useUser","Alert","Stack","Typography","useCallback","useEffect","useRef","useState","SEND_REFUSAL","newKey","globalThis","crypto","randomUUID","Date","now","Math","random","toString","slice","QuoteMessagesSection","props","hostId","quoteId","quote","canSend","data","user","enqueueSnackbar","messages","setMessages","loadError","setLoadError","message","setMessage","busy","setBusy","attempt","refused","quoteReplyRefusal","channel","to","quoteReplyRecipient","post","body","headers","response","method","JSON","stringify","ok","payload","json","catch","load","action","String","Array","isArray","send","trim","current","variant","allowDuplicate","persist","spacing","data-quote-messages","color","severity","title","map","entry","quoteReplyRefusalMessage","onMessageChange","messageMax","QUOTE_MESSAGE_MAX","messagePlaceholder","note","onSend","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,YAAYA,mBAAmB,uBAAa;AAC5C,SAASC,6BAA6B,QAAQ,oCAAgC;AAC9E,SAASC,aAAa,EAAEC,WAAW,QAAQ,2DAA0D;AACrG,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SAASC,eAAe,QAAQ,2CAA0C;AAC1E,SAASC,OAAO,QAAQ,iCAAgC;AACxD,SAASC,KAAK,EAAEC,KAAK,EAAEC,UAAU,QAAQ,gBAAe;AACxD,SAASC,WAAW,EAAEC,SAAS,EAAEC,MAAM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AAM;YACN1B,gBAAgB,0BAA0B;gBAAEkC,SAAS;gBAAWC,gBAAgB;YAAK;QACvF,SAAU;YACR3B,QAAQ;QACV;IACF,GAAG;QAACD;QAAMF;QAASU;QAAMf;QAAiBa;QAAIa;KAAK;IAEnD,qBACE,MAACnD;QAAM8D,SAAS;QAAKC,uBAAoB;;0BACvC,MAAC/D;gBAAM8D,SAAS;;kCACd,KAAC7D;wBAAW0D,SAAQ;kCAAa;;kCACjC,KAAC1D;wBAAW0D,SAAQ;wBAAQK,OAAM;kCAC/B;;;;YAGJpC,0BAAY,KAAC7B;gBAAMkE,UAAS;0BAAWrC;iBAAqB;0BAC7D,KAACjC;gBACCuE,OAAM;gBACNxC,UAAUA,SAASyC,GAAG,CAAC,CAACC,QAAW,aAAKA;;YAEzCjC,wBACC,KAACpC;gBAAMkE,UAAS;0BAAQzE,cAAc6E,wBAAwB,CAAClC;+BAE/D,KAACzC;gBACC4C,IAAIA;gBACJR,SAASA;gBACTwC,iBAAiBvC;gBACjBwC,YAAY/E,cAAcgF,iBAAiB;gBAC3CC,oBAAmB;gBACnBC,MACEpD,UACI,2LACAhB;gBAEN0B,MAAMA;gBACNV,SAASA;gBACTqD,QAAQ,IAAM,KAAKnB;;;;AAK7B;AACAvC,qBAAqB2D,WAAW,GAAG;AAEnC,eAAe3D,qBAAoB"}
|
|
@@ -159,7 +159,7 @@ const SEND_REFUSAL = commerceSitePermissionRefusal('commerce.quotes.send');
|
|
|
159
159
|
/*#__PURE__*/ _jsx(Typography, {
|
|
160
160
|
variant: "body2",
|
|
161
161
|
color: "text.secondary",
|
|
162
|
-
children: proofOnly ? 'Send this link to the customer. It opens the proof on your site, with no prices, where they can approve it or
|
|
162
|
+
children: proofOnly ? 'Send this link to the customer. It opens the proof on your site, with no prices, where they can approve it or reject it with changes. Only someone with the link can open it.' : unpaid ? 'Send this link to the customer. It opens the quote on your site, where they can pay it.' : 'The link opens the paid quote and the customer’s order.'
|
|
163
163
|
}),
|
|
164
164
|
edited && unpaid ? /*#__PURE__*/ _jsx(Typography, {
|
|
165
165
|
variant: "body2",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/quote-pay-link.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n'use client'\n\nimport * as CommerceModel from '../../model'\nimport { commerceSitePermissionRefusal } from '../../model/plugin-permissions'\nimport { BlockedControl } from '@aglyn/shared-ui-jsx/components/blocked-control.component'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport { authorizedFetch } from '@aglyn/shared-util-http/authorized-token'\nimport { useUser } from '@aglyn/tenant-feature-instance'\nimport {\n Button,\n Dialog,\n DialogActions,\n DialogContent,\n DialogContentText,\n DialogTitle,\n Stack,\n TextField,\n Typography,\n} from '@mui/material'\nimport { useCallback, useEffect, useState } from 'react'\nimport { PayLinkReadinessNoticeFor } from './pay-link-readiness-notice.component'\n\nconst SEND_REFUSAL = commerceSitePermissionRefusal('commerce.quotes.send')\n\nexport interface QuotePayLinkSectionProps {\n hostId: string\n quoteId: string\n quote: Pick<CommerceModel.HostOrder, 'status' | 'channel' | 'number' | 'quote' | 'lineItems'>\n /** Holds \"Send quotes and invoices to customers\" (`commerce.quotes.send`). */\n canSend: boolean\n /** The editor holds changes not saved yet, which the link does not show. */\n edited: boolean\n}\n\n/**\n * A quote's pay link (AGL-4094): the address the business sends the\n * customer, which opens the quote on the business's own site with a Pay\n * button. \"Copy pay link\" asks the server for it (it is signed there) and puts\n * it on the clipboard and on screen; \"Replace link\" makes a new one and the\n * one sent before stops opening the quote.\n *\n * The link shown is kept with the version it was made at, and drops as soon\n * as the quote's stored version (`quote.linkVersion`) moves past it: a\n * revision's first email and Replace link (here or anywhere else) both move\n * it, and the link from before then opens only \"This quote was updated\". A\n * link already on screen is fetched again at the new version; Copy pay link\n * never copies one older than the quote's.\n *\n * Above it, what the customer's Pay waits on, if anything (AGL-4162): the\n * link can still be copied and sent.\n *\n * It is the same link on a proof only quote (AGL-4184), called what it opens\n * there: the proof, for whoever holds the link, with nothing to pay.\n */\nexport function QuotePayLinkSection(props: QuotePayLinkSectionProps) {\n const { hostId, quoteId, quote, canSend, edited } = props\n const { data: user } = useUser()\n const { enqueueSnackbar } = useSnackbar()\n const [signed, setSigned] = useState<{ url: string; version: number } | null>(null)\n const [busy, setBusy] = useState(false)\n const [confirmingReplace, setConfirmingReplace] = useState(false)\n const unpaid = CommerceModel.isUnpaidQuote(quote)\n const version = CommerceModel.quoteLinkVersion(quote.quote)\n const proofOnly = CommerceModel.quoteIsProofOnly(quote)\n const linkName = proofOnly ? 'proof link' : 'pay link'\n const LinkName = proofOnly ? 'Proof link' : 'Pay link'\n const opens = proofOnly ? 'proof' : 'quote'\n // A link the server made at a version the stored quote has not caught up to yet is the newest one.\n const url = signed && signed.version >= version ? signed.url : ''\n\n const ask = useCallback(\n async (action: 'pay-link' | 'replace-link'): Promise<string | null> => {\n setBusy(true)\n try {\n const response = await authorizedFetch(user, '/api/commerce/quote', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ action, hostId, quoteId }),\n })\n const payload = await response.json().catch(() => ({}))\n if (!response.ok || !payload?.url) {\n enqueueSnackbar(payload?.error ?? `The ${linkName} could not be made`, { variant: 'error', allowDuplicate: true })\n return null\n }\n const made = Math.floor(Number(payload.linkVersion))\n setSigned({ url: String(payload.url), version: Number.isFinite(made) && made >= 1 ? made : version })\n return String(payload.url)\n } finally {\n setBusy(false)\n }\n },\n [user, hostId, quoteId, version, linkName, enqueueSnackbar],\n )\n\n // The quote's link moved on (a revision was emailed, or the link replaced):\n // the one on screen opens nothing now, so fetch the current one in its place.\n const stale = signed !== null && signed.version < version\n useEffect(() => {\n if (stale) void ask('pay-link')\n // Once per version the quote moves to; `ask` changing does not ask again.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [stale, version])\n\n const copy = useCallback(\n async (link: string, done: string) => {\n try {\n await navigator.clipboard.writeText(link)\n enqueueSnackbar(done, { variant: 'success', persist: false })\n } catch {\n // The link is on screen to copy by hand when the clipboard is refused.\n enqueueSnackbar('Copy the link below to send it', { variant: 'info', persist: false })\n }\n },\n [enqueueSnackbar],\n )\n\n const copyLink = useCallback(async () => {\n const link = url || (await ask('pay-link'))\n if (link) await copy(link, `${LinkName} copied`)\n }, [url, ask, copy, LinkName])\n\n const replaceLink = useCallback(async () => {\n const link = await ask('replace-link')\n setConfirmingReplace(false)\n if (link) await copy(link, `New ${linkName} copied. The earlier link no longer opens the ${opens}.`)\n }, [ask, copy, linkName, opens])\n\n return (\n <Stack spacing={1.5}>\n <Stack spacing={0.5}>\n <Typography variant=\"subtitle2\">{LinkName}</Typography>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {proofOnly\n ? 'Send this link to the customer. It opens the proof on your site, with no prices, where they can approve it or ask for changes. Only someone with the link can open it.'\n : unpaid\n ? 'Send this link to the customer. It opens the quote on your site, where they can pay it.'\n : 'The link opens the paid quote and the customer’s order.'}\n </Typography>\n {edited && unpaid ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {`Save your changes first: the link opens the ${opens} as it was last saved.`}\n </Typography>\n ) : null}\n </Stack>\n {unpaid ? <PayLinkReadinessNoticeFor hostId={hostId} order={quote} noun=\"quote\" /> : null}\n {url ? (\n <TextField\n label={LinkName}\n value={url}\n size=\"small\"\n fullWidth\n slotProps={{ htmlInput: { readOnly: true }, inputLabel: { shrink: true } }}\n onFocus={(event) => event.target.select()}\n />\n ) : null}\n <Stack direction=\"row\" spacing={1} sx={{ flexWrap: 'wrap', rowGap: 1 }}>\n <BlockedControl blocked={!canSend} reason={SEND_REFUSAL}>\n <Button variant=\"outlined\" size=\"small\" disabled={busy} onClick={() => void copyLink()}>\n {`Copy ${linkName}`}\n </Button>\n </BlockedControl>\n {unpaid ? (\n <BlockedControl blocked={!canSend} reason={SEND_REFUSAL}>\n <Button size=\"small\" disabled={busy} onClick={() => setConfirmingReplace(true)}>\n {'Replace link'}\n </Button>\n </BlockedControl>\n ) : null}\n </Stack>\n <Dialog open={confirmingReplace} onClose={() => setConfirmingReplace(false)} maxWidth=\"xs\" fullWidth>\n <DialogTitle>{`Replace the ${linkName}?`}</DialogTitle>\n <DialogContent>\n <DialogContentText>\n {`The link you sent before will stop working: it will tell the customer the ${opens} was updated, ` +\n 'and show nothing of it. Send them the new link.'}\n </DialogContentText>\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setConfirmingReplace(false)} disabled={busy}>\n {'Cancel'}\n </Button>\n <Button variant=\"contained\" disabled={busy} onClick={() => void replaceLink()}>\n {'Replace link'}\n </Button>\n </DialogActions>\n </Dialog>\n </Stack>\n )\n}\nQuotePayLinkSection.displayName = 'QuotePayLinkSection'\n\nexport default QuotePayLinkSection\n"],"names":["CommerceModel","commerceSitePermissionRefusal","BlockedControl","useSnackbar","authorizedFetch","useUser","Button","Dialog","DialogActions","DialogContent","DialogContentText","DialogTitle","Stack","TextField","Typography","useCallback","useEffect","useState","PayLinkReadinessNoticeFor","SEND_REFUSAL","QuotePayLinkSection","props","hostId","quoteId","quote","canSend","edited","data","user","enqueueSnackbar","signed","setSigned","busy","setBusy","confirmingReplace","setConfirmingReplace","unpaid","isUnpaidQuote","version","quoteLinkVersion","proofOnly","quoteIsProofOnly","linkName","LinkName","opens","url","ask","action","response","method","headers","body","JSON","stringify","payload","json","catch","ok","error","variant","allowDuplicate","made","Math","floor","Number","linkVersion","String","isFinite","stale","copy","link","done","navigator","clipboard","writeText","persist","copyLink","replaceLink","spacing","color","order","noun","label","value","size","fullWidth","slotProps","htmlInput","readOnly","inputLabel","shrink","onFocus","event","target","select","direction","sx","flexWrap","rowGap","blocked","reason","disabled","onClick","open","onClose","maxWidth","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;AAEA,YAAYA,mBAAmB,uBAAa;AAC5C,SAASC,6BAA6B,QAAQ,oCAAgC;AAC9E,SAASC,cAAc,QAAQ,4DAA2D;AAC1F,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SAASC,eAAe,QAAQ,2CAA0C;AAC1E,SAASC,OAAO,QAAQ,iCAAgC;AACxD,SACEC,MAAM,EACNC,MAAM,EACNC,aAAa,EACbC,aAAa,EACbC,iBAAiB,EACjBC,WAAW,EACXC,KAAK,EACLC,SAAS,EACTC,UAAU,QACL,gBAAe;AACtB,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAO;AACxD,SAASC,yBAAyB,QAAQ,2CAAuC;AAEjF,MAAMC,eAAelB,8BAA8B;AAYnD;;;;;;;;;;;;;;;;;;;CAmBC,GACD,OAAO,SAASmB,oBAAoBC,KAA+B;IACjE,MAAM,EAAEC,MAAM,EAAEC,OAAO,EAAEC,KAAK,EAAEC,OAAO,EAAEC,MAAM,EAAE,GAAGL;IACpD,MAAM,EAAEM,MAAMC,IAAI,EAAE,GAAGvB;IACvB,MAAM,EAAEwB,eAAe,EAAE,GAAG1B;IAC5B,MAAM,CAAC2B,QAAQC,UAAU,GAAGd,SAAkD;IAC9E,MAAM,CAACe,MAAMC,QAAQ,GAAGhB,SAAS;IACjC,MAAM,CAACiB,mBAAmBC,qBAAqB,GAAGlB,SAAS;IAC3D,MAAMmB,SAASpC,cAAcqC,aAAa,CAACb;IAC3C,MAAMc,UAAUtC,cAAcuC,gBAAgB,CAACf,MAAMA,KAAK;IAC1D,MAAMgB,YAAYxC,cAAcyC,gBAAgB,CAACjB;IACjD,MAAMkB,WAAWF,YAAY,eAAe;IAC5C,MAAMG,WAAWH,YAAY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gBAAE;gBACzEC,SAAS,CAACC,QAAUA,MAAMC,MAAM,CAACC,MAAM;iBAEvC;0BACJ,MAAClF;gBAAMmF,WAAU;gBAAMjB,SAAS;gBAAGkB,IAAI;oBAAEC,UAAU;oBAAQC,QAAQ;gBAAE;;kCACnE,KAAChG;wBAAeiG,SAAS,CAAC1E;wBAAS2E,QAAQjF;kCACzC,cAAA,KAACb;4BAAOqD,SAAQ;4BAAWyB,MAAK;4BAAQiB,UAAUrE;4BAAMsE,SAAS,IAAM,KAAK1B;sCACzE,CAAC,KAAK,EAAElC,UAAU;;;oBAGtBN,uBACC,KAAClC;wBAAeiG,SAAS,CAAC1E;wBAAS2E,QAAQjF;kCACzC,cAAA,KAACb;4BAAO8E,MAAK;4BAAQiB,UAAUrE;4BAAMsE,SAAS,IAAMnE,qBAAqB;sCACtE;;yBAGH;;;0BAEN,MAAC5B;gBAAOgG,MAAMrE;gBAAmBsE,SAAS,IAAMrE,qBAAqB;gBAAQsE,UAAS;gBAAKpB,SAAS;;kCAClG,KAAC1E;kCAAa,CAAC,YAAY,EAAE+B,SAAS,CAAC,CAAC;;kCACxC,KAACjC;kCACC,cAAA,KAACC;sCACE,CAAC,0EAA0E,EAAEkC,MAAM,cAAc,CAAC,GACjG;;;kCAGN,MAACpC;;0CACC,KAACF;gCAAOgG,SAAS,IAAMnE,qBAAqB;gCAAQkE,UAAUrE;0CAC3D;;0CAEH,KAAC1B;gCAAOqD,SAAQ;gCAAY0C,UAAUrE;gCAAMsE,SAAS,IAAM,KAAKzB;0CAC7D;;;;;;;;AAMb;AACAzD,oBAAoBsF,WAAW,GAAG;AAElC,eAAetF,oBAAmB"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/quote-pay-link.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n'use client'\n\nimport * as CommerceModel from '../../model'\nimport { commerceSitePermissionRefusal } from '../../model/plugin-permissions'\nimport { BlockedControl } from '@aglyn/shared-ui-jsx/components/blocked-control.component'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport { authorizedFetch } from '@aglyn/shared-util-http/authorized-token'\nimport { useUser } from '@aglyn/tenant-feature-instance'\nimport {\n Button,\n Dialog,\n DialogActions,\n DialogContent,\n DialogContentText,\n DialogTitle,\n Stack,\n TextField,\n Typography,\n} from '@mui/material'\nimport { useCallback, useEffect, useState } from 'react'\nimport { PayLinkReadinessNoticeFor } from './pay-link-readiness-notice.component'\n\nconst SEND_REFUSAL = commerceSitePermissionRefusal('commerce.quotes.send')\n\nexport interface QuotePayLinkSectionProps {\n hostId: string\n quoteId: string\n quote: Pick<CommerceModel.HostOrder, 'status' | 'channel' | 'number' | 'quote' | 'lineItems'>\n /** Holds \"Send quotes and invoices to customers\" (`commerce.quotes.send`). */\n canSend: boolean\n /** The editor holds changes not saved yet, which the link does not show. */\n edited: boolean\n}\n\n/**\n * A quote's pay link (AGL-4094): the address the business sends the\n * customer, which opens the quote on the business's own site with a Pay\n * button. \"Copy pay link\" asks the server for it (it is signed there) and puts\n * it on the clipboard and on screen; \"Replace link\" makes a new one and the\n * one sent before stops opening the quote.\n *\n * The link shown is kept with the version it was made at, and drops as soon\n * as the quote's stored version (`quote.linkVersion`) moves past it: a\n * revision's first email and Replace link (here or anywhere else) both move\n * it, and the link from before then opens only \"This quote was updated\". A\n * link already on screen is fetched again at the new version; Copy pay link\n * never copies one older than the quote's.\n *\n * Above it, what the customer's Pay waits on, if anything (AGL-4162): the\n * link can still be copied and sent.\n *\n * It is the same link on a proof only quote (AGL-4184), called what it opens\n * there: the proof, for whoever holds the link, with nothing to pay.\n */\nexport function QuotePayLinkSection(props: QuotePayLinkSectionProps) {\n const { hostId, quoteId, quote, canSend, edited } = props\n const { data: user } = useUser()\n const { enqueueSnackbar } = useSnackbar()\n const [signed, setSigned] = useState<{ url: string; version: number } | null>(null)\n const [busy, setBusy] = useState(false)\n const [confirmingReplace, setConfirmingReplace] = useState(false)\n const unpaid = CommerceModel.isUnpaidQuote(quote)\n const version = CommerceModel.quoteLinkVersion(quote.quote)\n const proofOnly = CommerceModel.quoteIsProofOnly(quote)\n const linkName = proofOnly ? 'proof link' : 'pay link'\n const LinkName = proofOnly ? 'Proof link' : 'Pay link'\n const opens = proofOnly ? 'proof' : 'quote'\n // A link the server made at a version the stored quote has not caught up to yet is the newest one.\n const url = signed && signed.version >= version ? signed.url : ''\n\n const ask = useCallback(\n async (action: 'pay-link' | 'replace-link'): Promise<string | null> => {\n setBusy(true)\n try {\n const response = await authorizedFetch(user, '/api/commerce/quote', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ action, hostId, quoteId }),\n })\n const payload = await response.json().catch(() => ({}))\n if (!response.ok || !payload?.url) {\n enqueueSnackbar(payload?.error ?? `The ${linkName} could not be made`, { variant: 'error', allowDuplicate: true })\n return null\n }\n const made = Math.floor(Number(payload.linkVersion))\n setSigned({ url: String(payload.url), version: Number.isFinite(made) && made >= 1 ? made : version })\n return String(payload.url)\n } finally {\n setBusy(false)\n }\n },\n [user, hostId, quoteId, version, linkName, enqueueSnackbar],\n )\n\n // The quote's link moved on (a revision was emailed, or the link replaced):\n // the one on screen opens nothing now, so fetch the current one in its place.\n const stale = signed !== null && signed.version < version\n useEffect(() => {\n if (stale) void ask('pay-link')\n // Once per version the quote moves to; `ask` changing does not ask again.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [stale, version])\n\n const copy = useCallback(\n async (link: string, done: string) => {\n try {\n await navigator.clipboard.writeText(link)\n enqueueSnackbar(done, { variant: 'success', persist: false })\n } catch {\n // The link is on screen to copy by hand when the clipboard is refused.\n enqueueSnackbar('Copy the link below to send it', { variant: 'info', persist: false })\n }\n },\n [enqueueSnackbar],\n )\n\n const copyLink = useCallback(async () => {\n const link = url || (await ask('pay-link'))\n if (link) await copy(link, `${LinkName} copied`)\n }, [url, ask, copy, LinkName])\n\n const replaceLink = useCallback(async () => {\n const link = await ask('replace-link')\n setConfirmingReplace(false)\n if (link) await copy(link, `New ${linkName} copied. The earlier link no longer opens the ${opens}.`)\n }, [ask, copy, linkName, opens])\n\n return (\n <Stack spacing={1.5}>\n <Stack spacing={0.5}>\n <Typography variant=\"subtitle2\">{LinkName}</Typography>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {proofOnly\n ? 'Send this link to the customer. It opens the proof on your site, with no prices, where they can approve it or reject it with changes. Only someone with the link can open it.'\n : unpaid\n ? 'Send this link to the customer. It opens the quote on your site, where they can pay it.'\n : 'The link opens the paid quote and the customer’s order.'}\n </Typography>\n {edited && unpaid ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {`Save your changes first: the link opens the ${opens} as it was last saved.`}\n </Typography>\n ) : null}\n </Stack>\n {unpaid ? <PayLinkReadinessNoticeFor hostId={hostId} order={quote} noun=\"quote\" /> : null}\n {url ? (\n <TextField\n label={LinkName}\n value={url}\n size=\"small\"\n fullWidth\n slotProps={{ htmlInput: { readOnly: true }, inputLabel: { shrink: true } }}\n onFocus={(event) => event.target.select()}\n />\n ) : null}\n <Stack direction=\"row\" spacing={1} sx={{ flexWrap: 'wrap', rowGap: 1 }}>\n <BlockedControl blocked={!canSend} reason={SEND_REFUSAL}>\n <Button variant=\"outlined\" size=\"small\" disabled={busy} onClick={() => void copyLink()}>\n {`Copy ${linkName}`}\n </Button>\n </BlockedControl>\n {unpaid ? (\n <BlockedControl blocked={!canSend} reason={SEND_REFUSAL}>\n <Button size=\"small\" disabled={busy} onClick={() => setConfirmingReplace(true)}>\n {'Replace link'}\n </Button>\n </BlockedControl>\n ) : null}\n </Stack>\n <Dialog open={confirmingReplace} onClose={() => setConfirmingReplace(false)} maxWidth=\"xs\" fullWidth>\n <DialogTitle>{`Replace the ${linkName}?`}</DialogTitle>\n <DialogContent>\n <DialogContentText>\n {`The link you sent before will stop working: it will tell the customer the ${opens} was updated, ` +\n 'and show nothing of it. Send them the new link.'}\n </DialogContentText>\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setConfirmingReplace(false)} disabled={busy}>\n {'Cancel'}\n </Button>\n <Button variant=\"contained\" disabled={busy} onClick={() => void replaceLink()}>\n {'Replace link'}\n </Button>\n </DialogActions>\n </Dialog>\n </Stack>\n )\n}\nQuotePayLinkSection.displayName = 'QuotePayLinkSection'\n\nexport default QuotePayLinkSection\n"],"names":["CommerceModel","commerceSitePermissionRefusal","BlockedControl","useSnackbar","authorizedFetch","useUser","Button","Dialog","DialogActions","DialogContent","DialogContentText","DialogTitle","Stack","TextField","Typography","useCallback","useEffect","useState","PayLinkReadinessNoticeFor","SEND_REFUSAL","QuotePayLinkSection","props","hostId","quoteId","quote","canSend","edited","data","user","enqueueSnackbar","signed","setSigned","busy","setBusy","confirmingReplace","setConfirmingReplace","unpaid","isUnpaidQuote","version","quoteLinkVersion","proofOnly","quoteIsProofOnly","linkName","LinkName","opens","url","ask","action","response","method","headers","body","JSON","stringify","payload","json","catch","ok","error","variant","allowDuplicate","made","Math","floor","Number","linkVersion","String","isFinite","stale","copy","link","done","navigator","clipboard","writeText","persist","copyLink","replaceLink","spacing","color","order","noun","label","value","size","fullWidth","slotProps","htmlInput","readOnly","inputLabel","shrink","onFocus","event","target","select","direction","sx","flexWrap","rowGap","blocked","reason","disabled","onClick","open","onClose","maxWidth","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;AAEA,YAAYA,mBAAmB,uBAAa;AAC5C,SAASC,6BAA6B,QAAQ,oCAAgC;AAC9E,SAASC,cAAc,QAAQ,4DAA2D;AAC1F,SAASC,WAAW,QAA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UAAUrE;4BAAMsE,SAAS,IAAM,KAAK1B;sCACzE,CAAC,KAAK,EAAElC,UAAU;;;oBAGtBN,uBACC,KAAClC;wBAAeiG,SAAS,CAAC1E;wBAAS2E,QAAQjF;kCACzC,cAAA,KAACb;4BAAO8E,MAAK;4BAAQiB,UAAUrE;4BAAMsE,SAAS,IAAMnE,qBAAqB;sCACtE;;yBAGH;;;0BAEN,MAAC5B;gBAAOgG,MAAMrE;gBAAmBsE,SAAS,IAAMrE,qBAAqB;gBAAQsE,UAAS;gBAAKpB,SAAS;;kCAClG,KAAC1E;kCAAa,CAAC,YAAY,EAAE+B,SAAS,CAAC,CAAC;;kCACxC,KAACjC;kCACC,cAAA,KAACC;sCACE,CAAC,0EAA0E,EAAEkC,MAAM,cAAc,CAAC,GACjG;;;kCAGN,MAACpC;;0CACC,KAACF;gCAAOgG,SAAS,IAAMnE,qBAAqB;gCAAQkE,UAAUrE;0CAC3D;;0CAEH,KAAC1B;gCAAOqD,SAAQ;gCAAY0C,UAAUrE;gCAAMsE,SAAS,IAAM,KAAKzB;0CAC7D;;;;;;;;AAMb;AACAzD,oBAAoBsF,WAAW,GAAG;AAElC,eAAetF,oBAAmB"}
|
|
@@ -160,6 +160,7 @@ function dateTime(atMs) {
|
|
|
160
160
|
const { response, tile } = props;
|
|
161
161
|
if (response.action === 'approve') {
|
|
162
162
|
var _response_userAgent;
|
|
163
|
+
var _response_confirmed;
|
|
163
164
|
return /*#__PURE__*/ _jsx(Alert, {
|
|
164
165
|
severity: "success",
|
|
165
166
|
children: /*#__PURE__*/ _jsxs(Stack, {
|
|
@@ -169,6 +170,28 @@ function dateTime(atMs) {
|
|
|
169
170
|
variant: "body2",
|
|
170
171
|
children: `Approved by ${response.name || 'the customer'} on ${dateTime(response.atMs)}.`
|
|
171
172
|
}),
|
|
173
|
+
((_response_confirmed = response.confirmed) == null ? void 0 : _response_confirmed.length) ? /*#__PURE__*/ _jsxs(Stack, {
|
|
174
|
+
spacing: 0.25,
|
|
175
|
+
"data-quote-approval-confirmed": "",
|
|
176
|
+
children: [
|
|
177
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
178
|
+
variant: "body2",
|
|
179
|
+
children: 'They confirmed:'
|
|
180
|
+
}),
|
|
181
|
+
/*#__PURE__*/ _jsx(Box, {
|
|
182
|
+
component: "ul",
|
|
183
|
+
sx: {
|
|
184
|
+
m: 0,
|
|
185
|
+
pl: 2.5
|
|
186
|
+
},
|
|
187
|
+
children: response.confirmed.map((statement)=>/*#__PURE__*/ _jsx(Typography, {
|
|
188
|
+
component: "li",
|
|
189
|
+
variant: "body2",
|
|
190
|
+
children: statement
|
|
191
|
+
}, statement))
|
|
192
|
+
})
|
|
193
|
+
]
|
|
194
|
+
}) : null,
|
|
172
195
|
/*#__PURE__*/ _jsx(Typography, {
|
|
173
196
|
variant: "caption",
|
|
174
197
|
color: "text.secondary",
|
|
@@ -188,7 +211,7 @@ function dateTime(atMs) {
|
|
|
188
211
|
children: [
|
|
189
212
|
/*#__PURE__*/ _jsx(Typography, {
|
|
190
213
|
variant: "body2",
|
|
191
|
-
children: `
|
|
214
|
+
children: `Rejected with changes${response.name ? ` by ${response.name}` : ''} on ${dateTime(response.atMs)}:`
|
|
192
215
|
}),
|
|
193
216
|
/*#__PURE__*/ _jsx(Typography, {
|
|
194
217
|
variant: "body2",
|
|
@@ -487,10 +510,14 @@ function dateTime(atMs) {
|
|
|
487
510
|
variant: "subtitle2",
|
|
488
511
|
children: `Proofs · Revision ${revision}`
|
|
489
512
|
}),
|
|
490
|
-
/*#__PURE__*/
|
|
513
|
+
/*#__PURE__*/ _jsxs(Typography, {
|
|
491
514
|
variant: "body2",
|
|
492
515
|
color: "text.secondary",
|
|
493
|
-
children:
|
|
516
|
+
children: [
|
|
517
|
+
proofOnly ? 'The customer sees these on the proof page, with no prices, and can approve them or reject them with changes.' : (section == null ? void 0 : section.requireProofApproval) ? 'The customer sees these on the quote page and approves them before they can pay.' : 'The customer sees these on the quote page, and can approve them or reject them with changes. Paying doesn’t wait on it.',
|
|
518
|
+
' To approve, they tick each statement from your Quotes settings and type their name.',
|
|
519
|
+
(section == null ? void 0 : section.requireProofSignIn) ? ' A customer with an account on your site signs in to see them; one without uses the private link.' : ''
|
|
520
|
+
]
|
|
494
521
|
})
|
|
495
522
|
]
|
|
496
523
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/quote-proofs.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n'use client'\n\nimport * as CommerceModel from '../../model'\nimport { commerceSitePermissionRefusal } from '../../model/plugin-permissions'\nimport { useMediaPicker } from '@aglyn/aglyn/app-utils/media-picker-context'\nimport {\n checkVisitorUploadSelection,\n formatVisitorUploadBytes,\n visitorUploadIsInline,\n VISITOR_UPLOAD_ACCEPT,\n VISITOR_UPLOAD_MAX_BYTES,\n} from '@aglyn/aglyn/app-utils/visitor-upload'\nimport { sendVisitorUpload } from '@aglyn/aglyn/app-utils/visitor-upload-client'\nimport { BlockedControl } from '@aglyn/shared-ui-jsx/components/blocked-control.component'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport { authorizedFetch } from '@aglyn/shared-util-http/authorized-token'\nimport { useUser } from '@aglyn/tenant-feature-instance'\nimport {\n Alert,\n Box,\n Button,\n Chip,\n CircularProgress,\n Dialog,\n DialogActions,\n DialogContent,\n DialogContentText,\n DialogTitle,\n Divider,\n Paper,\n Stack,\n Typography,\n} from '@mui/material'\nimport { useCallback, useEffect, useRef, useState, type ReactNode } from 'react'\n\nconst REFUSAL = commerceSitePermissionRefusal('commerce.quotes')\n\ntype User = Parameters<typeof authorizedFetch>[0]\n\n/** A file the console lists: a proof, or one the customer sent. Never its storage path. */\ninterface ListedFile {\n id: string\n name: string\n contentType: string\n size: number\n}\n\n/** An earlier revision as the route lists it. */\ntype RevisionView = Omit<CommerceModel.QuoteRevisionSnapshot, 'proofs' | 'responses'> & {\n proofs: ListedFile[]\n responses: Array<Omit<CommerceModel.QuoteCustomerResponse, 'files'> & { files?: ListedFile[] }>\n}\n\nexport interface QuoteProofsSectionProps {\n hostId: string\n quoteId: string\n quote: CommerceModel.HostOrder\n /** Holds \"Create and edit quotes\" (`commerce.quotes`). */\n canEdit: boolean\n /** A change here moved the quote's edit stamp; the editor saves against the new one. */\n onEdited: (updatedAtMs: number) => void\n}\n\nasync function postQuote(user: User, body: Record<string, unknown>): Promise<{ ok: boolean; payload: Record<string, any> }> {\n const response = await authorizedFetch(user, '/api/commerce/quote', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(body),\n })\n return { ok: response.ok, payload: await response.json().catch(() => ({})) }\n}\n\n/** One of the quote's files as a blob, fetched with the member's token; null when refused. */\nasync function fetchQuoteFile(\n user: User,\n body: { hostId: string; quoteId: string; fileId: string; revision?: number },\n): Promise<Blob | null> {\n try {\n const response = await authorizedFetch(user, '/api/commerce/quote', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ action: 'file', ...body }),\n })\n return response.ok ? await response.blob() : null\n } catch {\n return null\n }\n}\n\nfunction dateTime(atMs: number | undefined): string {\n return atMs ? new Date(atMs).toLocaleString(undefined, { dateStyle: 'medium', timeStyle: 'short' }) : ''\n}\n\n/** A picture of an image proof, loaded with the member's token. */\nfunction ProofThumbnail(props: { user: User; hostId: string; quoteId: string; file: ListedFile; revision?: number }) {\n const { user, hostId, quoteId, file, revision } = props\n const [src, setSrc] = useState<string | null>(null)\n useEffect(() => {\n let live = true\n let url = ''\n void fetchQuoteFile(user, { hostId, quoteId, fileId: file.id, ...(revision ? { revision } : {}) }).then((blob) => {\n if (!live || !blob) return\n url = URL.createObjectURL(blob)\n setSrc(url)\n })\n return () => {\n live = false\n if (url) URL.revokeObjectURL(url)\n }\n }, [user, hostId, quoteId, file.id, revision])\n return (\n <Box\n sx={(theme) => ({\n width: theme.spacing(16),\n height: theme.spacing(12),\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n bgcolor: 'action.hover',\n borderRadius: 1,\n overflow: 'hidden',\n })}\n >\n {src ? (\n <Box component=\"img\" src={src} alt={file.name} sx={{ maxWidth: 1, maxHeight: 1, objectFit: 'contain' }} />\n ) : (\n <CircularProgress size={20} aria-label={`Loading ${file.name}`} />\n )}\n </Box>\n )\n}\n\n/** A file: a picture for an image, a chip naming it for anything else; both download it. */\nfunction QuoteFileTile(props: {\n user: User\n hostId: string\n quoteId: string\n file: ListedFile\n revision?: number\n onDownload: (file: ListedFile, revision?: number) => void\n onRemove?: () => void\n removeBlocked?: boolean\n}) {\n const { file, revision, onDownload, onRemove, removeBlocked } = props\n const image = visitorUploadIsInline(file.contentType)\n return (\n <Paper variant=\"outlined\" sx={{ p: 1 }}>\n <Stack spacing={1} sx={(theme) => ({ width: image ? theme.spacing(16) : 'auto', maxWidth: theme.spacing(32) })}>\n {image ? <ProofThumbnail {...props} /> : null}\n <Chip\n size=\"small\"\n variant=\"outlined\"\n label={`${file.name} · ${formatVisitorUploadBytes(file.size)}`}\n onClick={() => onDownload(file, revision)}\n title={`Download ${file.name}`}\n />\n {onRemove ? (\n <BlockedControl blocked={Boolean(removeBlocked)} reason={REFUSAL}>\n <Button size=\"small\" color=\"inherit\" onClick={onRemove} aria-label={`Remove ${file.name}`}>\n {'Remove'}\n </Button>\n </BlockedControl>\n ) : null}\n </Stack>\n </Paper>\n )\n}\n\n/** What the customer said, with any files they sent. */\nfunction QuoteResponseNote(props: {\n response: Omit<CommerceModel.QuoteCustomerResponse, 'files'> & { files?: ListedFile[] }\n tile: (file: ListedFile) => ReactNode\n}) {\n const { response, tile } = props\n if (response.action === 'approve') {\n return (\n <Alert severity=\"success\">\n <Stack spacing={0.5}>\n <Typography variant=\"body2\">{`Approved by ${response.name || 'the customer'} on ${dateTime(response.atMs)}.`}</Typography>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {[response.ip ? `From ${response.ip}` : '', response.userAgent ?? ''].filter(Boolean).join(' · ')}\n </Typography>\n </Stack>\n </Alert>\n )\n }\n return (\n <Alert severity=\"warning\">\n <Stack spacing={1}>\n <Typography variant=\"body2\">{`Changes requested on ${dateTime(response.atMs)}:`}</Typography>\n <Typography variant=\"body2\" sx={{ whiteSpace: 'pre-line' }}>\n {response.comment}\n </Typography>\n {response.files?.length ? (\n <Stack direction=\"row\" spacing={1} useFlexGap sx={{ flexWrap: 'wrap' }}>\n {response.files.map((file) => tile(file))}\n </Stack>\n ) : null}\n </Stack>\n </Alert>\n )\n}\n\n/**\n * A quote's proofs and revisions (AGL-4096), in its editor: the current\n * revision's proofs (a picture for an image, a chip for a PDF or a design\n * file), Add proof and From media library (AGL-4184), what the customer last\n * said with any files they sent, \"Start revision N+1\", and every earlier\n * revision as it was kept.\n */\nexport function QuoteProofsSection(props: QuoteProofsSectionProps) {\n const { hostId, quoteId, quote, canEdit, onEdited } = props\n const { data: user } = useUser()\n const { enqueueSnackbar } = useSnackbar()\n const { pickMedia } = useMediaPicker()\n const section = quote.quote\n const revision = Math.max(1, Number(section?.revision ?? 1) || 1)\n const proofs = CommerceModel.currentQuoteProofs(section)\n const proofOnly = CommerceModel.quoteIsProofOnly(quote)\n const latest = CommerceModel.latestQuoteResponse(section)\n const unpaid = CommerceModel.isUnpaidQuote(quote)\n const addRefusal = CommerceModel.quoteProofChangeRefusal(quote, 'add')\n // A quote with no lines keeps its last proof (`needs-proof`), so it offers no way to remove it.\n const removable = CommerceModel.quoteProofChangeRefusal(quote, 'remove') === null && !(proofOnly && proofs.length === 1)\n const [sending, setSending] = useState<{ done: number; total: number } | null>(null)\n const [busy, setBusy] = useState(false)\n const [confirmingRevision, setConfirmingRevision] = useState(false)\n const [history, setHistory] = useState<RevisionView[] | null>(null)\n const [historyError, setHistoryError] = useState('')\n const picker = useRef<HTMLInputElement>(null)\n\n const loadHistory = useCallback(async () => {\n setHistoryError('')\n const answer = await postQuote(user, { action: 'revisions', hostId, quoteId }).catch(() => null)\n if (!answer?.ok) {\n setHistoryError(String(answer?.payload?.error ?? 'Earlier revisions could not be loaded.'))\n return\n }\n setHistory(Array.isArray(answer.payload['revisions']) ? (answer.payload['revisions'] as RevisionView[]) : [])\n }, [user, hostId, quoteId])\n\n // Earlier revisions are read when there are some, and again after one is added.\n useEffect(() => {\n if (revision > 1) void loadHistory()\n }, [revision, loadHistory])\n\n const download = useCallback(\n async (file: ListedFile, fromRevision?: number) => {\n const blob = await fetchQuoteFile(user, { hostId, quoteId, fileId: file.id, ...(fromRevision ? { revision: fromRevision } : {}) })\n if (!blob) return void enqueueSnackbar('The file could not be downloaded', { variant: 'error', allowDuplicate: true })\n const url = URL.createObjectURL(blob)\n const link = document.createElement('a')\n link.href = url\n link.download = file.name\n link.click()\n setTimeout(() => URL.revokeObjectURL(url), 1000)\n },\n [user, hostId, quoteId, enqueueSnackbar],\n )\n\n const addProofs = useCallback(\n async (files: File[]) => {\n const problem = checkVisitorUploadSelection(files, proofs.length, CommerceModel.QUOTE_MAX_PROOFS)\n if (problem) return void enqueueSnackbar(problem, { variant: 'error', allowDuplicate: true })\n setSending({ done: 0, total: files.length })\n try {\n for (const [index, file] of files.entries()) {\n let stamp = 0\n const sent = await sendVisitorUpload({\n file,\n requestTicket: async (request) => {\n const answer = await postQuote(user, { action: 'proof-ticket', hostId, quoteId, file: request })\n return answer.ok\n ? (answer.payload as { ticket: string; upload: { url: string; fields: Record<string, string> } })\n : { error: String(answer.payload['error'] ?? 'The proof could not be sent') }\n },\n finalize: async (ticket) => {\n const answer = await postQuote(user, { action: 'proof-finalize', hostId, quoteId, ticket })\n if (!answer.ok) return { error: String(answer.payload['error'] ?? 'The proof could not be kept') }\n stamp = Number(answer.payload['updatedAtMs']) || 0\n return { file: answer.payload['proof'] }\n },\n })\n if ('error' in sent) {\n enqueueSnackbar(sent.error, { variant: 'error', allowDuplicate: true })\n break\n }\n if (stamp) onEdited(stamp)\n setSending({ done: index + 1, total: files.length })\n }\n } finally {\n setSending(null)\n }\n },\n [user, hostId, quoteId, proofs.length, onEdited, enqueueSnackbar],\n )\n\n /**\n * A file from the media library: the shared picker offers what this member\n * can read, a private file included, and the server copies the bytes into the\n * quote's private proofs. Only the file's library and id are sent.\n */\n const addFromLibrary = useCallback(async () => {\n const picked = await pickMedia?.({ allowPrivate: true })\n if (!picked) return\n const problem = CommerceModel.quoteLibraryProofProblem(picked)\n if (problem) return void enqueueSnackbar(problem, { variant: 'error', allowDuplicate: true })\n setSending({ done: 0, total: 1 })\n try {\n const answer = await postQuote(user, {\n action: 'proof-from-media',\n hostId,\n quoteId,\n media: { mediaScope: picked.mediaScope, mediaId: picked.mediaId },\n })\n if (!answer.ok) {\n return void enqueueSnackbar(String(answer.payload['error'] ?? 'The proof could not be added'), {\n variant: 'error',\n allowDuplicate: true,\n })\n }\n onEdited(Number(answer.payload['updatedAtMs']) || 0)\n } catch {\n enqueueSnackbar('The proof could not be added', { variant: 'error', allowDuplicate: true })\n } finally {\n setSending(null)\n }\n }, [pickMedia, user, hostId, quoteId, onEdited, enqueueSnackbar])\n\n const removeProof = useCallback(\n async (proofId: string) => {\n setBusy(true)\n try {\n const answer = await postQuote(user, { action: 'proof-remove', hostId, quoteId, proofId })\n if (!answer.ok) {\n return void enqueueSnackbar(String(answer.payload['error'] ?? 'The proof could not be removed'), {\n variant: 'error',\n allowDuplicate: true,\n })\n }\n onEdited(Number(answer.payload['updatedAtMs']) || 0)\n } finally {\n setBusy(false)\n }\n },\n [user, hostId, quoteId, onEdited, enqueueSnackbar],\n )\n\n const startRevision = useCallback(async () => {\n setBusy(true)\n try {\n const answer = await postQuote(user, { action: 'start-revision', hostId, quoteId })\n if (!answer.ok) {\n return void enqueueSnackbar(String(answer.payload['error'] ?? 'The revision could not be started'), {\n variant: 'error',\n allowDuplicate: true,\n })\n }\n onEdited(Number(answer.payload['updatedAtMs']) || 0)\n enqueueSnackbar(`Revision ${Number(answer.payload['revision']) || revision + 1} started`, { variant: 'success', persist: false })\n setConfirmingRevision(false)\n } finally {\n setBusy(false)\n }\n }, [user, hostId, quoteId, revision, onEdited, enqueueSnackbar])\n\n const tile = (file: ListedFile, fromRevision?: number, onRemove?: () => void) => (\n <QuoteFileTile\n key={`${fromRevision ?? 'current'}-${file.id}`}\n user={user}\n hostId={hostId}\n quoteId={quoteId}\n file={file}\n revision={fromRevision}\n onDownload={(picked, at) => void download(picked, at)}\n onRemove={onRemove}\n removeBlocked={!canEdit}\n />\n )\n\n const earlier = (history ?? []).filter((entry) => Number(entry.revision) < revision).reverse()\n\n return (\n <Stack spacing={1.5}>\n <Stack spacing={0.5}>\n <Typography variant=\"subtitle2\">{`Proofs · Revision ${revision}`}</Typography>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {proofOnly\n ? 'The customer sees these on the proof page, with no prices, and can approve them or ask for changes.'\n : section?.requireProofApproval\n ? 'The customer sees these on the quote page and approves them before they can pay.'\n : 'The customer sees these on the quote page, and can approve them or ask for changes. Paying doesn’t wait on it.'}\n </Typography>\n </Stack>\n\n {latest ? <QuoteResponseNote response={latest} tile={(file) => tile(file)} /> : null}\n\n {proofs.length ? (\n <Stack direction=\"row\" spacing={1} useFlexGap sx={{ flexWrap: 'wrap' }}>\n {proofs.map((proof) =>\n tile(proof, undefined, removable ? () => void removeProof(proof.id) : undefined),\n )}\n </Stack>\n ) : (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {proofOnly\n ? 'No proof on this revision yet, so there is nothing to send. Add one for the customer to approve, or add items to the quote.'\n : 'No proofs on this revision yet. Add an image, a PDF or a design file for the customer to approve.'}\n </Typography>\n )}\n\n {unpaid ? (\n <Stack direction=\"row\" spacing={1} useFlexGap sx={{ flexWrap: 'wrap', alignItems: 'center' }}>\n <input\n ref={picker}\n type=\"file\"\n multiple\n hidden\n accept={VISITOR_UPLOAD_ACCEPT}\n data-testid=\"quote-proof-picker\"\n onChange={(event) => {\n const files = Array.from(event.target.files ?? [])\n event.target.value = ''\n if (files.length) void addProofs(files)\n }}\n />\n <BlockedControl\n blocked={!canEdit || Boolean(addRefusal)}\n reason={!canEdit ? REFUSAL : addRefusal ? CommerceModel.quoteProofRefusalMessage(addRefusal) : ''}\n >\n <Button variant=\"outlined\" size=\"small\" disabled={busy || Boolean(sending)} onClick={() => picker.current?.click()}>\n {sending ? `Sending ${sending.done + 1} of ${sending.total}…` : 'Add proof'}\n </Button>\n </BlockedControl>\n {pickMedia ? (\n <BlockedControl\n blocked={!canEdit || Boolean(addRefusal)}\n reason={!canEdit ? REFUSAL : addRefusal ? CommerceModel.quoteProofRefusalMessage(addRefusal) : ''}\n >\n <Button variant=\"outlined\" size=\"small\" disabled={busy || Boolean(sending)} onClick={() => void addFromLibrary()}>\n {'From media library'}\n </Button>\n </BlockedControl>\n ) : null}\n <BlockedControl blocked={!canEdit} reason={REFUSAL}>\n <Button size=\"small\" disabled={busy || Boolean(sending)} onClick={() => setConfirmingRevision(true)}>\n {`Start revision ${revision + 1}`}\n </Button>\n </BlockedControl>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`Up to ${CommerceModel.QUOTE_MAX_PROOFS} files, ${formatVisitorUploadBytes(VISITOR_UPLOAD_MAX_BYTES)} each.`}\n </Typography>\n </Stack>\n ) : null}\n\n {revision > 1 ? (\n <Stack spacing={1.5}>\n <Divider />\n <Typography variant=\"subtitle2\">{'Earlier revisions'}</Typography>\n {historyError ? <Alert severity=\"error\">{historyError}</Alert> : null}\n {history === null && !historyError ? <CircularProgress size={20} aria-label=\"Loading earlier revisions\" /> : null}\n {earlier.map((entry) => (\n <Paper key={entry.revision} variant=\"outlined\" sx={{ p: 2 }}>\n <Stack spacing={1}>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center', flexWrap: 'wrap', rowGap: 0.5 }}>\n <Typography variant=\"body2\" sx={{ fontWeight: 'fontWeightMedium' }}>{`Revision ${entry.revision}`}</Typography>\n <Chip\n size=\"small\"\n variant=\"outlined\"\n label={CommerceModel.QUOTE_STAGE_LABELS[entry.stage] ?? entry.stage}\n color={CommerceModel.QUOTE_STATUS_COLOR[entry.stage] ?? 'default'}\n />\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`Replaced ${dateTime(entry.closedAtMs)}`}\n </Typography>\n </Stack>\n {entry.proofs.length ? (\n <Stack direction=\"row\" spacing={1} useFlexGap sx={{ flexWrap: 'wrap' }}>\n {entry.proofs.map((proof) => tile(proof, entry.revision))}\n </Stack>\n ) : (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'No proofs.'}\n </Typography>\n )}\n {entry.responses.map((response, index) => (\n <QuoteResponseNote key={index} response={response} tile={(file) => tile(file, entry.revision)} />\n ))}\n </Stack>\n </Paper>\n ))}\n </Stack>\n ) : null}\n\n <Dialog open={confirmingRevision} onClose={() => setConfirmingRevision(false)} maxWidth=\"xs\" fullWidth>\n <DialogTitle>{`Start revision ${revision + 1}?`}</DialogTitle>\n <DialogContent>\n <DialogContentText>\n {`Revision ${revision} is kept as it is now, with its proofs and the customer’s answers. ` +\n `Revision ${revision + 1} starts with no proofs, ready for new ones and any changes to the quote.`}\n </DialogContentText>\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setConfirmingRevision(false)} disabled={busy}>\n {'Cancel'}\n </Button>\n <Button variant=\"contained\" disabled={busy} onClick={() => void startRevision()}>\n {`Start revision ${revision + 1}`}\n </Button>\n </DialogActions>\n </Dialog>\n </Stack>\n )\n}\nQuoteProofsSection.displayName = 'QuoteProofsSection'\n\nexport default QuoteProofsSection\n\n/**\n * The files a quote's request came with (AGL-4098), as the customer's files:\n * a picture for an image, a chip naming anything else, each downloaded\n * through the quote's own route. They stay where the request keeps them, so a\n * request deleted from the Inbox takes them with it.\n */\nexport function QuoteRequestFilesSection(props: { hostId: string; quoteId: string; quote: CommerceModel.HostOrder }) {\n const { hostId, quoteId, quote } = props\n const { data: user } = useUser()\n const { enqueueSnackbar } = useSnackbar()\n const request = quote.quote?.request\n const files = CommerceModel.quoteRequestFileViews(quote.quote?.requestFiles)\n const download = useCallback(\n async (file: ListedFile) => {\n const blob = await fetchQuoteFile(user, { hostId, quoteId, fileId: file.id })\n if (!blob) {\n return void enqueueSnackbar('The file could not be downloaded. The request may have been deleted from the Inbox.', {\n variant: 'error',\n allowDuplicate: true,\n })\n }\n const url = URL.createObjectURL(blob)\n const link = document.createElement('a')\n link.href = url\n link.download = file.name\n link.click()\n setTimeout(() => URL.revokeObjectURL(url), 1000)\n },\n [user, hostId, quoteId, enqueueSnackbar],\n )\n if (!request || !user) return null\n const when = request.receivedAtMs ? ` on ${dateTime(request.receivedAtMs)}` : ''\n return (\n <Stack spacing={1}>\n <Typography variant=\"subtitle2\">{'From the request'}</Typography>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {`Sent through “${request.formName}”${when}.` + (files.length ? ' The files they sent:' : ' They sent no files.')}\n </Typography>\n {files.length ? (\n <Stack direction=\"row\" spacing={1} useFlexGap sx={{ flexWrap: 'wrap' }}>\n {files.map((file) => (\n <QuoteFileTile\n key={file.id}\n user={user}\n hostId={hostId}\n quoteId={quoteId}\n file={file}\n onDownload={(picked) => void download(picked)}\n />\n ))}\n </Stack>\n ) : null}\n </Stack>\n )\n}\n"],"names":["CommerceModel","commerceSitePermissionRefusal","useMediaPicker","checkVisitorUploadSelection","formatVisitorUploadBytes","visitorUploadIsInline","VISITOR_UPLOAD_ACCEPT","VISITOR_UPLOAD_MAX_BYTES","sendVisitorUpload","BlockedControl","useSnackbar","authorizedFetch","useUser","Alert","Box","Button","Chip","CircularProgress","Dialog","DialogActions","DialogContent","DialogContentText","DialogTitle","Divider","Paper","Stack","Typography","useCallback","useEffect","useRef","useState","REFUSAL","postQuote","user","body","response","method","headers","JSON","stringify","ok","payload","json","catch","fetchQuoteFile","action","blob","dateTime","atMs","Date","toLocaleString","undefined","dateStyle","timeStyle","ProofThumbnail","props","hostId","quoteId","file","revision","src","setSrc","live","url","fileId","id","then","URL","createObjectURL","revokeObjectURL","sx","theme","width","spacing","height","display","alignItems","justifyContent","bgcolor","borderRadius","overflow","component","alt","name","maxWidth","maxHeight","objectFit","size","aria-label","QuoteFileTile","onDownload","onRemove","removeBlocked","image","contentType","variant","p","label","onClick","title","blocked","Boolean","reason","color","QuoteResponseNote","tile","severity","ip","userAgent","filter","join","whiteSpace","comment","files","length","direction","useFlexGap","flexWrap","map","QuoteProofsSection","quote","canEdit","onEdited","data","enqueueSnackbar","pickMedia","section","Math","max","Number","proofs","currentQuoteProofs","proofOnly","quoteIsProofOnly","latest","latestQuoteResponse","unpaid","isUnpaidQuote","addRefusal","quoteProofChangeRefusal","removable","sending","setSending","busy","setBusy","confirmingRevision","setConfirmingRevision","history","setHistory","historyError","setHistoryError","picker","loadHistory","answer","String","error","Array","isArray","download","fromRevision","allowDuplicate","link","document","createElement","href","click","setTimeout","addProofs","problem","QUOTE_MAX_PROOFS","done","total","index","entries","stamp","sent","requestTicket","request","finalize","ticket","addFromLibrary","picked","allowPrivate","quoteLibraryProofProblem","media","mediaScope","mediaId","removeProof","proofId","startRevision","persist","at","earlier","entry","reverse","requireProofApproval","proof","input","ref","type","multiple","hidden","accept","data-testid","onChange","event","from","target","value","quoteProofRefusalMessage","disabled","current","rowGap","fontWeight","QUOTE_STAGE_LABELS","stage","QUOTE_STATUS_COLOR","closedAtMs","responses","open","onClose","fullWidth","displayName","QuoteRequestFilesSection","quoteRequestFileViews","requestFiles","when","receivedAtMs","formName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;AAEA,YAAYA,mBAAmB,uBAAa;AAC5C,SAASC,6BAA6B,QAAQ,oCAAgC;AAC9E,SAASC,cAAc,QAAQ,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MAAMC,MAAM,GAAG,0BAA0B,sBAAqB;;YAEhHD,MAAMC,MAAM,iBACX,KAACzF;gBAAM0F,WAAU;gBAAM1C,SAAS;gBAAG2C,UAAU;gBAAC9C,IAAI;oBAAE+C,UAAU;gBAAO;0BAClEJ,MAAMK,GAAG,CAAC,CAAC5D,qBACV,KAAC+B;wBAECxD,MAAMA;wBACNuB,QAAQA;wBACRC,SAASA;wBACTC,MAAMA;wBACNgC,YAAY,CAAC2F,SAAW,KAAKvB,SAASuB;uBALjC3H,KAAKO,EAAE;iBAShB;;;AAGV"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/plugins/commerce/src/lib/components/console/quote-proofs.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n'use client'\n\nimport * as CommerceModel from '../../model'\nimport { commerceSitePermissionRefusal } from '../../model/plugin-permissions'\nimport { useMediaPicker } from '@aglyn/aglyn/app-utils/media-picker-context'\nimport {\n checkVisitorUploadSelection,\n formatVisitorUploadBytes,\n visitorUploadIsInline,\n VISITOR_UPLOAD_ACCEPT,\n VISITOR_UPLOAD_MAX_BYTES,\n} from '@aglyn/aglyn/app-utils/visitor-upload'\nimport { sendVisitorUpload } from '@aglyn/aglyn/app-utils/visitor-upload-client'\nimport { BlockedControl } from '@aglyn/shared-ui-jsx/components/blocked-control.component'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport { authorizedFetch } from '@aglyn/shared-util-http/authorized-token'\nimport { useUser } from '@aglyn/tenant-feature-instance'\nimport {\n Alert,\n Box,\n Button,\n Chip,\n CircularProgress,\n Dialog,\n DialogActions,\n DialogContent,\n DialogContentText,\n DialogTitle,\n Divider,\n Paper,\n Stack,\n Typography,\n} from '@mui/material'\nimport { useCallback, useEffect, useRef, useState, type ReactNode } from 'react'\n\nconst REFUSAL = commerceSitePermissionRefusal('commerce.quotes')\n\ntype User = Parameters<typeof authorizedFetch>[0]\n\n/** A file the console lists: a proof, or one the customer sent. Never its storage path. */\ninterface ListedFile {\n id: string\n name: string\n contentType: string\n size: number\n}\n\n/** An earlier revision as the route lists it. */\ntype RevisionView = Omit<CommerceModel.QuoteRevisionSnapshot, 'proofs' | 'responses'> & {\n proofs: ListedFile[]\n responses: Array<Omit<CommerceModel.QuoteCustomerResponse, 'files'> & { files?: ListedFile[] }>\n}\n\nexport interface QuoteProofsSectionProps {\n hostId: string\n quoteId: string\n quote: CommerceModel.HostOrder\n /** Holds \"Create and edit quotes\" (`commerce.quotes`). */\n canEdit: boolean\n /** A change here moved the quote's edit stamp; the editor saves against the new one. */\n onEdited: (updatedAtMs: number) => void\n}\n\nasync function postQuote(user: User, body: Record<string, unknown>): Promise<{ ok: boolean; payload: Record<string, any> }> {\n const response = await authorizedFetch(user, '/api/commerce/quote', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(body),\n })\n return { ok: response.ok, payload: await response.json().catch(() => ({})) }\n}\n\n/** One of the quote's files as a blob, fetched with the member's token; null when refused. */\nasync function fetchQuoteFile(\n user: User,\n body: { hostId: string; quoteId: string; fileId: string; revision?: number },\n): Promise<Blob | null> {\n try {\n const response = await authorizedFetch(user, '/api/commerce/quote', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ action: 'file', ...body }),\n })\n return response.ok ? await response.blob() : null\n } catch {\n return null\n }\n}\n\nfunction dateTime(atMs: number | undefined): string {\n return atMs ? new Date(atMs).toLocaleString(undefined, { dateStyle: 'medium', timeStyle: 'short' }) : ''\n}\n\n/** A picture of an image proof, loaded with the member's token. */\nfunction ProofThumbnail(props: { user: User; hostId: string; quoteId: string; file: ListedFile; revision?: number }) {\n const { user, hostId, quoteId, file, revision } = props\n const [src, setSrc] = useState<string | null>(null)\n useEffect(() => {\n let live = true\n let url = ''\n void fetchQuoteFile(user, { hostId, quoteId, fileId: file.id, ...(revision ? { revision } : {}) }).then((blob) => {\n if (!live || !blob) return\n url = URL.createObjectURL(blob)\n setSrc(url)\n })\n return () => {\n live = false\n if (url) URL.revokeObjectURL(url)\n }\n }, [user, hostId, quoteId, file.id, revision])\n return (\n <Box\n sx={(theme) => ({\n width: theme.spacing(16),\n height: theme.spacing(12),\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n bgcolor: 'action.hover',\n borderRadius: 1,\n overflow: 'hidden',\n })}\n >\n {src ? (\n <Box component=\"img\" src={src} alt={file.name} sx={{ maxWidth: 1, maxHeight: 1, objectFit: 'contain' }} />\n ) : (\n <CircularProgress size={20} aria-label={`Loading ${file.name}`} />\n )}\n </Box>\n )\n}\n\n/** A file: a picture for an image, a chip naming it for anything else; both download it. */\nfunction QuoteFileTile(props: {\n user: User\n hostId: string\n quoteId: string\n file: ListedFile\n revision?: number\n onDownload: (file: ListedFile, revision?: number) => void\n onRemove?: () => void\n removeBlocked?: boolean\n}) {\n const { file, revision, onDownload, onRemove, removeBlocked } = props\n const image = visitorUploadIsInline(file.contentType)\n return (\n <Paper variant=\"outlined\" sx={{ p: 1 }}>\n <Stack spacing={1} sx={(theme) => ({ width: image ? theme.spacing(16) : 'auto', maxWidth: theme.spacing(32) })}>\n {image ? <ProofThumbnail {...props} /> : null}\n <Chip\n size=\"small\"\n variant=\"outlined\"\n label={`${file.name} · ${formatVisitorUploadBytes(file.size)}`}\n onClick={() => onDownload(file, revision)}\n title={`Download ${file.name}`}\n />\n {onRemove ? (\n <BlockedControl blocked={Boolean(removeBlocked)} reason={REFUSAL}>\n <Button size=\"small\" color=\"inherit\" onClick={onRemove} aria-label={`Remove ${file.name}`}>\n {'Remove'}\n </Button>\n </BlockedControl>\n ) : null}\n </Stack>\n </Paper>\n )\n}\n\n/** What the customer said, with any files they sent. */\nfunction QuoteResponseNote(props: {\n response: Omit<CommerceModel.QuoteCustomerResponse, 'files'> & { files?: ListedFile[] }\n tile: (file: ListedFile) => ReactNode\n}) {\n const { response, tile } = props\n if (response.action === 'approve') {\n return (\n <Alert severity=\"success\">\n <Stack spacing={0.5}>\n <Typography variant=\"body2\">{`Approved by ${response.name || 'the customer'} on ${dateTime(response.atMs)}.`}</Typography>\n {response.confirmed?.length ? (\n <Stack spacing={0.25} data-quote-approval-confirmed=\"\">\n <Typography variant=\"body2\">{'They confirmed:'}</Typography>\n <Box component=\"ul\" sx={{ m: 0, pl: 2.5 }}>\n {response.confirmed.map((statement) => (\n <Typography key={statement} component=\"li\" variant=\"body2\">\n {statement}\n </Typography>\n ))}\n </Box>\n </Stack>\n ) : null}\n <Typography variant=\"caption\" color=\"text.secondary\">\n {[response.ip ? `From ${response.ip}` : '', response.userAgent ?? ''].filter(Boolean).join(' · ')}\n </Typography>\n </Stack>\n </Alert>\n )\n }\n return (\n <Alert severity=\"warning\">\n <Stack spacing={1}>\n <Typography variant=\"body2\">\n {`Rejected with changes${response.name ? ` by ${response.name}` : ''} on ${dateTime(response.atMs)}:`}\n </Typography>\n <Typography variant=\"body2\" sx={{ whiteSpace: 'pre-line' }}>\n {response.comment}\n </Typography>\n {response.files?.length ? (\n <Stack direction=\"row\" spacing={1} useFlexGap sx={{ flexWrap: 'wrap' }}>\n {response.files.map((file) => tile(file))}\n </Stack>\n ) : null}\n </Stack>\n </Alert>\n )\n}\n\n/**\n * A quote's proofs and revisions (AGL-4096), in its editor: the current\n * revision's proofs (a picture for an image, a chip for a PDF or a design\n * file), Add proof and From media library (AGL-4184), what the customer last\n * said with any files they sent, \"Start revision N+1\", and every earlier\n * revision as it was kept.\n */\nexport function QuoteProofsSection(props: QuoteProofsSectionProps) {\n const { hostId, quoteId, quote, canEdit, onEdited } = props\n const { data: user } = useUser()\n const { enqueueSnackbar } = useSnackbar()\n const { pickMedia } = useMediaPicker()\n const section = quote.quote\n const revision = Math.max(1, Number(section?.revision ?? 1) || 1)\n const proofs = CommerceModel.currentQuoteProofs(section)\n const proofOnly = CommerceModel.quoteIsProofOnly(quote)\n const latest = CommerceModel.latestQuoteResponse(section)\n const unpaid = CommerceModel.isUnpaidQuote(quote)\n const addRefusal = CommerceModel.quoteProofChangeRefusal(quote, 'add')\n // A quote with no lines keeps its last proof (`needs-proof`), so it offers no way to remove it.\n const removable = CommerceModel.quoteProofChangeRefusal(quote, 'remove') === null && !(proofOnly && proofs.length === 1)\n const [sending, setSending] = useState<{ done: number; total: number } | null>(null)\n const [busy, setBusy] = useState(false)\n const [confirmingRevision, setConfirmingRevision] = useState(false)\n const [history, setHistory] = useState<RevisionView[] | null>(null)\n const [historyError, setHistoryError] = useState('')\n const picker = useRef<HTMLInputElement>(null)\n\n const loadHistory = useCallback(async () => {\n setHistoryError('')\n const answer = await postQuote(user, { action: 'revisions', hostId, quoteId }).catch(() => null)\n if (!answer?.ok) {\n setHistoryError(String(answer?.payload?.error ?? 'Earlier revisions could not be loaded.'))\n return\n }\n setHistory(Array.isArray(answer.payload['revisions']) ? (answer.payload['revisions'] as RevisionView[]) : [])\n }, [user, hostId, quoteId])\n\n // Earlier revisions are read when there are some, and again after one is added.\n useEffect(() => {\n if (revision > 1) void loadHistory()\n }, [revision, loadHistory])\n\n const download = useCallback(\n async (file: ListedFile, fromRevision?: number) => {\n const blob = await fetchQuoteFile(user, { hostId, quoteId, fileId: file.id, ...(fromRevision ? { revision: fromRevision } : {}) })\n if (!blob) return void enqueueSnackbar('The file could not be downloaded', { variant: 'error', allowDuplicate: true })\n const url = URL.createObjectURL(blob)\n const link = document.createElement('a')\n link.href = url\n link.download = file.name\n link.click()\n setTimeout(() => URL.revokeObjectURL(url), 1000)\n },\n [user, hostId, quoteId, enqueueSnackbar],\n )\n\n const addProofs = useCallback(\n async (files: File[]) => {\n const problem = checkVisitorUploadSelection(files, proofs.length, CommerceModel.QUOTE_MAX_PROOFS)\n if (problem) return void enqueueSnackbar(problem, { variant: 'error', allowDuplicate: true })\n setSending({ done: 0, total: files.length })\n try {\n for (const [index, file] of files.entries()) {\n let stamp = 0\n const sent = await sendVisitorUpload({\n file,\n requestTicket: async (request) => {\n const answer = await postQuote(user, { action: 'proof-ticket', hostId, quoteId, file: request })\n return answer.ok\n ? (answer.payload as { ticket: string; upload: { url: string; fields: Record<string, string> } })\n : { error: String(answer.payload['error'] ?? 'The proof could not be sent') }\n },\n finalize: async (ticket) => {\n const answer = await postQuote(user, { action: 'proof-finalize', hostId, quoteId, ticket })\n if (!answer.ok) return { error: String(answer.payload['error'] ?? 'The proof could not be kept') }\n stamp = Number(answer.payload['updatedAtMs']) || 0\n return { file: answer.payload['proof'] }\n },\n })\n if ('error' in sent) {\n enqueueSnackbar(sent.error, { variant: 'error', allowDuplicate: true })\n break\n }\n if (stamp) onEdited(stamp)\n setSending({ done: index + 1, total: files.length })\n }\n } finally {\n setSending(null)\n }\n },\n [user, hostId, quoteId, proofs.length, onEdited, enqueueSnackbar],\n )\n\n /**\n * A file from the media library: the shared picker offers what this member\n * can read, a private file included, and the server copies the bytes into the\n * quote's private proofs. Only the file's library and id are sent.\n */\n const addFromLibrary = useCallback(async () => {\n const picked = await pickMedia?.({ allowPrivate: true })\n if (!picked) return\n const problem = CommerceModel.quoteLibraryProofProblem(picked)\n if (problem) return void enqueueSnackbar(problem, { variant: 'error', allowDuplicate: true })\n setSending({ done: 0, total: 1 })\n try {\n const answer = await postQuote(user, {\n action: 'proof-from-media',\n hostId,\n quoteId,\n media: { mediaScope: picked.mediaScope, mediaId: picked.mediaId },\n })\n if (!answer.ok) {\n return void enqueueSnackbar(String(answer.payload['error'] ?? 'The proof could not be added'), {\n variant: 'error',\n allowDuplicate: true,\n })\n }\n onEdited(Number(answer.payload['updatedAtMs']) || 0)\n } catch {\n enqueueSnackbar('The proof could not be added', { variant: 'error', allowDuplicate: true })\n } finally {\n setSending(null)\n }\n }, [pickMedia, user, hostId, quoteId, onEdited, enqueueSnackbar])\n\n const removeProof = useCallback(\n async (proofId: string) => {\n setBusy(true)\n try {\n const answer = await postQuote(user, { action: 'proof-remove', hostId, quoteId, proofId })\n if (!answer.ok) {\n return void enqueueSnackbar(String(answer.payload['error'] ?? 'The proof could not be removed'), {\n variant: 'error',\n allowDuplicate: true,\n })\n }\n onEdited(Number(answer.payload['updatedAtMs']) || 0)\n } finally {\n setBusy(false)\n }\n },\n [user, hostId, quoteId, onEdited, enqueueSnackbar],\n )\n\n const startRevision = useCallback(async () => {\n setBusy(true)\n try {\n const answer = await postQuote(user, { action: 'start-revision', hostId, quoteId })\n if (!answer.ok) {\n return void enqueueSnackbar(String(answer.payload['error'] ?? 'The revision could not be started'), {\n variant: 'error',\n allowDuplicate: true,\n })\n }\n onEdited(Number(answer.payload['updatedAtMs']) || 0)\n enqueueSnackbar(`Revision ${Number(answer.payload['revision']) || revision + 1} started`, { variant: 'success', persist: false })\n setConfirmingRevision(false)\n } finally {\n setBusy(false)\n }\n }, [user, hostId, quoteId, revision, onEdited, enqueueSnackbar])\n\n const tile = (file: ListedFile, fromRevision?: number, onRemove?: () => void) => (\n <QuoteFileTile\n key={`${fromRevision ?? 'current'}-${file.id}`}\n user={user}\n hostId={hostId}\n quoteId={quoteId}\n file={file}\n revision={fromRevision}\n onDownload={(picked, at) => void download(picked, at)}\n onRemove={onRemove}\n removeBlocked={!canEdit}\n />\n )\n\n const earlier = (history ?? []).filter((entry) => Number(entry.revision) < revision).reverse()\n\n return (\n <Stack spacing={1.5}>\n <Stack spacing={0.5}>\n <Typography variant=\"subtitle2\">{`Proofs · Revision ${revision}`}</Typography>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {proofOnly\n ? 'The customer sees these on the proof page, with no prices, and can approve them or reject them with changes.'\n : section?.requireProofApproval\n ? 'The customer sees these on the quote page and approves them before they can pay.'\n : 'The customer sees these on the quote page, and can approve them or reject them with changes. Paying doesn’t wait on it.'}\n {' To approve, they tick each statement from your Quotes settings and type their name.'}\n {section?.requireProofSignIn\n ? ' A customer with an account on your site signs in to see them; one without uses the private link.'\n : ''}\n </Typography>\n </Stack>\n\n {latest ? <QuoteResponseNote response={latest} tile={(file) => tile(file)} /> : null}\n\n {proofs.length ? (\n <Stack direction=\"row\" spacing={1} useFlexGap sx={{ flexWrap: 'wrap' }}>\n {proofs.map((proof) =>\n tile(proof, undefined, removable ? () => void removeProof(proof.id) : undefined),\n )}\n </Stack>\n ) : (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {proofOnly\n ? 'No proof on this revision yet, so there is nothing to send. Add one for the customer to approve, or add items to the quote.'\n : 'No proofs on this revision yet. Add an image, a PDF or a design file for the customer to approve.'}\n </Typography>\n )}\n\n {unpaid ? (\n <Stack direction=\"row\" spacing={1} useFlexGap sx={{ flexWrap: 'wrap', alignItems: 'center' }}>\n <input\n ref={picker}\n type=\"file\"\n multiple\n hidden\n accept={VISITOR_UPLOAD_ACCEPT}\n data-testid=\"quote-proof-picker\"\n onChange={(event) => {\n const files = Array.from(event.target.files ?? [])\n event.target.value = ''\n if (files.length) void addProofs(files)\n }}\n />\n <BlockedControl\n blocked={!canEdit || Boolean(addRefusal)}\n reason={!canEdit ? REFUSAL : addRefusal ? CommerceModel.quoteProofRefusalMessage(addRefusal) : ''}\n >\n <Button variant=\"outlined\" size=\"small\" disabled={busy || Boolean(sending)} onClick={() => picker.current?.click()}>\n {sending ? `Sending ${sending.done + 1} of ${sending.total}…` : 'Add proof'}\n </Button>\n </BlockedControl>\n {pickMedia ? (\n <BlockedControl\n blocked={!canEdit || Boolean(addRefusal)}\n reason={!canEdit ? REFUSAL : addRefusal ? CommerceModel.quoteProofRefusalMessage(addRefusal) : ''}\n >\n <Button variant=\"outlined\" size=\"small\" disabled={busy || Boolean(sending)} onClick={() => void addFromLibrary()}>\n {'From media library'}\n </Button>\n </BlockedControl>\n ) : null}\n <BlockedControl blocked={!canEdit} reason={REFUSAL}>\n <Button size=\"small\" disabled={busy || Boolean(sending)} onClick={() => setConfirmingRevision(true)}>\n {`Start revision ${revision + 1}`}\n </Button>\n </BlockedControl>\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`Up to ${CommerceModel.QUOTE_MAX_PROOFS} files, ${formatVisitorUploadBytes(VISITOR_UPLOAD_MAX_BYTES)} each.`}\n </Typography>\n </Stack>\n ) : null}\n\n {revision > 1 ? (\n <Stack spacing={1.5}>\n <Divider />\n <Typography variant=\"subtitle2\">{'Earlier revisions'}</Typography>\n {historyError ? <Alert severity=\"error\">{historyError}</Alert> : null}\n {history === null && !historyError ? <CircularProgress size={20} aria-label=\"Loading earlier revisions\" /> : null}\n {earlier.map((entry) => (\n <Paper key={entry.revision} variant=\"outlined\" sx={{ p: 2 }}>\n <Stack spacing={1}>\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center', flexWrap: 'wrap', rowGap: 0.5 }}>\n <Typography variant=\"body2\" sx={{ fontWeight: 'fontWeightMedium' }}>{`Revision ${entry.revision}`}</Typography>\n <Chip\n size=\"small\"\n variant=\"outlined\"\n label={CommerceModel.QUOTE_STAGE_LABELS[entry.stage] ?? entry.stage}\n color={CommerceModel.QUOTE_STATUS_COLOR[entry.stage] ?? 'default'}\n />\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`Replaced ${dateTime(entry.closedAtMs)}`}\n </Typography>\n </Stack>\n {entry.proofs.length ? (\n <Stack direction=\"row\" spacing={1} useFlexGap sx={{ flexWrap: 'wrap' }}>\n {entry.proofs.map((proof) => tile(proof, entry.revision))}\n </Stack>\n ) : (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'No proofs.'}\n </Typography>\n )}\n {entry.responses.map((response, index) => (\n <QuoteResponseNote key={index} response={response} tile={(file) => tile(file, entry.revision)} />\n ))}\n </Stack>\n </Paper>\n ))}\n </Stack>\n ) : null}\n\n <Dialog open={confirmingRevision} onClose={() => setConfirmingRevision(false)} maxWidth=\"xs\" fullWidth>\n <DialogTitle>{`Start revision ${revision + 1}?`}</DialogTitle>\n <DialogContent>\n <DialogContentText>\n {`Revision ${revision} is kept as it is now, with its proofs and the customer’s answers. ` +\n `Revision ${revision + 1} starts with no proofs, ready for new ones and any changes to the quote.`}\n </DialogContentText>\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setConfirmingRevision(false)} disabled={busy}>\n {'Cancel'}\n </Button>\n <Button variant=\"contained\" disabled={busy} onClick={() => void startRevision()}>\n {`Start revision ${revision + 1}`}\n </Button>\n </DialogActions>\n </Dialog>\n </Stack>\n )\n}\nQuoteProofsSection.displayName = 'QuoteProofsSection'\n\nexport default QuoteProofsSection\n\n/**\n * The files a quote's request came with (AGL-4098), as the customer's files:\n * a picture for an image, a chip naming anything else, each downloaded\n * through the quote's own route. They stay where the request keeps them, so a\n * request deleted from the Inbox takes them with it.\n */\nexport function QuoteRequestFilesSection(props: { hostId: string; quoteId: string; quote: CommerceModel.HostOrder }) {\n const { hostId, quoteId, quote } = props\n const { data: user } = useUser()\n const { enqueueSnackbar } = useSnackbar()\n const request = quote.quote?.request\n const files = CommerceModel.quoteRequestFileViews(quote.quote?.requestFiles)\n const download = useCallback(\n async (file: ListedFile) => {\n const blob = await fetchQuoteFile(user, { hostId, quoteId, fileId: file.id })\n if (!blob) {\n return void enqueueSnackbar('The file could not be downloaded. The request may have been deleted from the Inbox.', {\n variant: 'error',\n allowDuplicate: true,\n })\n }\n const url = URL.createObjectURL(blob)\n const link = document.createElement('a')\n link.href = url\n link.download = file.name\n link.click()\n setTimeout(() => URL.revokeObjectURL(url), 1000)\n },\n [user, hostId, quoteId, enqueueSnackbar],\n )\n if (!request || !user) return null\n const when = request.receivedAtMs ? ` on ${dateTime(request.receivedAtMs)}` : ''\n return (\n <Stack spacing={1}>\n <Typography variant=\"subtitle2\">{'From the request'}</Typography>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {`Sent through “${request.formName}”${when}.` + (files.length ? ' The files they sent:' : ' They sent no files.')}\n </Typography>\n {files.length ? (\n <Stack direction=\"row\" spacing={1} useFlexGap sx={{ flexWrap: 'wrap' }}>\n {files.map((file) => (\n <QuoteFileTile\n key={file.id}\n user={user}\n hostId={hostId}\n quoteId={quoteId}\n file={file}\n onDownload={(picked) => void download(picked)}\n />\n ))}\n </Stack>\n ) : null}\n </Stack>\n )\n}\n"],"names":["CommerceModel","commerceSitePermissionRefusal","useMediaPicker","checkVisitorUploadSelection","formatVisitorUploadBytes","visitorUploadIsInline","VISITOR_UPLOAD_ACCEPT","VISITOR_UPLOAD_MAX_BYTES","sendVisitorUpload","BlockedControl","useSnackbar","authorizedFetch","useUser","Alert","Box","Button","Chip","CircularProgress","Dialog","DialogActions","DialogContent","DialogContentText","DialogTitle","Divider","Paper","Stack","Typography","useCallback","useEffect","useRef","useState","REFUSAL","postQuote","user","body","response","method","headers","JSON","stringify","ok","payload","json","catch","fetchQuoteFile","action","blob","dateTime","atMs","Date","toLocaleString","undefined","dateStyle","timeStyle","ProofThumbnail","props","hostId","quoteId","file","revision","src","setSrc","live","url","fileId","id","then","URL","createObjectURL","revokeObjectURL","sx","theme","width","spacing","height","display","alignItems","justifyContent","bgcolor","borderRadius","overflow","component","alt","name","maxWidth","maxHeight","objectFit","size","aria-label","QuoteFileTile","onDownload","onRemove","removeBlocked","image","contentType","variant","p","label","onClick","title","blocked","Boolean","reason","color","QuoteResponseNote","tile","severity","confirmed","length","data-quote-approval-confirmed","m","pl","map","statement","ip","userAgent","filter","join","whiteSpace","comment","files","direction","useFlexGap","flexWrap","QuoteProofsSection","quote","canEdit","onEdited","data","enqueueSnackbar","pickMedia","section","Math","max","Number","proofs","currentQuoteProofs","proofOnly","quoteIsProofOnly","latest","latestQuoteResponse","unpaid","isUnpaidQuote","addRefusal","quoteProofChangeRefusal","removable","sending","setSending","busy","setBusy","confirmingRevision","setConfirmingRevision","history","setHistory","historyError","setHistoryError","picker","loadHistory","answer","String","error","Array","isArray","download","fromRevision","allowDuplicate","link","document","createElement","href","click","setTimeout","addProofs","problem","QUOTE_MAX_PROOFS","done","total","index","entries","stamp","sent","requestTicket","request","finalize","ticket","addFromLibrary","picked","allowPrivate","quoteLibraryProofProblem","media","mediaScope","mediaId","removeProof","proofId","startRevision","persist","at","earlier","entry","reverse","requireProofApproval","requireProofSignIn","proof","input","ref","type","multiple","hidden","accept","data-testid","onChange","event","from","target","value","quoteProofRefusalMessage","disabled","current","rowGap","fontWeight","QUOTE_STAGE_LABELS","stage","QUOTE_STATUS_COLOR","closedAtMs","responses","open","onClose","fullWidth","displayName","QuoteRequestFilesSection","quoteRequestFileViews","requestFiles","when","receivedAtMs","formName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;AAEA,YAAYA,mBAAmB,uBAAa;AAC5C,SAASC,6BAA6B,QAAQ,oCAAgC;AAC9E,SAASC,cAAc,QAAQ,8CAA6C;AAC5E,SACEC,2BAA2B,EAC3BC,wBAAwB,EACxBC,qBAAqB,EACrBC,qBAAqB,EACrBC,wBAAwB,QACnB,wCAAuC;AAC9C,SAASC,iBAAiB,QAAQ,+CAA8C;AAChF,SAASC,cAAc,QAAQ,4DAA2D;AAC1F,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SAASC,eAAe,QAAQ,2CAA0C;AAC1E,SAASC,OAAO,QAAQ,iCAAgC;AACxD,SACEC,KAAK,EACLC,GAAG,EACHC,MAAM,EACNC,IAAI,EACJC,gBAAgB,EAChBC,MAAM,EACNC,aAAa,EACbC,aAAa,EACbC,iBAAiB,EACjBC,WAAW,EACXC,OAAO,EACPC,KAAK,EACLC,KAAK,EACLC,UAAU,QACL,gBAAe;AACtB,SAASC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAwB,QAAO;AAEhF,MAAMC,UAAU9B,8BAA8B;AA4B9C,eAAe+B,UAAUC,IAAU,EAAEC,IAA6B;IAChE,MAAMC,WAAW,MAAMxB,gBAAgBsB,MAAM,uBAAuB;QAClEG,QAAQ;QACRC,S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CAACtD,qBACV,KAAC+B;wBAECxD,MAAMA;wBACNuB,QAAQA;wBACRC,SAASA;wBACTC,MAAMA;wBACNgC,YAAY,CAACgG,SAAW,KAAKvB,SAASuB;uBALjChI,KAAKO,EAAE;iBAShB;;;AAGV"}
|
|
@@ -18,9 +18,13 @@ export interface QuoteSettingsCardProps {
|
|
|
18
18
|
hostId: string;
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
|
-
* The store's quote defaults
|
|
22
|
-
*
|
|
23
|
-
*
|
|
21
|
+
* The store's quote defaults, on `hosts/{hostId}/settings/store` under
|
|
22
|
+
* `quotes`: whether a new quote starts out asking the customer to approve the
|
|
23
|
+
* proof before they can pay (AGL-4093), whether it starts out asking a
|
|
24
|
+
* customer with a site account to sign in to see the proof (AGL-4206), and
|
|
25
|
+
* what every customer ticks before Approve works (AGL-4206). Each quote keeps
|
|
26
|
+
* its own switches; the statements are the store's, read when the customer
|
|
27
|
+
* opens the quote.
|
|
24
28
|
*/
|
|
25
29
|
export declare function QuoteSettingsCard(props: QuoteSettingsCardProps): import("react").JSX.Element;
|
|
26
30
|
export declare namespace QuoteSettingsCard {
|