@enyxs/wikex-components 0.11.14 → 0.11.15

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.
@@ -0,0 +1,200 @@
1
+ "use client";
2
+
3
+ // src/wikex/consultation-manager.tsx
4
+ import { useState } from "react";
5
+ import { Alert, Box, Button, Card, Chip, Dialog, DialogActions, DialogContent, DialogTitle, MenuItem, Stack, Table, TableBody, TableCell, TableHead, TablePagination, TableRow, TextField, Typography } from "@mui/material";
6
+
7
+ // src/consultation-model.ts
8
+ var consultationStatuses = {
9
+ new: "M\u1EDBi",
10
+ contacted: "\u0110\xE3 li\xEAn h\u1EC7",
11
+ completed: "Ho\xE0n t\u1EA5t",
12
+ cancelled: "Kh\xF4ng ti\u1EBFp t\u1EE5c"
13
+ };
14
+ var consultationCities = { "ho-chi-minh-city": "TP. H\u1ED3 Ch\xED Minh", hanoi: "H\xE0 N\u1ED9i", other: "Kh\xE1c" };
15
+ var consultationCapitals = { "under-10m": "D\u01B0\u1EDBi 10 tri\u1EC7u", "10m-30m": "10\u201330 tri\u1EC7u", "30m-100m": "30\u2013100 tri\u1EC7u", "over-100m": "Tr\xEAn 100 tri\u1EC7u" };
16
+
17
+ // src/wikex/consultation-manager.tsx
18
+ import { jsx, jsxs } from "react/jsx-runtime";
19
+ var date = (value) => new Intl.DateTimeFormat("vi-VN", { timeZone: "Asia/Ho_Chi_Minh", dateStyle: "short", timeStyle: "short" }).format(new Date(value));
20
+ var city = (value) => consultationCities[value] || value || "Ch\u01B0a cung c\u1EA5p";
21
+ var capital = (value) => consultationCapitals[value] || value || "Ch\u01B0a cung c\u1EA5p";
22
+ function ConsultationManager({
23
+ data,
24
+ search,
25
+ status,
26
+ loading,
27
+ busy,
28
+ canWrite,
29
+ notice,
30
+ onSearch,
31
+ onStatus,
32
+ onPage,
33
+ onPageSize,
34
+ onReload,
35
+ onSave,
36
+ onDelete,
37
+ onDismissNotice
38
+ }) {
39
+ const [editing, setEditing] = useState(null);
40
+ const [deleting, setDeleting] = useState(null);
41
+ const [draftStatus, setDraftStatus] = useState("new");
42
+ const [notes, setNotes] = useState("");
43
+ return /* @__PURE__ */ jsxs(Stack, { spacing: 3, sx: { minWidth: 0 }, children: [
44
+ /* @__PURE__ */ jsxs(Stack, { direction: { xs: "column", sm: "row" }, gap: 2, justifyContent: "space-between", alignItems: { sm: "center" }, children: [
45
+ /* @__PURE__ */ jsxs(Stack, { spacing: 1, children: [
46
+ /* @__PURE__ */ jsx(Typography, { variant: "h4", children: "\u0110\u0103ng k\xFD t\u01B0 v\u1EA5n" }),
47
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", color: "text.secondary", children: "Th\xF4ng tin t\u1EEB form \u0111\u0103ng k\xFD tr\xEAn website. Theo d\xF5i li\xEAn h\u1EC7 v\xE0 ghi ch\xFA x\u1EED l\xFD." })
48
+ ] }),
49
+ /* @__PURE__ */ jsx(Button, { variant: "outlined", disabled: loading || busy, onClick: onReload, children: "T\u1EA3i l\u1EA1i danh s\xE1ch" })
50
+ ] }),
51
+ !canWrite && /* @__PURE__ */ jsx(Alert, { severity: "info", children: "B\u1EA1n c\xF3 quy\u1EC1n xem \u0111\u0103ng k\xFD. C\u1EA7n quy\u1EC1n ch\u1EC9nh s\u1EEDa \u0111\u0103ng k\xFD t\u01B0 v\u1EA5n \u0111\u1EC3 c\u1EADp nh\u1EADt ho\u1EB7c x\xF3a." }),
52
+ notice && /* @__PURE__ */ jsx(Alert, { severity: notice.severity, onClose: onDismissNotice, children: notice.message }),
53
+ /* @__PURE__ */ jsx(Card, { sx: { p: 3 }, children: /* @__PURE__ */ jsxs(Stack, { direction: { xs: "column", sm: "row" }, spacing: 2, children: [
54
+ /* @__PURE__ */ jsx(TextField, { size: "small", fullWidth: true, label: "T\xECm theo t\xEAn, \u0111i\u1EC7n tho\u1EA1i ho\u1EB7c email", value: search, disabled: busy, onChange: (event) => onSearch(event.target.value) }),
55
+ /* @__PURE__ */ jsxs(TextField, { select: true, size: "small", label: "Tr\u1EA1ng th\xE1i", value: status, disabled: busy, sx: { minWidth: 200 }, onChange: (event) => onStatus(event.target.value), children: [
56
+ /* @__PURE__ */ jsx(MenuItem, { value: "", children: "T\u1EA5t c\u1EA3" }),
57
+ Object.entries(consultationStatuses).map(([key, label]) => /* @__PURE__ */ jsx(MenuItem, { value: key, children: label }, key))
58
+ ] })
59
+ ] }) }),
60
+ /* @__PURE__ */ jsxs(Card, { "aria-busy": loading, sx: { opacity: loading ? 0.65 : 1 }, children: [
61
+ /* @__PURE__ */ jsx(Box, { sx: { overflowX: "auto" }, children: /* @__PURE__ */ jsxs(Table, { "aria-label": "Danh s\xE1ch \u0111\u0103ng k\xFD t\u01B0 v\u1EA5n", sx: { minWidth: 1050 }, children: [
62
+ /* @__PURE__ */ jsx(TableHead, { children: /* @__PURE__ */ jsx(TableRow, { children: ["Kh\xE1ch h\xE0ng", "\u0110i\u1EC7n tho\u1EA1i / Email", "Khu v\u1EF1c", "Th\u1ECB tr\u01B0\u1EDDng / V\u1ED1n", "Tr\u1EA1ng th\xE1i", "Ng\xE0y g\u1EEDi", "Thao t\xE1c"].map((title) => /* @__PURE__ */ jsx(TableCell, { children: title }, title)) }) }),
63
+ /* @__PURE__ */ jsxs(TableBody, { children: [
64
+ data.items.map((item) => /* @__PURE__ */ jsxs(TableRow, { children: [
65
+ /* @__PURE__ */ jsxs(TableCell, { sx: { maxWidth: 220, overflowWrap: "anywhere" }, children: [
66
+ /* @__PURE__ */ jsx(Typography, { variant: "subtitle2", children: item.name }),
67
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", color: "text.secondary", children: item.language.toUpperCase() })
68
+ ] }),
69
+ /* @__PURE__ */ jsxs(TableCell, { sx: { maxWidth: 260, overflowWrap: "anywhere" }, children: [
70
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", children: item.phone }),
71
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", color: "text.secondary", children: item.email })
72
+ ] }),
73
+ /* @__PURE__ */ jsx(TableCell, { children: city(item.city) }),
74
+ /* @__PURE__ */ jsxs(TableCell, { sx: { maxWidth: 220, overflowWrap: "anywhere" }, children: [
75
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", children: item.markets.join(", ") || "Ch\u01B0a cung c\u1EA5p" }),
76
+ item.otherMarket && /* @__PURE__ */ jsxs(Typography, { variant: "body2", children: [
77
+ "Kh\xE1c: ",
78
+ item.otherMarket
79
+ ] }),
80
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", color: "text.secondary", children: capital(item.capital) })
81
+ ] }),
82
+ /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Chip, { size: "small", label: consultationStatuses[item.status], color: item.status === "new" ? "warning" : item.status === "completed" ? "success" : "default" }) }),
83
+ /* @__PURE__ */ jsx(TableCell, { sx: { whiteSpace: "nowrap" }, children: date(item.createdAt) }),
84
+ /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsxs(Stack, { direction: "row", spacing: 1, children: [
85
+ /* @__PURE__ */ jsx(Button, { size: "small", disabled: busy, onClick: () => {
86
+ setEditing(item);
87
+ setDraftStatus(item.status);
88
+ setNotes(item.notes);
89
+ }, children: "Xem / x\u1EED l\xFD" }),
90
+ canWrite && /* @__PURE__ */ jsx(Button, { size: "small", color: "error", disabled: busy, onClick: () => setDeleting(item), children: "X\xF3a" })
91
+ ] }) })
92
+ ] }, item.id)),
93
+ !data.items.length && /* @__PURE__ */ jsx(TableRow, { children: /* @__PURE__ */ jsx(TableCell, { colSpan: 7, align: "center", sx: { py: 6 }, children: loading ? "\u0110ang t\u1EA3i \u0111\u0103ng k\xFD\u2026" : "Ch\u01B0a c\xF3 \u0111\u0103ng k\xFD ph\xF9 h\u1EE3p." }) })
94
+ ] })
95
+ ] }) }),
96
+ /* @__PURE__ */ jsx(
97
+ TablePagination,
98
+ {
99
+ component: "div",
100
+ count: data.total,
101
+ page: data.page - 1,
102
+ rowsPerPage: data.pageSize,
103
+ rowsPerPageOptions: [10, 25, 50, 100],
104
+ labelRowsPerPage: "S\u1ED1 d\xF2ng m\u1ED7i trang",
105
+ labelDisplayedRows: ({ from, to, count }) => `${from}\u2013${to} / ${count}`,
106
+ onPageChange: (_, next) => onPage(next + 1),
107
+ onRowsPerPageChange: (event) => onPageSize(Number(event.target.value)),
108
+ disabled: loading || busy,
109
+ slotProps: { select: { native: false }, actions: { previousButton: { "aria-label": "Trang tr\u01B0\u1EDBc" }, nextButton: { "aria-label": "Trang sau" } } }
110
+ }
111
+ )
112
+ ] }),
113
+ /* @__PURE__ */ jsxs(Dialog, { open: Boolean(editing), onClose: () => !busy && setEditing(null), fullWidth: true, maxWidth: "sm", children: [
114
+ /* @__PURE__ */ jsx(DialogTitle, { children: "Chi ti\u1EBFt \u0111\u0103ng k\xFD t\u01B0 v\u1EA5n" }),
115
+ /* @__PURE__ */ jsx(DialogContent, { children: /* @__PURE__ */ jsxs(Stack, { spacing: 2, sx: { pt: 1 }, children: [
116
+ notice?.severity === "error" && /* @__PURE__ */ jsx(Alert, { severity: "error", children: notice.message }),
117
+ editing && /* @__PURE__ */ jsxs(Stack, { spacing: 0.75, sx: { overflowWrap: "anywhere" }, children: [
118
+ /* @__PURE__ */ jsxs(Typography, { children: [
119
+ /* @__PURE__ */ jsx("strong", { children: "H\u1ECD v\xE0 t\xEAn:" }),
120
+ " ",
121
+ editing.name
122
+ ] }),
123
+ /* @__PURE__ */ jsxs(Typography, { children: [
124
+ /* @__PURE__ */ jsx("strong", { children: "\u0110i\u1EC7n tho\u1EA1i:" }),
125
+ " ",
126
+ editing.phone
127
+ ] }),
128
+ /* @__PURE__ */ jsxs(Typography, { children: [
129
+ /* @__PURE__ */ jsx("strong", { children: "Email:" }),
130
+ " ",
131
+ editing.email
132
+ ] }),
133
+ /* @__PURE__ */ jsxs(Typography, { children: [
134
+ /* @__PURE__ */ jsx("strong", { children: "Khu v\u1EF1c:" }),
135
+ " ",
136
+ city(editing.city)
137
+ ] }),
138
+ /* @__PURE__ */ jsxs(Typography, { children: [
139
+ /* @__PURE__ */ jsx("strong", { children: "Th\u1ECB tr\u01B0\u1EDDng:" }),
140
+ " ",
141
+ editing.markets.join(", ") || "Ch\u01B0a cung c\u1EA5p",
142
+ editing.otherMarket ? ` \xB7 Kh\xE1c: ${editing.otherMarket}` : ""
143
+ ] }),
144
+ /* @__PURE__ */ jsxs(Typography, { children: [
145
+ /* @__PURE__ */ jsx("strong", { children: "S\u1ED1 v\u1ED1n:" }),
146
+ " ",
147
+ capital(editing.capital)
148
+ ] }),
149
+ /* @__PURE__ */ jsxs(Typography, { children: [
150
+ /* @__PURE__ */ jsx("strong", { children: "Trang g\u1EEDi:" }),
151
+ " ",
152
+ editing.sourcePath
153
+ ] }),
154
+ /* @__PURE__ */ jsxs(Typography, { children: [
155
+ /* @__PURE__ */ jsx("strong", { children: "Ng\xE0y g\u1EEDi:" }),
156
+ " ",
157
+ date(editing.createdAt)
158
+ ] })
159
+ ] }),
160
+ /* @__PURE__ */ jsx(TextField, { select: true, label: "Tr\u1EA1ng th\xE1i x\u1EED l\xFD", value: draftStatus, disabled: busy || !canWrite, onChange: (event) => setDraftStatus(event.target.value), children: Object.entries(consultationStatuses).map(([key, label]) => /* @__PURE__ */ jsx(MenuItem, { value: key, children: label }, key)) }),
161
+ /* @__PURE__ */ jsx(TextField, { label: "Ghi ch\xFA n\u1ED9i b\u1ED9", value: notes, disabled: busy || !canWrite, multiline: true, minRows: 4, inputProps: { maxLength: 5e3 }, onChange: (event) => setNotes(event.target.value) })
162
+ ] }) }),
163
+ /* @__PURE__ */ jsxs(DialogActions, { children: [
164
+ /* @__PURE__ */ jsx(Button, { disabled: busy, onClick: () => setEditing(null), children: "\u0110\xF3ng" }),
165
+ canWrite && /* @__PURE__ */ jsx(Button, { variant: "contained", loading: busy, disabled: busy, onClick: async () => {
166
+ if (!editing) return;
167
+ try {
168
+ await onSave(editing, draftStatus, notes);
169
+ setEditing(null);
170
+ } catch {
171
+ }
172
+ }, children: "L\u01B0u x\u1EED l\xFD" })
173
+ ] })
174
+ ] }),
175
+ /* @__PURE__ */ jsxs(Dialog, { open: Boolean(deleting), onClose: () => !busy && setDeleting(null), children: [
176
+ /* @__PURE__ */ jsx(DialogTitle, { children: "X\xF3a \u0111\u0103ng k\xFD t\u01B0 v\u1EA5n?" }),
177
+ /* @__PURE__ */ jsxs(DialogContent, { children: [
178
+ notice?.severity === "error" && /* @__PURE__ */ jsx(Alert, { severity: "error", sx: { mb: 2 }, children: notice.message }),
179
+ "Th\xF4ng tin \u0111\u0103ng k\xFD c\u1EE7a ",
180
+ deleting?.name,
181
+ " s\u1EBD b\u1ECB x\xF3a v\u0129nh vi\u1EC5n."
182
+ ] }),
183
+ /* @__PURE__ */ jsxs(DialogActions, { children: [
184
+ /* @__PURE__ */ jsx(Button, { disabled: busy, onClick: () => setDeleting(null), children: "H\u1EE7y" }),
185
+ /* @__PURE__ */ jsx(Button, { color: "error", disabled: busy, onClick: async () => {
186
+ if (!deleting) return;
187
+ try {
188
+ await onDelete(deleting);
189
+ setDeleting(null);
190
+ } catch {
191
+ }
192
+ }, children: "X\xF3a \u0111\u0103ng k\xFD" })
193
+ ] })
194
+ ] })
195
+ ] });
196
+ }
197
+ export {
198
+ ConsultationManager
199
+ };
200
+ //# sourceMappingURL=consultations.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/wikex/consultation-manager.tsx","../src/consultation-model.ts"],"sourcesContent":["'use client';\n\nimport { useState } from 'react';\nimport { Alert, Box, Button, Card, Chip, Dialog, DialogActions, DialogContent, DialogTitle, MenuItem, Stack, Table, TableBody, TableCell, TableHead, TablePagination, TableRow, TextField, Typography } from '@mui/material';\nimport { consultationStatuses, consultationCities, consultationCapitals } from '../consultation-model';\nimport type { Consultation, ConsultationList, ConsultationStatus } from '../consultation-model';\n\nexport type ConsultationManagerProps = {\n data: ConsultationList;\n search: string;\n status: ConsultationStatus | '';\n loading: boolean;\n busy: boolean;\n canWrite: boolean;\n notice: { severity: 'success' | 'error'; message: string } | null;\n onSearch: (value: string) => void;\n onStatus: (value: ConsultationStatus | '') => void;\n onPage: (page: number) => void;\n onPageSize: (size: number) => void;\n onReload: () => void;\n onSave: (item: Consultation, status: ConsultationStatus, notes: string) => Promise<void>;\n onDelete: (item: Consultation) => Promise<void>;\n onDismissNotice: () => void;\n};\nconst date = (value: string) => new Intl.DateTimeFormat('vi-VN', { timeZone: 'Asia/Ho_Chi_Minh', dateStyle: 'short', timeStyle: 'short' }).format(new Date(value));\nconst city = (value: string) => consultationCities[value] || value || 'Chưa cung cấp';\nconst capital = (value: string) => consultationCapitals[value] || value || 'Chưa cung cấp';\n\nexport function ConsultationManager({ data, search, status, loading, busy, canWrite, notice, onSearch, onStatus,\n onPage, onPageSize, onReload, onSave, onDelete, onDismissNotice }: ConsultationManagerProps) {\n const [editing, setEditing] = useState<Consultation | null>(null);\n const [deleting, setDeleting] = useState<Consultation | null>(null);\n const [draftStatus, setDraftStatus] = useState<ConsultationStatus>('new');\n const [notes, setNotes] = useState('');\n return <Stack spacing={3} sx={{ minWidth: 0 }}>\n <Stack direction={{ xs: 'column', sm: 'row' }} gap={2} justifyContent=\"space-between\" alignItems={{ sm: 'center' }}>\n <Stack spacing={1}><Typography variant=\"h4\">Đăng ký tư vấn</Typography>\n <Typography variant=\"body2\" color=\"text.secondary\">Thông tin từ form đăng ký trên website. Theo dõi liên hệ và ghi chú xử lý.</Typography></Stack>\n <Button variant=\"outlined\" disabled={loading || busy} onClick={onReload}>Tải lại danh sách</Button>\n </Stack>\n {!canWrite && <Alert severity=\"info\">Bạn có quyền xem đăng ký. Cần quyền chỉnh sửa đăng ký tư vấn để cập nhật hoặc xóa.</Alert>}\n {notice && <Alert severity={notice.severity} onClose={onDismissNotice}>{notice.message}</Alert>}\n <Card sx={{ p: 3 }}><Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>\n <TextField size=\"small\" fullWidth label=\"Tìm theo tên, điện thoại hoặc email\" value={search} disabled={busy} onChange={event => onSearch(event.target.value)} />\n <TextField select size=\"small\" label=\"Trạng thái\" value={status} disabled={busy} sx={{ minWidth: 200 }} onChange={event => onStatus(event.target.value as ConsultationStatus | '')}>\n <MenuItem value=\"\">Tất cả</MenuItem>{Object.entries(consultationStatuses).map(([key, label]) => <MenuItem key={key} value={key}>{label}</MenuItem>)}\n </TextField>\n </Stack></Card>\n <Card aria-busy={loading} sx={{ opacity: loading ? 0.65 : 1 }}>\n <Box sx={{ overflowX: 'auto' }}><Table aria-label=\"Danh sách đăng ký tư vấn\" sx={{ minWidth: 1050 }}>\n <TableHead><TableRow>{['Khách hàng', 'Điện thoại / Email', 'Khu vực', 'Thị trường / Vốn', 'Trạng thái', 'Ngày gửi', 'Thao tác'].map(title => <TableCell key={title}>{title}</TableCell>)}</TableRow></TableHead>\n <TableBody>{data.items.map(item => <TableRow key={item.id}>\n <TableCell sx={{ maxWidth: 220, overflowWrap: 'anywhere' }}><Typography variant=\"subtitle2\">{item.name}</Typography><Typography variant=\"caption\" color=\"text.secondary\">{item.language.toUpperCase()}</Typography></TableCell>\n <TableCell sx={{ maxWidth: 260, overflowWrap: 'anywhere' }}><Typography variant=\"body2\">{item.phone}</Typography><Typography variant=\"body2\" color=\"text.secondary\">{item.email}</Typography></TableCell>\n <TableCell>{city(item.city)}</TableCell>\n <TableCell sx={{ maxWidth: 220, overflowWrap: 'anywhere' }}><Typography variant=\"body2\">{item.markets.join(', ') || 'Chưa cung cấp'}</Typography>{item.otherMarket && <Typography variant=\"body2\">Khác: {item.otherMarket}</Typography>}<Typography variant=\"caption\" color=\"text.secondary\">{capital(item.capital)}</Typography></TableCell>\n <TableCell><Chip size=\"small\" label={consultationStatuses[item.status]} color={item.status === 'new' ? 'warning' : item.status === 'completed' ? 'success' : 'default'} /></TableCell>\n <TableCell sx={{ whiteSpace: 'nowrap' }}>{date(item.createdAt)}</TableCell>\n <TableCell><Stack direction=\"row\" spacing={1}><Button size=\"small\" disabled={busy} onClick={() => { setEditing(item); setDraftStatus(item.status); setNotes(item.notes); }}>Xem / xử lý</Button>{canWrite && <Button size=\"small\" color=\"error\" disabled={busy} onClick={() => setDeleting(item)}>Xóa</Button>}</Stack></TableCell>\n </TableRow>)}{!data.items.length && <TableRow><TableCell colSpan={7} align=\"center\" sx={{ py: 6 }}>{loading ? 'Đang tải đăng ký…' : 'Chưa có đăng ký phù hợp.'}</TableCell></TableRow>}</TableBody>\n </Table></Box>\n <TablePagination component=\"div\" count={data.total} page={data.page - 1} rowsPerPage={data.pageSize}\n rowsPerPageOptions={[10, 25, 50, 100]} labelRowsPerPage=\"Số dòng mỗi trang\" labelDisplayedRows={({ from, to, count }) => `${from}–${to} / ${count}`}\n onPageChange={(_, next) => onPage(next + 1)} onRowsPerPageChange={event => onPageSize(Number(event.target.value))}\n disabled={loading || busy} slotProps={{ select: { native: false }, actions: { previousButton: { 'aria-label': 'Trang trước' }, nextButton: { 'aria-label': 'Trang sau' } } }} />\n </Card>\n <Dialog open={Boolean(editing)} onClose={() => !busy && setEditing(null)} fullWidth maxWidth=\"sm\">\n <DialogTitle>Chi tiết đăng ký tư vấn</DialogTitle><DialogContent><Stack spacing={2} sx={{ pt: 1 }}>\n {notice?.severity === 'error' && <Alert severity=\"error\">{notice.message}</Alert>}\n {editing && <Stack spacing={0.75} sx={{ overflowWrap: 'anywhere' }}>\n <Typography><strong>Họ và tên:</strong> {editing.name}</Typography><Typography><strong>Điện thoại:</strong> {editing.phone}</Typography><Typography><strong>Email:</strong> {editing.email}</Typography>\n <Typography><strong>Khu vực:</strong> {city(editing.city)}</Typography><Typography><strong>Thị trường:</strong> {editing.markets.join(', ') || 'Chưa cung cấp'}{editing.otherMarket ? ` · Khác: ${editing.otherMarket}` : ''}</Typography>\n <Typography><strong>Số vốn:</strong> {capital(editing.capital)}</Typography><Typography><strong>Trang gửi:</strong> {editing.sourcePath}</Typography><Typography><strong>Ngày gửi:</strong> {date(editing.createdAt)}</Typography>\n </Stack>}\n <TextField select label=\"Trạng thái xử lý\" value={draftStatus} disabled={busy || !canWrite} onChange={event => setDraftStatus(event.target.value as ConsultationStatus)}>\n {Object.entries(consultationStatuses).map(([key, label]) => <MenuItem key={key} value={key}>{label}</MenuItem>)}\n </TextField>\n <TextField label=\"Ghi chú nội bộ\" value={notes} disabled={busy || !canWrite} multiline minRows={4} inputProps={{ maxLength: 5000 }} onChange={event => setNotes(event.target.value)} />\n </Stack></DialogContent><DialogActions><Button disabled={busy} onClick={() => setEditing(null)}>Đóng</Button>{canWrite && <Button variant=\"contained\" loading={busy} disabled={busy} onClick={async () => {\n if (!editing) return;\n try { await onSave(editing, draftStatus, notes); setEditing(null); } catch { /* Host reports the error and retains the draft. */ }\n }}>Lưu xử lý</Button>}</DialogActions>\n </Dialog>\n <Dialog open={Boolean(deleting)} onClose={() => !busy && setDeleting(null)}><DialogTitle>Xóa đăng ký tư vấn?</DialogTitle><DialogContent>\n {notice?.severity === 'error' && <Alert severity=\"error\" sx={{ mb: 2 }}>{notice.message}</Alert>}\n Thông tin đăng ký của {deleting?.name} sẽ bị xóa vĩnh viễn.\n </DialogContent><DialogActions><Button disabled={busy} onClick={() => setDeleting(null)}>Hủy</Button><Button color=\"error\" disabled={busy} onClick={async () => {\n if (!deleting) return;\n try { await onDelete(deleting); setDeleting(null); } catch { /* Host reports the error. */ }\n }}>Xóa đăng ký</Button></DialogActions></Dialog>\n </Stack>;\n}\n","export type ConsultationSubmission = {\n submissionId: string;\n name: string;\n phone: string;\n email: string;\n city: string;\n markets: string[];\n otherMarket: string;\n capital: string;\n language: 'vi' | 'en';\n sourcePath: string;\n website: string;\n};\n\nexport const consultationStatuses = {\n new: 'Mới', contacted: 'Đã liên hệ', completed: 'Hoàn tất', cancelled: 'Không tiếp tục',\n} as const;\nexport type ConsultationStatus = keyof typeof consultationStatuses;\nexport const consultationCities: Record<string, string> = { 'ho-chi-minh-city': 'TP. Hồ Chí Minh', hanoi: 'Hà Nội', other: 'Khác' };\nexport const consultationCapitals: Record<string, string> = { 'under-10m': 'Dưới 10 triệu', '10m-30m': '10–30 triệu', '30m-100m': '30–100 triệu', 'over-100m': 'Trên 100 triệu' };\nexport type Consultation = Omit<ConsultationSubmission, 'website' | 'submissionId'> & {\n id: string; status: ConsultationStatus; notes: string; createdAt: string; updatedAt: string;\n};\nexport type ConsultationList = { items: Consultation[]; total: number; page: number; pageSize: number };\n"],"mappings":";;;AAEA,SAAS,gBAAgB;AACzB,SAAS,OAAO,KAAK,QAAQ,MAAM,MAAM,QAAQ,eAAe,eAAe,aAAa,UAAU,OAAO,OAAO,WAAW,WAAW,WAAW,iBAAiB,UAAU,WAAW,kBAAkB;;;ACWtM,IAAM,uBAAuB;AAAA,EAClC,KAAK;AAAA,EAAO,WAAW;AAAA,EAAc,WAAW;AAAA,EAAY,WAAW;AACzE;AAEO,IAAM,qBAA6C,EAAE,oBAAoB,2BAAmB,OAAO,kBAAU,OAAO,UAAO;AAC3H,IAAM,uBAA+C,EAAE,aAAa,gCAAiB,WAAW,yBAAe,YAAY,0BAAgB,aAAa,yBAAiB;;;ADiB1K,SAAmB,KAAnB;AAZN,IAAM,OAAO,CAAC,UAAkB,IAAI,KAAK,eAAe,SAAS,EAAE,UAAU,oBAAoB,WAAW,SAAS,WAAW,QAAQ,CAAC,EAAE,OAAO,IAAI,KAAK,KAAK,CAAC;AACjK,IAAM,OAAO,CAAC,UAAkB,mBAAmB,KAAK,KAAK,SAAS;AACtE,IAAM,UAAU,CAAC,UAAkB,qBAAqB,KAAK,KAAK,SAAS;AAEpE,SAAS,oBAAoB;AAAA,EAAE;AAAA,EAAM;AAAA,EAAQ;AAAA,EAAQ;AAAA,EAAS;AAAA,EAAM;AAAA,EAAU;AAAA,EAAQ;AAAA,EAAU;AAAA,EACrG;AAAA,EAAQ;AAAA,EAAY;AAAA,EAAU;AAAA,EAAQ;AAAA,EAAU;AAAgB,GAA6B;AAC7F,QAAM,CAAC,SAAS,UAAU,IAAI,SAA8B,IAAI;AAChE,QAAM,CAAC,UAAU,WAAW,IAAI,S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AAA,QAAK;AAAA,SACxC;AAAA,MAAgB,qBAAC,iBAAc;AAAA,4BAAC,UAAO,UAAU,MAAM,SAAS,MAAM,YAAY,IAAI,GAAG,sBAAG;AAAA,QAAS,oBAAC,UAAO,OAAM,SAAQ,UAAU,MAAM,SAAS,YAAY;AAC9J,cAAI,CAAC,SAAU;AACf,cAAI;AAAE,kBAAM,SAAS,QAAQ;AAAG,wBAAY,IAAI;AAAA,UAAG,QAAQ;AAAA,UAAgC;AAAA,QAC7F,GAAG,yCAAW;AAAA,SAAS;AAAA,OAAgB;AAAA,KACzC;AACF;","names":[]}
package/dist/index.d.mts CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as react from 'react';
2
2
  import { ComponentType } from 'react';
