first commit
This commit is contained in:
263
assets/marketplaces.lazy-Ci7Q3pIV.js
Normal file
263
assets/marketplaces.lazy-Ci7Q3pIV.js
Normal file
@ -0,0 +1,263 @@
|
||||
import {ad as v, aS as T, $ as I, r as h, aT as p, ac as u, aU as S, aV as B, j as e, a4 as m, aW as _, a1 as R, a2 as b, e as P, X as w, a3 as j, a5 as E, a6 as q, a7 as C, t as A, s as M, N as D, c as F} from "./index-CdMy-Rhi.js";
|
||||
/**
|
||||
* @license @tabler/icons-react v3.21.0 - MIT
|
||||
*
|
||||
* This source code is licensed under the MIT license.
|
||||
* See the LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
var N = v("outline", "refresh", "IconRefresh", [["path", {
|
||||
d: "M20 11a8.1 8.1 0 0 0 -15.5 -2m-.5 -4v4h4",
|
||||
key: "svg-0"
|
||||
}], ["path", {
|
||||
d: "M4 13a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4",
|
||||
key: "svg-1"
|
||||
}]]);
|
||||
const $ = "_container_b84hd_1"
|
||||
, y = {
|
||||
container: $,
|
||||
"top-panel": "_top-panel_b84hd_8",
|
||||
"top-panel-last-item": "_top-panel-last-item_b84hd_14"
|
||||
}
|
||||
, z = () => {
|
||||
const s = T()
|
||||
, o = I(a => a.tasks.tasks)
|
||||
, [l,f] = h.useState()
|
||||
, [i,d] = h.useState([])
|
||||
, c = async () => {
|
||||
l && p.getClientMarketplaces({
|
||||
requestBody: {
|
||||
clientId: l.id
|
||||
}
|
||||
}).then(a => {
|
||||
d(a.marketplaces)
|
||||
}
|
||||
)
|
||||
}
|
||||
, x = a => {
|
||||
p.createMarketplace({
|
||||
requestBody: {
|
||||
marketplace: {
|
||||
...a,
|
||||
clientId: a.client.id,
|
||||
baseMarketplaceKey: a.baseMarketplace.key
|
||||
}
|
||||
}
|
||||
}).then(async ({ok: n, message: r}) => {
|
||||
u.guess(n, {
|
||||
message: r
|
||||
}),
|
||||
n && await c()
|
||||
}
|
||||
)
|
||||
}
|
||||
, k = a => {
|
||||
p.deleteMarketplace({
|
||||
requestBody: {
|
||||
marketplaceId: a.id
|
||||
}
|
||||
}).then(async ({ok: n, message: r}) => {
|
||||
u.guess(n, {
|
||||
message: r
|
||||
}),
|
||||
n && await c()
|
||||
}
|
||||
)
|
||||
}
|
||||
, g = a => {
|
||||
p.updateMarketplace({
|
||||
requestBody: {
|
||||
marketplace: a
|
||||
}
|
||||
}).then(async ({ok: n, message: r}) => {
|
||||
u.guess(n, {
|
||||
message: r
|
||||
}),
|
||||
n && await c()
|
||||
}
|
||||
)
|
||||
}
|
||||
, t = a => {
|
||||
if (o.find(r => r.info.marketplaceId === a.id)) {
|
||||
u.error({
|
||||
title: "Ошибка",
|
||||
message: `Синхронизация маркетплейса ${a.name} уже запущена`
|
||||
});
|
||||
return
|
||||
}
|
||||
S.createSynchronizeMarketplaceTask({
|
||||
requestBody: {
|
||||
marketplaceId: a.id
|
||||
}
|
||||
}).then( ({taskId: r}) => {
|
||||
s(B({
|
||||
id: r,
|
||||
config: {
|
||||
onErrorData: {
|
||||
title: "Ошибка",
|
||||
message: `Ошибка синхронизации маркетплейса: ${a.name}`
|
||||
},
|
||||
onLoadingData: {
|
||||
title: "Синхронизация",
|
||||
message: `Синхронизация маркетплейса: ${a.name}`
|
||||
},
|
||||
onSuccessData: {
|
||||
title: "Успех",
|
||||
message: `Маркетплейс ${a.name} успешно синхронизирован`
|
||||
}
|
||||
},
|
||||
info: {
|
||||
marketplaceId: a.id
|
||||
}
|
||||
}))
|
||||
}
|
||||
)
|
||||
}
|
||||
;
|
||||
return h.useEffect( () => {
|
||||
c()
|
||||
}
|
||||
, [l]),
|
||||
{
|
||||
client: l,
|
||||
setClient: f,
|
||||
items: i,
|
||||
onDelete: k,
|
||||
onChange: g,
|
||||
onCreate: x,
|
||||
onSynchronize: t
|
||||
}
|
||||
}
|
||||
, K = () => h.useMemo( () => [{
|
||||
header: "Маркетплейс",
|
||||
size: 10,
|
||||
Cell: ({row: s}) => {
|
||||
var o;
|
||||
return e.jsx(m, {
|
||||
variant: "transparent",
|
||||
children: e.jsx(_, {
|
||||
src: ((o = s.original.baseMarketplace) == null ? void 0 : o.iconUrl) || ""
|
||||
})
|
||||
})
|
||||
}
|
||||
}, {
|
||||
accessorKey: "name",
|
||||
header: "Название",
|
||||
enableSorting: !1
|
||||
}, {
|
||||
accessorKey: "client.name",
|
||||
header: "Клиент",
|
||||
enableSorting: !1
|
||||
}], [])
|
||||
, L = ({onDelete: s, onChange: o, onCreate: l, items: f, client: i, onSynchronize: d}) => {
|
||||
const c = K()
|
||||
, x = t => {
|
||||
s && C.openConfirmModal({
|
||||
title: "Удаление маркетплейса",
|
||||
children: e.jsxs(A, {
|
||||
size: "sm",
|
||||
children: ["Вы уверены что хотите удалить маркетплейс ", t.name]
|
||||
}),
|
||||
labels: {
|
||||
confirm: "Да",
|
||||
cancel: "Нет"
|
||||
},
|
||||
confirmProps: {
|
||||
color: "red"
|
||||
},
|
||||
onConfirm: () => s(t)
|
||||
})
|
||||
}
|
||||
, k = t => {
|
||||
o && C.openContextModal({
|
||||
modal: "marketplaceFormModal",
|
||||
withCloseButton: !1,
|
||||
innerProps: {
|
||||
onChange: a => o(a),
|
||||
element: t
|
||||
}
|
||||
})
|
||||
}
|
||||
, g = () => {
|
||||
!l || !i || C.openContextModal({
|
||||
modal: "marketplaceFormModal",
|
||||
withCloseButton: !1,
|
||||
innerProps: {
|
||||
onCreate: t => l({
|
||||
...t,
|
||||
client: i
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
;
|
||||
return e.jsx(R, {
|
||||
data: f,
|
||||
columns: c,
|
||||
restProps: {
|
||||
enableSorting: !1,
|
||||
enableColumnActions: !1,
|
||||
enableTopToolbar: !0,
|
||||
renderTopToolbar: e.jsx(b, {
|
||||
p: P(10),
|
||||
justify: "end",
|
||||
children: e.jsx(w, {
|
||||
disabled: !i,
|
||||
variant: "default",
|
||||
onClick: () => g(),
|
||||
children: "Добавить"
|
||||
})
|
||||
}),
|
||||
enableRowActions: !0,
|
||||
renderRowActions: ({row: t}) => e.jsxs(b, {
|
||||
gap: "md",
|
||||
children: [e.jsx(j, {
|
||||
label: "Редактировать",
|
||||
children: e.jsx(m, {
|
||||
onClick: () => k(t.original),
|
||||
variant: "default",
|
||||
children: e.jsx(E, {})
|
||||
})
|
||||
}), e.jsx(j, {
|
||||
label: "Удалить",
|
||||
children: e.jsx(m, {
|
||||
onClick: () => x(t.original),
|
||||
variant: "default",
|
||||
children: e.jsx(q, {})
|
||||
})
|
||||
}), e.jsx(j, {
|
||||
label: "Синхронизировать",
|
||||
children: e.jsx(m, {
|
||||
onClick: () => d && d(t.original),
|
||||
variant: "default",
|
||||
children: e.jsx(N, {})
|
||||
})
|
||||
})]
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
, U = () => {
|
||||
const s = z();
|
||||
return e.jsxs("div", {
|
||||
className: y.container,
|
||||
children: [e.jsx(M, {
|
||||
children: e.jsx("div", {
|
||||
className: y["top-panel"],
|
||||
children: e.jsx(D, {
|
||||
placeholder: "Выберите клиента",
|
||||
onChange: s.setClient
|
||||
})
|
||||
})
|
||||
}), e.jsx(M, {
|
||||
children: e.jsx(e.Fragment, {
|
||||
children: e.jsx(L, {
|
||||
...s
|
||||
})
|
||||
})
|
||||
})]
|
||||
})
|
||||
}
|
||||
, W = F("/marketplaces")({
|
||||
component: U
|
||||
});
|
||||
export {W as Route};
|
||||
Reference in New Issue
Block a user