@pisell/private-materials 6.3.220 → 6.3.222

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.
Files changed (125) hide show
  1. package/build/lowcode/assets-daily.json +11 -11
  2. package/build/lowcode/assets-dev.json +2 -2
  3. package/build/lowcode/assets-prod.json +11 -11
  4. package/build/lowcode/meta.js +1 -1
  5. package/build/lowcode/render/default/view.css +1 -1
  6. package/build/lowcode/render/default/view.js +13 -13
  7. package/build/lowcode/view.css +1 -1
  8. package/build/lowcode/view.js +13 -13
  9. package/es/components/kioskSkuDetail/index.js +7 -7
  10. package/es/components/pay/toC/PaymentMethods/MWCreditCard/tds2.js +53 -26
  11. package/es/components/scanOrder/components/Content/index.js +14 -2
  12. package/es/components/scanOrder/components/ExitConfirmModal/index.js +84 -0
  13. package/es/components/scanOrder/components/ExitConfirmModal/index.less +182 -0
  14. package/es/components/scanOrder/locales.js +20 -0
  15. package/es/index.d.ts +9 -1
  16. package/es/index.js +6 -2
  17. package/es/plus/inventory/BindingModal.js +94 -0
  18. package/es/plus/inventory/InventoryItemManagement.d.ts +7 -0
  19. package/es/plus/inventory/InventoryItemManagement.js +204 -0
  20. package/es/plus/inventory/InventoryLocationManagement.d.ts +7 -0
  21. package/es/plus/inventory/InventoryLocationManagement.js +296 -0
  22. package/es/plus/inventory/InventoryUnitManagement.d.ts +7 -0
  23. package/es/plus/inventory/InventoryUnitManagement.js +144 -0
  24. package/es/plus/inventory/ItemDrawer.js +266 -0
  25. package/es/plus/inventory/RecordDialog.js +141 -0
  26. package/es/plus/inventory/StockList.js +132 -0
  27. package/es/plus/inventory/api.js +66 -0
  28. package/es/plus/inventory/components.js +172 -0
  29. package/es/plus/inventory/context.js +118 -0
  30. package/es/plus/inventory/forms.js +46 -0
  31. package/es/plus/inventory/hooks.js +235 -0
  32. package/es/plus/inventory/index.less +559 -0
  33. package/es/plus/inventory/locales.js +277 -0
  34. package/es/plus/inventory/types.d.ts +10 -0
  35. package/es/plus/inventory/utils.js +24 -0
  36. package/es/plus/panpacificTask/JobCard.js +22 -0
  37. package/es/plus/panpacificTask/JobDrawer.js +366 -0
  38. package/es/plus/panpacificTask/JobForm.js +312 -0
  39. package/es/plus/panpacificTask/JobStatus.js +29 -0
  40. package/es/plus/panpacificTask/PanpacificTask.d.ts +7 -0
  41. package/es/plus/panpacificTask/PanpacificTask.js +552 -0
  42. package/es/plus/panpacificTask/PhotoPreview.js +37 -0
  43. package/es/plus/panpacificTask/README.md +114 -0
  44. package/es/plus/panpacificTask/attachments.js +64 -0
  45. package/es/plus/panpacificTask/index.d.ts +2 -0
  46. package/es/plus/panpacificTask/index.less +539 -0
  47. package/es/plus/panpacificTask/locales.js +586 -0
  48. package/es/plus/panpacificTask/model.js +260 -0
  49. package/es/plus/panpacificTask/saveJob.js +68 -0
  50. package/es/plus/panpacificTask/serve.js +243 -0
  51. package/es/plus/panpacificTask/tenant.js +16 -0
  52. package/es/plus/panpacificTask/types.d.ts +19 -0
  53. package/es/plus/pisellReservation/data/bookingToReservationTables.js +1 -1
  54. package/es/plus/pisellReservation/floorMap/floorPlanApi.js +1 -1
  55. package/es/plus/pisellReservation/floorMap/reservationMock.js +1 -1
  56. package/es/plus/pisellSupersetDashboard/README.md +291 -0
  57. package/es/plus/pisellSupersetDashboard/index.d.ts +15 -0
  58. package/es/plus/pisellSupersetDashboard/index.js +187 -0
  59. package/es/plus/pisellSupersetDashboard/index.less +83 -0
  60. package/es/plus/pisellSupersetDashboard/locales.js +36 -0
  61. package/es/plus/pisellSupersetDashboard/serve.js +51 -0
  62. package/es/plus/pisellSupersetDashboard/types.d.ts +17 -0
  63. package/es/plus/skuOptionsSelection/store/createStore.js +2 -2
  64. package/es/private-materials/lowcode/authmodal/meta.d.ts +1 -0
  65. package/es/pro/Login2.0/AuthModal.d.ts +1 -1
  66. package/es/pro/Login2.0/index.d.ts +1 -2
  67. package/es/pro/Login2.0/shared/types.d.ts +1 -1
  68. package/lib/components/kioskSkuDetail/index.js +7 -7
  69. package/lib/components/pay/toC/PaymentMethods/MWCreditCard/tds2.js +53 -26
  70. package/lib/components/scanOrder/components/Content/index.js +14 -2
  71. package/lib/components/scanOrder/components/ExitConfirmModal/index.js +86 -0
  72. package/lib/components/scanOrder/components/ExitConfirmModal/index.less +182 -0
  73. package/lib/components/scanOrder/locales.js +20 -0
  74. package/lib/index.d.ts +9 -1
  75. package/lib/index.js +136 -126
  76. package/lib/plus/inventory/BindingModal.js +96 -0
  77. package/lib/plus/inventory/InventoryItemManagement.d.ts +7 -0
  78. package/lib/plus/inventory/InventoryItemManagement.js +206 -0
  79. package/lib/plus/inventory/InventoryLocationManagement.d.ts +7 -0
  80. package/lib/plus/inventory/InventoryLocationManagement.js +298 -0
  81. package/lib/plus/inventory/InventoryUnitManagement.d.ts +7 -0
  82. package/lib/plus/inventory/InventoryUnitManagement.js +146 -0
  83. package/lib/plus/inventory/ItemDrawer.js +268 -0
  84. package/lib/plus/inventory/RecordDialog.js +143 -0
  85. package/lib/plus/inventory/StockList.js +134 -0
  86. package/lib/plus/inventory/api.js +66 -0
  87. package/lib/plus/inventory/components.js +181 -0
  88. package/lib/plus/inventory/context.js +121 -0
  89. package/lib/plus/inventory/forms.js +50 -0
  90. package/lib/plus/inventory/hooks.js +240 -0
  91. package/lib/plus/inventory/index.less +559 -0
  92. package/lib/plus/inventory/locales.js +277 -0
  93. package/lib/plus/inventory/types.d.ts +10 -0
  94. package/lib/plus/inventory/utils.js +30 -0
  95. package/lib/plus/panpacificTask/JobCard.js +24 -0
  96. package/lib/plus/panpacificTask/JobDrawer.js +368 -0
  97. package/lib/plus/panpacificTask/JobForm.js +314 -0
  98. package/lib/plus/panpacificTask/JobStatus.js +33 -0
  99. package/lib/plus/panpacificTask/PanpacificTask.d.ts +7 -0
  100. package/lib/plus/panpacificTask/PanpacificTask.js +555 -0
  101. package/lib/plus/panpacificTask/PhotoPreview.js +39 -0
  102. package/lib/plus/panpacificTask/README.md +114 -0
  103. package/lib/plus/panpacificTask/attachments.js +66 -0
  104. package/lib/plus/panpacificTask/index.d.ts +2 -0
  105. package/lib/plus/panpacificTask/index.less +539 -0
  106. package/lib/plus/panpacificTask/locales.js +586 -0
  107. package/lib/plus/panpacificTask/model.js +289 -0
  108. package/lib/plus/panpacificTask/saveJob.js +68 -0
  109. package/lib/plus/panpacificTask/serve.js +260 -0
  110. package/lib/plus/panpacificTask/tenant.js +17 -0
  111. package/lib/plus/panpacificTask/types.d.ts +19 -0
  112. package/lib/plus/pisellSupersetDashboard/README.md +291 -0
  113. package/lib/plus/pisellSupersetDashboard/index.d.ts +15 -0
  114. package/lib/plus/pisellSupersetDashboard/index.js +189 -0
  115. package/lib/plus/pisellSupersetDashboard/index.less +83 -0
  116. package/lib/plus/pisellSupersetDashboard/locales.js +36 -0
  117. package/lib/plus/pisellSupersetDashboard/serve.js +52 -0
  118. package/lib/plus/pisellSupersetDashboard/types.d.ts +17 -0
  119. package/lowcode/inventory-item-management/meta.ts +20 -0
  120. package/lowcode/inventory-location-management/meta.ts +20 -0
  121. package/lowcode/inventory-unit-management/meta.ts +20 -0
  122. package/lowcode/panpacific-task/meta.ts +51 -0
  123. package/lowcode/pisell-superset-dashboard/meta.ts +75 -0
  124. package/package.json +4 -2
  125. package/es/plus/pisellReservation/index.js +0 -17
