@lotics/ui 8.0.0 → 10.0.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/AGENTS.md +177 -70
- package/examples/tpl_allocate.tsx +2 -2
- package/examples/tpl_attendance.tsx +2 -2
- package/examples/tpl_calendar.tsx +1 -1
- package/examples/tpl_dashboard.tsx +1 -1
- package/examples/tpl_item_list.tsx +1015 -124
- package/examples/tpl_pick.tsx +3 -3
- package/examples/tpl_pivot.tsx +1 -1
- package/examples/tpl_record.tsx +1354 -0
- package/examples/tpl_report.tsx +7 -7
- package/examples/tpl_rollup.tsx +6 -6
- package/examples/tpl_shifts.tsx +2 -2
- package/examples/tpl_statements.tsx +221 -0
- package/examples/tpl_stock.tsx +7 -7
- package/examples/tpl_task_board.tsx +16 -13
- package/examples/tpl_tasks.tsx +15 -28
- package/examples/tpl_tower.tsx +2 -2
- package/package.json +8 -7
- package/src/capture_row.tsx +59 -0
- package/src/checklist.tsx +104 -0
- package/src/chip.tsx +12 -3
- package/src/detail_row.tsx +137 -10
- package/src/inline_date_picker.tsx +8 -3
- package/src/inline_edit.tsx +40 -10
- package/src/inline_member_select.tsx +3 -0
- package/src/inline_number_input.tsx +5 -2
- package/src/inline_select.tsx +8 -3
- package/src/inline_tag_select.tsx +140 -0
- package/src/inline_text_input.tsx +5 -2
- package/src/inline_time_picker.tsx +5 -2
- package/src/ledger.tsx +220 -0
- package/src/locale.tsx +25 -0
- package/src/page_header.tsx +0 -2
- package/src/popover_nav.tsx +40 -0
- package/src/progress_bar.tsx +32 -1
- package/src/record_summary.tsx +101 -0
- package/src/section_heading.tsx +16 -8
- package/src/suggestion_chip.tsx +47 -0
- package/src/trend_footer.tsx +3 -1
- package/src/use_screen_size.ts +1 -1
- package/src/use_section_nav.test.ts +69 -0
- package/src/use_section_nav.ts +59 -0
- package/examples/tpl_billing.tsx +0 -344
- package/examples/tpl_detail.tsx +0 -232
- package/examples/tpl_directory.tsx +0 -260
- package/examples/tpl_intake.tsx +0 -206
- package/examples/tpl_order.tsx +0 -482
- package/examples/tpl_quick.tsx +0 -211
- package/examples/tpl_record_plain.tsx +0 -259
- package/examples/tpl_settings.tsx +0 -178
- package/examples/tpl_timeline.tsx +0 -244
- package/examples/tpl_wizard.tsx +0 -223
- package/src/animation_horizontal_slide.tsx +0 -75
- package/src/form_time_picker.tsx +0 -22
- package/src/highlighted_text.tsx +0 -92
- package/src/menu_title.tsx +0 -15
- package/src/pager_view.tsx +0 -167
- package/src/popover_header.tsx +0 -38
package/examples/tpl_billing.tsx
DELETED
|
@@ -1,344 +0,0 @@
|
|
|
1
|
-
import { useState } from "react";
|
|
2
|
-
import { ScrollView, View } from "react-native";
|
|
3
|
-
import { Text } from "@lotics/ui/text";
|
|
4
|
-
import { colors } from "@lotics/ui/colors";
|
|
5
|
-
import { Button } from "@lotics/ui/button";
|
|
6
|
-
import { Card, CardBody, CardHeader, CardHeaderMeta, CardHeaderTitle } from "@lotics/ui/card";
|
|
7
|
-
import { Badge } from "@lotics/ui/badge";
|
|
8
|
-
import { Link } from "@lotics/ui/link";
|
|
9
|
-
import { Icon } from "@lotics/ui/icon";
|
|
10
|
-
import { Divider } from "@lotics/ui/divider";
|
|
11
|
-
import { NumberInput } from "@lotics/ui/number_input";
|
|
12
|
-
import { Picker } from "@lotics/ui/picker";
|
|
13
|
-
import type { PickerOption } from "@lotics/ui/picker";
|
|
14
|
-
import { Callout, CalloutText } from "@lotics/ui/callout";
|
|
15
|
-
import { Dialog, DialogFooter, DialogHeader, DialogHeaderTitle } from "@lotics/ui/dialog";
|
|
16
|
-
import { Alert } from "@lotics/ui/alert";
|
|
17
|
-
import { formatMoney } from "@lotics/ui/format_money";
|
|
18
|
-
|
|
19
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
20
|
-
// Template · Billing & invoicing — the charges→invoice→collect flow as ONE
|
|
21
|
-
// banded card, not a stack of disconnected cards. It's a single document, so it
|
|
22
|
-
// reads as one: the bill-to, each invoice, the collect total, and the deposit
|
|
23
|
-
// are BANDS separated by hairline Dividers. The INVOICE DOCUMENT is the unit —
|
|
24
|
-
// each band is anchored by its own title + status badge and owns its editable
|
|
25
|
-
// charge lines (amount + how it's paid), its live total, and its issue action,
|
|
26
|
-
// so a charge never lives apart from the document it bills on. Issuing a real
|
|
27
|
-
// e-invoice is irreversible and needs a bill-to tax ID, so it's gated inline
|
|
28
|
-
// (never a dead end) and confirmed in a Dialog. A refundable DEPOSIT is its own
|
|
29
|
-
// (tinted) band — collected separately, never folded into the total due.
|
|
30
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
31
|
-
|
|
32
|
-
type Method = "cash" | "transfer" | "card";
|
|
33
|
-
const METHODS: PickerOption<Method>[] = [
|
|
34
|
-
{ value: "cash", label: "Cash" },
|
|
35
|
-
{ value: "transfer", label: "Bank transfer" },
|
|
36
|
-
{ value: "card", label: "Card" },
|
|
37
|
-
];
|
|
38
|
-
|
|
39
|
-
interface Charge {
|
|
40
|
-
key: string;
|
|
41
|
-
label: string;
|
|
42
|
-
/** The expected list price — offered as a one-tap fill while the line is unset. */
|
|
43
|
-
standard: number;
|
|
44
|
-
amount: number;
|
|
45
|
-
method: Method | "";
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
interface Invoice {
|
|
49
|
-
key: string;
|
|
50
|
-
title: string;
|
|
51
|
-
charges: Charge[];
|
|
52
|
-
/** Lookup code once issued to the e-invoice provider; "" = not issued. */
|
|
53
|
-
ref: string;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const INITIAL: Invoice[] = [
|
|
57
|
-
{
|
|
58
|
-
key: "service",
|
|
59
|
-
title: "Service",
|
|
60
|
-
ref: "",
|
|
61
|
-
charges: [
|
|
62
|
-
{ key: "labor", label: "Labor", standard: 1_200_000, amount: 1_200_000, method: "cash" },
|
|
63
|
-
{ key: "parts", label: "Parts", standard: 0, amount: 0, method: "" },
|
|
64
|
-
],
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
key: "inspection",
|
|
68
|
-
title: "Inspection",
|
|
69
|
-
ref: "",
|
|
70
|
-
charges: [{ key: "insp", label: "Inspection fee", standard: 150_000, amount: 150_000, method: "" }],
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
key: "disposal",
|
|
74
|
-
title: "Disposal",
|
|
75
|
-
ref: "INV-2026-0414",
|
|
76
|
-
charges: [{ key: "disp", label: "Disposal fee", standard: 80_000, amount: 80_000, method: "transfer" }],
|
|
77
|
-
},
|
|
78
|
-
];
|
|
79
|
-
|
|
80
|
-
type Status = "none" | "draft" | "issued";
|
|
81
|
-
const invoiceTotal = (inv: Invoice) => inv.charges.reduce((s, c) => s + c.amount, 0);
|
|
82
|
-
const invoiceStatus = (inv: Invoice): Status => (inv.ref ? "issued" : invoiceTotal(inv) > 0 ? "draft" : "none");
|
|
83
|
-
const missingMethods = (inv: Invoice) => inv.charges.filter((c) => c.amount > 0 && !c.method);
|
|
84
|
-
|
|
85
|
-
/** One charge: label, an amount that reads blank until entered (a one-tap
|
|
86
|
-
* Standard fill + "Set 0" while unset), and the payment method — which turns
|
|
87
|
-
* required the moment the line carries an amount. */
|
|
88
|
-
function ChargeLine({
|
|
89
|
-
charge, onAmount, onMethod, disabled,
|
|
90
|
-
}: {
|
|
91
|
-
charge: Charge;
|
|
92
|
-
onAmount: (v: number) => void;
|
|
93
|
-
onMethod: (m: Method) => void;
|
|
94
|
-
disabled: boolean;
|
|
95
|
-
}) {
|
|
96
|
-
const unset = charge.amount <= 0;
|
|
97
|
-
const needsMethod = charge.amount > 0 && !charge.method;
|
|
98
|
-
return (
|
|
99
|
-
<View style={{ flexDirection: "row", alignItems: "flex-start", gap: 10, flexWrap: "wrap" }}>
|
|
100
|
-
<Text size="sm" color="muted" style={{ width: 116, paddingTop: 10 }}>{charge.label}</Text>
|
|
101
|
-
<View style={{ flexGrow: 1, flexBasis: 130, gap: 4 }}>
|
|
102
|
-
<NumberInput
|
|
103
|
-
value={unset ? null : charge.amount}
|
|
104
|
-
onValueChange={(v) => onAmount(v ?? 0)}
|
|
105
|
-
min={0}
|
|
106
|
-
disabled={disabled}
|
|
107
|
-
accessibilityLabel={`${charge.label} amount`}
|
|
108
|
-
/>
|
|
109
|
-
{unset && !disabled ? (
|
|
110
|
-
<View style={{ flexDirection: "row", gap: 8, flexWrap: "wrap" }}>
|
|
111
|
-
{charge.standard > 0 ? (
|
|
112
|
-
<Button title={`Standard ${formatMoney(charge.standard)}`} color="secondary" onPress={() => onAmount(charge.standard)} />
|
|
113
|
-
) : null}
|
|
114
|
-
<Button title="Set 0" color="secondary" onPress={() => onAmount(0)} />
|
|
115
|
-
</View>
|
|
116
|
-
) : null}
|
|
117
|
-
</View>
|
|
118
|
-
<View style={{ flexBasis: 168, gap: 4 }}>
|
|
119
|
-
<Picker
|
|
120
|
-
options={METHODS}
|
|
121
|
-
value={charge.method || null}
|
|
122
|
-
onValueChange={onMethod}
|
|
123
|
-
placeholder="How paid…"
|
|
124
|
-
disabled={disabled || unset}
|
|
125
|
-
accessibilityLabel={`Payment method · ${charge.label}`}
|
|
126
|
-
/>
|
|
127
|
-
{needsMethod ? <Text size="xs" color="danger">Choose a method</Text> : null}
|
|
128
|
-
</View>
|
|
129
|
-
</View>
|
|
130
|
-
);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/** One invoice document, rendered as a BAND inside the single billing card: a
|
|
134
|
-
* title + status header, its charge lines, and a total + issue row. The leading
|
|
135
|
-
* Divider sets it off from the band above without a second card. */
|
|
136
|
-
function InvoiceBand({
|
|
137
|
-
inv, taxId, onAmount, onMethod, onIssue,
|
|
138
|
-
}: {
|
|
139
|
-
inv: Invoice;
|
|
140
|
-
taxId: string;
|
|
141
|
-
onAmount: (chKey: string, v: number) => void;
|
|
142
|
-
onMethod: (chKey: string, m: Method) => void;
|
|
143
|
-
onIssue: (inv: Invoice) => void;
|
|
144
|
-
}) {
|
|
145
|
-
const total = invoiceTotal(inv);
|
|
146
|
-
const status = invoiceStatus(inv);
|
|
147
|
-
const missing = missingMethods(inv);
|
|
148
|
-
const canIssue = total > 0 && missing.length === 0 && !!taxId;
|
|
149
|
-
const blockReason = !taxId ? "Add the customer's tax ID to issue." : missing.length ? "Choose a payment method for every charged line." : "";
|
|
150
|
-
return (
|
|
151
|
-
<>
|
|
152
|
-
<Divider />
|
|
153
|
-
<CardBody style={{ gap: 10 }}>
|
|
154
|
-
<View style={{ flexDirection: "row", alignItems: "center", gap: 8 }}>
|
|
155
|
-
<Text weight="semibold">{inv.title}</Text>
|
|
156
|
-
<View style={{ flex: 1 }} />
|
|
157
|
-
{status === "issued" ? (
|
|
158
|
-
<View style={{ flexDirection: "row", alignItems: "center", gap: 8 }}>
|
|
159
|
-
<Badge variant="dot" label="Issued" color="emerald" />
|
|
160
|
-
<Link size="xs" onPress={() => {}} accessibilityLabel={`Open invoice ${inv.ref}`}>{inv.ref}</Link>
|
|
161
|
-
</View>
|
|
162
|
-
) : status === "draft" ? (
|
|
163
|
-
<Badge variant="dot" label="Draft" color="amber" />
|
|
164
|
-
) : (
|
|
165
|
-
<Badge variant="dot" label="Nothing to bill" color="zinc" />
|
|
166
|
-
)}
|
|
167
|
-
</View>
|
|
168
|
-
{inv.charges.map((c) => (
|
|
169
|
-
<ChargeLine
|
|
170
|
-
key={c.key}
|
|
171
|
-
charge={c}
|
|
172
|
-
disabled={status === "issued"}
|
|
173
|
-
onAmount={(v) => onAmount(c.key, v)}
|
|
174
|
-
onMethod={(m) => onMethod(c.key, m)}
|
|
175
|
-
/>
|
|
176
|
-
))}
|
|
177
|
-
{total > 0 ? (
|
|
178
|
-
<View style={{ flexDirection: "row", alignItems: "center", gap: 8, flexWrap: "wrap", paddingTop: 2 }}>
|
|
179
|
-
<Text size="sm" color="muted" style={{ flex: 1 }}>
|
|
180
|
-
Total <Text weight="semibold" color="default" tabular>{formatMoney(total)}</Text>
|
|
181
|
-
</Text>
|
|
182
|
-
{status === "issued" ? (
|
|
183
|
-
<>
|
|
184
|
-
<Button title="Re-issue" color="secondary" disabled={!canIssue} onPress={() => onIssue(inv)} />
|
|
185
|
-
</>
|
|
186
|
-
) : (
|
|
187
|
-
<Button title="Issue invoice" color="primary" disabled={!canIssue} onPress={() => onIssue(inv)} />
|
|
188
|
-
)}
|
|
189
|
-
</View>
|
|
190
|
-
) : null}
|
|
191
|
-
{total > 0 && status !== "issued" && !canIssue ? <Text size="xs" color="muted">{blockReason}</Text> : null}
|
|
192
|
-
</CardBody>
|
|
193
|
-
</>
|
|
194
|
-
);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
export function TplBilling() {
|
|
198
|
-
const [invoices, setInvoices] = useState<Invoice[]>(INITIAL);
|
|
199
|
-
// The bill-to: issuing an e-invoice needs a tax ID. Toggle it to see the gate.
|
|
200
|
-
const [taxId, setTaxId] = useState("0312456780");
|
|
201
|
-
const [deposit, setDeposit] = useState(0);
|
|
202
|
-
const [confirm, setConfirm] = useState<Invoice | null>(null);
|
|
203
|
-
const seq = useState(() => ({ n: 414 }))[0];
|
|
204
|
-
|
|
205
|
-
const patchCharge = (invKey: string, chKey: string, patch: Partial<Charge>) =>
|
|
206
|
-
setInvoices((prev) =>
|
|
207
|
-
prev.map((inv) =>
|
|
208
|
-
inv.key !== invKey ? inv : { ...inv, charges: inv.charges.map((c) => (c.key === chKey ? { ...c, ...patch } : c)) },
|
|
209
|
-
),
|
|
210
|
-
);
|
|
211
|
-
|
|
212
|
-
const grandTotal = invoices.reduce((s, inv) => s + invoiceTotal(inv), 0);
|
|
213
|
-
const allMissing = invoices.flatMap(missingMethods);
|
|
214
|
-
const issuedCount = invoices.filter((i) => invoiceStatus(i) === "issued").length;
|
|
215
|
-
|
|
216
|
-
const issue = (inv: Invoice) => {
|
|
217
|
-
seq.n += 1;
|
|
218
|
-
const ref = `INV-2026-${String(seq.n).padStart(4, "0")}`;
|
|
219
|
-
setInvoices((prev) => prev.map((x) => (x.key === inv.key ? { ...x, ref } : x)));
|
|
220
|
-
setConfirm(null);
|
|
221
|
-
};
|
|
222
|
-
|
|
223
|
-
const printReceipt = () => {
|
|
224
|
-
if (allMissing.length > 0) {
|
|
225
|
-
Alert.alert(
|
|
226
|
-
"Missing payment method",
|
|
227
|
-
`Choose how these charges were paid before printing the receipt:\n\n${allMissing.map((c) => `• ${c.label} (${formatMoney(c.amount)})`).join("\n")}`,
|
|
228
|
-
[{ text: "OK" }],
|
|
229
|
-
);
|
|
230
|
-
return;
|
|
231
|
-
}
|
|
232
|
-
Alert.alert("Receipt", `Printing receipt for ${formatMoney(grandTotal)}.`, [{ text: "OK" }]);
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
return (
|
|
236
|
-
<ScrollView style={{ flex: 1, backgroundColor: colors.white }} contentContainerStyle={{ padding: 28 }}>
|
|
237
|
-
<View style={{ width: "100%", maxWidth: 640, alignSelf: "center", gap: 16 }}>
|
|
238
|
-
<View style={{ flexDirection: "row", alignItems: "center", gap: 10 }}>
|
|
239
|
-
<Text size="xl" weight="semibold">Billing</Text>
|
|
240
|
-
<Badge label="Order #4821" color="zinc" />
|
|
241
|
-
</View>
|
|
242
|
-
|
|
243
|
-
{/* ONE banded card — bill-to · each invoice · collect · deposit */}
|
|
244
|
-
<Card style={{ padding: 0 }}>
|
|
245
|
-
<CardHeader>
|
|
246
|
-
<CardHeaderTitle info="One document: the bill-to, each invoice, the total, and the deposit are bands of the same card.">
|
|
247
|
-
Phí & hóa đơn
|
|
248
|
-
</CardHeaderTitle>
|
|
249
|
-
<CardHeaderMeta>{formatMoney(grandTotal)}</CardHeaderMeta>
|
|
250
|
-
</CardHeader>
|
|
251
|
-
|
|
252
|
-
{/* bill-to band — issuing needs a tax ID; the toggle shows the gate */}
|
|
253
|
-
<CardBody>
|
|
254
|
-
<View style={{ flexDirection: "row", alignItems: "center", gap: 8, flexWrap: "wrap" }}>
|
|
255
|
-
<Icon name="building-2" size={16} color={colors.zinc[500]} />
|
|
256
|
-
<Text weight="medium">Harbor Freight Lines</Text>
|
|
257
|
-
<Text size="sm" color="muted">·</Text>
|
|
258
|
-
{taxId ? (
|
|
259
|
-
<Text size="sm" color="muted" tabular>MST {taxId}</Text>
|
|
260
|
-
) : (
|
|
261
|
-
<Text size="sm" color="danger">No tax ID — required to issue</Text>
|
|
262
|
-
)}
|
|
263
|
-
<View style={{ flex: 1 }} />
|
|
264
|
-
<Button title={taxId ? "Remove tax ID" : "Add tax ID"} color="muted" onPress={() => setTaxId((t) => (t ? "" : "0312456780"))} />
|
|
265
|
-
</View>
|
|
266
|
-
</CardBody>
|
|
267
|
-
|
|
268
|
-
{/* invoice bands */}
|
|
269
|
-
{invoices.map((inv) => (
|
|
270
|
-
<InvoiceBand
|
|
271
|
-
key={inv.key}
|
|
272
|
-
inv={inv}
|
|
273
|
-
taxId={taxId}
|
|
274
|
-
onAmount={(chKey, v) => patchCharge(inv.key, chKey, { amount: v })}
|
|
275
|
-
onMethod={(chKey, m) => patchCharge(inv.key, chKey, { method: m })}
|
|
276
|
-
onIssue={setConfirm}
|
|
277
|
-
/>
|
|
278
|
-
))}
|
|
279
|
-
|
|
280
|
-
{/* collect band */}
|
|
281
|
-
<Divider />
|
|
282
|
-
<CardBody style={{ gap: 10 }}>
|
|
283
|
-
<View style={{ flexDirection: "row", alignItems: "center", gap: 8 }}>
|
|
284
|
-
<Text weight="semibold" style={{ flex: 1 }}>Tổng thu</Text>
|
|
285
|
-
<Text weight="semibold" size="lg" tabular>{formatMoney(grandTotal)}</Text>
|
|
286
|
-
</View>
|
|
287
|
-
{allMissing.length > 0 ? (
|
|
288
|
-
<Callout tone="warning">
|
|
289
|
-
<CalloutText>
|
|
290
|
-
{allMissing.length} charged {allMissing.length === 1 ? "line has" : "lines have"} no payment method — set them before printing the receipt.
|
|
291
|
-
</CalloutText>
|
|
292
|
-
</Callout>
|
|
293
|
-
) : null}
|
|
294
|
-
<View style={{ flexDirection: "row", alignItems: "center", gap: 8 }}>
|
|
295
|
-
<Text size="xs" color="muted" style={{ flex: 1 }}>{issuedCount} of {invoices.length} issued</Text>
|
|
296
|
-
<Button title="Print receipt" color="primary" disabled={grandTotal <= 0} onPress={printReceipt} />
|
|
297
|
-
</View>
|
|
298
|
-
</CardBody>
|
|
299
|
-
|
|
300
|
-
{/* deposit band — tinted + labelled separate, never part of the total */}
|
|
301
|
-
<Divider />
|
|
302
|
-
<CardBody style={{ backgroundColor: colors.white, gap: 8 }}>
|
|
303
|
-
<View style={{ flexDirection: "row", alignItems: "center", gap: 8 }}>
|
|
304
|
-
<Text weight="semibold">Deposit</Text>
|
|
305
|
-
<Badge label="Collected separately" color="zinc" />
|
|
306
|
-
</View>
|
|
307
|
-
<View style={{ flexDirection: "row", alignItems: "center", gap: 10, flexWrap: "wrap" }}>
|
|
308
|
-
<Text size="sm" color="muted" style={{ width: 116 }}>Refundable</Text>
|
|
309
|
-
<View style={{ flexGrow: 1, flexBasis: 130 }}>
|
|
310
|
-
<NumberInput value={deposit || null} onValueChange={(v) => setDeposit(v ?? 0)} min={0} accessibilityLabel="Deposit amount" />
|
|
311
|
-
</View>
|
|
312
|
-
<Button
|
|
313
|
-
title="Deposit receipt"
|
|
314
|
-
color="secondary"
|
|
315
|
-
disabled={deposit <= 0}
|
|
316
|
-
onPress={() => Alert.alert("Deposit receipt", `Printing deposit receipt for ${formatMoney(deposit)}.`, [{ text: "OK" }])}
|
|
317
|
-
/>
|
|
318
|
-
</View>
|
|
319
|
-
</CardBody>
|
|
320
|
-
</Card>
|
|
321
|
-
</View>
|
|
322
|
-
|
|
323
|
-
{/* issuing an e-invoice is irreversible — confirm in a Dialog (stage gate) */}
|
|
324
|
-
<Dialog width={460} open={confirm !== null} onOpenChange={(o) => { if (!o) setConfirm(null); }}>
|
|
325
|
-
<DialogHeader>
|
|
326
|
-
<DialogHeaderTitle>{confirm?.ref ? "Re-issue invoice?" : "Issue e-invoice?"}</DialogHeaderTitle>
|
|
327
|
-
</DialogHeader>
|
|
328
|
-
<View style={{ paddingHorizontal: 24, paddingVertical: 12 }}>
|
|
329
|
-
<Callout tone="warning">
|
|
330
|
-
<CalloutText>
|
|
331
|
-
{confirm
|
|
332
|
-
? `Issue a real e-invoice for "${confirm.title}" (${formatMoney(invoiceTotal(confirm))}) to the provider. This writes a lookup code to the record and can't be undone.`
|
|
333
|
-
: ""}
|
|
334
|
-
</CalloutText>
|
|
335
|
-
</Callout>
|
|
336
|
-
</View>
|
|
337
|
-
<DialogFooter>
|
|
338
|
-
<Button title="Cancel" color="secondary" onPress={() => setConfirm(null)} />
|
|
339
|
-
<Button title="Issue" color="primary" onPress={() => confirm && issue(confirm)} />
|
|
340
|
-
</DialogFooter>
|
|
341
|
-
</Dialog>
|
|
342
|
-
</ScrollView>
|
|
343
|
-
);
|
|
344
|
-
}
|
package/examples/tpl_detail.tsx
DELETED
|
@@ -1,232 +0,0 @@
|
|
|
1
|
-
import { useState } from "react";
|
|
2
|
-
import { ScrollView, View } from "react-native";
|
|
3
|
-
import { Text } from "@lotics/ui/text";
|
|
4
|
-
import { colors, solid } from "@lotics/ui/colors";
|
|
5
|
-
import { Badge } from "@lotics/ui/badge";
|
|
6
|
-
import { Button } from "@lotics/ui/button";
|
|
7
|
-
import { Card, CardBody } from "@lotics/ui/card";
|
|
8
|
-
import { Divider } from "@lotics/ui/divider";
|
|
9
|
-
import { FileBadge } from "@lotics/ui/file_badge";
|
|
10
|
-
import { formatMoney } from "@lotics/ui/format_money";
|
|
11
|
-
import { KPICard } from "@lotics/ui/kpi_card";
|
|
12
|
-
import { Stepper } from "@lotics/ui/stepper";
|
|
13
|
-
import { Tabs } from "@lotics/ui/tabs";
|
|
14
|
-
import { Timeline, TimelineItem } from "@lotics/ui/timeline";
|
|
15
|
-
|
|
16
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
17
|
-
// Template · Record detail — a single order's detail screen. Bands:
|
|
18
|
-
// breadcrumb line · header (id + status + actions) · stat rail (one card,
|
|
19
|
-
// five hairline columns) · Tabs with real switching: Overview (pipeline +
|
|
20
|
-
// key-value list) / Documents (file rows) / Audit log (timeline — every event
|
|
21
|
-
// expands in place; document events link to the Documents tab).
|
|
22
|
-
// ─────────────────────────────────────────────────────────────────────────────
|
|
23
|
-
|
|
24
|
-
const PIPELINE = ["Intake", "Order", "Prod", "Ship", "Recon", "Paid"];
|
|
25
|
-
const PIPE_AT = 3;
|
|
26
|
-
|
|
27
|
-
const FIELDS: { label: string; value: string }[] = [
|
|
28
|
-
{ label: "Order received", value: "12/05" },
|
|
29
|
-
{ label: "Customer PO", value: "NEW-2668" },
|
|
30
|
-
{ label: "Specification", value: "500×300×200 · 5-ply BC" },
|
|
31
|
-
{ label: "Unit price", value: `${formatMoney(14_000)}/box` },
|
|
32
|
-
{ label: "Delivered", value: "1,800 / 1,800" },
|
|
33
|
-
{ label: "Payment terms", value: "Net 30" },
|
|
34
|
-
];
|
|
35
|
-
|
|
36
|
-
const FILES: { name: string; mime: string; size: string }[] = [
|
|
37
|
-
{ name: "Quote_QT-2026-0042.pdf", mime: "application/pdf", size: "182 KB" },
|
|
38
|
-
{ name: "ProductionOrder_MO-2026-0042.pdf", mime: "application/pdf", size: "96 KB" },
|
|
39
|
-
{ name: "DeliveryNote_DN-0042.xlsx", mime: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", size: "24 KB" },
|
|
40
|
-
];
|
|
41
|
-
|
|
42
|
-
// Every log event expands in place (Timeline rows become pressable when they
|
|
43
|
-
// carry details) — the read-only drill-down door. Events that produced a
|
|
44
|
-
// a document also carry the real path to it (the Documents tab).
|
|
45
|
-
const LOG: {
|
|
46
|
-
id: string;
|
|
47
|
-
icon: TimelineItem["icon"];
|
|
48
|
-
iconColor: string;
|
|
49
|
-
label: string;
|
|
50
|
-
time: string;
|
|
51
|
-
detail: string;
|
|
52
|
-
chungTu?: string;
|
|
53
|
-
}[] = [
|
|
54
|
-
{
|
|
55
|
-
id: "log-5",
|
|
56
|
-
icon: "circle-check",
|
|
57
|
-
iconColor: solid("emerald"),
|
|
58
|
-
label: "Delivered in full 1,800/1,800 — awaiting note reconciliation",
|
|
59
|
-
time: "04/06 16:40",
|
|
60
|
-
detail: "Customer signed for all 1,800 boxes · reconcile against DN-0042 before closing receivables.",
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
id: "log-4",
|
|
64
|
-
icon: "package",
|
|
65
|
-
iconColor: solid("blue"),
|
|
66
|
-
label: "Shipped 1,800 boxes — loaded on truck 29C-123.45",
|
|
67
|
-
time: "04/06 07:15",
|
|
68
|
-
detail: "Dispatched from finished-goods warehouse · truck 29C-123.45 · driver Ben Tran.",
|
|
69
|
-
chungTu: "DeliveryNote_DN-0042.xlsx",
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
id: "log-3",
|
|
73
|
-
icon: "check",
|
|
74
|
-
iconColor: solid("blue"),
|
|
75
|
-
label: "Production complete — moved to finished goods",
|
|
76
|
-
time: "02/06 17:05",
|
|
77
|
-
detail: "Completed at the Eastside plant · 1,800 boxes received into finished goods.",
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
id: "log-2",
|
|
81
|
-
icon: "file-text",
|
|
82
|
-
iconColor: solid("blue"),
|
|
83
|
-
label: "Production order MO-2026-0042 issued to the plant",
|
|
84
|
-
time: "26/05 09:20",
|
|
85
|
-
detail: "Sent to the Eastside plant · 5-ply BC blanks · die KB-118 on hand.",
|
|
86
|
-
chungTu: "ProductionOrder_MO-2026-0042.pdf",
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
id: "log-1",
|
|
90
|
-
icon: "plus",
|
|
91
|
-
iconColor: colors.zinc[400],
|
|
92
|
-
label: "Order created from PO NEW-2668 — Tessa Tran",
|
|
93
|
-
time: "12/05 10:02",
|
|
94
|
-
detail: "Created from PO NEW-2668 received by email · created by Tessa Tran.",
|
|
95
|
-
},
|
|
96
|
-
];
|
|
97
|
-
|
|
98
|
-
const STATS = [
|
|
99
|
-
{ label: "Customer", value: "NEWTECONS" },
|
|
100
|
-
{ label: "Quantity", value: "1,800" },
|
|
101
|
-
{ label: "Value", value: formatMoney(25_200_000) },
|
|
102
|
-
{ label: "Needed by", value: "28/05", tone: "danger" as const },
|
|
103
|
-
{ label: "Owner", value: "Tessa Tran" },
|
|
104
|
-
];
|
|
105
|
-
|
|
106
|
-
const TABS = [
|
|
107
|
-
{ label: "Overview", value: "tongquan" },
|
|
108
|
-
{ label: "Documents", value: "chungtu" },
|
|
109
|
-
{ label: "Audit log", value: "nhatky" },
|
|
110
|
-
];
|
|
111
|
-
|
|
112
|
-
function TongQuan() {
|
|
113
|
-
return (
|
|
114
|
-
<View style={{ gap: 12 }}>
|
|
115
|
-
<Card style={{ padding: 0 }}>
|
|
116
|
-
<CardBody style={{ gap: 12 }}>
|
|
117
|
-
<Text size="xs" color="muted" transform="uppercase">
|
|
118
|
-
Pipeline
|
|
119
|
-
</Text>
|
|
120
|
-
{/* a detail screen has room for the journey itself — every
|
|
121
|
-
milestone labeled, the current one marked */}
|
|
122
|
-
<Stepper steps={PIPELINE} current={PIPE_AT} color={solid("blue")} />
|
|
123
|
-
<Text size="xs" color="muted">
|
|
124
|
-
Delivered in full — awaiting reconciliation
|
|
125
|
-
</Text>
|
|
126
|
-
</CardBody>
|
|
127
|
-
</Card>
|
|
128
|
-
<Card style={{ padding: 0 }}>
|
|
129
|
-
{FIELDS.map((f, i) => (
|
|
130
|
-
<View key={f.label}>
|
|
131
|
-
{i > 0 ? <Divider /> : null}
|
|
132
|
-
<View style={{ flexDirection: "row", alignItems: "center", paddingHorizontal: 16, paddingVertical: 12, gap: 16 }}>
|
|
133
|
-
<Text size="sm" color="muted">{f.label}</Text>
|
|
134
|
-
<View style={{ flex: 1 }} />
|
|
135
|
-
<Text size="sm" weight="medium" tabular align="right">
|
|
136
|
-
{f.value}
|
|
137
|
-
</Text>
|
|
138
|
-
</View>
|
|
139
|
-
</View>
|
|
140
|
-
))}
|
|
141
|
-
</Card>
|
|
142
|
-
</View>
|
|
143
|
-
);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
function ChungTu() {
|
|
147
|
-
return (
|
|
148
|
-
<Card style={{ padding: 0 }}>
|
|
149
|
-
{FILES.map((f, i) => (
|
|
150
|
-
<View key={f.name}>
|
|
151
|
-
{i > 0 ? <Divider /> : null}
|
|
152
|
-
<View style={{ flexDirection: "row", alignItems: "center", paddingHorizontal: 16, paddingVertical: 12, gap: 12 }}>
|
|
153
|
-
<FileBadge mimeType={f.mime} size={24} />
|
|
154
|
-
<Text size="sm" weight="medium" numberOfLines={1} style={{ flexShrink: 1 }}>{f.name}</Text>
|
|
155
|
-
<Text size="xs" color="muted" tabular>{f.size}</Text>
|
|
156
|
-
<View style={{ flex: 1 }} />
|
|
157
|
-
<Button title="Download" color="muted" onPress={() => {}} />
|
|
158
|
-
</View>
|
|
159
|
-
</View>
|
|
160
|
-
))}
|
|
161
|
-
</Card>
|
|
162
|
-
);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
function NhatKy({ onMoChungTu }: { onMoChungTu: () => void }) {
|
|
166
|
-
const items: TimelineItem[] = LOG.map((e) => ({
|
|
167
|
-
id: e.id,
|
|
168
|
-
icon: e.icon,
|
|
169
|
-
iconColor: e.iconColor,
|
|
170
|
-
label: e.label,
|
|
171
|
-
right: <Text size="xs" color="muted" tabular>{e.time}</Text>,
|
|
172
|
-
details: (
|
|
173
|
-
<View style={{ gap: 8 }}>
|
|
174
|
-
<Text size="xs" color="muted">{e.detail}</Text>
|
|
175
|
-
{e.chungTu ? (
|
|
176
|
-
<View style={{ flexDirection: "row" }}>
|
|
177
|
-
<Button title="Open document" color="muted" onPress={onMoChungTu} />
|
|
178
|
-
</View>
|
|
179
|
-
) : null}
|
|
180
|
-
</View>
|
|
181
|
-
),
|
|
182
|
-
}));
|
|
183
|
-
return (
|
|
184
|
-
<Card style={{ padding: 16 }}>
|
|
185
|
-
<Timeline items={items} />
|
|
186
|
-
</Card>
|
|
187
|
-
);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
export function TplDetail() {
|
|
191
|
-
const [tab, setTab] = useState<string>("tongquan");
|
|
192
|
-
|
|
193
|
-
return (
|
|
194
|
-
<ScrollView style={{ flex: 1, backgroundColor: colors.white }} contentContainerStyle={{ padding: 28 }}>
|
|
195
|
-
<View style={{ width: "100%", maxWidth: 880, alignSelf: "center", gap: 16 }}>
|
|
196
|
-
{/* breadcrumb line */}
|
|
197
|
-
<Text size="xs" color="muted">Orders / SO-2026-0042</Text>
|
|
198
|
-
|
|
199
|
-
{/* header band */}
|
|
200
|
-
<View style={{ flexDirection: "row", alignItems: "center", gap: 10 }}>
|
|
201
|
-
<Text size="xl" weight="semibold" tabular>SO-2026-0042</Text>
|
|
202
|
-
<Badge label="Shipping" color="blue" />
|
|
203
|
-
<Badge label="Overdue" color="red" />
|
|
204
|
-
<View style={{ flex: 1 }} />
|
|
205
|
-
<Button title="Print documents" color="secondary" onPress={() => {}} />
|
|
206
|
-
<Button title="Update" color="primary" onPress={() => {}} />
|
|
207
|
-
</View>
|
|
208
|
-
<Text size="sm" color="muted">Carton box NEW 2668 500×300×200 — NEWTECONS</Text>
|
|
209
|
-
|
|
210
|
-
{/* stat rail: one card, five KPI columns */}
|
|
211
|
-
<Card style={{ padding: 0 }}>
|
|
212
|
-
<View style={{ flexDirection: "row", paddingVertical: 14, paddingHorizontal: 16, gap: 16 }}>
|
|
213
|
-
{STATS.map((s) => (
|
|
214
|
-
<KPICard key={s.label} label={s.label} value={s.value} tone={s.tone} size="sm" style={{ flex: 1 }} />
|
|
215
|
-
))}
|
|
216
|
-
</View>
|
|
217
|
-
</Card>
|
|
218
|
-
|
|
219
|
-
<Tabs
|
|
220
|
-
accessibilityLabel="Record sections"
|
|
221
|
-
options={TABS}
|
|
222
|
-
selectedTab={tab}
|
|
223
|
-
onSelectTab={setTab}
|
|
224
|
-
/>
|
|
225
|
-
|
|
226
|
-
{tab === "tongquan" ? <TongQuan /> : null}
|
|
227
|
-
{tab === "chungtu" ? <ChungTu /> : null}
|
|
228
|
-
{tab === "nhatky" ? <NhatKy onMoChungTu={() => setTab("chungtu")} /> : null}
|
|
229
|
-
</View>
|
|
230
|
-
</ScrollView>
|
|
231
|
-
);
|
|
232
|
-
}
|