@zaamx/netme-pos 0.0.9 → 0.0.11
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 +511 -10
- package/.medusa/server/src/admin/index.mjs +514 -13
- package/.medusa/server/src/api/admin/netme-pos/products/[id]/route.js +5 -2
- package/.medusa/server/src/api/admin/netme-pos/products/helpers.js +89 -24
- package/.medusa/server/src/api/admin/netme-pos/products/route.js +7 -2
- package/.medusa/server/src/api/admin/netme-pos/products/validators.js +3 -1
- package/.medusa/server/src/api/admin/payment-options/[id]/route.js +70 -0
- package/.medusa/server/src/api/admin/payment-options/route.js +84 -0
- package/.medusa/server/src/api/middlewares.js +2 -1
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { defineRouteConfig } from "@medusajs/admin-sdk";
|
|
3
|
-
import { EllipsisHorizontal, PencilSquare, Trash, Users } from "@medusajs/icons";
|
|
4
|
-
import { toast, Drawer, Label, Input, Text, Button, Prompt, DropdownMenu, IconButton, FocusModal, createDataTableColumnHelper, useDataTable, DataTable, Container, Heading } from "@medusajs/ui";
|
|
5
|
-
import { useState, useMemo } from "react";
|
|
3
|
+
import { EllipsisHorizontal, PencilSquare, Trash, Users, CurrencyDollar } from "@medusajs/icons";
|
|
4
|
+
import { toast, Drawer, Label, Input, Text, Button, Prompt, DropdownMenu, IconButton, FocusModal, createDataTableColumnHelper, useDataTable, DataTable, Container, Heading, Select, Badge } from "@medusajs/ui";
|
|
5
|
+
import { useState, useMemo, useEffect } from "react";
|
|
6
6
|
import { useQueryClient, useMutation, useQuery } from "@tanstack/react-query";
|
|
7
7
|
import Medusa from "@medusajs/js-sdk";
|
|
8
8
|
const sdk = new Medusa({
|
|
@@ -308,24 +308,24 @@ const CreateOperatorModal = () => {
|
|
|
308
308
|
] }) }) })
|
|
309
309
|
] });
|
|
310
310
|
};
|
|
311
|
-
const columnHelper = createDataTableColumnHelper();
|
|
312
|
-
const useColumns = () => {
|
|
311
|
+
const columnHelper$1 = createDataTableColumnHelper();
|
|
312
|
+
const useColumns$1 = () => {
|
|
313
313
|
return useMemo(
|
|
314
314
|
() => [
|
|
315
|
-
columnHelper.accessor("first_name", {
|
|
315
|
+
columnHelper$1.accessor("first_name", {
|
|
316
316
|
header: "First Name"
|
|
317
317
|
}),
|
|
318
|
-
columnHelper.accessor("last_name", {
|
|
318
|
+
columnHelper$1.accessor("last_name", {
|
|
319
319
|
header: "Last Name"
|
|
320
320
|
}),
|
|
321
|
-
columnHelper.accessor("email", {
|
|
321
|
+
columnHelper$1.accessor("email", {
|
|
322
322
|
header: "Email"
|
|
323
323
|
}),
|
|
324
|
-
columnHelper.accessor("created_at", {
|
|
324
|
+
columnHelper$1.accessor("created_at", {
|
|
325
325
|
header: "Date Added",
|
|
326
326
|
cell: ({ getValue }) => new Date(getValue()).toLocaleDateString()
|
|
327
327
|
}),
|
|
328
|
-
columnHelper.display({
|
|
328
|
+
columnHelper$1.display({
|
|
329
329
|
id: "actions",
|
|
330
330
|
cell: ({ row }) => /* @__PURE__ */ jsx(OperatorActions, { operator: row.original })
|
|
331
331
|
})
|
|
@@ -352,7 +352,7 @@ const OperatorTable = () => {
|
|
|
352
352
|
queryKey: ["operators", limit, offset, searchValue],
|
|
353
353
|
placeholderData: (previousData) => previousData
|
|
354
354
|
});
|
|
355
|
-
const columns = useColumns();
|
|
355
|
+
const columns = useColumns$1();
|
|
356
356
|
const table = useDataTable({
|
|
357
357
|
data: (data == null ? void 0 : data.operators) || [],
|
|
358
358
|
columns,
|
|
@@ -383,10 +383,499 @@ const OperatorsPage = () => {
|
|
|
383
383
|
/* @__PURE__ */ jsx(OperatorTable, {})
|
|
384
384
|
] });
|
|
385
385
|
};
|
|
386
|
-
const config = defineRouteConfig({
|
|
386
|
+
const config$1 = defineRouteConfig({
|
|
387
387
|
label: "Operators",
|
|
388
388
|
icon: Users
|
|
389
389
|
});
|
|
390
|
+
const STATUS_OPTIONS = [
|
|
391
|
+
"pending",
|
|
392
|
+
"paid",
|
|
393
|
+
"approved",
|
|
394
|
+
"rejected",
|
|
395
|
+
"canceled"
|
|
396
|
+
];
|
|
397
|
+
const toForm = (po) => ({
|
|
398
|
+
payment_method: po.payment_method ?? "",
|
|
399
|
+
amount: po.amount != null ? String(po.amount) : "",
|
|
400
|
+
status: po.status ?? "",
|
|
401
|
+
concept: po.concept ?? "",
|
|
402
|
+
reference_code: po.reference_code ?? "",
|
|
403
|
+
institution: po.institution ?? "",
|
|
404
|
+
depositor_name: po.depositor_name ?? "",
|
|
405
|
+
terminal_reference: po.terminal_reference ?? "",
|
|
406
|
+
ticket_amount: po.ticket_amount != null ? String(po.ticket_amount) : "",
|
|
407
|
+
authorizer: po.authorizer ?? "",
|
|
408
|
+
receipt_file: po.receipt_file ?? ""
|
|
409
|
+
});
|
|
410
|
+
const EditPaymentOptionDrawer = ({
|
|
411
|
+
paymentOption,
|
|
412
|
+
open,
|
|
413
|
+
setOpen
|
|
414
|
+
}) => {
|
|
415
|
+
const [formData, setFormData] = useState(toForm(paymentOption));
|
|
416
|
+
const queryClient = useQueryClient();
|
|
417
|
+
useEffect(() => {
|
|
418
|
+
if (open) {
|
|
419
|
+
setFormData(toForm(paymentOption));
|
|
420
|
+
}
|
|
421
|
+
}, [open, paymentOption]);
|
|
422
|
+
const update = (key, value) => setFormData((prev) => ({ ...prev, [key]: value }));
|
|
423
|
+
const updateMutation = useMutation({
|
|
424
|
+
mutationFn: () => {
|
|
425
|
+
const payload = {
|
|
426
|
+
payment_method: formData.payment_method,
|
|
427
|
+
status: formData.status,
|
|
428
|
+
concept: formData.concept,
|
|
429
|
+
reference_code: formData.reference_code,
|
|
430
|
+
institution: formData.institution,
|
|
431
|
+
depositor_name: formData.depositor_name,
|
|
432
|
+
terminal_reference: formData.terminal_reference,
|
|
433
|
+
authorizer: formData.authorizer,
|
|
434
|
+
receipt_file: formData.receipt_file
|
|
435
|
+
};
|
|
436
|
+
if (formData.amount.trim() !== "") {
|
|
437
|
+
payload.amount = Number(formData.amount);
|
|
438
|
+
}
|
|
439
|
+
if (formData.ticket_amount.trim() !== "") {
|
|
440
|
+
payload.ticket_amount = Number(formData.ticket_amount);
|
|
441
|
+
}
|
|
442
|
+
return sdk.client.fetch(
|
|
443
|
+
`/admin/payment-options/${paymentOption.id}`,
|
|
444
|
+
{
|
|
445
|
+
method: "POST",
|
|
446
|
+
body: payload
|
|
447
|
+
}
|
|
448
|
+
);
|
|
449
|
+
},
|
|
450
|
+
onSuccess: () => {
|
|
451
|
+
queryClient.invalidateQueries({ queryKey: ["payment-options"] });
|
|
452
|
+
toast.success("Nota de pago actualizada");
|
|
453
|
+
setOpen(false);
|
|
454
|
+
},
|
|
455
|
+
onError: (error) => {
|
|
456
|
+
toast.error(error.message || "No se pudo actualizar la nota de pago");
|
|
457
|
+
}
|
|
458
|
+
});
|
|
459
|
+
const statusOptions = STATUS_OPTIONS.includes(formData.status) || !formData.status ? STATUS_OPTIONS : [formData.status, ...STATUS_OPTIONS];
|
|
460
|
+
return /* @__PURE__ */ jsx(Drawer, { open, onOpenChange: setOpen, children: /* @__PURE__ */ jsxs(Drawer.Content, { children: [
|
|
461
|
+
/* @__PURE__ */ jsx(Drawer.Header, { children: /* @__PURE__ */ jsx(Drawer.Title, { children: "Editar nota de pago" }) }),
|
|
462
|
+
/* @__PURE__ */ jsx(Drawer.Body, { className: "flex-1 overflow-auto p-4", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-4", children: [
|
|
463
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-1", children: [
|
|
464
|
+
paymentOption.order_display_id ? /* @__PURE__ */ jsxs(Text, { size: "small", leading: "compact", className: "text-ui-fg-subtle", children: [
|
|
465
|
+
"Orden #",
|
|
466
|
+
paymentOption.order_display_id
|
|
467
|
+
] }) : null,
|
|
468
|
+
/* @__PURE__ */ jsxs(Text, { size: "small", leading: "compact", className: "text-ui-fg-subtle", children: [
|
|
469
|
+
"Pago: ",
|
|
470
|
+
paymentOption.payment_id
|
|
471
|
+
] })
|
|
472
|
+
] }),
|
|
473
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-2", children: [
|
|
474
|
+
/* @__PURE__ */ jsx(Label, { children: "Método de pago" }),
|
|
475
|
+
/* @__PURE__ */ jsx(
|
|
476
|
+
Input,
|
|
477
|
+
{
|
|
478
|
+
value: formData.payment_method,
|
|
479
|
+
onChange: (e) => update("payment_method", e.target.value)
|
|
480
|
+
}
|
|
481
|
+
)
|
|
482
|
+
] }),
|
|
483
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
|
|
484
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-2", children: [
|
|
485
|
+
/* @__PURE__ */ jsx(Label, { children: "Monto" }),
|
|
486
|
+
/* @__PURE__ */ jsx(
|
|
487
|
+
Input,
|
|
488
|
+
{
|
|
489
|
+
type: "number",
|
|
490
|
+
step: "0.01",
|
|
491
|
+
value: formData.amount,
|
|
492
|
+
onChange: (e) => update("amount", e.target.value)
|
|
493
|
+
}
|
|
494
|
+
)
|
|
495
|
+
] }),
|
|
496
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-2", children: [
|
|
497
|
+
/* @__PURE__ */ jsx(Label, { children: "Estatus" }),
|
|
498
|
+
/* @__PURE__ */ jsxs(
|
|
499
|
+
Select,
|
|
500
|
+
{
|
|
501
|
+
value: formData.status,
|
|
502
|
+
onValueChange: (value) => update("status", value),
|
|
503
|
+
children: [
|
|
504
|
+
/* @__PURE__ */ jsx(Select.Trigger, { children: /* @__PURE__ */ jsx(Select.Value, { placeholder: "Seleccionar estatus" }) }),
|
|
505
|
+
/* @__PURE__ */ jsx(Select.Content, { children: statusOptions.map((s) => /* @__PURE__ */ jsx(Select.Item, { value: s, children: s }, s)) })
|
|
506
|
+
]
|
|
507
|
+
}
|
|
508
|
+
)
|
|
509
|
+
] })
|
|
510
|
+
] }),
|
|
511
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-2", children: [
|
|
512
|
+
/* @__PURE__ */ jsx(Label, { children: "Concepto" }),
|
|
513
|
+
/* @__PURE__ */ jsx(
|
|
514
|
+
Input,
|
|
515
|
+
{
|
|
516
|
+
value: formData.concept,
|
|
517
|
+
onChange: (e) => update("concept", e.target.value)
|
|
518
|
+
}
|
|
519
|
+
)
|
|
520
|
+
] }),
|
|
521
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-2", children: [
|
|
522
|
+
/* @__PURE__ */ jsx(Label, { children: "Folio / Referencia" }),
|
|
523
|
+
/* @__PURE__ */ jsx(
|
|
524
|
+
Input,
|
|
525
|
+
{
|
|
526
|
+
value: formData.reference_code,
|
|
527
|
+
onChange: (e) => update("reference_code", e.target.value)
|
|
528
|
+
}
|
|
529
|
+
)
|
|
530
|
+
] }),
|
|
531
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-2", children: [
|
|
532
|
+
/* @__PURE__ */ jsx(Label, { children: "Institución" }),
|
|
533
|
+
/* @__PURE__ */ jsx(
|
|
534
|
+
Input,
|
|
535
|
+
{
|
|
536
|
+
value: formData.institution,
|
|
537
|
+
onChange: (e) => update("institution", e.target.value)
|
|
538
|
+
}
|
|
539
|
+
)
|
|
540
|
+
] }),
|
|
541
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-2", children: [
|
|
542
|
+
/* @__PURE__ */ jsx(Label, { children: "Nombre del depositante" }),
|
|
543
|
+
/* @__PURE__ */ jsx(
|
|
544
|
+
Input,
|
|
545
|
+
{
|
|
546
|
+
value: formData.depositor_name,
|
|
547
|
+
onChange: (e) => update("depositor_name", e.target.value)
|
|
548
|
+
}
|
|
549
|
+
)
|
|
550
|
+
] }),
|
|
551
|
+
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-x-3", children: [
|
|
552
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-2", children: [
|
|
553
|
+
/* @__PURE__ */ jsx(Label, { children: "Referencia de terminal" }),
|
|
554
|
+
/* @__PURE__ */ jsx(
|
|
555
|
+
Input,
|
|
556
|
+
{
|
|
557
|
+
value: formData.terminal_reference,
|
|
558
|
+
onChange: (e) => update("terminal_reference", e.target.value)
|
|
559
|
+
}
|
|
560
|
+
)
|
|
561
|
+
] }),
|
|
562
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-2", children: [
|
|
563
|
+
/* @__PURE__ */ jsx(Label, { children: "Monto del ticket" }),
|
|
564
|
+
/* @__PURE__ */ jsx(
|
|
565
|
+
Input,
|
|
566
|
+
{
|
|
567
|
+
type: "number",
|
|
568
|
+
step: "0.01",
|
|
569
|
+
value: formData.ticket_amount,
|
|
570
|
+
onChange: (e) => update("ticket_amount", e.target.value)
|
|
571
|
+
}
|
|
572
|
+
)
|
|
573
|
+
] })
|
|
574
|
+
] }),
|
|
575
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-2", children: [
|
|
576
|
+
/* @__PURE__ */ jsx(Label, { children: "Autorizó" }),
|
|
577
|
+
/* @__PURE__ */ jsx(
|
|
578
|
+
Input,
|
|
579
|
+
{
|
|
580
|
+
value: formData.authorizer,
|
|
581
|
+
onChange: (e) => update("authorizer", e.target.value)
|
|
582
|
+
}
|
|
583
|
+
)
|
|
584
|
+
] }),
|
|
585
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-2", children: [
|
|
586
|
+
/* @__PURE__ */ jsx(Label, { children: "Comprobante (URL)" }),
|
|
587
|
+
/* @__PURE__ */ jsx(
|
|
588
|
+
Input,
|
|
589
|
+
{
|
|
590
|
+
value: formData.receipt_file,
|
|
591
|
+
onChange: (e) => update("receipt_file", e.target.value)
|
|
592
|
+
}
|
|
593
|
+
),
|
|
594
|
+
formData.receipt_file && /* @__PURE__ */ jsx(
|
|
595
|
+
"a",
|
|
596
|
+
{
|
|
597
|
+
href: formData.receipt_file,
|
|
598
|
+
target: "_blank",
|
|
599
|
+
rel: "noreferrer",
|
|
600
|
+
className: "text-ui-fg-interactive text-xs",
|
|
601
|
+
children: "Ver comprobante"
|
|
602
|
+
}
|
|
603
|
+
)
|
|
604
|
+
] })
|
|
605
|
+
] }) }),
|
|
606
|
+
/* @__PURE__ */ jsx(Drawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
|
|
607
|
+
/* @__PURE__ */ jsx(Drawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
608
|
+
Button,
|
|
609
|
+
{
|
|
610
|
+
size: "small",
|
|
611
|
+
variant: "secondary",
|
|
612
|
+
disabled: updateMutation.isPending,
|
|
613
|
+
children: "Cancelar"
|
|
614
|
+
}
|
|
615
|
+
) }),
|
|
616
|
+
/* @__PURE__ */ jsx(
|
|
617
|
+
Button,
|
|
618
|
+
{
|
|
619
|
+
size: "small",
|
|
620
|
+
onClick: () => updateMutation.mutate(),
|
|
621
|
+
isLoading: updateMutation.isPending,
|
|
622
|
+
children: "Guardar"
|
|
623
|
+
}
|
|
624
|
+
)
|
|
625
|
+
] }) })
|
|
626
|
+
] }) });
|
|
627
|
+
};
|
|
628
|
+
const DeletePaymentOptionModal = ({
|
|
629
|
+
paymentOption,
|
|
630
|
+
open,
|
|
631
|
+
setOpen
|
|
632
|
+
}) => {
|
|
633
|
+
const queryClient = useQueryClient();
|
|
634
|
+
const deleteMutation = useMutation({
|
|
635
|
+
mutationFn: () => sdk.client.fetch(`/admin/payment-options/${paymentOption.id}`, {
|
|
636
|
+
method: "DELETE"
|
|
637
|
+
}),
|
|
638
|
+
onSuccess: () => {
|
|
639
|
+
queryClient.invalidateQueries({ queryKey: ["payment-options"] });
|
|
640
|
+
toast.success("Nota de pago eliminada");
|
|
641
|
+
setOpen(false);
|
|
642
|
+
},
|
|
643
|
+
onError: (error) => {
|
|
644
|
+
toast.error(error.message || "No se pudo eliminar la nota de pago");
|
|
645
|
+
}
|
|
646
|
+
});
|
|
647
|
+
const label = paymentOption.reference_code || paymentOption.concept || paymentOption.payment_method || paymentOption.id;
|
|
648
|
+
return /* @__PURE__ */ jsx(Prompt, { open, onOpenChange: setOpen, children: /* @__PURE__ */ jsxs(Prompt.Content, { children: [
|
|
649
|
+
/* @__PURE__ */ jsxs(Prompt.Header, { children: [
|
|
650
|
+
/* @__PURE__ */ jsx(Prompt.Title, { children: "Eliminar nota de pago" }),
|
|
651
|
+
/* @__PURE__ */ jsxs(Prompt.Description, { children: [
|
|
652
|
+
'¿Seguro que deseas eliminar la nota de pago "',
|
|
653
|
+
label,
|
|
654
|
+
'"? Esta acción no se puede deshacer.'
|
|
655
|
+
] })
|
|
656
|
+
] }),
|
|
657
|
+
/* @__PURE__ */ jsxs(Prompt.Footer, { children: [
|
|
658
|
+
/* @__PURE__ */ jsx(Prompt.Cancel, { children: "Cancelar" }),
|
|
659
|
+
/* @__PURE__ */ jsx(
|
|
660
|
+
Prompt.Action,
|
|
661
|
+
{
|
|
662
|
+
onClick: () => deleteMutation.mutate(),
|
|
663
|
+
disabled: deleteMutation.isPending,
|
|
664
|
+
children: "Eliminar"
|
|
665
|
+
}
|
|
666
|
+
)
|
|
667
|
+
] })
|
|
668
|
+
] }) });
|
|
669
|
+
};
|
|
670
|
+
const PaymentOptionActions = ({
|
|
671
|
+
paymentOption
|
|
672
|
+
}) => {
|
|
673
|
+
const [editOpen, setEditOpen] = useState(false);
|
|
674
|
+
const [deleteOpen, setDeleteOpen] = useState(false);
|
|
675
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
676
|
+
/* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
677
|
+
/* @__PURE__ */ jsx(DropdownMenu.Trigger, { asChild: true, children: /* @__PURE__ */ jsx(IconButton, { size: "small", variant: "transparent", children: /* @__PURE__ */ jsx(EllipsisHorizontal, {}) }) }),
|
|
678
|
+
/* @__PURE__ */ jsxs(DropdownMenu.Content, { children: [
|
|
679
|
+
/* @__PURE__ */ jsxs(
|
|
680
|
+
DropdownMenu.Item,
|
|
681
|
+
{
|
|
682
|
+
onClick: () => setEditOpen(true),
|
|
683
|
+
className: "gap-x-2",
|
|
684
|
+
children: [
|
|
685
|
+
/* @__PURE__ */ jsx(PencilSquare, { className: "text-ui-fg-subtle" }),
|
|
686
|
+
"Editar"
|
|
687
|
+
]
|
|
688
|
+
}
|
|
689
|
+
),
|
|
690
|
+
/* @__PURE__ */ jsx(DropdownMenu.Separator, {}),
|
|
691
|
+
/* @__PURE__ */ jsxs(
|
|
692
|
+
DropdownMenu.Item,
|
|
693
|
+
{
|
|
694
|
+
onClick: () => setDeleteOpen(true),
|
|
695
|
+
className: "gap-x-2",
|
|
696
|
+
children: [
|
|
697
|
+
/* @__PURE__ */ jsx(Trash, { className: "text-ui-fg-subtle" }),
|
|
698
|
+
"Eliminar"
|
|
699
|
+
]
|
|
700
|
+
}
|
|
701
|
+
)
|
|
702
|
+
] })
|
|
703
|
+
] }),
|
|
704
|
+
/* @__PURE__ */ jsx(
|
|
705
|
+
EditPaymentOptionDrawer,
|
|
706
|
+
{
|
|
707
|
+
paymentOption,
|
|
708
|
+
open: editOpen,
|
|
709
|
+
setOpen: setEditOpen
|
|
710
|
+
}
|
|
711
|
+
),
|
|
712
|
+
/* @__PURE__ */ jsx(
|
|
713
|
+
DeletePaymentOptionModal,
|
|
714
|
+
{
|
|
715
|
+
paymentOption,
|
|
716
|
+
open: deleteOpen,
|
|
717
|
+
setOpen: setDeleteOpen
|
|
718
|
+
}
|
|
719
|
+
)
|
|
720
|
+
] });
|
|
721
|
+
};
|
|
722
|
+
const columnHelper = createDataTableColumnHelper();
|
|
723
|
+
const formatAmount = (value) => {
|
|
724
|
+
const n = Number(value ?? 0);
|
|
725
|
+
return n.toLocaleString("es-MX", {
|
|
726
|
+
minimumFractionDigits: 2,
|
|
727
|
+
maximumFractionDigits: 2
|
|
728
|
+
});
|
|
729
|
+
};
|
|
730
|
+
const statusColor = (status) => {
|
|
731
|
+
switch ((status || "").toLowerCase()) {
|
|
732
|
+
case "paid":
|
|
733
|
+
case "pagado":
|
|
734
|
+
case "approved":
|
|
735
|
+
case "aprobado":
|
|
736
|
+
case "completed":
|
|
737
|
+
return "green";
|
|
738
|
+
case "pending":
|
|
739
|
+
case "pendiente":
|
|
740
|
+
case "in_progress":
|
|
741
|
+
return "orange";
|
|
742
|
+
case "rejected":
|
|
743
|
+
case "rechazado":
|
|
744
|
+
case "failed":
|
|
745
|
+
case "canceled":
|
|
746
|
+
case "cancelled":
|
|
747
|
+
case "cancelado":
|
|
748
|
+
return "red";
|
|
749
|
+
default:
|
|
750
|
+
return "grey";
|
|
751
|
+
}
|
|
752
|
+
};
|
|
753
|
+
const useColumns = () => {
|
|
754
|
+
return useMemo(
|
|
755
|
+
() => [
|
|
756
|
+
columnHelper.accessor("order_display_id", {
|
|
757
|
+
header: "Orden",
|
|
758
|
+
cell: ({ row }) => {
|
|
759
|
+
const displayId = row.original.order_display_id;
|
|
760
|
+
const orderId = row.original.order_id;
|
|
761
|
+
if (!displayId) {
|
|
762
|
+
return "—";
|
|
763
|
+
}
|
|
764
|
+
if (!orderId) {
|
|
765
|
+
return `#${displayId}`;
|
|
766
|
+
}
|
|
767
|
+
return /* @__PURE__ */ jsxs(
|
|
768
|
+
"a",
|
|
769
|
+
{
|
|
770
|
+
href: `/app/orders/${orderId}`,
|
|
771
|
+
className: "text-ui-fg-interactive hover:underline",
|
|
772
|
+
onClick: (e) => e.stopPropagation(),
|
|
773
|
+
children: [
|
|
774
|
+
"#",
|
|
775
|
+
displayId
|
|
776
|
+
]
|
|
777
|
+
}
|
|
778
|
+
);
|
|
779
|
+
}
|
|
780
|
+
}),
|
|
781
|
+
columnHelper.accessor("reference_code", {
|
|
782
|
+
header: "Folio / Referencia",
|
|
783
|
+
cell: ({ getValue }) => getValue() || "—"
|
|
784
|
+
}),
|
|
785
|
+
columnHelper.accessor("payment_method", {
|
|
786
|
+
header: "Método",
|
|
787
|
+
cell: ({ getValue }) => getValue() || "—"
|
|
788
|
+
}),
|
|
789
|
+
columnHelper.accessor("amount", {
|
|
790
|
+
header: "Monto",
|
|
791
|
+
cell: ({ getValue }) => formatAmount(getValue())
|
|
792
|
+
}),
|
|
793
|
+
columnHelper.accessor("status", {
|
|
794
|
+
header: "Estatus",
|
|
795
|
+
cell: ({ getValue }) => {
|
|
796
|
+
const status = getValue();
|
|
797
|
+
if (!status) {
|
|
798
|
+
return "—";
|
|
799
|
+
}
|
|
800
|
+
return /* @__PURE__ */ jsx(Badge, { size: "2xsmall", color: statusColor(status), children: status });
|
|
801
|
+
}
|
|
802
|
+
}),
|
|
803
|
+
columnHelper.accessor("concept", {
|
|
804
|
+
header: "Concepto",
|
|
805
|
+
cell: ({ getValue }) => getValue() || "—"
|
|
806
|
+
}),
|
|
807
|
+
columnHelper.accessor("created_at", {
|
|
808
|
+
header: "Fecha",
|
|
809
|
+
cell: ({ getValue }) => new Date(getValue()).toLocaleString()
|
|
810
|
+
}),
|
|
811
|
+
columnHelper.display({
|
|
812
|
+
id: "actions",
|
|
813
|
+
cell: ({ row }) => /* @__PURE__ */ jsx(PaymentOptionActions, { paymentOption: row.original })
|
|
814
|
+
})
|
|
815
|
+
],
|
|
816
|
+
[]
|
|
817
|
+
);
|
|
818
|
+
};
|
|
819
|
+
const PaymentOptionTable = () => {
|
|
820
|
+
const [searchValue, setSearchValue] = useState("");
|
|
821
|
+
const [pagination, setPagination] = useState({
|
|
822
|
+
pageIndex: 0,
|
|
823
|
+
pageSize: 15
|
|
824
|
+
});
|
|
825
|
+
const limit = pagination.pageSize;
|
|
826
|
+
const offset = pagination.pageIndex * limit;
|
|
827
|
+
const { data, isLoading } = useQuery({
|
|
828
|
+
queryFn: () => sdk.client.fetch("/admin/payment-options", {
|
|
829
|
+
query: {
|
|
830
|
+
limit,
|
|
831
|
+
offset,
|
|
832
|
+
q: searchValue || void 0
|
|
833
|
+
}
|
|
834
|
+
}),
|
|
835
|
+
queryKey: ["payment-options", limit, offset, searchValue],
|
|
836
|
+
placeholderData: (previousData) => previousData
|
|
837
|
+
});
|
|
838
|
+
const columns = useColumns();
|
|
839
|
+
const table = useDataTable({
|
|
840
|
+
data: (data == null ? void 0 : data.payment_options) || [],
|
|
841
|
+
columns,
|
|
842
|
+
getRowId: (row) => row.id,
|
|
843
|
+
rowCount: (data == null ? void 0 : data.count) || 0,
|
|
844
|
+
isLoading,
|
|
845
|
+
search: {
|
|
846
|
+
state: searchValue,
|
|
847
|
+
onSearchChange: setSearchValue
|
|
848
|
+
},
|
|
849
|
+
pagination: {
|
|
850
|
+
state: pagination,
|
|
851
|
+
onPaginationChange: setPagination
|
|
852
|
+
}
|
|
853
|
+
});
|
|
854
|
+
return /* @__PURE__ */ jsxs(DataTable, { instance: table, children: [
|
|
855
|
+
/* @__PURE__ */ jsx(DataTable.Toolbar, { children: /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between gap-x-2", children: [
|
|
856
|
+
/* @__PURE__ */ jsxs(Text, { size: "small", className: "text-ui-fg-subtle", children: [
|
|
857
|
+
(data == null ? void 0 : data.count) ?? 0,
|
|
858
|
+
" notas"
|
|
859
|
+
] }),
|
|
860
|
+
/* @__PURE__ */ jsx(DataTable.Search, { placeholder: "Buscar por orden, folio, concepto, método..." })
|
|
861
|
+
] }) }),
|
|
862
|
+
/* @__PURE__ */ jsx(DataTable.Table, {}),
|
|
863
|
+
/* @__PURE__ */ jsx(DataTable.Pagination, {})
|
|
864
|
+
] });
|
|
865
|
+
};
|
|
866
|
+
const PaymentOptionsPage = () => {
|
|
867
|
+
return /* @__PURE__ */ jsxs(Container, { className: "flex flex-col items-stretch overflow-hidden p-0", children: [
|
|
868
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center justify-between border-b border-ui-border-base px-6 py-4", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-1", children: [
|
|
869
|
+
/* @__PURE__ */ jsx(Heading, { level: "h2", children: "Notas de pago (POS)" }),
|
|
870
|
+
/* @__PURE__ */ jsx(Text, { size: "small", className: "text-ui-fg-subtle", children: "Revisa, edita o elimina las notas de pago registradas desde el POS." })
|
|
871
|
+
] }) }),
|
|
872
|
+
/* @__PURE__ */ jsx(PaymentOptionTable, {})
|
|
873
|
+
] });
|
|
874
|
+
};
|
|
875
|
+
const config = defineRouteConfig({
|
|
876
|
+
label: "Notas de pago",
|
|
877
|
+
icon: CurrencyDollar
|
|
878
|
+
});
|
|
390
879
|
const i18nTranslations0 = {};
|
|
391
880
|
const widgetModule = { widgets: [] };
|
|
392
881
|
const routeModule = {
|
|
@@ -394,15 +883,27 @@ const routeModule = {
|
|
|
394
883
|
{
|
|
395
884
|
Component: OperatorsPage,
|
|
396
885
|
path: "/operators"
|
|
886
|
+
},
|
|
887
|
+
{
|
|
888
|
+
Component: PaymentOptionsPage,
|
|
889
|
+
path: "/payment-options"
|
|
397
890
|
}
|
|
398
891
|
]
|
|
399
892
|
};
|
|
400
893
|
const menuItemModule = {
|
|
401
894
|
menuItems: [
|
|
895
|
+
{
|
|
896
|
+
label: config$1.label,
|
|
897
|
+
icon: config$1.icon,
|
|
898
|
+
path: "/operators",
|
|
899
|
+
nested: void 0,
|
|
900
|
+
rank: void 0,
|
|
901
|
+
translationNs: void 0
|
|
902
|
+
},
|
|
402
903
|
{
|
|
403
904
|
label: config.label,
|
|
404
905
|
icon: config.icon,
|
|
405
|
-
path: "/
|
|
906
|
+
path: "/payment-options",
|
|
406
907
|
nested: void 0,
|
|
407
908
|
rank: void 0,
|
|
408
909
|
translationNs: void 0
|
|
@@ -11,6 +11,9 @@ const GET = async (req, res) => {
|
|
|
11
11
|
const withInventoryQuantity = req.queryConfig.fields.some((field) => field.includes("variants.inventory_quantity"));
|
|
12
12
|
if (withInventoryQuantity) {
|
|
13
13
|
req.queryConfig.fields = req.queryConfig.fields.filter((field) => !field.includes("variants.inventory_quantity"));
|
|
14
|
+
if (!req.queryConfig.fields.includes("variants.manage_inventory")) {
|
|
15
|
+
req.queryConfig.fields.push("variants.manage_inventory");
|
|
16
|
+
}
|
|
14
17
|
}
|
|
15
18
|
const filters = {
|
|
16
19
|
id: req.params.id,
|
|
@@ -39,7 +42,7 @@ const GET = async (req, res) => {
|
|
|
39
42
|
throw new utils_1.MedusaError(utils_1.MedusaError.Types.NOT_FOUND, `Product with id: ${req.params.id} was not found`);
|
|
40
43
|
}
|
|
41
44
|
if (withInventoryQuantity) {
|
|
42
|
-
await (0, helpers_1.wrapVariantsWithInventoryQuantity)(req, product.variants || [], (0, helpers_1.
|
|
45
|
+
await (0, helpers_1.wrapVariantsWithInventoryQuantity)(req, product.variants || [], (0, helpers_1.getInventoryScope)(req));
|
|
43
46
|
}
|
|
44
47
|
if (includesCategoriesField) {
|
|
45
48
|
(0, helpers_1.filterOutInternalProductCategories)([product]);
|
|
@@ -48,4 +51,4 @@ const GET = async (req, res) => {
|
|
|
48
51
|
res.json({ product });
|
|
49
52
|
};
|
|
50
53
|
exports.GET = GET;
|
|
51
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
54
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicm91dGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi8uLi9zcmMvYXBpL2FkbWluL25ldG1lLXBvcy9wcm9kdWN0cy9baWRdL3JvdXRlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUNBLHFEQUlrQztBQUNsQyx3Q0FNbUI7QUFFbkI7OztHQUdHO0FBQ0ksTUFBTSxHQUFHLEdBQUcsS0FBSyxFQUFFLEdBQXVCLEVBQUUsR0FBbUIsRUFBRSxFQUFFO0lBQ3hFLE1BQU0scUJBQXFCLEdBQUcsR0FBRyxDQUFDLFdBQVcsQ0FBQyxNQUFNLENBQUMsSUFBSSxDQUFDLENBQUMsS0F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