149 lines
4.1 KiB
JavaScript
149 lines
4.1 KiB
JavaScript
import {r as j, j as e, aD as C, aF as f, a1 as B, a2 as T, a3 as m, a4 as p, a5 as g, a6 as y, a7 as b, b1 as F, s as x, X as I, b2 as d, ac as u, c as k} from "./index-CdMy-Rhi.js";
|
|
const v = "_container_kxb8n_1"
|
|
, h = {
|
|
container: v,
|
|
"top-panel": "_top-panel_kxb8n_8"
|
|
}
|
|
, w = () => j.useMemo( () => [{
|
|
accessorKey: "name",
|
|
header: "Название"
|
|
}, {
|
|
accessorKey: "attributes",
|
|
header: "Атрибуты",
|
|
Cell: ({row: n}) => e.jsx(e.Fragment, {
|
|
children: n.original.attributes.map(s => s.name).join(", ")
|
|
})
|
|
}, {
|
|
accessorKey: "size.name",
|
|
header: "Размер"
|
|
}, {
|
|
accessorKey: "isDefault",
|
|
header: "По умолчанию",
|
|
Cell: ({row: n}) => n.original.isDefault ? e.jsx(C, {}) : e.jsx(f, {})
|
|
}], [])
|
|
, _ = ({items: n, onDelete: s, onChange: c}) => {
|
|
const i = w()
|
|
, l = o => {
|
|
c && b.openContextModal({
|
|
modal: "barcodeTemplateFormModal",
|
|
title: "Создание шаблона",
|
|
withCloseButton: !1,
|
|
innerProps: {
|
|
onChange: t => c(t),
|
|
element: o
|
|
}
|
|
})
|
|
}
|
|
;
|
|
return e.jsx(e.Fragment, {
|
|
children: e.jsx(B, {
|
|
striped: !0,
|
|
data: n,
|
|
columns: i,
|
|
restProps: {
|
|
enableColumnActions: !1,
|
|
enableRowActions: !0,
|
|
renderRowActions: ({row: o}) => e.jsxs(T, {
|
|
gap: "md",
|
|
children: [e.jsx(m, {
|
|
label: "Редактировать",
|
|
children: e.jsx(p, {
|
|
onClick: () => l(o.original),
|
|
variant: "default",
|
|
children: e.jsx(g, {})
|
|
})
|
|
}), e.jsx(m, {
|
|
label: "Удалить",
|
|
children: e.jsx(p, {
|
|
onClick: () => {
|
|
s && s(o.original)
|
|
}
|
|
,
|
|
variant: "default",
|
|
children: e.jsx(y, {})
|
|
})
|
|
})]
|
|
})
|
|
}
|
|
})
|
|
})
|
|
}
|
|
, A = () => {
|
|
const {barcodeTemplates: n, refetch: s} = F()
|
|
, c = t => {
|
|
d.createBarcodeTemplate({
|
|
requestBody: {
|
|
...t,
|
|
attributeIds: t.attributes.map(a => a.id)
|
|
}
|
|
}).then(async ({ok: a, message: r}) => {
|
|
u.guess(a, {
|
|
message: r
|
|
}),
|
|
a && await s()
|
|
}
|
|
)
|
|
}
|
|
, i = t => {
|
|
d.updateBarcodeTemplate({
|
|
requestBody: {
|
|
...t,
|
|
attributeIds: t.attributes.map(a => a.id)
|
|
}
|
|
}).then(async ({ok: a, message: r}) => {
|
|
u.guess(a, {
|
|
message: r
|
|
}),
|
|
a && await s()
|
|
}
|
|
)
|
|
}
|
|
, l = t => {
|
|
d.deleteBarcodeTemplate({
|
|
requestBody: {
|
|
id: t.id
|
|
}
|
|
}).then(async ({ok: a, message: r}) => {
|
|
u.guess(a, {
|
|
message: r
|
|
}),
|
|
a && await s()
|
|
}
|
|
)
|
|
}
|
|
, o = () => {
|
|
b.openContextModal({
|
|
modal: "barcodeTemplateFormModal",
|
|
title: "Создание шаблона",
|
|
withCloseButton: !1,
|
|
innerProps: {
|
|
onCreate: c
|
|
}
|
|
})
|
|
}
|
|
;
|
|
return e.jsxs("div", {
|
|
className: h.container,
|
|
children: [e.jsx(x, {
|
|
children: e.jsx("div", {
|
|
className: h["top-panel"],
|
|
children: e.jsx(I, {
|
|
onClick: () => o(),
|
|
variant: "default",
|
|
children: "Создать шаблон"
|
|
})
|
|
})
|
|
}), e.jsx(x, {
|
|
children: e.jsx(_, {
|
|
items: n,
|
|
onChange: i,
|
|
onDelete: l
|
|
})
|
|
})]
|
|
})
|
|
}
|
|
, P = k("/barcode")({
|
|
component: A
|
|
});
|
|
export {P as Route};
|