first commit

This commit is contained in:
2025-07-24 20:14:43 +03:00
commit 4423badefd
30 changed files with 131277 additions and 0 deletions

View File

@ -0,0 +1,265 @@
import {i as w, r as i, j as e, aJ as L, a1 as M, a2 as y, a3 as C, a4 as P, aH as N, a5 as R, a6 as k, a7 as f, aK as A, aA as E, s as S, e as F, az as q, X as H, aL as D, aM as V, aN as b, ac as g, t as J, c as X} from "./index-CdMy-Rhi.js";
import {s as d} from "./ProductsPage.module-BjEXBNuV.js";
import {L as z} from "./List-Xt0hH74q.js";
const G = () => {
const n = w();
return i.useMemo( () => [{
accessorKey: "article",
header: "Артикул",
enableSorting: !1,
size: 100
}, {
accessorKey: "factoryArticle",
header: "Складской артикул",
enableSorting: !1,
size: 100
}, {
accessorKey: "name",
header: "Название",
enableSorting: !1,
size: 150
}, {
accessorKey: "barcodes",
header: "Штрихкоды",
Cell: ({cell: o}) => e.jsx(z, {
size: "sm",
children: e.jsx(L, {
maxHeight: parseFloat(n.lineHeights.sm) * 25,
showLabel: "Показать все",
hideLabel: "Скрыть",
children: o.getValue().map(r => e.jsx(z.Item, {
children: r
}, r))
})
}),
enableSorting: !1,
size: 50
}, {
accessorKey: "barcodeTemplate.name",
header: "Шаблон штрихкода",
enableSorting: !1,
size: 50
}, {
accessorKey: "brand",
header: "Бренд",
enableSorting: !1,
size: 50
}, {
accessorKey: "composition",
header: "Состав",
enableSorting: !1,
size: 50
}, {
accessorKey: "color",
header: "Цвет",
enableSorting: !1,
size: 50
}, {
accessorKey: "size",
header: "Размер",
enableSorting: !1,
size: 50
}, {
accessorKey: "additionalInfo",
header: "Доп. информация",
enableSorting: !1,
size: 120
}], [])
}
, O = ({items: n, onDelete: o, onChange: r, tableRef: x}) => {
const c = G()
, u = s => {
r && f.openContextModal({
modal: "createProduct",
title: "Создание товара",
withCloseButton: !1,
innerProps: {
onChange: p => r(p),
product: s
}
})
}
, h = s => {
f.openContextModal({
modal: "printBarcode",
title: "Печать штрихкода",
withCloseButton: !0,
innerProps: {
productId: s.id
}
})
}
;
return e.jsx(M, {
ref: x,
data: n,
columns: c,
restProps: {
enableColumnActions: !1,
enableRowActions: !0,
renderRowActions: ({row: s}) => e.jsxs(y, {
gap: "md",
children: [e.jsx(C, {
label: "Печать штрихкода",
children: e.jsx(P, {
onClick: () => h(s.original),
variant: "default",
children: e.jsx(N, {})
})
}), e.jsx(C, {
label: "Редактировать",
children: e.jsx(P, {
onClick: () => u(s.original),
variant: "default",
children: e.jsx(R, {})
})
}), e.jsx(C, {
label: "Удалить",
children: e.jsx(P, {
onClick: () => {
o && o(s.original)
}
,
variant: "default",
children: e.jsx(k, {})
})
})]
})
}
})
}
, Q = () => {
const [n,o] = i.useState(-1)
, [r,x] = i.useState(1)
, [c,u] = i.useState(1)
, [h,s] = i.useState("")
, [p] = A(h, 500)
, {products: I, paginationInfo: m, refetch: j} = E({
clientId: n,
page: c - 1,
itemsPerPage: 10,
searchInput: p
})
, v = a => {
b.createProduct({
requestBody: a
}).then(async ({ok: t, message: l}) => {
g.guess(t, {
message: l
}),
t && await j()
}
)
}
, B = a => {
b.updateProduct({
requestBody: {
product: a
}
}).then(async ({ok: t, message: l}) => {
g.guess(t, {
message: l
}),
t && await j()
}
)
}
, K = () => {
if (n < 0) {
g.error({
message: "Необходимо выбрать клиента"
});
return
}
f.openContextModal({
modal: "createProduct",
title: "Создание товара",
withCloseButton: !1,
innerProps: {
clientId: n,
onCreate: v
}
})
}
, T = a => {
f.openConfirmModal({
title: "Удаление товара",
children: e.jsxs(J, {
size: "sm",
children: ["Вы уверены что хотите удалить товар ", a.name]
}),
labels: {
confirm: "Да",
cancel: "Нет"
},
confirmProps: {
color: "red"
},
onConfirm: () => b.deleteProduct({
requestBody: {
productId: a.id
}
}).then(async ({ok: t, message: l}) => {
g.guess(t, {
message: l
}),
t && await j()
}
)
})
}
;
return i.useEffect( () => {
m && (x(m.totalPages),
c > m.totalPages && u(1))
}
, [m]),
e.jsx(e.Fragment, {
children: e.jsxs("div", {
className: d.container,
children: [e.jsx(S, {
children: e.jsxs("div", {
className: d["top-panel"],
children: [e.jsxs(y, {
gap: F(10),
children: [e.jsx(q, {
onChange: a => o(a.id)
}), e.jsx(H, {
onClick: () => K(),
variant: "default",
children: "Создать"
})]
}), e.jsx(y, {
children: e.jsx(D, {
placeholder: "Артикул, название, шк",
onChange: a => s(a.currentTarget.value),
value: h
})
})]
})
}), e.jsx(S, {
children: e.jsx("div", {
className: d["body-container"],
children: e.jsxs("div", {
className: d["table-container"],
children: [e.jsx(O, {
onChange: B,
onDelete: T,
items: I
}), e.jsx(V, {
className: d["table-pagination"],
withEdges: !0,
onChange: a => u(a),
total: r,
value: c
})]
})
})
})]
})
})
}
, Z = X("/products")({
component: Q
});
export {Z as Route};