@@ -0,0 +1,144 @@
1
+ import { _objectSpread2 } from "../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
2
+ import { _asyncToGenerator } from "../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js";
3
+ import { InventoryProvider, useInventory } from "./context.js";
4
+ import { useInventoryList, useInventoryMutation } from "./hooks.js";
5
+ import { InventoryHeader, InventoryTable, RequestError, SearchInput, StatusSelect, StatusTag } from "./components.js";
6
+ import RecordDialog from "./RecordDialog.js";
7
+ import React, { useMemo, useState } from "react";
8
+ import { Button, Space } from "antd";
9
+ import { useDebounce } from "ahooks";
10
+ import { PlusOutlined, ReloadOutlined } from "@ant-design/icons";
11
+ //#region src/plus/inventory/InventoryUnitManagement.tsx
12
+ function UnitPage({ className, style }) {
13
+ const { api, t, name, confirm, success } = useInventory();
14
+ const [search, setSearch] = useState("");
15
+ const keyword = useDebounce(search, { wait: 300 });
16
+ const [status, setStatus] = useState();
17
+ const [target, setTarget] = useState();
18
+ const mutation = useInventoryMutation();
19
+ const list = useInventoryList("item-unit", {
20
+ search: keyword || void 0,
21
+ status
22
+ });
23
+ const remove = (record) => void mutation.run(_asyncToGenerator(function* () {
24
+ if (!(yield confirm("deleteTitle", /* @__PURE__ */ React.createElement(React.Fragment, null, name(record), /* @__PURE__ */ React.createElement("p", null, t("deleteHint")))))) return;
25
+ try {
26
+ yield api.remove("item-unit", record.id);
27
+ success("deleted");
28
+ } finally {
29
+ list.reload();
30
+ }
31
+ }));
32
+ const columns = useMemo(() => [
33
+ {
34
+ title: t("name"),
35
+ key: "name",
36
+ dataIndex: "name",
37
+ width: 260,
38
+ render: (_, record) => /* @__PURE__ */ React.createElement(Button, {
39
+ type: "link",
40
+ onClick: () => setTarget({
41
+ resource: "item-unit",
42
+ id: record.id,
43
+ mode: "view"
44
+ })
45
+ }, name(record))
46
+ },
47
+ {
48
+ title: t("status"),
49
+ key: "status",
50
+ dataIndex: "status",
51
+ render: (value) => /* @__PURE__ */ React.createElement(StatusTag, { status: value })
52
+ },
53
+ {
54
+ title: t("sort"),
55
+ key: "sort",
56
+ dataIndex: "sort"
57
+ },
58
+ {
59
+ title: t("updated"),
60
+ key: "updated_at",
61
+ dataIndex: "updated_at",
62
+ render: (value) => value || "—"
63
+ },
64
+ {
65
+ title: t("actions"),
66
+ key: "actions",
67
+ dataIndex: "actions",
68
+ fixed: "right",
69
+ width: 220,
70
+ render: (_, record) => /* @__PURE__ */ React.createElement(Space, { size: 0 }, /* @__PURE__ */ React.createElement(Button, {
71
+ type: "link",
72
+ disabled: mutation.busy,
73
+ onClick: () => setTarget({
74
+ resource: "item-unit",
75
+ id: record.id,
76
+ mode: "view"
77
+ })
78
+ }, t("view")), /* @__PURE__ */ React.createElement(Button, {
79
+ type: "link",
80
+ disabled: mutation.busy,
81
+ onClick: () => setTarget({
82
+ resource: "item-unit",
83
+ id: record.id,
84
+ mode: "edit"
85
+ })
86
+ }, t("edit")), /* @__PURE__ */ React.createElement(Button, {
87
+ type: "link",
88
+ danger: true,
89
+ disabled: mutation.busy,
90
+ onClick: () => remove(record)
91
+ }, t("remove")))
92
+ }
93
+ ], [
94
+ t,
95
+ name,
96
+ mutation.busy,
97
+ api,
98
+ confirm
99
+ ]);
100
+ return /* @__PURE__ */ React.createElement("div", {
101
+ className: `inventory-page ${className || ""}`,
102
+ style
103
+ }, /* @__PURE__ */ React.createElement(InventoryHeader, {
104
+ title: t("units"),
105
+ description: t("unitHint")
106
+ }, /* @__PURE__ */ React.createElement(Button, {
107
+ type: "primary",
108
+ icon: /* @__PURE__ */ React.createElement(PlusOutlined, null),
109
+ disabled: mutation.busy,
110
+ onClick: () => setTarget({
111
+ resource: "item-unit",
112
+ mode: "create"
113
+ })
114
+ }, t("add"), " ", t("unit"))), /* @__PURE__ */ React.createElement("div", { className: "inventory-toolbar" }, /* @__PURE__ */ React.createElement(SearchInput, {
115
+ value: search,
116
+ onChange: setSearch
117
+ }), /* @__PURE__ */ React.createElement(StatusSelect, {
118
+ value: status,
119
+ onChange: setStatus
120
+ }), /* @__PURE__ */ React.createElement(Button, {
121
+ icon: /* @__PURE__ */ React.createElement(ReloadOutlined, null),
122
+ onClick: list.reload,
123
+ disabled: mutation.busy
124
+ }, t("refresh"))), /* @__PURE__ */ React.createElement(RequestError, {
125
+ error: list.error,
126
+ retry: list.reload
127
+ }), /* @__PURE__ */ React.createElement(InventoryTable, _objectSpread2(_objectSpread2({}, list), {}, {
128
+ loading: list.loading || mutation.busy,
129
+ columns,
130
+ tableKey: "units"
131
+ })), target && /* @__PURE__ */ React.createElement(RecordDialog, {
132
+ target,
133
+ onClose: () => setTarget(void 0),
134
+ onSaved: () => {
135
+ setTarget(void 0);
136
+ list.reload();
137
+ }
138
+ }));
139
+ }
140
+ function InventoryUnitManagement(props) {
141
+ return /* @__PURE__ */ React.createElement(InventoryProvider, { id: props.__id }, /* @__PURE__ */ React.createElement(UnitPage, props));
142
+ }
143
+ //#endregion
144
+ export { InventoryUnitManagement as default };
@@ -0,0 +1,266 @@
1
+ import { _asyncToGenerator } from "../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js";
2
+ import { inventoryQuantity, optionalText } from "./utils.js";
3
+ import { useInventory } from "./context.js";
4
+ import { useInventoryMutation, useInventoryQuery, useUnsavedChanges } from "./hooks.js";
5
+ import { RequestError, StatusTag } from "./components.js";
6
+ import { NameField, StatusField } from "./forms.js";
7
+ import StockList from "./StockList.js";
8
+ import React, { useEffect, useState } from "react";
9
+ import { Alert, Button, Card, Drawer, Form, Input, Select, Spin, Tooltip } from "antd";
10
+ import { AppstoreOutlined, CloseOutlined, InfoCircleOutlined, LinkOutlined } from "@ant-design/icons";
11
+ //#region src/plus/inventory/ItemDrawer.tsx
12
+ function DetailRow({ label, children }) {
13
+ return /* @__PURE__ */ React.createElement("div", { className: "inventory-drawer__info-row" }, /* @__PURE__ */ React.createElement("dt", null, label), /* @__PURE__ */ React.createElement("dd", null, children));
14
+ }
15
+ function ItemDrawer({ target, onClose, onChanged }) {
16
+ const { api, t, name, success, scopeId } = useInventory();
17
+ const [itemId, setItemId] = useState(target.id);
18
+ const [mode, setMode] = useState(target.mode);
19
+ const [tab, setTab] = useState("basic");
20
+ const [bindingsVisited, setBindingsVisited] = useState(false);
21
+ const [form] = Form.useForm();
22
+ const dirty = useUnsavedChanges();
23
+ const mutation = useInventoryMutation();
24
+ const query = useInventoryQuery(() => api.detail("item", itemId, ["unit"]), `item-${itemId}`, !!itemId);
25
+ const units = useInventoryQuery(() => api.units(), "drawer-units");
26
+ const record = query.data;
27
+ const readonly = mode === "view";
28
+ const unavailable = !!itemId && !query.loading && !query.error && record === null;
29
+ const disabled = readonly || mutation.busy || query.loading || !!query.error || unavailable;
30
+ useEffect(() => {
31
+ if (itemId && !record) return;
32
+ form.setFieldsValue(record ? {
33
+ name: record.name,
34
+ unit_id: record.unit_id || null,
35
+ sku: record.sku,
36
+ barcode: record.barcode,
37
+ cover: record.cover,
38
+ note: record.note,
39
+ stock_mode: record.stock_mode,
40
+ status: record.status
41
+ } : {
42
+ name: { original: "" },
43
+ unit_id: null,
44
+ sku: null,
45
+ barcode: null,
46
+ cover: null,
47
+ note: null,
48
+ stock_mode: "tracked",
49
+ status: "active"
50
+ });
51
+ dirty.setDirty(false);
52
+ }, [
53
+ record,
54
+ itemId,
55
+ form
56
+ ]);
57
+ const close = function() {
58
+ var _ref = _asyncToGenerator(function* () {
59
+ if (!mutation.busy && (yield dirty.canLeave())) onClose();
60
+ });
61
+ return function close() {
62
+ return _ref.apply(this, arguments);
63
+ };
64
+ }();
65
+ const cancelEdit = function() {
66
+ var _ref2 = _asyncToGenerator(function* () {
67
+ if (!(yield dirty.canLeave())) return;
68
+ if (!itemId) {
69
+ onClose();
70
+ return;
71
+ }
72
+ dirty.setDirty(false);
73
+ setMode("view");
74
+ query.reload();
75
+ });
76
+ return function cancelEdit() {
77
+ return _ref2.apply(this, arguments);
78
+ };
79
+ }();
80
+ const save = () => mutation.run(_asyncToGenerator(function* () {
81
+ let values;
82
+ try {
83
+ values = yield form.validateFields();
84
+ } catch (_unused) {
85
+ return;
86
+ }
87
+ setItemId((yield api.save("item", itemId, {
88
+ name: values.name,
89
+ unit_id: values.unit_id || null,
90
+ sku: optionalText(values.sku),
91
+ barcode: optionalText(values.barcode),
92
+ cover: optionalText(values.cover),
93
+ note: optionalText(values.note),
94
+ stock_mode: values.stock_mode,
95
+ status: values.status
96
+ })).id);
97
+ setMode("view");
98
+ dirty.setDirty(false);
99
+ query.reload();
100
+ success("success");
101
+ onChanged();
102
+ }));
103
+ const unitOptions = (units.data || []).map((unit) => ({
104
+ value: unit.id,
105
+ label: `${name(unit)}${unit.status === "inactive" ? ` (${t("inactive")})` : ""}`
106
+ }));
107
+ if ((record === null || record === void 0 ? void 0 : record.unit_id) && !unitOptions.some((option) => option.value === record.unit_id)) unitOptions.push({
108
+ value: record.unit_id,
109
+ label: record.unit ? name(record.unit) : `${t("missing")} (#${record.unit_id})`
110
+ });
111
+ const basic = /* @__PURE__ */ React.createElement(Form, {
112
+ form,
113
+ layout: "vertical",
114
+ disabled,
115
+ onValuesChange: () => dirty.setDirty(true)
116
+ }, /* @__PURE__ */ React.createElement(Card, {
117
+ className: "inventory-drawer__card",
118
+ title: t("basic")
119
+ }, /* @__PURE__ */ React.createElement(NameField, { disabled }), /* @__PURE__ */ React.createElement("div", { className: "inventory-form-columns" }, /* @__PURE__ */ React.createElement(Form.Item, {
120
+ name: "sku",
121
+ label: t("sku")
122
+ }, /* @__PURE__ */ React.createElement(Input, { maxLength: 128 })), /* @__PURE__ */ React.createElement(Form.Item, {
123
+ name: "barcode",
124
+ label: t("barcode")
125
+ }, /* @__PURE__ */ React.createElement(Input, { maxLength: 128 })), /* @__PURE__ */ React.createElement(Form.Item, {
126
+ name: "unit_id",
127
+ label: t("unit")
128
+ }, /* @__PURE__ */ React.createElement(Select, {
129
+ showSearch: true,
130
+ allowClear: true,
131
+ optionFilterProp: "label",
132
+ placeholder: t("noUnit"),
133
+ options: unitOptions,
134
+ loading: units.loading,
135
+ onDropdownVisibleChange: (open) => {
136
+ if (open) units.reload();
137
+ }
138
+ })), /* @__PURE__ */ React.createElement(Form.Item, {
139
+ name: "stock_mode",
140
+ label: t("stockMode"),
141
+ rules: [{
142
+ required: true,
143
+ message: t("required")
144
+ }]
145
+ }, /* @__PURE__ */ React.createElement(Select, { options: ["tracked", "unlimited"].map((value) => ({
146
+ value,
147
+ label: t(value)
148
+ })) }))), /* @__PURE__ */ React.createElement(RequestError, {
149
+ error: units.error,
150
+ retry: units.reload
151
+ }), /* @__PURE__ */ React.createElement(Form.Item, {
152
+ name: "cover",
153
+ label: t("cover"),
154
+ rules: [{ validator: (_, value) => {
155
+ if (!(value === null || value === void 0 ? void 0 : value.trim())) return Promise.resolve();
156
+ try {
157
+ const url = new URL(value.trim());
158
+ if (["https:", "http:"].includes(url.protocol) && value.trim().length <= 255) return Promise.resolve();
159
+ } catch (_unused2) {}
160
+ return Promise.reject(new Error(t("invalidUrl")));
161
+ } }]
162
+ }, /* @__PURE__ */ React.createElement(Input, { maxLength: 255 })), /* @__PURE__ */ React.createElement(Form.Item, {
163
+ name: "note",
164
+ label: t("note")
165
+ }, /* @__PURE__ */ React.createElement(Input.TextArea, {
166
+ maxLength: 500,
167
+ rows: 3,
168
+ showCount: true
169
+ })), /* @__PURE__ */ React.createElement(StatusField, null)));
170
+ const details = record && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Card, {
171
+ className: "inventory-drawer__card",
172
+ title: t("basic")
173
+ }, /* @__PURE__ */ React.createElement("dl", { className: "inventory-drawer__info-list" }, /* @__PURE__ */ React.createElement(DetailRow, { label: t("name") }, name(record)), /* @__PURE__ */ React.createElement(DetailRow, { label: t("sku") }, record.sku || "—"), /* @__PURE__ */ React.createElement(DetailRow, { label: t("barcode") }, record.barcode || "—"), /* @__PURE__ */ React.createElement(DetailRow, { label: t("unit") }, record.unit ? name(record.unit) : record.unit_id ? `${t("missing")} (#${record.unit_id})` : t("noUnit")), /* @__PURE__ */ React.createElement(DetailRow, { label: t("cover") }, record.cover || "—"), /* @__PURE__ */ React.createElement(DetailRow, { label: t("note") }, record.note || "—"))), /* @__PURE__ */ React.createElement(Card, {
174
+ className: "inventory-drawer__card",
175
+ title: t("status")
176
+ }, /* @__PURE__ */ React.createElement("dl", { className: "inventory-drawer__info-list" }, /* @__PURE__ */ React.createElement(DetailRow, { label: t("status") }, /* @__PURE__ */ React.createElement(StatusTag, { status: record.status })), /* @__PURE__ */ React.createElement(DetailRow, { label: t("stockMode") }, t(record.stock_mode)))), /* @__PURE__ */ React.createElement(Card, {
177
+ className: "inventory-drawer__card",
178
+ title: t("stockSummary")
179
+ }, /* @__PURE__ */ React.createElement("div", { className: "inventory-metrics" }, /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("span", null, t("totalQuantity")), /* @__PURE__ */ React.createElement("strong", null, inventoryQuantity(record.stock_quantity))), /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("span", null, t("totalAvailable")), /* @__PURE__ */ React.createElement("strong", null, inventoryQuantity(record.stock_available_quantity))))));
180
+ const title = mode === "create" ? `${t("add")} ${t("item")}` : record ? name(record) : `${t("item")} #${itemId}`;
181
+ const bindingDisabled = !itemId || !readonly || query.loading || unavailable || !!query.error;
182
+ const bindingHint = !itemId ? t("saveFirst") : !readonly ? t("editBasicFirst") : void 0;
183
+ return /* @__PURE__ */ React.createElement(Drawer, {
184
+ open: true,
185
+ width: "min(720px, 100vw)",
186
+ onClose: () => void close(),
187
+ maskClosable: false,
188
+ closable: false,
189
+ destroyOnClose: true,
190
+ className: "inventory-drawer",
191
+ rootClassName: "inventory-drawer-root",
192
+ "aria-labelledby": `${scopeId}-item-drawer-title`,
193
+ styles: { body: {
194
+ padding: 0,
195
+ overflow: "hidden"
196
+ } }
197
+ }, /* @__PURE__ */ React.createElement("div", { className: "inventory-drawer__root" }, /* @__PURE__ */ React.createElement("nav", {
198
+ className: "inventory-drawer__sidebar",
199
+ "aria-label": t("item")
200
+ }, /* @__PURE__ */ React.createElement("button", {
201
+ type: "button",
202
+ className: `inventory-drawer__sidebar-item ${tab === "basic" ? "is-active" : ""}`,
203
+ "aria-current": tab === "basic" ? "page" : void 0,
204
+ onClick: () => setTab("basic")
205
+ }, /* @__PURE__ */ React.createElement(InfoCircleOutlined, null), /* @__PURE__ */ React.createElement("span", null, t("basic"))), /* @__PURE__ */ React.createElement(Tooltip, {
206
+ title: bindingHint,
207
+ placement: "right"
208
+ }, /* @__PURE__ */ React.createElement("span", { className: "inventory-drawer__sidebar-slot" }, /* @__PURE__ */ React.createElement("button", {
209
+ type: "button",
210
+ className: `inventory-drawer__sidebar-item ${tab === "bindings" ? "is-active" : ""}`,
211
+ "aria-current": tab === "bindings" ? "page" : void 0,
212
+ disabled: bindingDisabled,
213
+ onClick: () => {
214
+ setBindingsVisited(true);
215
+ setTab("bindings");
216
+ }
217
+ }, /* @__PURE__ */ React.createElement(LinkOutlined, null), /* @__PURE__ */ React.createElement("span", null, t("bindings")))))), /* @__PURE__ */ React.createElement("div", { className: "inventory-drawer__main" }, /* @__PURE__ */ React.createElement("header", { className: "inventory-drawer__header" }, /* @__PURE__ */ React.createElement("div", { className: "inventory-drawer__icon" }, (record === null || record === void 0 ? void 0 : record.cover) && /* @__PURE__ */ React.createElement("img", {
218
+ src: record.cover,
219
+ alt: ""
220
+ }), !(record === null || record === void 0 ? void 0 : record.cover) && /* @__PURE__ */ React.createElement(AppstoreOutlined, null)), /* @__PURE__ */ React.createElement("div", { className: "inventory-drawer__heading" }, /* @__PURE__ */ React.createElement("h2", { id: `${scopeId}-item-drawer-title` }, title), /* @__PURE__ */ React.createElement("div", { className: "inventory-drawer__subtitle" }, (record === null || record === void 0 ? void 0 : record.sku) || t("item"))), /* @__PURE__ */ React.createElement(Button, {
221
+ type: "text",
222
+ icon: /* @__PURE__ */ React.createElement(CloseOutlined, null),
223
+ "aria-label": t("close"),
224
+ disabled: mutation.busy,
225
+ onClick: () => void close()
226
+ })), /* @__PURE__ */ React.createElement("div", { className: "inventory-drawer__content" }, /* @__PURE__ */ React.createElement(RequestError, {
227
+ error: query.error,
228
+ retry: query.reload
229
+ }), unavailable && /* @__PURE__ */ React.createElement(Alert, {
230
+ type: "warning",
231
+ message: t("missing"),
232
+ showIcon: true
233
+ }), /* @__PURE__ */ React.createElement(Spin, { spinning: query.loading }, /* @__PURE__ */ React.createElement("section", {
234
+ hidden: tab !== "basic",
235
+ "aria-label": t("basic")
236
+ }, readonly && details, /* @__PURE__ */ React.createElement("div", { hidden: readonly }, basic)), /* @__PURE__ */ React.createElement("section", {
237
+ hidden: tab !== "bindings",
238
+ "aria-label": t("bindings")
239
+ }, bindingsVisited && itemId && !unavailable && !query.error && /* @__PURE__ */ React.createElement(Card, {
240
+ className: "inventory-drawer__card",
241
+ title: t("bindings")
242
+ }, /* @__PURE__ */ React.createElement(StockList, {
243
+ key: itemId,
244
+ owner: "item",
245
+ id: itemId,
246
+ onChanged: () => {
247
+ query.reload();
248
+ onChanged();
249
+ }
250
+ }))))), /* @__PURE__ */ React.createElement("footer", { className: "inventory-drawer__footer" }, /* @__PURE__ */ React.createElement(Button, {
251
+ disabled: mutation.busy,
252
+ onClick: () => void (readonly ? close() : cancelEdit())
253
+ }, t(readonly ? "close" : "cancel")), /* @__PURE__ */ React.createElement(Button, {
254
+ type: "primary",
255
+ loading: mutation.busy,
256
+ disabled: query.loading || !!query.error || unavailable || readonly && !record,
257
+ onClick: () => {
258
+ if (readonly) {
259
+ setMode("edit");
260
+ setTab("basic");
261
+ } else save();
262
+ }
263
+ }, t(readonly ? "edit" : "save"))))));
264
+ }
265
+ //#endregion
266
+ export { ItemDrawer as default };
@@ -0,0 +1,141 @@
1
+ import { _asyncToGenerator } from "../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js";
2
+ import { inventoryQuantity } from "./utils.js";
3
+ import { useInventory } from "./context.js";
4
+ import { useInventoryMutation, useInventoryQuery, useUnsavedChanges } from "./hooks.js";
5
+ import { PagedInventorySelect, RequestError } from "./components.js";
6
+ import { NameField, SortField, StatusField } from "./forms.js";
7
+ import StockList from "./StockList.js";
8
+ import React, { useEffect, useState } from "react";
9
+ import { Alert, Form, Spin } from "antd";
10
+ import { PisellModal } from "@pisell/materials";
11
+ //#region src/plus/inventory/RecordDialog.tsx
12
+ function RecordDialog({ target, onClose, onSaved }) {
13
+ var _shelf, _ref, _location;
14
+ const { api, t, success } = useInventory();
15
+ const [form] = Form.useForm();
16
+ const [mode, setMode] = useState(target.mode);
17
+ const dirty = useUnsavedChanges();
18
+ const mutation = useInventoryMutation();
19
+ const query = useInventoryQuery(() => api.detail(target.resource, target.id, target.resource === "shelf" ? ["location"] : target.resource === "space" ? ["shelf.location"] : void 0), `${target.resource}-${target.id}`, !!target.id);
20
+ const readonly = mode === "view";
21
+ const locationId = Form.useWatch("location_id", form);
22
+ const record = query.data;
23
+ const currentShelf = (_shelf = record === null || record === void 0 ? void 0 : record.shelf) !== null && _shelf !== void 0 ? _shelf : target.shelf;
24
+ const currentLocation = (_ref = (_location = record === null || record === void 0 ? void 0 : record.location) !== null && _location !== void 0 ? _location : currentShelf === null || currentShelf === void 0 ? void 0 : currentShelf.location) !== null && _ref !== void 0 ? _ref : target.location;
25
+ useEffect(() => {
26
+ var _record$sort, _target$location$id, _target$location, _target$shelf, _target$shelf2;
27
+ if (target.id && !record) return;
28
+ form.setFieldsValue(record ? {
29
+ name: record.name,
30
+ status: record.status,
31
+ sort: (_record$sort = record.sort) !== null && _record$sort !== void 0 ? _record$sort : 0,
32
+ location_id: target.resource === "shelf" ? record.location_id : currentShelf === null || currentShelf === void 0 ? void 0 : currentShelf.location_id,
33
+ shelf_id: target.resource === "space" ? record.shelf_id : void 0
34
+ } : {
35
+ name: { original: "" },
36
+ status: "active",
37
+ sort: 0,
38
+ location_id: (_target$location$id = (_target$location = target.location) === null || _target$location === void 0 ? void 0 : _target$location.id) !== null && _target$location$id !== void 0 ? _target$location$id : (_target$shelf = target.shelf) === null || _target$shelf === void 0 ? void 0 : _target$shelf.location_id,
39
+ shelf_id: (_target$shelf2 = target.shelf) === null || _target$shelf2 === void 0 ? void 0 : _target$shelf2.id
40
+ });
41
+ dirty.setDirty(false);
42
+ }, [
43
+ record,
44
+ target.id,
45
+ form
46
+ ]);
47
+ const close = function() {
48
+ var _ref2 = _asyncToGenerator(function* () {
49
+ if (!mutation.busy && (yield dirty.canLeave())) onClose();
50
+ });
51
+ return function close() {
52
+ return _ref2.apply(this, arguments);
53
+ };
54
+ }();
55
+ const submit = () => mutation.run(_asyncToGenerator(function* () {
56
+ let values;
57
+ try {
58
+ values = yield form.validateFields();
59
+ } catch (_unused) {
60
+ return;
61
+ }
62
+ const payload = {
63
+ name: values.name,
64
+ status: values.status,
65
+ sort: values.sort
66
+ };
67
+ if (target.resource === "shelf") payload.location_id = values.location_id;
68
+ if (target.resource === "space") payload.shelf_id = values.shelf_id;
69
+ const saved = yield api.save(target.resource, target.id, payload);
70
+ dirty.setDirty(false);
71
+ success("success");
72
+ onSaved(saved);
73
+ }));
74
+ const label = t(target.resource === "item-unit" ? "unit" : target.resource);
75
+ const unavailable = !!target.id && !query.loading && !query.error && record === null;
76
+ const disabled = readonly || mutation.busy || query.loading || !!query.error || unavailable;
77
+ return /* @__PURE__ */ React.createElement(PisellModal, {
78
+ open: true,
79
+ title: `${t(mode === "create" ? "add" : mode === "edit" ? "edit" : "view")} · ${label}`,
80
+ size: target.resource === "space" && readonly ? "large" : "middle",
81
+ onCancel: () => void close(),
82
+ closable: !mutation.busy,
83
+ maskClosable: false,
84
+ cancelText: t(readonly ? "close" : "cancel"),
85
+ cancelButtonProps: { disabled: mutation.busy },
86
+ okText: t(readonly ? "edit" : "save"),
87
+ okVisible: !unavailable && !query.error,
88
+ okButtonProps: { disabled: query.loading },
89
+ confirmLoading: mutation.busy,
90
+ onOk: () => {
91
+ if (readonly) setMode("edit");
92
+ else submit();
93
+ }
94
+ }, /* @__PURE__ */ React.createElement("div", { className: "inventory-modal-body" }, /* @__PURE__ */ React.createElement(RequestError, {
95
+ error: query.error,
96
+ retry: query.reload
97
+ }), unavailable && /* @__PURE__ */ React.createElement(Alert, {
98
+ type: "warning",
99
+ showIcon: true,
100
+ message: t("missing")
101
+ }), /* @__PURE__ */ React.createElement(Spin, { spinning: query.loading }, /* @__PURE__ */ React.createElement(Form, {
102
+ form,
103
+ layout: "vertical",
104
+ disabled,
105
+ onValuesChange: () => dirty.setDirty(true)
106
+ }, /* @__PURE__ */ React.createElement(NameField, { disabled }), target.resource !== "item-unit" && target.resource !== "location" && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Form.Item, {
107
+ name: "location_id",
108
+ label: t("location"),
109
+ rules: [{
110
+ required: true,
111
+ message: t("required")
112
+ }]
113
+ }, /* @__PURE__ */ React.createElement(PagedInventorySelect, {
114
+ resource: "location",
115
+ disabled,
116
+ selected: currentLocation,
117
+ placeholder: t("chooseLocation"),
118
+ onChange: () => {
119
+ if (target.resource === "space") form.setFieldValue("shelf_id", void 0);
120
+ }
121
+ })), target.resource === "space" && /* @__PURE__ */ React.createElement(Form.Item, {
122
+ name: "shelf_id",
123
+ label: t("shelf"),
124
+ rules: [{
125
+ required: true,
126
+ message: t("required")
127
+ }]
128
+ }, /* @__PURE__ */ React.createElement(PagedInventorySelect, {
129
+ key: `shelf-${locationId}`,
130
+ resource: "shelf",
131
+ disabled: disabled || !locationId,
132
+ filters: { location_id: locationId },
133
+ selected: currentShelf,
134
+ placeholder: t("chooseShelf")
135
+ }))), /* @__PURE__ */ React.createElement("div", { className: "inventory-form-columns" }, /* @__PURE__ */ React.createElement(StatusField, null), /* @__PURE__ */ React.createElement(SortField, null))), /* @__PURE__ */ React.createElement("p", { className: "inventory-muted" }, t("statusHint")), !readonly && (target.resource === "shelf" || target.resource === "space") && /* @__PURE__ */ React.createElement("p", { className: "inventory-muted" }, t("parentHint")), readonly && target.resource === "space" && record && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", { className: "inventory-section-heading" }, /* @__PURE__ */ React.createElement("h3", null, t("referencedStock")), /* @__PURE__ */ React.createElement("span", null, t("totalQuantity"), ":", " ", inventoryQuantity(record.stock_quantity))), /* @__PURE__ */ React.createElement(StockList, {
136
+ owner: "space",
137
+ id: record.id
138
+ })))));
139
+ }
140
+ //#endregion
141
+ export { RecordDialog as default };