3
+ import { ConsultationSubmission } from './consultation-model.mjs';
3
4
  export { WikexCommodityPageTemplate, wikexCommodityPageTemplates, wikexCommodityRoutes } from './page-templates.mjs';
4
5
  export { F as FeesTable, a as FeesTableProps } from './fees-table-BxHiMpdc.mjs';
5
6
  export { FeesTableColumn, FeesTableData, FeesTableRow } from './fees-model.mjs';
@@ -43,6 +44,7 @@ type CmsComponentDefinition = {
43
44
  defaults: Record<string, string | number>;
44
45
  };
45
46
  type CmsRendererProps = {
47
+ onConsultationSubmit?: (data: ConsultationSubmission) => Promise<void>;
46
48
  content: Record<string, string | number>;
47
49
  editable?: boolean;
48
50
  readOnlyFields?: string[];
@@ -92,4 +94,4 @@ declare const wikexCmsBlocks: {
92
94
  definition: CmsComponentDefinition;
93
95
  }[];
94
96
 
95
- export { type CmsBlock, type CmsComponentCategory, type CmsComponentDefinition, type CmsComponentPlacement, type CmsFieldDefinition, type CmsFieldType, type CmsListItemField, type CmsRendererProps, type CmsTextTarget, minimalMarketingBlocks, minimalUiBlocks, minimalUiComponents, siteChromeBlocks, wikexCmsBlocks, wikexCommodityBlocks, wikexComponents };
97
+ export { type CmsBlock, type CmsComponentCategory, type CmsComponentDefinition, type CmsComponentPlacement, type CmsFieldDefinition, type CmsFieldType, type CmsListItemField, type CmsRendererProps, type CmsTextTarget, ConsultationSubmission, minimalMarketingBlocks, minimalUiBlocks, minimalUiComponents, siteChromeBlocks, wikexCmsBlocks, wikexCommodityBlocks, wikexComponents };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as react from 'react';
2
2
  import { ComponentType } from 'react';
3
+ import { ConsultationSubmission } from './consultation-model.js';
3
4
  export { WikexCommodityPageTemplate, wikexCommodityPageTemplates, wikexCommodityRoutes } from './page-templates.js';
4
5
  export { F as FeesTable, a as FeesTableProps } from './fees-table-i7g0SHgV.js';
5
6
  export { FeesTableColumn, FeesTableData, FeesTableRow } from './fees-model.js';
@@ -43,6 +44,7 @@ type CmsComponentDefinition = {
43
44
  defaults: Record<string, string | number>;
44
45
  };
45
46
  type CmsRendererProps = {
47
+ onConsultationSubmit?: (data: ConsultationSubmission) => Promise<void>;
46
48
  content: Record<string, string | number>;
47
49
  editable?: boolean;
48
50
  readOnlyFields?: string[];
@@ -92,4 +94,4 @@ declare const wikexCmsBlocks: {
92
94
  definition: CmsComponentDefinition;
93
95
  }[];
94
96
 
95
- export { type CmsBlock, type CmsComponentCategory, type CmsComponentDefinition, type CmsComponentPlacement, type CmsFieldDefinition, type CmsFieldType, type CmsListItemField, type CmsRendererProps, type CmsTextTarget, minimalMarketingBlocks, minimalUiBlocks, minimalUiComponents, siteChromeBlocks, wikexCmsBlocks, wikexCommodityBlocks, wikexComponents };
97
+ export { type CmsBlock, type CmsComponentCategory, type CmsComponentDefinition, type CmsComponentPlacement, type CmsFieldDefinition, type CmsFieldType, type CmsListItemField, type CmsRendererProps, type CmsTextTarget, ConsultationSubmission, minimalMarketingBlocks, minimalUiBlocks, minimalUiComponents, siteChromeBlocks, wikexCmsBlocks, wikexCommodityBlocks, wikexComponents };
package/dist/index.js CHANGED
@@ -3926,6 +3926,7 @@ var import_styled_components4 = __toESM(require("styled-components"));
3926
3926
  // src/commodity-original/components/LandingPage/RegisterSection.tsx
3927
3927
  var import_image2 = __toESM(require("next/image.js"));
3928
3928
  var import_react9 = require("react");
3929
+ var import_Alert = __toESM(require("@mui/material/Alert"));
3929
3930
  var import_Select = __toESM(require("@mui/material/Select"));
3930
3931
  var import_MenuItem = __toESM(require("@mui/material/MenuItem"));
3931
3932
  var import_Checkbox = __toESM(require("@mui/material/Checkbox"));
@@ -4088,6 +4089,7 @@ var registerMenuProps = (container) => ({
4088
4089
  }
4089
4090
  });
4090
4091
  function RegisterSelect({
4092
+ disabled = false,
4091
4093
  ariaLabel,
4092
4094
  defaultValue = "",
4093
4095
  name,
@@ -4099,6 +4101,7 @@ function RegisterSelect({
4099
4101
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
4100
4102
  import_Select.default,
4101
4103
  {
4104
+ disabled,
4102
4105
  ref: root,
4103
4106
  name,
4104
4107
  value: value4,
@@ -4120,6 +4123,7 @@ function RegisterSelect({
4120
4123
  );
4121
4124
  }
4122
4125
  function RegisterCheckboxSelect({
4126
+ disabled = false,
4123
4127
  labelledBy,
4124
4128
  name,
4125
4129
  options,
@@ -4137,6 +4141,7 @@ function RegisterCheckboxSelect({
4137
4141
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
4138
4142
  import_Select.default,
4139
4143
  {
4144
+ disabled,
4140
4145
  ref: root,
4141
4146
  multiple: true,
4142
4147
  fullWidth: true,
@@ -4176,10 +4181,58 @@ function RegisterCheckboxSelect({
4176
4181
  ] });
4177
4182
  }
4178
4183
  function RegisterSection({
4179
- variant = "landing"
4184
+ variant = "landing",
4185
+ editable = false,
4186
+ onConsultationSubmit
4180
4187
  }) {
4181
4188
  const { isMobile } = useResponsive();
4182
- const { t } = (0, import_react_i18next.useTranslation)();
4189
+ const { t, i18n } = (0, import_react_i18next.useTranslation)();
4190
+ const english = i18n.resolvedLanguage?.startsWith("en") ?? false;
4191
+ const [pending, setPending] = (0, import_react9.useState)(false);
4192
+ const [formVersion, setFormVersion] = (0, import_react9.useState)(0);
4193
+ const [notice, setNotice] = (0, import_react9.useState)(null);
4194
+ const submitting = (0, import_react9.useRef)(false);
4195
+ const submissionId = (0, import_react9.useRef)("");
4196
+ const submitConsultation = async (event) => {
4197
+ event.preventDefault();
4198
+ if (submitting.current) return;
4199
+ if (editable || !onConsultationSubmit) {
4200
+ setNotice({ severity: "error", message: english ? "This form is only available on the public website." : "Vui l\xF2ng g\u1EEDi form tr\xEAn trang website c\xF4ng khai." });
4201
+ return;
4202
+ }
4203
+ const form = event.currentTarget;
4204
+ const values = new FormData(form);
4205
+ if (!submissionId.current) submissionId.current = crypto.randomUUID();
4206
+ const text = (key) => String(values.get(key) ?? "").trim();
4207
+ const data = {
4208
+ submissionId: submissionId.current,
4209
+ name: text("name"),
4210
+ phone: text("phone"),
4211
+ email: text("email"),
4212
+ city: text("city"),
4213
+ markets: values.getAll("market").map(String),
4214
+ otherMarket: text("market-other"),
4215
+ capital: text("capital"),
4216
+ language: english ? "en" : "vi",
4217
+ sourcePath: window.location.pathname,
4218
+ website: text("website")
4219
+ };
4220
+ submitting.current = true;
4221
+ setPending(true);
4222
+ setNotice(null);
4223
+ try {
4224
+ await onConsultationSubmit(data);
4225
+ form.reset();
4226
+ setFormVersion((current) => current + 1);
4227
+ submissionId.current = "";
4228
+ setNotice({ severity: "success", message: english ? "Your consultation request has been sent. We will contact you soon." : "\u0110\xE3 g\u1EEDi \u0111\u0103ng k\xFD t\u01B0 v\u1EA5n th\xE0nh c\xF4ng. Ch\xFAng t\xF4i s\u1EBD li\xEAn h\u1EC7 v\u1EDBi b\u1EA1n s\u1EDBm." });
4229
+ } catch (error) {
4230
+ setNotice({ severity: "error", message: error instanceof Error ? error.message : english ? "Unable to submit. Please try again." : "Kh\xF4ng th\u1EC3 g\u1EEDi \u0111\u0103ng k\xFD. Vui l\xF2ng th\u1EED l\u1EA1i." });
4231
+ } finally {
4232
+ submitting.current = false;
4233
+ setPending(false);
4234
+ }
4235
+ };
4183
4236
  const aboutVisual = useCmsImage(
4184
4237
  "registerAboutVisualImage",
4185
4238
  "/about-us/register_visual.webp"
@@ -4359,7 +4412,9 @@ function RegisterSection({
4359
4412
  "form",
4360
4413
  {
4361
4414
  className: "register-form-frame",
4362
- onSubmit: (event) => event.preventDefault(),
4415
+ onSubmit: submitConsultation,
4416
+ "aria-busy": pending,
4417
+ "data-consultation-form": true,
4363
4418
  children: [
4364
4419
  !isMobile && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
4365
4420
  Button_default,
@@ -4389,7 +4444,8 @@ function RegisterSection({
4389
4444
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("h2", { children: t("landing.register.title") }),
4390
4445
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { children: t("landing.register.confidential") })
4391
4446
  ] }),
4392
- /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "register-fields", children: [
4447
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("fieldset", { className: "register-fields", disabled: pending, style: { border: 0, padding: 0, margin: 0, minWidth: 0 }, children: [
4448
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { "aria-hidden": "true", style: { display: "none" }, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("input", { name: "website", tabIndex: -1, autoComplete: "off" }) }),
4393
4449
  /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "field-row", children: [
4394
4450
  /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("label", { children: [
4395
4451
  t("landing.register.fields.name"),
@@ -4437,6 +4493,7 @@ function RegisterSection({
4437
4493
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
4438
4494
  RegisterSelect,
4439
4495
  {
4496
+ disabled: pending,
4440
4497
  name: "city",
4441
4498
  ariaLabel: t("landing.register.fields.city"),
4442
4499
  placeholder: t("landing.register.cityPlaceholder"),
@@ -4457,6 +4514,7 @@ function RegisterSection({
4457
4514
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
4458
4515
  RegisterCheckboxSelect,
4459
4516
  {
4517
+ disabled: pending,
4460
4518
  legend: t("landing.register.marketLegend"),
4461
4519
  name: "market",
4462
4520
  labelledBy: "register-market-label",
@@ -4472,6 +4530,7 @@ function RegisterSection({
4472
4530
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
4473
4531
  RegisterSelect,
4474
4532
  {
4533
+ disabled: pending,
4475
4534
  name: "capital",
4476
4535
  ariaLabel: t("landing.register.fields.capital"),
4477
4536
  placeholder: t("landing.register.capitalPlaceholder"),
@@ -4479,12 +4538,14 @@ function RegisterSection({
4479
4538
  }
4480
4539
  )
4481
4540
  ] })
4482
- ] }),
4541
+ ] }, formVersion),
4542
+ notice && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_Alert.default, { severity: notice.severity, role: notice.severity === "success" ? "status" : "alert", sx: { mt: 2, mb: 2, textAlign: "left" }, children: notice.message }),
4483
4543
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
4484
4544
  Button_default,
4485
4545
  {
4486
4546
  className: "register-submit",
4487
4547
  type: "submit",
4548
+ disabled: pending,
4488
4549
  size: "md",
4489
4550
  radius: 8,
4490
4551
  tint: "#F9BB3A",
@@ -4497,7 +4558,7 @@ function RegisterSection({
4497
4558
  speed: 1.5,
4498
4559
  followMouse: false,
4499
4560
  autoAnimate: true,
4500
- children: t("landing.register.submit")
4561
+ children: pending ? english ? "Sending\u2026" : "\u0110ang g\u1EEDi\u2026" : t("landing.register.submit")
4501
4562
  }
4502
4563
  )
4503
4564
  ] })