@zaamx/netme-pos 0.0.15 → 0.0.18
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/.medusa/server/src/admin/index.js +216 -216
- package/.medusa/server/src/admin/index.mjs +220 -220
- package/.medusa/server/src/api/admin/orders/sales/pending-by-location/route.js +152 -0
- package/.medusa/server/src/api/admin/orders/sales/route.js +398 -0
- package/.medusa/server/src/api/middlewares.js +168 -1
- package/.medusa/server/src/api/store/netme-pos/draft-orders/[id]/convert-to-order/route.js +37 -0
- package/.medusa/server/src/api/store/netme-pos/draft-orders/[id]/edit/confirm/route.js +20 -0
- package/.medusa/server/src/api/store/netme-pos/draft-orders/[id]/edit/items/[action_id]/route.js +74 -0
- package/.medusa/server/src/api/store/netme-pos/draft-orders/[id]/edit/items/item/[item_id]/route.js +41 -0
- package/.medusa/server/src/api/store/netme-pos/draft-orders/[id]/edit/items/route.js +31 -0
- package/.medusa/server/src/api/store/netme-pos/draft-orders/[id]/edit/promotions/route.js +31 -0
- package/.medusa/server/src/api/store/netme-pos/draft-orders/[id]/edit/request/route.js +16 -0
- package/.medusa/server/src/api/store/netme-pos/draft-orders/[id]/edit/route.js +32 -0
- package/.medusa/server/src/api/store/netme-pos/draft-orders/[id]/edit/shipping-methods/[action_id]/route.js +32 -0
- package/.medusa/server/src/api/store/netme-pos/draft-orders/[id]/edit/shipping-methods/method/[method_id]/route.js +30 -0
- package/.medusa/server/src/api/store/netme-pos/draft-orders/[id]/edit/shipping-methods/route.js +19 -0
- package/.medusa/server/src/api/store/netme-pos/draft-orders/[id]/route.js +63 -0
- package/.medusa/server/src/api/store/netme-pos/draft-orders/guards.js +77 -0
- package/.medusa/server/src/api/store/netme-pos/draft-orders/helpers.js +19 -0
- package/.medusa/server/src/api/store/netme-pos/draft-orders/pricing.js +136 -0
- package/.medusa/server/src/api/store/netme-pos/draft-orders/query-config.js +60 -0
- package/.medusa/server/src/api/store/netme-pos/draft-orders/route.js +140 -0
- package/.medusa/server/src/api/store/netme-pos/draft-orders/validators.js +217 -0
- package/.medusa/server/src/api/store/netme-pos/fulfillment-validators.js +74 -0
- package/.medusa/server/src/api/store/netme-pos/payment-collections/[id]/mark-as-paid/route.js +34 -0
- package/.medusa/server/src/api/store/netme-pos/payment-collections/[id]/payment-sessions/route.js +28 -0
- package/.medusa/server/src/api/store/netme-pos/payment-collections/guards.js +27 -0
- package/.medusa/server/src/api/store/netme-pos/products/[id]/route.js +10 -0
- package/.medusa/server/src/api/store/netme-pos/products/route.js +14 -0
- package/.medusa/server/src/api/store/netme-pos/scope.js +106 -0
- package/.medusa/server/src/api/store/netme-pos/shipping-options/route.js +100 -0
- package/.medusa/server/src/api/store/netme-pos/stock-locations/route.js +45 -0
- package/.medusa/server/src/links/agent-draft-order.js +31 -0
- package/.medusa/server/src/workflows/ensure-agent-can-act-for/index.js +36 -0
- package/package.json +1 -1
|
@@ -5,8 +5,8 @@ const icons = require("@medusajs/icons");
|
|
|
5
5
|
const ui = require("@medusajs/ui");
|
|
6
6
|
const react = require("react");
|
|
7
7
|
const reactQuery = require("@tanstack/react-query");
|
|
8
|
-
const reactRouterDom = require("react-router-dom");
|
|
9
8
|
const Medusa = require("@medusajs/js-sdk");
|
|
9
|
+
const reactRouterDom = require("react-router-dom");
|
|
10
10
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
11
11
|
const Medusa__default = /* @__PURE__ */ _interopDefault(Medusa);
|
|
12
12
|
const sdk = new Medusa__default.default({
|
|
@@ -18,187 +18,6 @@ const sdk = new Medusa__default.default({
|
|
|
18
18
|
type: "session"
|
|
19
19
|
}
|
|
20
20
|
});
|
|
21
|
-
const POS_ROLES = [
|
|
22
|
-
{ value: "cashier", label: "Cajero" },
|
|
23
|
-
{ value: "supervisor", label: "Supervisor" },
|
|
24
|
-
{ value: "manager", label: "Gerente" }
|
|
25
|
-
];
|
|
26
|
-
const CAPABILITY_GROUPS = [
|
|
27
|
-
{
|
|
28
|
-
title: "Venta / carrito",
|
|
29
|
-
items: [
|
|
30
|
-
{ key: "cancel_sale", label: "Cancelar venta", description: "Botón que borra el draft" },
|
|
31
|
-
{ key: "pause_sale", label: "Pausar venta", description: "Guardar para después" },
|
|
32
|
-
{ key: "remove_item", label: "Eliminar ítems del carrito" },
|
|
33
|
-
{ key: "edit_quantity", label: "Cambiar cantidades" },
|
|
34
|
-
{ key: "apply_promotion", label: "Aplicar / quitar cupón" },
|
|
35
|
-
{ key: "apply_manual_discount", label: "Descuento manual (override de precio)", description: "Acción sensible" }
|
|
36
|
-
]
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
title: "Configuración de la sesión",
|
|
40
|
-
items: [
|
|
41
|
-
{ key: "change_region", label: "Cambiar región" },
|
|
42
|
-
{ key: "change_sales_channel", label: "Cambiar canal de venta" },
|
|
43
|
-
{ key: "change_location", label: "Cambiar ubicación de surtido" }
|
|
44
|
-
]
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
title: "Pago",
|
|
48
|
-
items: [
|
|
49
|
-
{ key: "pay_cash", label: "Cobrar en caja (efectivo)" },
|
|
50
|
-
{ key: "pay_card", label: "Cobrar con tarjeta (Stripe)" },
|
|
51
|
-
{ key: "use_store_credit", label: "Pagar con Monedero (store credit)" },
|
|
52
|
-
{ key: "capture_payment", label: "Capturar pago" },
|
|
53
|
-
{ key: "capture_without_docs", label: "Capturar sin documentación", description: "Acción sensible" }
|
|
54
|
-
]
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
title: "Envío / dirección",
|
|
58
|
-
items: [
|
|
59
|
-
{ key: "edit_shipping", label: "Elegir / cambiar método de envío" },
|
|
60
|
-
{ key: "edit_customer_address", label: "Editar dirección de envío del cliente" }
|
|
61
|
-
]
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
title: "Ventas pendientes",
|
|
65
|
-
items: [
|
|
66
|
-
{ key: "view_pending_drafts", label: "Ver ventas pendientes (/pos-drafts)" },
|
|
67
|
-
{ key: "recover_draft", label: "Recuperar / cargar un draft" }
|
|
68
|
-
]
|
|
69
|
-
}
|
|
70
|
-
];
|
|
71
|
-
const CAPABILITY_KEYS = CAPABILITY_GROUPS.flatMap(
|
|
72
|
-
(g) => g.items.map((i) => i.key)
|
|
73
|
-
);
|
|
74
|
-
const allTrue = () => CAPABILITY_KEYS.reduce(
|
|
75
|
-
(acc, key) => ({ ...acc, [key]: true }),
|
|
76
|
-
{}
|
|
77
|
-
);
|
|
78
|
-
const ROLE_PRESETS = {
|
|
79
|
-
cashier: {
|
|
80
|
-
...allTrue(),
|
|
81
|
-
cancel_sale: false,
|
|
82
|
-
apply_manual_discount: false,
|
|
83
|
-
change_region: false,
|
|
84
|
-
change_sales_channel: false,
|
|
85
|
-
capture_payment: false,
|
|
86
|
-
capture_without_docs: false,
|
|
87
|
-
view_pending_drafts: false,
|
|
88
|
-
recover_draft: false
|
|
89
|
-
},
|
|
90
|
-
supervisor: {
|
|
91
|
-
...allTrue(),
|
|
92
|
-
capture_without_docs: false
|
|
93
|
-
},
|
|
94
|
-
manager: {
|
|
95
|
-
...allTrue()
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
const presetForRole = (role) => {
|
|
99
|
-
if (role && ROLE_PRESETS[role]) {
|
|
100
|
-
return ROLE_PRESETS[role];
|
|
101
|
-
}
|
|
102
|
-
return allTrue();
|
|
103
|
-
};
|
|
104
|
-
const resolveCapabilities = (role, stored) => {
|
|
105
|
-
const preset = presetForRole(role);
|
|
106
|
-
return CAPABILITY_KEYS.reduce((acc, key) => {
|
|
107
|
-
const storedValue = stored && typeof stored[key] === "boolean" ? stored[key] : void 0;
|
|
108
|
-
acc[key] = storedValue ?? preset[key] ?? true;
|
|
109
|
-
return acc;
|
|
110
|
-
}, {});
|
|
111
|
-
};
|
|
112
|
-
const columnHelper$2 = ui.createDataTableColumnHelper();
|
|
113
|
-
const roleLabel = (role) => {
|
|
114
|
-
var _a;
|
|
115
|
-
return ((_a = POS_ROLES.find((r) => r.value === role)) == null ? void 0 : _a.label) || null;
|
|
116
|
-
};
|
|
117
|
-
const scopeSummary = (ids) => Array.isArray(ids) ? `${ids.length} seleccionada${ids.length === 1 ? "" : "s"}` : "Todas";
|
|
118
|
-
const useColumns$2 = () => react.useMemo(
|
|
119
|
-
() => [
|
|
120
|
-
columnHelper$2.accessor("first_name", {
|
|
121
|
-
header: "Nombre",
|
|
122
|
-
cell: ({ row }) => `${row.original.first_name ?? ""} ${row.original.last_name ?? ""}`.trim() || "—"
|
|
123
|
-
}),
|
|
124
|
-
columnHelper$2.accessor("email", {
|
|
125
|
-
header: "Email"
|
|
126
|
-
}),
|
|
127
|
-
columnHelper$2.display({
|
|
128
|
-
id: "role",
|
|
129
|
-
header: "Rol POS",
|
|
130
|
-
cell: ({ row }) => {
|
|
131
|
-
var _a;
|
|
132
|
-
const label = roleLabel((_a = row.original.metadata) == null ? void 0 : _a.pos_role);
|
|
133
|
-
return label ? /* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { size: "2xsmall", color: "blue", children: label }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Sin rol" });
|
|
134
|
-
}
|
|
135
|
-
}),
|
|
136
|
-
columnHelper$2.display({
|
|
137
|
-
id: "locations",
|
|
138
|
-
header: "Ubicaciones",
|
|
139
|
-
cell: ({ row }) => {
|
|
140
|
-
var _a;
|
|
141
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", children: scopeSummary((_a = row.original.metadata) == null ? void 0 : _a.pos_stock_location_ids) });
|
|
142
|
-
}
|
|
143
|
-
}),
|
|
144
|
-
columnHelper$2.display({
|
|
145
|
-
id: "actions",
|
|
146
|
-
cell: ({ row }) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { asChild: true, size: "small", variant: "secondary", children: /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Link, { to: `/pos-permissions/${row.original.id}`, children: "Editar permisos" }) }) })
|
|
147
|
-
})
|
|
148
|
-
],
|
|
149
|
-
[]
|
|
150
|
-
);
|
|
151
|
-
const PosPermissionsPage = () => {
|
|
152
|
-
const [searchValue, setSearchValue] = react.useState("");
|
|
153
|
-
const [pagination, setPagination] = react.useState({
|
|
154
|
-
pageIndex: 0,
|
|
155
|
-
pageSize: 15
|
|
156
|
-
});
|
|
157
|
-
const limit = pagination.pageSize;
|
|
158
|
-
const offset = pagination.pageIndex * limit;
|
|
159
|
-
const { data, isLoading } = reactQuery.useQuery({
|
|
160
|
-
queryFn: () => sdk.client.fetch("/admin/operators", {
|
|
161
|
-
query: {
|
|
162
|
-
limit,
|
|
163
|
-
offset,
|
|
164
|
-
q: searchValue || void 0
|
|
165
|
-
}
|
|
166
|
-
}),
|
|
167
|
-
queryKey: ["operators", "pos-permissions", limit, offset, searchValue],
|
|
168
|
-
placeholderData: (previousData) => previousData
|
|
169
|
-
});
|
|
170
|
-
const columns = useColumns$2();
|
|
171
|
-
const table = ui.useDataTable({
|
|
172
|
-
data: (data == null ? void 0 : data.operators) || [],
|
|
173
|
-
columns,
|
|
174
|
-
getRowId: (row) => row.id,
|
|
175
|
-
rowCount: (data == null ? void 0 : data.count) || 0,
|
|
176
|
-
isLoading,
|
|
177
|
-
search: {
|
|
178
|
-
state: searchValue,
|
|
179
|
-
onSearchChange: setSearchValue
|
|
180
|
-
},
|
|
181
|
-
pagination: {
|
|
182
|
-
state: pagination,
|
|
183
|
-
onPaginationChange: setPagination
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "flex flex-col items-stretch overflow-hidden p-0", children: [
|
|
187
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-between border-b border-ui-border-base px-6 py-4", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-1", children: [
|
|
188
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", children: "Permisos POS" }),
|
|
189
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Define el alcance (ubicaciones, canales, regiones) y las capacidades de cada operador del Punto de Venta." })
|
|
190
|
-
] }) }),
|
|
191
|
-
/* @__PURE__ */ jsxRuntime.jsxs(ui.DataTable, { instance: table, children: [
|
|
192
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.DataTable.Toolbar, { children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex w-full items-center justify-end", children: /* @__PURE__ */ jsxRuntime.jsx(ui.DataTable.Search, { placeholder: "Buscar operador..." }) }) }),
|
|
193
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.DataTable.Table, {}),
|
|
194
|
-
/* @__PURE__ */ jsxRuntime.jsx(ui.DataTable.Pagination, {})
|
|
195
|
-
] })
|
|
196
|
-
] });
|
|
197
|
-
};
|
|
198
|
-
const config$2 = adminSdk.defineRouteConfig({
|
|
199
|
-
label: "Permisos POS",
|
|
200
|
-
icon: icons.ShieldCheck
|
|
201
|
-
});
|
|
202
21
|
const EditOperatorDrawer = ({
|
|
203
22
|
operator,
|
|
204
23
|
open,
|
|
@@ -505,24 +324,24 @@ const CreateOperatorModal = () => {
|
|
|
505
324
|
] }) }) })
|
|
506
325
|
] });
|
|
507
326
|
};
|
|
508
|
-
const columnHelper$
|
|
509
|
-
const useColumns$
|
|
327
|
+
const columnHelper$2 = ui.createDataTableColumnHelper();
|
|
328
|
+
const useColumns$2 = () => {
|
|
510
329
|
return react.useMemo(
|
|
511
330
|
() => [
|
|
512
|
-
columnHelper$
|
|
331
|
+
columnHelper$2.accessor("first_name", {
|
|
513
332
|
header: "First Name"
|
|
514
333
|
}),
|
|
515
|
-
columnHelper$
|
|
334
|
+
columnHelper$2.accessor("last_name", {
|
|
516
335
|
header: "Last Name"
|
|
517
336
|
}),
|
|
518
|
-
columnHelper$
|
|
337
|
+
columnHelper$2.accessor("email", {
|
|
519
338
|
header: "Email"
|
|
520
339
|
}),
|
|
521
|
-
columnHelper$
|
|
340
|
+
columnHelper$2.accessor("created_at", {
|
|
522
341
|
header: "Date Added",
|
|
523
342
|
cell: ({ getValue }) => new Date(getValue()).toLocaleDateString()
|
|
524
343
|
}),
|
|
525
|
-
columnHelper$
|
|
344
|
+
columnHelper$2.display({
|
|
526
345
|
id: "actions",
|
|
527
346
|
cell: ({ row }) => /* @__PURE__ */ jsxRuntime.jsx(OperatorActions, { operator: row.original })
|
|
528
347
|
})
|
|
@@ -549,7 +368,7 @@ const OperatorTable = () => {
|
|
|
549
368
|
queryKey: ["operators", limit, offset, searchValue],
|
|
550
369
|
placeholderData: (previousData) => previousData
|
|
551
370
|
});
|
|
552
|
-
const columns = useColumns$
|
|
371
|
+
const columns = useColumns$2();
|
|
553
372
|
const table = ui.useDataTable({
|
|
554
373
|
data: (data == null ? void 0 : data.operators) || [],
|
|
555
374
|
columns,
|
|
@@ -580,7 +399,7 @@ const OperatorsPage = () => {
|
|
|
580
399
|
/* @__PURE__ */ jsxRuntime.jsx(OperatorTable, {})
|
|
581
400
|
] });
|
|
582
401
|
};
|
|
583
|
-
const config$
|
|
402
|
+
const config$2 = adminSdk.defineRouteConfig({
|
|
584
403
|
label: "Operators",
|
|
585
404
|
icon: icons.Users
|
|
586
405
|
});
|
|
@@ -916,7 +735,7 @@ const PaymentOptionActions = ({
|
|
|
916
735
|
)
|
|
917
736
|
] });
|
|
918
737
|
};
|
|
919
|
-
const columnHelper = ui.createDataTableColumnHelper();
|
|
738
|
+
const columnHelper$1 = ui.createDataTableColumnHelper();
|
|
920
739
|
const formatAmount = (value) => {
|
|
921
740
|
const n = Number(value ?? 0);
|
|
922
741
|
return n.toLocaleString("es-MX", {
|
|
@@ -947,10 +766,10 @@ const statusColor = (status) => {
|
|
|
947
766
|
return "grey";
|
|
948
767
|
}
|
|
949
768
|
};
|
|
950
|
-
const useColumns = () => {
|
|
769
|
+
const useColumns$1 = () => {
|
|
951
770
|
return react.useMemo(
|
|
952
771
|
() => [
|
|
953
|
-
columnHelper.accessor("order_display_id", {
|
|
772
|
+
columnHelper$1.accessor("order_display_id", {
|
|
954
773
|
header: "Orden",
|
|
955
774
|
cell: ({ row }) => {
|
|
956
775
|
const displayId = row.original.order_display_id;
|
|
@@ -975,19 +794,19 @@ const useColumns = () => {
|
|
|
975
794
|
);
|
|
976
795
|
}
|
|
977
796
|
}),
|
|
978
|
-
columnHelper.accessor("reference_code", {
|
|
797
|
+
columnHelper$1.accessor("reference_code", {
|
|
979
798
|
header: "Folio / Referencia",
|
|
980
799
|
cell: ({ getValue }) => getValue() || "—"
|
|
981
800
|
}),
|
|
982
|
-
columnHelper.accessor("payment_method", {
|
|
801
|
+
columnHelper$1.accessor("payment_method", {
|
|
983
802
|
header: "Método",
|
|
984
803
|
cell: ({ getValue }) => getValue() || "—"
|
|
985
804
|
}),
|
|
986
|
-
columnHelper.accessor("amount", {
|
|
805
|
+
columnHelper$1.accessor("amount", {
|
|
987
806
|
header: "Monto",
|
|
988
807
|
cell: ({ getValue }) => formatAmount(getValue())
|
|
989
808
|
}),
|
|
990
|
-
columnHelper.accessor("status", {
|
|
809
|
+
columnHelper$1.accessor("status", {
|
|
991
810
|
header: "Estatus",
|
|
992
811
|
cell: ({ getValue }) => {
|
|
993
812
|
const status = getValue();
|
|
@@ -997,15 +816,15 @@ const useColumns = () => {
|
|
|
997
816
|
return /* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { size: "2xsmall", color: statusColor(status), children: status });
|
|
998
817
|
}
|
|
999
818
|
}),
|
|
1000
|
-
columnHelper.accessor("concept", {
|
|
819
|
+
columnHelper$1.accessor("concept", {
|
|
1001
820
|
header: "Concepto",
|
|
1002
821
|
cell: ({ getValue }) => getValue() || "—"
|
|
1003
822
|
}),
|
|
1004
|
-
columnHelper.accessor("created_at", {
|
|
823
|
+
columnHelper$1.accessor("created_at", {
|
|
1005
824
|
header: "Fecha",
|
|
1006
825
|
cell: ({ getValue }) => new Date(getValue()).toLocaleString()
|
|
1007
826
|
}),
|
|
1008
|
-
columnHelper.display({
|
|
827
|
+
columnHelper$1.display({
|
|
1009
828
|
id: "actions",
|
|
1010
829
|
cell: ({ row }) => /* @__PURE__ */ jsxRuntime.jsx(PaymentOptionActions, { paymentOption: row.original })
|
|
1011
830
|
})
|
|
@@ -1032,7 +851,7 @@ const PaymentOptionTable = () => {
|
|
|
1032
851
|
queryKey: ["payment-options", limit, offset, searchValue],
|
|
1033
852
|
placeholderData: (previousData) => previousData
|
|
1034
853
|
});
|
|
1035
|
-
const columns = useColumns();
|
|
854
|
+
const columns = useColumns$1();
|
|
1036
855
|
const table = ui.useDataTable({
|
|
1037
856
|
data: (data == null ? void 0 : data.payment_options) || [],
|
|
1038
857
|
columns,
|
|
@@ -1069,10 +888,191 @@ const PaymentOptionsPage = () => {
|
|
|
1069
888
|
/* @__PURE__ */ jsxRuntime.jsx(PaymentOptionTable, {})
|
|
1070
889
|
] });
|
|
1071
890
|
};
|
|
1072
|
-
const config = adminSdk.defineRouteConfig({
|
|
891
|
+
const config$1 = adminSdk.defineRouteConfig({
|
|
1073
892
|
label: "Notas de pago",
|
|
1074
893
|
icon: icons.CurrencyDollar
|
|
1075
894
|
});
|
|
895
|
+
const POS_ROLES = [
|
|
896
|
+
{ value: "cashier", label: "Cajero" },
|
|
897
|
+
{ value: "supervisor", label: "Supervisor" },
|
|
898
|
+
{ value: "manager", label: "Gerente" }
|
|
899
|
+
];
|
|
900
|
+
const CAPABILITY_GROUPS = [
|
|
901
|
+
{
|
|
902
|
+
title: "Venta / carrito",
|
|
903
|
+
items: [
|
|
904
|
+
{ key: "cancel_sale", label: "Cancelar venta", description: "Botón que borra el draft" },
|
|
905
|
+
{ key: "pause_sale", label: "Pausar venta", description: "Guardar para después" },
|
|
906
|
+
{ key: "remove_item", label: "Eliminar ítems del carrito" },
|
|
907
|
+
{ key: "edit_quantity", label: "Cambiar cantidades" },
|
|
908
|
+
{ key: "apply_promotion", label: "Aplicar / quitar cupón" },
|
|
909
|
+
{ key: "apply_manual_discount", label: "Descuento manual (override de precio)", description: "Acción sensible" }
|
|
910
|
+
]
|
|
911
|
+
},
|
|
912
|
+
{
|
|
913
|
+
title: "Configuración de la sesión",
|
|
914
|
+
items: [
|
|
915
|
+
{ key: "change_region", label: "Cambiar región" },
|
|
916
|
+
{ key: "change_sales_channel", label: "Cambiar canal de venta" },
|
|
917
|
+
{ key: "change_location", label: "Cambiar ubicación de surtido" }
|
|
918
|
+
]
|
|
919
|
+
},
|
|
920
|
+
{
|
|
921
|
+
title: "Pago",
|
|
922
|
+
items: [
|
|
923
|
+
{ key: "pay_cash", label: "Cobrar en caja (efectivo)" },
|
|
924
|
+
{ key: "pay_card", label: "Cobrar con tarjeta (Stripe)" },
|
|
925
|
+
{ key: "use_store_credit", label: "Pagar con Monedero (store credit)" },
|
|
926
|
+
{ key: "capture_payment", label: "Capturar pago" },
|
|
927
|
+
{ key: "capture_without_docs", label: "Capturar sin documentación", description: "Acción sensible" }
|
|
928
|
+
]
|
|
929
|
+
},
|
|
930
|
+
{
|
|
931
|
+
title: "Envío / dirección",
|
|
932
|
+
items: [
|
|
933
|
+
{ key: "edit_shipping", label: "Elegir / cambiar método de envío" },
|
|
934
|
+
{ key: "edit_customer_address", label: "Editar dirección de envío del cliente" }
|
|
935
|
+
]
|
|
936
|
+
},
|
|
937
|
+
{
|
|
938
|
+
title: "Ventas pendientes",
|
|
939
|
+
items: [
|
|
940
|
+
{ key: "view_pending_drafts", label: "Ver ventas pendientes (/pos-drafts)" },
|
|
941
|
+
{ key: "recover_draft", label: "Recuperar / cargar un draft" }
|
|
942
|
+
]
|
|
943
|
+
}
|
|
944
|
+
];
|
|
945
|
+
const CAPABILITY_KEYS = CAPABILITY_GROUPS.flatMap(
|
|
946
|
+
(g) => g.items.map((i) => i.key)
|
|
947
|
+
);
|
|
948
|
+
const allTrue = () => CAPABILITY_KEYS.reduce(
|
|
949
|
+
(acc, key) => ({ ...acc, [key]: true }),
|
|
950
|
+
{}
|
|
951
|
+
);
|
|
952
|
+
const ROLE_PRESETS = {
|
|
953
|
+
cashier: {
|
|
954
|
+
...allTrue(),
|
|
955
|
+
cancel_sale: false,
|
|
956
|
+
apply_manual_discount: false,
|
|
957
|
+
change_region: false,
|
|
958
|
+
change_sales_channel: false,
|
|
959
|
+
capture_payment: false,
|
|
960
|
+
capture_without_docs: false,
|
|
961
|
+
view_pending_drafts: false,
|
|
962
|
+
recover_draft: false
|
|
963
|
+
},
|
|
964
|
+
supervisor: {
|
|
965
|
+
...allTrue(),
|
|
966
|
+
capture_without_docs: false
|
|
967
|
+
},
|
|
968
|
+
manager: {
|
|
969
|
+
...allTrue()
|
|
970
|
+
}
|
|
971
|
+
};
|
|
972
|
+
const presetForRole = (role) => {
|
|
973
|
+
if (role && ROLE_PRESETS[role]) {
|
|
974
|
+
return ROLE_PRESETS[role];
|
|
975
|
+
}
|
|
976
|
+
return allTrue();
|
|
977
|
+
};
|
|
978
|
+
const resolveCapabilities = (role, stored) => {
|
|
979
|
+
const preset = presetForRole(role);
|
|
980
|
+
return CAPABILITY_KEYS.reduce((acc, key) => {
|
|
981
|
+
const storedValue = stored && typeof stored[key] === "boolean" ? stored[key] : void 0;
|
|
982
|
+
acc[key] = storedValue ?? preset[key] ?? true;
|
|
983
|
+
return acc;
|
|
984
|
+
}, {});
|
|
985
|
+
};
|
|
986
|
+
const columnHelper = ui.createDataTableColumnHelper();
|
|
987
|
+
const roleLabel = (role) => {
|
|
988
|
+
var _a;
|
|
989
|
+
return ((_a = POS_ROLES.find((r) => r.value === role)) == null ? void 0 : _a.label) || null;
|
|
990
|
+
};
|
|
991
|
+
const scopeSummary = (ids) => Array.isArray(ids) ? `${ids.length} seleccionada${ids.length === 1 ? "" : "s"}` : "Todas";
|
|
992
|
+
const useColumns = () => react.useMemo(
|
|
993
|
+
() => [
|
|
994
|
+
columnHelper.accessor("first_name", {
|
|
995
|
+
header: "Nombre",
|
|
996
|
+
cell: ({ row }) => `${row.original.first_name ?? ""} ${row.original.last_name ?? ""}`.trim() || "—"
|
|
997
|
+
}),
|
|
998
|
+
columnHelper.accessor("email", {
|
|
999
|
+
header: "Email"
|
|
1000
|
+
}),
|
|
1001
|
+
columnHelper.display({
|
|
1002
|
+
id: "role",
|
|
1003
|
+
header: "Rol POS",
|
|
1004
|
+
cell: ({ row }) => {
|
|
1005
|
+
var _a;
|
|
1006
|
+
const label = roleLabel((_a = row.original.metadata) == null ? void 0 : _a.pos_role);
|
|
1007
|
+
return label ? /* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { size: "2xsmall", color: "blue", children: label }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Sin rol" });
|
|
1008
|
+
}
|
|
1009
|
+
}),
|
|
1010
|
+
columnHelper.display({
|
|
1011
|
+
id: "locations",
|
|
1012
|
+
header: "Ubicaciones",
|
|
1013
|
+
cell: ({ row }) => {
|
|
1014
|
+
var _a;
|
|
1015
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", children: scopeSummary((_a = row.original.metadata) == null ? void 0 : _a.pos_stock_location_ids) });
|
|
1016
|
+
}
|
|
1017
|
+
}),
|
|
1018
|
+
columnHelper.display({
|
|
1019
|
+
id: "actions",
|
|
1020
|
+
cell: ({ row }) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { asChild: true, size: "small", variant: "secondary", children: /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Link, { to: `/pos-permissions/${row.original.id}`, children: "Editar permisos" }) }) })
|
|
1021
|
+
})
|
|
1022
|
+
],
|
|
1023
|
+
[]
|
|
1024
|
+
);
|
|
1025
|
+
const PosPermissionsPage = () => {
|
|
1026
|
+
const [searchValue, setSearchValue] = react.useState("");
|
|
1027
|
+
const [pagination, setPagination] = react.useState({
|
|
1028
|
+
pageIndex: 0,
|
|
1029
|
+
pageSize: 15
|
|
1030
|
+
});
|
|
1031
|
+
const limit = pagination.pageSize;
|
|
1032
|
+
const offset = pagination.pageIndex * limit;
|
|
1033
|
+
const { data, isLoading } = reactQuery.useQuery({
|
|
1034
|
+
queryFn: () => sdk.client.fetch("/admin/operators", {
|
|
1035
|
+
query: {
|
|
1036
|
+
limit,
|
|
1037
|
+
offset,
|
|
1038
|
+
q: searchValue || void 0
|
|
1039
|
+
}
|
|
1040
|
+
}),
|
|
1041
|
+
queryKey: ["operators", "pos-permissions", limit, offset, searchValue],
|
|
1042
|
+
placeholderData: (previousData) => previousData
|
|
1043
|
+
});
|
|
1044
|
+
const columns = useColumns();
|
|
1045
|
+
const table = ui.useDataTable({
|
|
1046
|
+
data: (data == null ? void 0 : data.operators) || [],
|
|
1047
|
+
columns,
|
|
1048
|
+
getRowId: (row) => row.id,
|
|
1049
|
+
rowCount: (data == null ? void 0 : data.count) || 0,
|
|
1050
|
+
isLoading,
|
|
1051
|
+
search: {
|
|
1052
|
+
state: searchValue,
|
|
1053
|
+
onSearchChange: setSearchValue
|
|
1054
|
+
},
|
|
1055
|
+
pagination: {
|
|
1056
|
+
state: pagination,
|
|
1057
|
+
onPaginationChange: setPagination
|
|
1058
|
+
}
|
|
1059
|
+
});
|
|
1060
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "flex flex-col items-stretch overflow-hidden p-0", children: [
|
|
1061
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-between border-b border-ui-border-base px-6 py-4", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-1", children: [
|
|
1062
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", children: "Permisos POS" }),
|
|
1063
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Define el alcance (ubicaciones, canales, regiones) y las capacidades de cada operador del Punto de Venta." })
|
|
1064
|
+
] }) }),
|
|
1065
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.DataTable, { instance: table, children: [
|
|
1066
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.DataTable.Toolbar, { children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex w-full items-center justify-end", children: /* @__PURE__ */ jsxRuntime.jsx(ui.DataTable.Search, { placeholder: "Buscar operador..." }) }) }),
|
|
1067
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.DataTable.Table, {}),
|
|
1068
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.DataTable.Pagination, {})
|
|
1069
|
+
] })
|
|
1070
|
+
] });
|
|
1071
|
+
};
|
|
1072
|
+
const config = adminSdk.defineRouteConfig({
|
|
1073
|
+
label: "Permisos POS",
|
|
1074
|
+
icon: icons.ShieldCheck
|
|
1075
|
+
});
|
|
1076
1076
|
const MultiSelect = ({
|
|
1077
1077
|
options,
|
|
1078
1078
|
value,
|
|
@@ -1697,10 +1697,6 @@ const i18nTranslations0 = {};
|
|
|
1697
1697
|
const widgetModule = { widgets: [] };
|
|
1698
1698
|
const routeModule = {
|
|
1699
1699
|
routes: [
|
|
1700
|
-
{
|
|
1701
|
-
Component: PosPermissionsPage,
|
|
1702
|
-
path: "/pos-permissions"
|
|
1703
|
-
},
|
|
1704
1700
|
{
|
|
1705
1701
|
Component: OperatorsPage,
|
|
1706
1702
|
path: "/operators"
|
|
@@ -1709,6 +1705,10 @@ const routeModule = {
|
|
|
1709
1705
|
Component: PaymentOptionsPage,
|
|
1710
1706
|
path: "/payment-options"
|
|
1711
1707
|
},
|
|
1708
|
+
{
|
|
1709
|
+
Component: PosPermissionsPage,
|
|
1710
|
+
path: "/pos-permissions"
|
|
1711
|
+
},
|
|
1712
1712
|
{
|
|
1713
1713
|
Component: PosPermissionEditorPage,
|
|
1714
1714
|
path: "/pos-permissions/:id"
|
|
@@ -1718,25 +1718,25 @@ const routeModule = {
|
|
|
1718
1718
|
const menuItemModule = {
|
|
1719
1719
|
menuItems: [
|
|
1720
1720
|
{
|
|
1721
|
-
label: config.label,
|
|
1722
|
-
icon: config.icon,
|
|
1723
|
-
path: "/
|
|
1721
|
+
label: config$2.label,
|
|
1722
|
+
icon: config$2.icon,
|
|
1723
|
+
path: "/operators",
|
|
1724
1724
|
nested: void 0,
|
|
1725
1725
|
rank: void 0,
|
|
1726
1726
|
translationNs: void 0
|
|
1727
1727
|
},
|
|
1728
1728
|
{
|
|
1729
|
-
label: config$
|
|
1730
|
-
icon: config$
|
|
1731
|
-
path: "/
|
|
1729
|
+
label: config$1.label,
|
|
1730
|
+
icon: config$1.icon,
|
|
1731
|
+
path: "/payment-options",
|
|
1732
1732
|
nested: void 0,
|
|
1733
1733
|
rank: void 0,
|
|
1734
1734
|
translationNs: void 0
|
|
1735
1735
|
},
|
|
1736
1736
|
{
|
|
1737
|
-
label: config
|
|
1738
|
-
icon: config
|
|
1739
|
-
path: "/
|
|
1737
|
+
label: config.label,
|
|
1738
|
+
icon: config.icon,
|
|
1739
|
+
path: "/pos-permissions",
|
|
1740
1740
|
nested: void 0,
|
|
1741
1741
|
rank: void 0,
|
|
1742
1742
|
translationNs: void 0
|