bananas-commerce-admin 0.19.5 → 0.19.7
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/dist/esm/components/Card/CardPill.js +18 -2
- package/dist/esm/components/Card/CardPill.js.map +1 -1
- package/dist/esm/components/Chip.js +3 -0
- package/dist/esm/components/Chip.js.map +1 -1
- package/dist/esm/extensions/catalog/components/ArticleCard.js +2 -0
- package/dist/esm/extensions/catalog/components/ArticleCard.js.map +1 -1
- package/dist/esm/extensions/catalog/contrib/SiteAvailability.js +66 -0
- package/dist/esm/extensions/catalog/contrib/SiteAvailability.js.map +1 -0
- package/dist/esm/extensions/catalog/index.js +13 -0
- package/dist/esm/extensions/catalog/index.js.map +1 -1
- package/dist/esm/extensions/catalog/pages/article/detail.js +51 -1
- package/dist/esm/extensions/catalog/pages/article/detail.js.map +1 -1
- package/dist/esm/extensions/catalog/types/contrib.js +2 -0
- package/dist/esm/extensions/catalog/types/contrib.js.map +1 -0
- package/dist/types/components/Card/CardPill.d.ts +1 -0
- package/dist/types/components/Card/shared.d.ts +1 -1
- package/dist/types/extensions/catalog/contrib/SiteAvailability.d.ts +4 -0
- package/dist/types/extensions/catalog/index.d.ts +3 -1
- package/dist/types/extensions/catalog/types/article.d.ts +7 -0
- package/dist/types/extensions/catalog/types/contrib.d.ts +15 -0
- package/package.json +1 -1
- package/src/components/Card/CardPill.tsx +24 -2
- package/src/components/Card/shared.ts +1 -1
- package/src/components/Chip.tsx +3 -0
- package/src/extensions/catalog/components/ArticleCard.tsx +2 -0
- package/src/extensions/catalog/contrib/SiteAvailability.tsx +138 -0
- package/src/extensions/catalog/index.tsx +16 -1
- package/src/extensions/catalog/pages/article/detail.tsx +78 -0
- package/src/extensions/catalog/types/article.ts +8 -0
- package/src/extensions/catalog/types/contrib.ts +16 -0
|
@@ -1,10 +1,26 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import CancelIcon from "@mui/icons-material/Cancel";
|
|
3
3
|
import CheckCircleIcon from "@mui/icons-material/CheckCircle";
|
|
4
|
+
import WarningIcon from "@mui/icons-material/Warning";
|
|
4
5
|
import Chip from "../Chip";
|
|
5
6
|
// TODO Logic for picking icon
|
|
6
|
-
export const CardPill = ({ label, color, icon, size = "small" }) => {
|
|
7
|
-
|
|
7
|
+
export const CardPill = ({ label, color, icon, size = "small", variant, }) => {
|
|
8
|
+
let resolvedIcon;
|
|
9
|
+
if (icon === undefined) {
|
|
10
|
+
if (color === "success") {
|
|
11
|
+
resolvedIcon = React.createElement(CheckCircleIcon, null);
|
|
12
|
+
}
|
|
13
|
+
else if (color === "warning") {
|
|
14
|
+
resolvedIcon = React.createElement(WarningIcon, null);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
resolvedIcon = React.createElement(CancelIcon, null);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
resolvedIcon = icon ?? undefined;
|
|
22
|
+
}
|
|
23
|
+
return (React.createElement(Chip, { color: color ?? "success", icon: resolvedIcon, label: label, size: size, variant: variant }));
|
|
8
24
|
};
|
|
9
25
|
export default CardPill;
|
|
10
26
|
//# sourceMappingURL=CardPill.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CardPill.js","sourceRoot":"","sources":["../../../../src/components/Card/CardPill.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,UAAU,MAAM,4BAA4B,CAAC;AACpD,OAAO,eAAe,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"CardPill.js","sourceRoot":"","sources":["../../../../src/components/Card/CardPill.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,UAAU,MAAM,4BAA4B,CAAC;AACpD,OAAO,eAAe,MAAM,iCAAiC,CAAC;AAC9D,OAAO,WAAW,MAAM,6BAA6B,CAAC;AAItD,OAAO,IAAI,MAAM,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,CAAC,CACH,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
1
|
+
{"version":3,"file":"Chip.js","sourceRoot":"","sources":["../../../src/components/Chip.tsx"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,oBAAoB,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,MAAM,CAAC,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAChD,KAAK,CAAC,WAAW,CAAC;IAChB,YAAY,EAAE,CAAC;IACf,qBAAqB,EAAE;QACrB,MAAM,EAAE,EAAE;KACX;IACD,sBAAsB,EAAE;QACtB,EAAE,EAAE,CAAC;KACN;IACD,gBAAgB,EAAE;QAChB,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,iBAAiB;KAC/C;CACF,CAAC,CACH,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -22,6 +22,7 @@ export const ArticleCard = ({ article, create, onCreated, onUpdated, }) => {
|
|
|
22
22
|
const { t } = useI18n();
|
|
23
23
|
const { user } = useUser();
|
|
24
24
|
article ??= {
|
|
25
|
+
id: 0,
|
|
25
26
|
name: "",
|
|
26
27
|
variant: "",
|
|
27
28
|
item_type: "",
|
|
@@ -31,6 +32,7 @@ export const ArticleCard = ({ article, create, onCreated, onUpdated, }) => {
|
|
|
31
32
|
gtin: "",
|
|
32
33
|
tax_code: "",
|
|
33
34
|
is_active: true,
|
|
35
|
+
variants: [],
|
|
34
36
|
};
|
|
35
37
|
const handleSave = useCallback(async (values) => {
|
|
36
38
|
if (create != null) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArticleCard.js","sourceRoot":"","sources":["../../../../../src/extensions/catalog/components/ArticleCard.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,M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C,KAAK,EAAC,OAAO,EAAC,QAAQ,EAAC,OAAO,GAAG,EACtD,KAAK,EAAE,OAAO,CAAC,SAAS,EACxB,QAAQ,EAAE,oBAAC,eAAe,IAAC,KAAK,EAAC,SAAS,EAAC,QAAQ,EAAC,OAAO,GAAG,GAC9D,CACD,CACJ,CACO,CACT,CACJ,CACW;QAEd,oBAAC,WAAW;YACT,CAAC,MAAM,IAAI,oBAAC,gBAAgB,OAAG;YAChC,oBAAC,cAAc,IAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,GAAI,CACzC,CACT,CACR,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import LocalOfferOutlinedIcon from "@mui/icons-material/LocalOfferOutlined";
|
|
3
|
+
import ReportIcon from "@mui/icons-material/Report";
|
|
4
|
+
import WarningIcon from "@mui/icons-material/Warning";
|
|
5
|
+
import { Grid2 as Grid, Stack, Typography } from "@mui/material";
|
|
6
|
+
import Card from "../../../components/Card";
|
|
7
|
+
import CardContent from "../../../components/Card/CardContent";
|
|
8
|
+
import CardHeader from "../../../components/Card/CardHeader";
|
|
9
|
+
import CardPill from "../../../components/Card/CardPill";
|
|
10
|
+
import Content from "../../../containers/Content";
|
|
11
|
+
const parseStatus = (value) => {
|
|
12
|
+
if (!value) {
|
|
13
|
+
return { codes: [] };
|
|
14
|
+
}
|
|
15
|
+
const trimmed = value.trim();
|
|
16
|
+
const match = /^([^[]+)\[([^\]]*)\]>?$/.exec(trimmed);
|
|
17
|
+
if (!match) {
|
|
18
|
+
return { label: trimmed, codes: [] };
|
|
19
|
+
}
|
|
20
|
+
const [, label, codes] = match;
|
|
21
|
+
return {
|
|
22
|
+
label: label.trim(),
|
|
23
|
+
codes: codes
|
|
24
|
+
.split(",")
|
|
25
|
+
.map((code) => code.trim())
|
|
26
|
+
.filter(Boolean),
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
const formatItem = (label, value) => (React.createElement(Stack, { key: label, direction: "row", justifyContent: "space-between", spacing: 2 },
|
|
30
|
+
React.createElement(Typography, { color: "text.secondary", variant: "body2" }, label),
|
|
31
|
+
typeof value === "string" || typeof value === "number" ? (React.createElement(Typography, { variant: "body2" }, value)) : (value)));
|
|
32
|
+
const ItemCard = ({ item }) => {
|
|
33
|
+
const { label: errorLabel, codes: errorCodes } = parseStatus(item.error);
|
|
34
|
+
const { label: warningLabel, codes: warningCodes } = parseStatus(item.warning);
|
|
35
|
+
return (React.createElement(Card, null,
|
|
36
|
+
React.createElement(CardHeader, { title: item.site_code }),
|
|
37
|
+
React.createElement(CardContent, null,
|
|
38
|
+
React.createElement(Stack, { spacing: 1 },
|
|
39
|
+
formatItem("Reference", item.reference),
|
|
40
|
+
formatItem("Name", item.name),
|
|
41
|
+
formatItem("Variant", item.variant || "—"),
|
|
42
|
+
formatItem("Price", item.base_price !== item.price ? (React.createElement(Stack, { alignItems: "center", direction: "row", spacing: 1 },
|
|
43
|
+
React.createElement(Typography, { color: "text.disabled", sx: { textDecoration: "line-through" }, variant: "body2" },
|
|
44
|
+
item.base_price,
|
|
45
|
+
" ",
|
|
46
|
+
item.currency),
|
|
47
|
+
React.createElement(LocalOfferOutlinedIcon, { color: "error", fontSize: "small" }),
|
|
48
|
+
React.createElement(Typography, { color: "error", variant: "body2" },
|
|
49
|
+
item.price,
|
|
50
|
+
" ",
|
|
51
|
+
item.currency))) : (`${item.price} ${item.currency}`)),
|
|
52
|
+
React.createElement(Stack, { alignItems: "center", alignSelf: "flex-start", direction: "row", flexWrap: "wrap", gap: 1 },
|
|
53
|
+
errorLabel && React.createElement(CardPill, { color: "error", icon: React.createElement(ReportIcon, null), label: errorLabel }),
|
|
54
|
+
errorCodes.map((code) => (React.createElement(CardPill, { key: `error-${code}`, color: "error", icon: null, label: code, variant: "outlined" }))),
|
|
55
|
+
warningLabel && (React.createElement(CardPill, { color: "warning", icon: React.createElement(WarningIcon, null), label: warningLabel })),
|
|
56
|
+
warningCodes.map((code) => (React.createElement(CardPill, { key: `warning-${code}`, color: "warning", icon: null, label: code, variant: "outlined" }))),
|
|
57
|
+
React.createElement(CardPill, { color: item.is_available ? "success" : "warning", label: item.is_available ? "Available" : "Unavailable" }))))));
|
|
58
|
+
};
|
|
59
|
+
const SiteAvailability = ({ data }) => {
|
|
60
|
+
const items = data.items ?? [];
|
|
61
|
+
return (React.createElement(Content, { layout: "fullWidth" }, items.length > 0 ? (React.createElement(Grid, { container: true, columns: 12, spacing: 2, width: "100%" }, items.map((item) => (React.createElement(Grid, { key: `${item.site_code}-${item.reference}`, size: { xs: 12, md: 4 } },
|
|
62
|
+
React.createElement(Stack, { spacing: 2 },
|
|
63
|
+
React.createElement(ItemCard, { item: item }))))))) : (React.createElement(Typography, { color: "text.secondary", variant: "body2" }, "No items found"))));
|
|
64
|
+
};
|
|
65
|
+
export default SiteAvailability;
|
|
66
|
+
//# sourceMappingURL=SiteAvailability.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SiteAvailability.js","sourceRoot":"","sources":["../../../../../src/extensions/catalog/contrib/SiteAvailability.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,sBAAsB,MAAM,wCAAwC,CAAC;AAC5E,OAAO,UAAU,MAAM,4BAA4B,CAAC;AACpD,OAAO,WAAW,MAAM,6BAA6B,CAAC;AACtD,OAAO,EAAE,KAAK,IAAI,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEjE,OAAO,IAAI,MAAM,0BAA0B,CAAC;AAC5C,OAAO,WAAW,MAAM,sCAAsC,CAAC;AAC/D,OAAO,UAAU,MAAM,qCAAqC,CAAC;AAC7D,OAAO,QAAQ,MAAM,mCAAmC,CAAC;AACzD,OAAO,OAAO,MAAM,6BAA6B,CAAC;AAIlD,MAAM,WAAW,GAAG,CAAC,KAAgC,EAA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AAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAClB,oBAAC,IAAI,IAAC,SAAS,QAAC,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAC,MAAM,IAClD,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CACnB,oBAAC,IAAI,IAAC,GAAG,EAAE,GAAG,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE;QACvE,oBAAC,KAAK,IAAC,OAAO,EAAE,CAAC;YACf,oBAAC,QAAQ,IAAC,IAAI,EAAE,IAAI,GAAI,CAClB,CACH,CACR,CAAC,CACG,CACR,CAAC,CAAC,CAAC,CACF,oBAAC,UAAU,IAAC,KAAK,EAAC,gBAAgB,EAAC,OAAO,EAAC,OAAO,qBAErC,CACd,CACO,CACX,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import StorefrontIcon from "@mui/icons-material/Storefront";
|
|
1
2
|
import WorkspacesIcon from "../../assets/symbols/Workspaces";
|
|
2
3
|
export * from "./types/article";
|
|
4
|
+
export * from "./types/contrib";
|
|
3
5
|
const routes = {
|
|
4
6
|
article: {
|
|
5
7
|
create: { page: async () => (await import("./pages/article/create")).default, offline: true },
|
|
@@ -26,4 +28,15 @@ export const navigation = {
|
|
|
26
28
|
permission: "catalog.view_article",
|
|
27
29
|
},
|
|
28
30
|
};
|
|
31
|
+
export const contrib = {
|
|
32
|
+
pos: {
|
|
33
|
+
"catalog:article:detail:items": {
|
|
34
|
+
title: "Availability",
|
|
35
|
+
icon: StorefrontIcon,
|
|
36
|
+
component: async () => (await import("./contrib/SiteAvailability")).default,
|
|
37
|
+
variant: "tab",
|
|
38
|
+
permission: "catalog.view_article",
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
};
|
|
29
42
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/extensions/catalog/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/extensions/catalog/index.tsx"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,gCAAgC,CAAC;AAI5D,OAAO,cAAc,MAAM,iCAAiC,CAAC;AAI7D,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAEhC,MAAM,MAAM,GAYR;IACF,OAAO,EAAE;QACP,MAAM,EAAE,EAAE,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,MAAM,CAAC,wBAAwB,CAAC,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE;QAC7F,MAAM,EAAE,EAAE,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,MAAM,CAAC,wBAAwB,CAAC,CAAC,CAAC,OAAO,EAAE;QAC9E,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,MAAM,CAAC,sBAAsB,CAAC,CAAC,CAAC,OAAO,EAAE;KAC3E;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,MAAM,GAAoB;IACrC,GAAG,EAAE,SAAS;IACd,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE;QACf,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QAElE,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;YACjB,OAAO;gBACL,IAAI,EAAE,IAAI,EAAE;gBACZ,GAAG,GAAG;aACP,CAAC;QACJ,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAwB;IAC7C,sBAAsB,EAAE;QACtB,IAAI,EAAE,cAAc;QACpB,UAAU,EAAE,sBAAsB;KACnC;CACO,CAAC;AAEX,MAAM,CAAC,MAAM,OAAO,GAAwC;IAC1D,GAAG,EAAE;QACH,8BAA8B,EAAE;YAC9B,KAAK,EAAE,cAAc;YACrB,IAAI,EAAE,cAAc;YACpB,SAAS,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,MAAM,CAAC,4BAA4B,CAAC,CAAC,CAAC,OAAO;YAC3E,OAAO,EAAE,KAAK;YACd,UAAU,EAAE,sBAAsB;SACnC;KACF;CACO,CAAC"}
|
|
@@ -1,20 +1,31 @@
|
|
|
1
1
|
import React, { useState } from "react";
|
|
2
2
|
import CategoryOutlinedIcon from "@mui/icons-material/CategoryOutlined";
|
|
3
|
+
import { TableBody, TableRow } from "@mui/material";
|
|
3
4
|
import Typography from "@mui/material/Typography";
|
|
5
|
+
import Card from "../../../../components/Card";
|
|
6
|
+
import CardContent from "../../../../components/Card/CardContent";
|
|
7
|
+
import CardHeader from "../../../../components/Card/CardHeader";
|
|
4
8
|
import { ContribInlines } from "../../../../components/ContribInlines";
|
|
5
9
|
import { Header } from "../../../../components/Header";
|
|
6
10
|
import { Page } from "../../../../components/Page";
|
|
7
11
|
import { Tab } from "../../../../components/Tab";
|
|
12
|
+
import Table from "../../../../components/Table";
|
|
13
|
+
import { TableCell } from "../../../../components/Table/TableCell";
|
|
8
14
|
import { TabPanel } from "../../../../components/TabPanel";
|
|
9
15
|
import { TabPanels } from "../../../../components/TabPanels";
|
|
10
16
|
import { Tabs } from "../../../../components/Tabs";
|
|
11
17
|
import { TitleBar } from "../../../../components/TitleBar";
|
|
12
18
|
import Content, { LeftColumn, RightColumn } from "../../../../containers/Content";
|
|
19
|
+
import { useI18n } from "../../../../contexts/I18nContext";
|
|
20
|
+
import { useRouter } from "../../../../contexts/RouterContext";
|
|
13
21
|
import { ArticleCard } from "../../components/ArticleCard";
|
|
14
22
|
import { MeasurementsCard } from "../../components/MeasurementsCard";
|
|
15
23
|
import { PHYSICAL_ITEM_TYPES } from "../../utils";
|
|
16
24
|
const ArticleDetailPage = ({ data }) => {
|
|
17
25
|
const [article, setArticle] = useState(data);
|
|
26
|
+
const { t } = useI18n();
|
|
27
|
+
const { navigate } = useRouter();
|
|
28
|
+
const hasOtherVariants = article.variants.some((variant) => variant.id !== article.id);
|
|
18
29
|
return (React.createElement(Page, null,
|
|
19
30
|
React.createElement(Header, { variant: "opaque" },
|
|
20
31
|
React.createElement(TitleBar, { title: React.createElement(React.Fragment, null,
|
|
@@ -28,7 +39,46 @@ const ArticleDetailPage = ({ data }) => {
|
|
|
28
39
|
React.createElement(LeftColumn, null,
|
|
29
40
|
React.createElement(ArticleCard, { article: article, onUpdated: setArticle }),
|
|
30
41
|
React.createElement(ContribInlines, { contribParams: { code: data.code }, data: data })),
|
|
31
|
-
React.createElement(RightColumn, null,
|
|
42
|
+
React.createElement(RightColumn, null,
|
|
43
|
+
PHYSICAL_ITEM_TYPES.includes(article.item_type) && (React.createElement(MeasurementsCard, { measurements: article.measurements, setMeasurements: (measurements) => setArticle((previous) => ({ ...previous, measurements })) })),
|
|
44
|
+
hasOtherVariants && (React.createElement(Card, null,
|
|
45
|
+
React.createElement(CardHeader, { title: t("Variants") }),
|
|
46
|
+
React.createElement(CardContent, { sx: {
|
|
47
|
+
p: 0,
|
|
48
|
+
"&:last-child": { pb: 0 },
|
|
49
|
+
} },
|
|
50
|
+
React.createElement(Table, { count: article.variants.length, tableContainerProps: {
|
|
51
|
+
sx: (theme) => ({
|
|
52
|
+
borderTop: `1px solid ${theme.palette.divider}`,
|
|
53
|
+
px: 0,
|
|
54
|
+
}),
|
|
55
|
+
} },
|
|
56
|
+
React.createElement(TableBody, { sx: {
|
|
57
|
+
"& .MuiTableRow-root:first-of-type .MuiTableCell-root": (theme) => ({
|
|
58
|
+
borderTop: `1px solid ${theme.palette.divider}`,
|
|
59
|
+
}),
|
|
60
|
+
"& .MuiTableRow-root:last-of-type .MuiTableCell-root": {
|
|
61
|
+
borderBottom: "none",
|
|
62
|
+
},
|
|
63
|
+
} }, article.variants.map((variant) => {
|
|
64
|
+
const isCurrent = variant.id === article.id;
|
|
65
|
+
return (React.createElement(TableRow, { key: variant.id, hover: true, selected: isCurrent, sx: (theme) => ({
|
|
66
|
+
cursor: "pointer",
|
|
67
|
+
...(isCurrent
|
|
68
|
+
? {
|
|
69
|
+
backgroundColor: theme.palette.action.hover,
|
|
70
|
+
"& .MuiTableCell-root": {
|
|
71
|
+
fontWeight: 600,
|
|
72
|
+
},
|
|
73
|
+
}
|
|
74
|
+
: undefined),
|
|
75
|
+
}), onClick: () => navigate("catalog.article:detail", { params: { id: variant.id } }) },
|
|
76
|
+
React.createElement(TableCell, null, variant.variant),
|
|
77
|
+
React.createElement(TableCell, { typographyProps: {
|
|
78
|
+
variant: "caption",
|
|
79
|
+
color: "text.secondary",
|
|
80
|
+
} }, variant.code)));
|
|
81
|
+
}))))))))))));
|
|
32
82
|
};
|
|
33
83
|
export default ArticleDetailPage;
|
|
34
84
|
//# sourceMappingURL=detail.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"detail.js","sourceRoot":"","sources":["../../../../../../src/extensions/catalog/pages/article/detail.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAExC,OAAO,oBAAoB,MAAM,sCAAsC,CAAC;AACxE,OAAO,UAAU,MAAM,0BAA0B,CAAC;AAElD,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AACvE,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AACnD,OAAO,EAAE,GAAG,EAAE,MAAM,4BAA4B,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE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CAChD,CAAC;4CACF,qDAAqD,EAAE;gDACrD,YAAY,EAAE,MAAM;6CACrB;yCACF,IAEA,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;wCAChC,MAAM,SAAS,GAAG,OAAO,CAAC,EAAE,KAAK,OAAO,CAAC,EAAE,CAAC;wCAC5C,OAAO,CACL,oBAAC,QAAQ,IACP,GAAG,EAAE,OAAO,CAAC,EAAE,EACf,KAAK,QACL,QAAQ,EAAE,SAAS,EACnB,EAAE,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;gDACd,MAAM,EAAE,SAAS;gDACjB,GAAG,CAAC,SAAS;oDACX,CAAC,CAAC;wDACE,eAAe,EAAE,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK;wDAC3C,sBAAsB,EAAE;4DACtB,UAAU,EAAE,GAAG;yDAChB;qDACF;oDACH,CAAC,CAAC,SAAS,CAAC;6CACf,CAAC,EACF,OAAO,EAAE,GAAG,EAAE,CACZ,QAAQ,CAAC,wBAAwB,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC;4CAGpE,oBAAC,SAAS,QAAE,OAAO,CAAC,OAAO,CAAa;4CACxC,oBAAC,SAAS,IACR,eAAe,EAAE;oDACf,OAAO,EAAE,SAAS;oDAClB,KAAK,EAAE,gBAAgB;iDACxB,IAEA,OAAO,CAAC,IAAI,CACH,CACH,CACZ,CAAC;oCACJ,CAAC,CAAC,CACQ,CACN,CACI,CACT,CACR,CACW,CACN,CACD,CACD,CACP,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contrib.js","sourceRoot":"","sources":["../../../../../src/extensions/catalog/types/contrib.ts"],"names":[],"mappings":""}
|
|
@@ -4,6 +4,7 @@ import { OverridableStringUnion } from "@mui/types";
|
|
|
4
4
|
import { Pill } from "./shared";
|
|
5
5
|
export interface CardPillProps extends Pill {
|
|
6
6
|
size?: OverridableStringUnion<"small" | "medium", ChipPropsSizeOverrides>;
|
|
7
|
+
variant?: "filled" | "outlined";
|
|
7
8
|
}
|
|
8
9
|
export declare const CardPill: React.FC<CardPillProps>;
|
|
9
10
|
export default CardPill;
|
|
@@ -6,7 +6,7 @@ export interface FormOption {
|
|
|
6
6
|
export interface Pill {
|
|
7
7
|
label: string;
|
|
8
8
|
color?: "success" | "error" | "warning" | "info" | "default";
|
|
9
|
-
icon?: React.ReactElement;
|
|
9
|
+
icon?: React.ReactElement | null;
|
|
10
10
|
}
|
|
11
11
|
export interface CardFieldBaseProps extends React.PropsWithChildren {
|
|
12
12
|
formName: string;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { RouterExtension } from "../../router/Router";
|
|
2
|
-
import { NavigationOverrides } from "../../types";
|
|
2
|
+
import { ContribComponentMap, NavigationOverrides } from "../../types";
|
|
3
3
|
export * from "./types/article";
|
|
4
|
+
export * from "./types/contrib";
|
|
4
5
|
export declare const router: RouterExtension;
|
|
5
6
|
export declare const navigation: NavigationOverrides;
|
|
7
|
+
export declare const contrib: Record<string, ContribComponentMap>;
|
|
@@ -15,7 +15,13 @@ export interface Measurements {
|
|
|
15
15
|
dimensions?: Dimensions;
|
|
16
16
|
weight?: number;
|
|
17
17
|
}
|
|
18
|
+
export interface ArticleVariant {
|
|
19
|
+
id: number;
|
|
20
|
+
code: string;
|
|
21
|
+
variant: string;
|
|
22
|
+
}
|
|
18
23
|
export interface ArticleDetail {
|
|
24
|
+
id: number;
|
|
19
25
|
name: string;
|
|
20
26
|
variant: string;
|
|
21
27
|
item_type: string;
|
|
@@ -26,6 +32,7 @@ export interface ArticleDetail {
|
|
|
26
32
|
tax_code: string;
|
|
27
33
|
is_active: boolean;
|
|
28
34
|
measurements?: Measurements;
|
|
35
|
+
variants: ArticleVariant[];
|
|
29
36
|
}
|
|
30
37
|
export interface ArticleCreated {
|
|
31
38
|
id: number;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface SiteItem {
|
|
2
|
+
site_code: string;
|
|
3
|
+
currency: string;
|
|
4
|
+
reference: string;
|
|
5
|
+
name: string;
|
|
6
|
+
variant: string;
|
|
7
|
+
base_price: string;
|
|
8
|
+
price: string;
|
|
9
|
+
is_available: boolean;
|
|
10
|
+
error?: string | null;
|
|
11
|
+
warning?: string | null;
|
|
12
|
+
}
|
|
13
|
+
export interface SiteItemsResponse {
|
|
14
|
+
items: SiteItem[];
|
|
15
|
+
}
|
package/package.json
CHANGED
|
@@ -2,6 +2,7 @@ import React from "react";
|
|
|
2
2
|
|
|
3
3
|
import CancelIcon from "@mui/icons-material/Cancel";
|
|
4
4
|
import CheckCircleIcon from "@mui/icons-material/CheckCircle";
|
|
5
|
+
import WarningIcon from "@mui/icons-material/Warning";
|
|
5
6
|
import { ChipPropsSizeOverrides } from "@mui/material/Chip";
|
|
6
7
|
import { OverridableStringUnion } from "@mui/types";
|
|
7
8
|
|
|
@@ -11,16 +12,37 @@ import { Pill } from "./shared";
|
|
|
11
12
|
|
|
12
13
|
export interface CardPillProps extends Pill {
|
|
13
14
|
size?: OverridableStringUnion<"small" | "medium", ChipPropsSizeOverrides>;
|
|
15
|
+
variant?: "filled" | "outlined";
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
// TODO Logic for picking icon
|
|
17
|
-
export const CardPill: React.FC<CardPillProps> = ({
|
|
19
|
+
export const CardPill: React.FC<CardPillProps> = ({
|
|
20
|
+
label,
|
|
21
|
+
color,
|
|
22
|
+
icon,
|
|
23
|
+
size = "small",
|
|
24
|
+
variant,
|
|
25
|
+
}) => {
|
|
26
|
+
let resolvedIcon: React.ReactElement | undefined;
|
|
27
|
+
if (icon === undefined) {
|
|
28
|
+
if (color === "success") {
|
|
29
|
+
resolvedIcon = <CheckCircleIcon />;
|
|
30
|
+
} else if (color === "warning") {
|
|
31
|
+
resolvedIcon = <WarningIcon />;
|
|
32
|
+
} else {
|
|
33
|
+
resolvedIcon = <CancelIcon />;
|
|
34
|
+
}
|
|
35
|
+
} else {
|
|
36
|
+
resolvedIcon = icon ?? undefined;
|
|
37
|
+
}
|
|
38
|
+
|
|
18
39
|
return (
|
|
19
40
|
<Chip
|
|
20
41
|
color={color ?? "success"}
|
|
21
|
-
icon={
|
|
42
|
+
icon={resolvedIcon}
|
|
22
43
|
label={label}
|
|
23
44
|
size={size}
|
|
45
|
+
variant={variant}
|
|
24
46
|
/>
|
|
25
47
|
);
|
|
26
48
|
};
|
|
@@ -8,7 +8,7 @@ export interface FormOption {
|
|
|
8
8
|
export interface Pill {
|
|
9
9
|
label: string;
|
|
10
10
|
color?: "success" | "error" | "warning" | "info" | "default";
|
|
11
|
-
icon?: React.ReactElement;
|
|
11
|
+
icon?: React.ReactElement | null;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export interface CardFieldBaseProps extends React.PropsWithChildren {
|
package/src/components/Chip.tsx
CHANGED
|
@@ -46,6 +46,7 @@ export const ArticleCard: React.FC<ArticleCardProps> = ({
|
|
|
46
46
|
const { user } = useUser();
|
|
47
47
|
|
|
48
48
|
article ??= {
|
|
49
|
+
id: 0,
|
|
49
50
|
name: "",
|
|
50
51
|
variant: "",
|
|
51
52
|
item_type: "",
|
|
@@ -55,6 +56,7 @@ export const ArticleCard: React.FC<ArticleCardProps> = ({
|
|
|
55
56
|
gtin: "",
|
|
56
57
|
tax_code: "",
|
|
57
58
|
is_active: true,
|
|
59
|
+
variants: [],
|
|
58
60
|
};
|
|
59
61
|
|
|
60
62
|
const handleSave = useCallback(
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import LocalOfferOutlinedIcon from "@mui/icons-material/LocalOfferOutlined";
|
|
4
|
+
import ReportIcon from "@mui/icons-material/Report";
|
|
5
|
+
import WarningIcon from "@mui/icons-material/Warning";
|
|
6
|
+
import { Grid2 as Grid, Stack, Typography } from "@mui/material";
|
|
7
|
+
|
|
8
|
+
import Card from "../../../components/Card";
|
|
9
|
+
import CardContent from "../../../components/Card/CardContent";
|
|
10
|
+
import CardHeader from "../../../components/Card/CardHeader";
|
|
11
|
+
import CardPill from "../../../components/Card/CardPill";
|
|
12
|
+
import Content from "../../../containers/Content";
|
|
13
|
+
import { ContribComponent } from "../../../types";
|
|
14
|
+
import { SiteItem, SiteItemsResponse } from "../types/contrib";
|
|
15
|
+
|
|
16
|
+
const parseStatus = (value: string | null | undefined): { label?: string; codes: string[] } => {
|
|
17
|
+
if (!value) {
|
|
18
|
+
return { codes: [] };
|
|
19
|
+
}
|
|
20
|
+
const trimmed = value.trim();
|
|
21
|
+
const match = /^([^[]+)\[([^\]]*)\]>?$/.exec(trimmed);
|
|
22
|
+
if (!match) {
|
|
23
|
+
return { label: trimmed, codes: [] };
|
|
24
|
+
}
|
|
25
|
+
const [, label, codes] = match;
|
|
26
|
+
return {
|
|
27
|
+
label: label.trim(),
|
|
28
|
+
codes: codes
|
|
29
|
+
.split(",")
|
|
30
|
+
.map((code) => code.trim())
|
|
31
|
+
.filter(Boolean),
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const formatItem = (label: string, value: React.ReactNode) => (
|
|
36
|
+
<Stack key={label} direction="row" justifyContent="space-between" spacing={2}>
|
|
37
|
+
<Typography color="text.secondary" variant="body2">
|
|
38
|
+
{label}
|
|
39
|
+
</Typography>
|
|
40
|
+
{typeof value === "string" || typeof value === "number" ? (
|
|
41
|
+
<Typography variant="body2">{value}</Typography>
|
|
42
|
+
) : (
|
|
43
|
+
value
|
|
44
|
+
)}
|
|
45
|
+
</Stack>
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
const ItemCard: React.FC<{ item: SiteItem }> = ({ item }) => {
|
|
49
|
+
const { label: errorLabel, codes: errorCodes } = parseStatus(item.error);
|
|
50
|
+
const { label: warningLabel, codes: warningCodes } = parseStatus(item.warning);
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<Card>
|
|
54
|
+
<CardHeader title={item.site_code} />
|
|
55
|
+
<CardContent>
|
|
56
|
+
<Stack spacing={1}>
|
|
57
|
+
{formatItem("Reference", item.reference)}
|
|
58
|
+
{formatItem("Name", item.name)}
|
|
59
|
+
{formatItem("Variant", item.variant || "—")}
|
|
60
|
+
{formatItem(
|
|
61
|
+
"Price",
|
|
62
|
+
item.base_price !== item.price ? (
|
|
63
|
+
<Stack alignItems="center" direction="row" spacing={1}>
|
|
64
|
+
<Typography
|
|
65
|
+
color="text.disabled"
|
|
66
|
+
sx={{ textDecoration: "line-through" }}
|
|
67
|
+
variant="body2"
|
|
68
|
+
>
|
|
69
|
+
{item.base_price} {item.currency}
|
|
70
|
+
</Typography>
|
|
71
|
+
<LocalOfferOutlinedIcon color="error" fontSize="small" />
|
|
72
|
+
<Typography color="error" variant="body2">
|
|
73
|
+
{item.price} {item.currency}
|
|
74
|
+
</Typography>
|
|
75
|
+
</Stack>
|
|
76
|
+
) : (
|
|
77
|
+
`${item.price} ${item.currency}`
|
|
78
|
+
),
|
|
79
|
+
)}
|
|
80
|
+
<Stack alignItems="center" alignSelf="flex-start" direction="row" flexWrap="wrap" gap={1}>
|
|
81
|
+
{errorLabel && <CardPill color="error" icon={<ReportIcon />} label={errorLabel} />}
|
|
82
|
+
{errorCodes.map((code) => (
|
|
83
|
+
<CardPill
|
|
84
|
+
key={`error-${code}`}
|
|
85
|
+
color="error"
|
|
86
|
+
icon={null}
|
|
87
|
+
label={code}
|
|
88
|
+
variant="outlined"
|
|
89
|
+
/>
|
|
90
|
+
))}
|
|
91
|
+
{warningLabel && (
|
|
92
|
+
<CardPill color="warning" icon={<WarningIcon />} label={warningLabel} />
|
|
93
|
+
)}
|
|
94
|
+
{warningCodes.map((code) => (
|
|
95
|
+
<CardPill
|
|
96
|
+
key={`warning-${code}`}
|
|
97
|
+
color="warning"
|
|
98
|
+
icon={null}
|
|
99
|
+
label={code}
|
|
100
|
+
variant="outlined"
|
|
101
|
+
/>
|
|
102
|
+
))}
|
|
103
|
+
<CardPill
|
|
104
|
+
color={item.is_available ? "success" : "warning"}
|
|
105
|
+
label={item.is_available ? "Available" : "Unavailable"}
|
|
106
|
+
/>
|
|
107
|
+
</Stack>
|
|
108
|
+
</Stack>
|
|
109
|
+
</CardContent>
|
|
110
|
+
</Card>
|
|
111
|
+
);
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const SiteAvailability: ContribComponent<SiteItemsResponse> = ({ data }) => {
|
|
115
|
+
const items = data.items ?? [];
|
|
116
|
+
|
|
117
|
+
return (
|
|
118
|
+
<Content layout="fullWidth">
|
|
119
|
+
{items.length > 0 ? (
|
|
120
|
+
<Grid container columns={12} spacing={2} width="100%">
|
|
121
|
+
{items.map((item) => (
|
|
122
|
+
<Grid key={`${item.site_code}-${item.reference}`} size={{ xs: 12, md: 4 }}>
|
|
123
|
+
<Stack spacing={2}>
|
|
124
|
+
<ItemCard item={item} />
|
|
125
|
+
</Stack>
|
|
126
|
+
</Grid>
|
|
127
|
+
))}
|
|
128
|
+
</Grid>
|
|
129
|
+
) : (
|
|
130
|
+
<Typography color="text.secondary" variant="body2">
|
|
131
|
+
No items found
|
|
132
|
+
</Typography>
|
|
133
|
+
)}
|
|
134
|
+
</Content>
|
|
135
|
+
);
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
export default SiteAvailability;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
import StorefrontIcon from "@mui/icons-material/Storefront";
|
|
2
|
+
|
|
1
3
|
import { OpenAPI } from "openapi-types";
|
|
2
4
|
|
|
3
5
|
import WorkspacesIcon from "../../assets/symbols/Workspaces";
|
|
4
6
|
import { RouterExtension } from "../../router/Router";
|
|
5
|
-
import { NavigationOverrides, PageComponent } from "../../types";
|
|
7
|
+
import { ContribComponentMap, NavigationOverrides, PageComponent } from "../../types";
|
|
6
8
|
|
|
7
9
|
export * from "./types/article";
|
|
10
|
+
export * from "./types/contrib";
|
|
8
11
|
|
|
9
12
|
const routes: Record<
|
|
10
13
|
string,
|
|
@@ -48,3 +51,15 @@ export const navigation: NavigationOverrides = {
|
|
|
48
51
|
permission: "catalog.view_article",
|
|
49
52
|
},
|
|
50
53
|
} as const;
|
|
54
|
+
|
|
55
|
+
export const contrib: Record<string, ContribComponentMap> = {
|
|
56
|
+
pos: {
|
|
57
|
+
"catalog:article:detail:items": {
|
|
58
|
+
title: "Availability",
|
|
59
|
+
icon: StorefrontIcon,
|
|
60
|
+
component: async () => (await import("./contrib/SiteAvailability")).default,
|
|
61
|
+
variant: "tab",
|
|
62
|
+
permission: "catalog.view_article",
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
} as const;
|
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
import React, { useState } from "react";
|
|
2
2
|
|
|
3
3
|
import CategoryOutlinedIcon from "@mui/icons-material/CategoryOutlined";
|
|
4
|
+
import { TableBody, TableRow } from "@mui/material";
|
|
4
5
|
import Typography from "@mui/material/Typography";
|
|
5
6
|
|
|
7
|
+
import Card from "../../../../components/Card";
|
|
8
|
+
import CardContent from "../../../../components/Card/CardContent";
|
|
9
|
+
import CardHeader from "../../../../components/Card/CardHeader";
|
|
6
10
|
import { ContribInlines } from "../../../../components/ContribInlines";
|
|
7
11
|
import { Header } from "../../../../components/Header";
|
|
8
12
|
import { Page } from "../../../../components/Page";
|
|
9
13
|
import { Tab } from "../../../../components/Tab";
|
|
14
|
+
import Table from "../../../../components/Table";
|
|
15
|
+
import { TableCell } from "../../../../components/Table/TableCell";
|
|
10
16
|
import { TabPanel } from "../../../../components/TabPanel";
|
|
11
17
|
import { TabPanels } from "../../../../components/TabPanels";
|
|
12
18
|
import { Tabs } from "../../../../components/Tabs";
|
|
13
19
|
import { TitleBar } from "../../../../components/TitleBar";
|
|
14
20
|
import Content, { LeftColumn, RightColumn } from "../../../../containers/Content";
|
|
21
|
+
import { useI18n } from "../../../../contexts/I18nContext";
|
|
22
|
+
import { useRouter } from "../../../../contexts/RouterContext";
|
|
15
23
|
import { PageComponent } from "../../../../types";
|
|
16
24
|
import { ArticleCard } from "../../components/ArticleCard";
|
|
17
25
|
import { MeasurementsCard } from "../../components/MeasurementsCard";
|
|
@@ -20,6 +28,9 @@ import { PHYSICAL_ITEM_TYPES } from "../../utils";
|
|
|
20
28
|
|
|
21
29
|
const ArticleDetailPage: PageComponent<ArticleDetail> = ({ data }) => {
|
|
22
30
|
const [article, setArticle] = useState(data);
|
|
31
|
+
const { t } = useI18n();
|
|
32
|
+
const { navigate } = useRouter();
|
|
33
|
+
const hasOtherVariants = article.variants.some((variant) => variant.id !== article.id);
|
|
23
34
|
|
|
24
35
|
return (
|
|
25
36
|
<Page>
|
|
@@ -56,6 +67,73 @@ const ArticleDetailPage: PageComponent<ArticleDetail> = ({ data }) => {
|
|
|
56
67
|
}
|
|
57
68
|
/>
|
|
58
69
|
)}
|
|
70
|
+
{hasOtherVariants && (
|
|
71
|
+
<Card>
|
|
72
|
+
<CardHeader title={t("Variants")} />
|
|
73
|
+
<CardContent
|
|
74
|
+
sx={{
|
|
75
|
+
p: 0,
|
|
76
|
+
"&:last-child": { pb: 0 },
|
|
77
|
+
}}
|
|
78
|
+
>
|
|
79
|
+
<Table
|
|
80
|
+
count={article.variants.length}
|
|
81
|
+
tableContainerProps={{
|
|
82
|
+
sx: (theme) => ({
|
|
83
|
+
borderTop: `1px solid ${theme.palette.divider}`,
|
|
84
|
+
px: 0,
|
|
85
|
+
}),
|
|
86
|
+
}}
|
|
87
|
+
>
|
|
88
|
+
<TableBody
|
|
89
|
+
sx={{
|
|
90
|
+
"& .MuiTableRow-root:first-of-type .MuiTableCell-root": (theme) => ({
|
|
91
|
+
borderTop: `1px solid ${theme.palette.divider}`,
|
|
92
|
+
}),
|
|
93
|
+
"& .MuiTableRow-root:last-of-type .MuiTableCell-root": {
|
|
94
|
+
borderBottom: "none",
|
|
95
|
+
},
|
|
96
|
+
}}
|
|
97
|
+
>
|
|
98
|
+
{article.variants.map((variant) => {
|
|
99
|
+
const isCurrent = variant.id === article.id;
|
|
100
|
+
return (
|
|
101
|
+
<TableRow
|
|
102
|
+
key={variant.id}
|
|
103
|
+
hover
|
|
104
|
+
selected={isCurrent}
|
|
105
|
+
sx={(theme) => ({
|
|
106
|
+
cursor: "pointer",
|
|
107
|
+
...(isCurrent
|
|
108
|
+
? {
|
|
109
|
+
backgroundColor: theme.palette.action.hover,
|
|
110
|
+
"& .MuiTableCell-root": {
|
|
111
|
+
fontWeight: 600,
|
|
112
|
+
},
|
|
113
|
+
}
|
|
114
|
+
: undefined),
|
|
115
|
+
})}
|
|
116
|
+
onClick={() =>
|
|
117
|
+
navigate("catalog.article:detail", { params: { id: variant.id } })
|
|
118
|
+
}
|
|
119
|
+
>
|
|
120
|
+
<TableCell>{variant.variant}</TableCell>
|
|
121
|
+
<TableCell
|
|
122
|
+
typographyProps={{
|
|
123
|
+
variant: "caption",
|
|
124
|
+
color: "text.secondary",
|
|
125
|
+
}}
|
|
126
|
+
>
|
|
127
|
+
{variant.code}
|
|
128
|
+
</TableCell>
|
|
129
|
+
</TableRow>
|
|
130
|
+
);
|
|
131
|
+
})}
|
|
132
|
+
</TableBody>
|
|
133
|
+
</Table>
|
|
134
|
+
</CardContent>
|
|
135
|
+
</Card>
|
|
136
|
+
)}
|
|
59
137
|
</RightColumn>
|
|
60
138
|
</Content>
|
|
61
139
|
</TabPanel>
|
|
@@ -18,7 +18,14 @@ export interface Measurements {
|
|
|
18
18
|
weight?: number;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
export interface ArticleVariant {
|
|
22
|
+
id: number;
|
|
23
|
+
code: string;
|
|
24
|
+
variant: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
21
27
|
export interface ArticleDetail {
|
|
28
|
+
id: number;
|
|
22
29
|
name: string;
|
|
23
30
|
variant: string;
|
|
24
31
|
item_type: string;
|
|
@@ -29,6 +36,7 @@ export interface ArticleDetail {
|
|
|
29
36
|
tax_code: string;
|
|
30
37
|
is_active: boolean;
|
|
31
38
|
measurements?: Measurements;
|
|
39
|
+
variants: ArticleVariant[];
|
|
32
40
|
}
|
|
33
41
|
|
|
34
42
|
export interface ArticleCreated {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface SiteItem {
|
|
2
|
+
site_code: string;
|
|
3
|
+
currency: string;
|
|
4
|
+
reference: string;
|
|
5
|
+
name: string;
|
|
6
|
+
variant: string;
|
|
7
|
+
base_price: string;
|
|
8
|
+
price: string;
|
|
9
|
+
is_available: boolean;
|
|
10
|
+
error?: string | null;
|
|
11
|
+
warning?: string | null;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface SiteItemsResponse {
|
|
15
|
+
items: SiteItem[];
|
|
16
|
+
}
|