umwd-components 0.1.731 → 0.1.733
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/cjs/src/components/common/Address.js +1 -1
- package/dist/cjs/src/components/common/csv/CsvDownloader.js +1 -1
- package/dist/cjs/src/components/e-commerce/cart/CartSummary.js +1 -1
- package/dist/cjs/src/components/e-commerce/cart/CartSummaryRow.js +1 -1
- package/dist/cjs/src/components/e-commerce/categories/CategorySelectorV2.js +1 -1
- package/dist/cjs/src/components/e-commerce/categories/EditCategoryForm.js +1 -1
- package/dist/cjs/src/components/e-commerce/checkout/Step4.js +1 -1
- package/dist/cjs/src/components/e-commerce/customer/CustomerProfileDisplay.js +1 -1
- package/dist/cjs/src/components/e-commerce/customer/CustomerProfileEditForm.js +1 -1
- package/dist/cjs/src/components/e-commerce/enduser/EnduserProfileEditForm.js +1 -1
- package/dist/cjs/src/components/e-commerce/iro/IROItemFields.js +1 -1
- package/dist/cjs/src/components/e-commerce/iro/IroItemUpdater.js +1 -1
- package/dist/cjs/src/components/e-commerce/iro/ManageIROForm.js +1 -1
- package/dist/cjs/src/components/e-commerce/iro/RmaForm.js +1 -1
- package/dist/cjs/src/components/e-commerce/iro/TextualIROItemUpdater.js +1 -1
- package/dist/cjs/src/components/e-commerce/iro/TextualManageIROForm.js +1 -1
- package/dist/cjs/src/components/e-commerce/opo/ManageOpoForm.js +1 -1
- package/dist/cjs/src/components/e-commerce/opo/OPOItemFields.js +1 -1
- package/dist/cjs/src/components/e-commerce/opo/OpoItemUpdater.js +1 -1
- package/dist/cjs/src/components/e-commerce/opo/OpoSummary.js +1 -1
- package/dist/cjs/src/components/e-commerce/opo/OpoSummaryRow.js +1 -1
- package/dist/cjs/src/components/e-commerce/opo/TextualManageOpoForm.js +1 -1
- package/dist/cjs/src/components/e-commerce/opo/TextualOpoItemUpdater.js +1 -1
- package/dist/cjs/src/components/e-commerce/products/EditProductForm.js +1 -1
- package/dist/cjs/src/components/e-commerce/products/EditStockForm.js +1 -1
- package/dist/cjs/src/components/e-commerce/products/PriceFields.js +1 -1
- package/dist/cjs/src/components/e-commerce/products/ProductCard.js +1 -1
- package/dist/cjs/src/components/e-commerce/products/ProductCategoryCard.js +1 -1
- package/dist/cjs/src/components/e-commerce/products/ProductSelector.js +1 -1
- package/dist/cjs/src/components/e-commerce/products/SingleProduct.js +1 -1
- package/dist/cjs/src/components/logistics/dispatcher/DispatcherProfileEditForm.js +1 -1
- package/dist/cjs/src/components/logistics/ipo/IPOItemFields.js +1 -1
- package/dist/cjs/src/components/logistics/ipo/IPOItemUpdater.js +1 -1
- package/dist/cjs/src/components/logistics/ipo/ManageIPOForm.js +1 -1
- package/dist/cjs/src/components/logistics/ipo/TextualIPOItemUpdater.js +1 -1
- package/dist/cjs/src/components/logistics/ipo/TextualManageIPOForm.js +1 -1
- package/dist/cjs/src/components/logistics/vendor/EditVendorForm.js +1 -1
- package/dist/cjs/src/components/logistics/vendor/VendorDisplay.js +1 -1
- package/dist/cjs/src/components/logistics/vendor/VendorSelector.js +1 -1
- package/dist/cjs/src/components/page-elements/CategoryBlock.js +1 -1
- package/dist/cjs/src/components/public-information/PublicInformationForm.js +1 -1
- package/dist/cjs/src/context/e-commerce/cart/CartContext.js +1 -1
- package/dist/cjs/src/data/actions/e-commerce/categories/updateCategoryAction.js +1 -1
- package/dist/cjs/src/data/actions/e-commerce/product/updateProductAction.js +1 -1
- package/dist/cjs/src/data/actions/logistics/vendor/updateVendorAction.js +1 -1
- package/dist/cjs/src/data/actions/media/uploadBase64MediaAction.js +1 -1
- package/dist/cjs/src/data/actions/pagebuilder-actions.js +1 -1
- package/dist/cjs/src/data/actions/profile-actions.js +1 -1
- package/dist/cjs/src/data/actions/public-information/updatePublicInformationAction.js +1 -1
- package/dist/cjs/src/data/loaders/e-commerce/getSingleCustomer.js +1 -1
- package/dist/cjs/src/data/loaders/e-commerce/getSingleProduct.js +1 -1
- package/dist/cjs/src/data/loaders/logistics/getIpoNames.js +1 -1
- package/dist/cjs/src/data/loaders/logistics/getTableIpos.js +1 -1
- package/dist/cjs/src/data/loaders/logistics/getVendorNames.js +1 -1
- package/dist/cjs/src/data/loaders/logistics/queryAllIpos.js +1 -1
- package/dist/cjs/src/data/loaders/logistics/queryAllVendors.js +1 -1
- package/dist/cjs/src/data/loaders/page-elements/getSinglePage.js +1 -1
- package/dist/cjs/src/lib/molliePaymentProvider.js +1 -1
- package/dist/cjs/src/lib/parseFormData.js +1 -1
- package/dist/cjs/tsconfig.build.tsbuildinfo +1 -1
- package/dist/esm/_virtual/index3.js +2 -2
- package/dist/esm/_virtual/index4.js +2 -2
- package/dist/esm/node_modules/prop-types/node_modules/react-is/index.js +1 -1
- package/dist/esm/node_modules/safe-buffer/index.js +1 -1
- package/dist/esm/src/components/common/Address.js +4 -4
- package/dist/esm/src/components/common/csv/CsvDownloader.js +0 -1
- package/dist/esm/src/components/e-commerce/cart/CartSummary.js +1 -1
- package/dist/esm/src/components/e-commerce/cart/CartSummaryRow.js +4 -4
- package/dist/esm/src/components/e-commerce/categories/CategorySelectorV2.js +4 -3
- package/dist/esm/src/components/e-commerce/categories/EditCategoryForm.js +3 -3
- package/dist/esm/src/components/e-commerce/checkout/Step4.js +1 -1
- package/dist/esm/src/components/e-commerce/customer/CustomerProfileDisplay.js +1 -1
- package/dist/esm/src/components/e-commerce/customer/CustomerProfileEditForm.js +4 -3
- package/dist/esm/src/components/e-commerce/enduser/EnduserProfileEditForm.js +2 -2
- package/dist/esm/src/components/e-commerce/iro/IROItemFields.js +2 -2
- package/dist/esm/src/components/e-commerce/iro/IroItemUpdater.js +9 -4
- package/dist/esm/src/components/e-commerce/iro/ManageIROForm.js +4 -2
- package/dist/esm/src/components/e-commerce/iro/RmaForm.js +3 -3
- package/dist/esm/src/components/e-commerce/iro/TextualIROItemUpdater.js +4 -4
- package/dist/esm/src/components/e-commerce/iro/TextualManageIROForm.js +10 -8
- package/dist/esm/src/components/e-commerce/opo/ManageOpoForm.js +2 -2
- package/dist/esm/src/components/e-commerce/opo/OPOItemFields.js +1 -1
- package/dist/esm/src/components/e-commerce/opo/OpoItemUpdater.js +9 -4
- package/dist/esm/src/components/e-commerce/opo/OpoSummary.js +1 -1
- package/dist/esm/src/components/e-commerce/opo/OpoSummaryRow.js +1 -1
- package/dist/esm/src/components/e-commerce/opo/TextualManageOpoForm.js +7 -7
- package/dist/esm/src/components/e-commerce/opo/TextualOpoItemUpdater.js +4 -4
- package/dist/esm/src/components/e-commerce/products/EditProductForm.js +19 -17
- package/dist/esm/src/components/e-commerce/products/EditStockForm.js +39 -16
- package/dist/esm/src/components/e-commerce/products/PriceFields.js +3 -2
- package/dist/esm/src/components/e-commerce/products/ProductCard.js +3 -3
- package/dist/esm/src/components/e-commerce/products/ProductCategoryCard.js +1 -1
- package/dist/esm/src/components/e-commerce/products/ProductSelector.js +5 -5
- package/dist/esm/src/components/e-commerce/products/SingleProduct.js +5 -5
- package/dist/esm/src/components/logistics/dispatcher/DispatcherProfileEditForm.js +2 -2
- package/dist/esm/src/components/logistics/ipo/IPOItemFields.js +2 -2
- package/dist/esm/src/components/logistics/ipo/IPOItemUpdater.js +9 -4
- package/dist/esm/src/components/logistics/ipo/ManageIPOForm.js +7 -5
- package/dist/esm/src/components/logistics/ipo/TextualIPOItemUpdater.js +4 -4
- package/dist/esm/src/components/logistics/ipo/TextualManageIPOForm.js +10 -8
- package/dist/esm/src/components/logistics/vendor/EditVendorForm.js +77 -75
- package/dist/esm/src/components/logistics/vendor/VendorDisplay.js +1 -1
- package/dist/esm/src/components/logistics/vendor/VendorSelector.js +5 -4
- package/dist/esm/src/components/page-elements/CategoryBlock.js +1 -1
- package/dist/esm/src/components/public-information/PublicInformationForm.js +42 -42
- package/dist/esm/src/context/e-commerce/cart/CartContext.js +2 -2
- package/dist/esm/src/data/actions/e-commerce/categories/updateCategoryAction.js +3 -3
- package/dist/esm/src/data/actions/e-commerce/enduser/profile-actions.js +2 -2
- package/dist/esm/src/data/actions/e-commerce/product/updateProductAction.js +5 -6
- package/dist/esm/src/data/actions/logistics/dispatcher/profile-actions.js +2 -2
- package/dist/esm/src/data/actions/logistics/vendor/updateVendorAction.js +2 -2
- package/dist/esm/src/data/actions/media/uploadBase64MediaAction.js +3 -3
- package/dist/esm/src/data/actions/pagebuilder-actions.js +3 -3
- package/dist/esm/src/data/actions/profile-actions.js +3 -3
- package/dist/esm/src/data/actions/public-information/updatePublicInformationAction.js +2 -5
- package/dist/esm/src/data/loaders/e-commerce/getAllOpos.js +8 -0
- package/dist/esm/src/data/loaders/e-commerce/getSingleCustomer.js +15 -6
- package/dist/esm/src/data/loaders/e-commerce/getSingleProduct.js +2 -2
- package/dist/esm/src/data/loaders/e-commerce/getSingleStock.js +2 -2
- package/dist/esm/src/data/loaders/logistics/getIpoNames.js +1 -1
- package/dist/esm/src/data/loaders/logistics/getSingleVendor.js +2 -2
- package/dist/esm/src/data/loaders/logistics/getTableIpos.js +1 -1
- package/dist/esm/src/data/loaders/logistics/getVendorNames.js +1 -1
- package/dist/esm/src/data/loaders/logistics/queryAllIpos.js +0 -1
- package/dist/esm/src/data/loaders/logistics/queryAllVendors.js +0 -1
- package/dist/esm/src/data/loaders/page-elements/getSinglePage.js +0 -1
- package/dist/esm/src/lib/molliePaymentProvider.js +7 -3
- package/dist/esm/src/lib/parseFormData.js +1 -0
- package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
- package/dist/esm/types/components/logistics/ipo/IPOItemFields.d.ts +1 -1
- package/dist/esm/types/components/logistics/report/PreReportsDisplay.d.ts +2 -2
- package/dist/esm/types/components/page-elements/CategoryBlock.d.ts +1 -1
- package/dist/esm/types/data/actions/e-commerce/categories/updateCategoryAction.d.ts +1 -1
- package/dist/esm/types/data/actions/e-commerce/checkout-action.d.ts +2 -1
- package/dist/esm/types/data/actions/e-commerce/enduser/profile-actions.d.ts +2 -1
- package/dist/esm/types/data/actions/e-commerce/product/updateProductAction.d.ts +1 -1
- package/dist/esm/types/data/actions/logistics/dispatcher/profile-actions.d.ts +2 -1
- package/dist/esm/types/data/actions/logistics/vendor/updateVendorAction.d.ts +1 -1
- package/dist/esm/types/data/actions/media/uploadBase64MediaAction.d.ts +1 -1
- package/dist/esm/types/data/actions/pagebuilder-actions.d.ts +3 -3
- package/dist/esm/types/data/actions/profile-actions.d.ts +1 -1
- package/dist/esm/types/data/actions/public-information/updatePublicInformationAction.d.ts +1 -1
- package/dist/esm/types/data/loaders/e-commerce/getAllOpos.d.ts +8 -0
- package/dist/esm/types/data/loaders/e-commerce/getSingleProduct.d.ts +3 -2
- package/dist/esm/types/data/loaders/e-commerce/getSingleStock.d.ts +1 -1
- package/dist/esm/types/data/loaders/logistics/getSingleVendor.d.ts +1 -1
- package/dist/esm/types/data/loaders/page-elements/getSinglePage.d.ts +2 -1
- package/dist/esm/types/types/AddressProps.d.ts +1 -1
- package/dist/esm/types/types/e-commerce/cart/types.d.ts +2 -2
- package/dist/esm/types/types/e-commerce/category/types.d.ts +3 -3
- package/dist/esm/types/types/e-commerce/customer/types.d.ts +3 -7
- package/dist/esm/types/types/e-commerce/enduser/types.d.ts +1 -1
- package/dist/esm/types/types/e-commerce/invoice/types.d.ts +6 -6
- package/dist/esm/types/types/e-commerce/iro/types.d.ts +2 -4
- package/dist/esm/types/types/e-commerce/opo/types.d.ts +2 -4
- package/dist/esm/types/types/e-commerce/product/types.d.ts +9 -16
- package/dist/esm/types/types/logistics/Ipo.d.ts +2 -4
- package/dist/esm/types/types/logistics/Note.d.ts +1 -1
- package/dist/esm/types/types/logistics/Report.d.ts +4 -4
- package/dist/esm/types/types/logistics/Vendor.d.ts +4 -4
- package/dist/esm/types/types/logistics/dispatcher/types.d.ts +1 -1
- package/dist/esm/types/types/public-information/types.d.ts +1 -1
- package/package.json +1 -1
|
@@ -133,14 +133,14 @@ function TextualManageIPOForm({ data, sx, revalidateCallback, handleClose, role,
|
|
|
133
133
|
const parseItems = (items) => {
|
|
134
134
|
return items.map((item) => {
|
|
135
135
|
return {
|
|
136
|
-
id: item.
|
|
136
|
+
id: item.documentId,
|
|
137
137
|
ordered_quantity: item.ordered_quantity,
|
|
138
138
|
received_quantity: item.received_quantity,
|
|
139
139
|
registered_quantity: item.registered_quantity,
|
|
140
140
|
released_quantity: item.released_quantity,
|
|
141
141
|
reports: item.reports?.map((report) => {
|
|
142
142
|
return {
|
|
143
|
-
|
|
143
|
+
documentId: "documentId" in report ? report.documentId : undefined,
|
|
144
144
|
quantity: report.quantity,
|
|
145
145
|
content: report.content,
|
|
146
146
|
type: report.type,
|
|
@@ -151,7 +151,7 @@ function TextualManageIPOForm({ data, sx, revalidateCallback, handleClose, role,
|
|
|
151
151
|
};
|
|
152
152
|
const handleUpdateQuantity = (value, itemID, type) => {
|
|
153
153
|
const newItems = [...items];
|
|
154
|
-
const index = newItems.findIndex((item) => item.
|
|
154
|
+
const index = newItems.findIndex((item) => item.documentId === itemID);
|
|
155
155
|
newItems[index][type] = value;
|
|
156
156
|
setItems(newItems);
|
|
157
157
|
};
|
|
@@ -160,7 +160,7 @@ function TextualManageIPOForm({ data, sx, revalidateCallback, handleClose, role,
|
|
|
160
160
|
* - only used with Textual form */
|
|
161
161
|
const handleAddReport = (report, itemID) => {
|
|
162
162
|
const newItems = [...items];
|
|
163
|
-
const index = newItems.findIndex((item) => item.
|
|
163
|
+
const index = newItems.findIndex((item) => item.documentId === itemID);
|
|
164
164
|
const reportsOnItem = newItems[index]?.reports || [];
|
|
165
165
|
const newReports = [...reportsOnItem, report];
|
|
166
166
|
if (newItems[index]?.reports == undefined) {
|
|
@@ -171,7 +171,7 @@ function TextualManageIPOForm({ data, sx, revalidateCallback, handleClose, role,
|
|
|
171
171
|
};
|
|
172
172
|
const handleRemoveReportAtIndex = (itemID, index) => {
|
|
173
173
|
const newItems = [...items];
|
|
174
|
-
const itemIndex = newItems.findIndex((item) => item.
|
|
174
|
+
const itemIndex = newItems.findIndex((item) => item.documentId === itemID);
|
|
175
175
|
const reportsOnItem = newItems[itemIndex]?.reports || [];
|
|
176
176
|
const dbReports = reportsOnItem.filter((report) => "id" in report);
|
|
177
177
|
const preReports = reportsOnItem.filter((report) => !("id" in report));
|
|
@@ -207,12 +207,14 @@ function TextualManageIPOForm({ data, sx, revalidateCallback, handleClose, role,
|
|
|
207
207
|
return (jsx(Box, { sx: [
|
|
208
208
|
// You cannot spread `sx` directly because `SxProps` (typeof sx) can be an array.
|
|
209
209
|
...(Array.isArray(sx) ? sx : [sx]),
|
|
210
|
-
], children: jsxs(Grid, { container: true, spacing: 2, children: [jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { spacing: 2, children: [jsxs(Stack, { direction: "row", spacing: 2, justifyContent: "space-between", children: [jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h3", component: "h1", children: "Management Inbound Purchase Order" }), jsx(Typography, { variant: "body1", children: "Manage arrival, registration and recieval of purchase order" })] }), jsx(NoteTakingComponent, { content: "", related: [
|
|
210
|
+
], children: jsxs(Grid, { container: true, spacing: 2, children: [jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { spacing: 2, children: [jsxs(Stack, { direction: "row", spacing: 2, justifyContent: "space-between", children: [jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h3", component: "h1", children: "Management Inbound Purchase Order" }), jsx(Typography, { variant: "body1", children: "Manage arrival, registration and recieval of purchase order" })] }), jsx(NoteTakingComponent, { content: "", related: [
|
|
211
|
+
{ id: data.documentId, __type: "api::logistics.ipo" },
|
|
212
|
+
], revalidateCallback: revalidateCallback })] }), jsx(Divider, {})] }) }), jsx(Grid, { item: true, xs: 12, children: jsx(Typography, { variant: "h5", sx: { py: 1 }, children: "Details" }) }), jsx(Grid, { item: true, xs: 6, children: jsx(Paper, { elevation: 2, sx: { p: 2, height: "100%" }, children: jsxs(Stack, { spacing: 2, children: [jsxs(Stack, { direction: "row", spacing: 2, alignItems: "center", children: [jsx(NumbersIcon, { color: "primary" }), jsx(Typography, { variant: "subtitle1", color: "text.secondary", width: "200px", children: "Purchase Order Number" }), jsx(Typography, { variant: "body1", fontWeight: "medium", children: data.ipo_number })] }), jsxs(Stack, { direction: "row", spacing: 2, alignItems: "center", children: [jsx(DescriptionIcon, { color: "primary" }), jsx(Typography, { variant: "subtitle1", color: "text.secondary", width: "200px", children: "Custom Reference" }), jsx(Typography, { variant: "body1", fontWeight: "medium", children: data.customer_reference })] }), jsxs(Stack, { direction: "row", spacing: 2, alignItems: "center", children: [jsx(CalendarTodayIcon, { color: "primary" }), jsx(Typography, { variant: "subtitle1", color: "text.secondary", width: "200px", children: "Order Date" }), jsx(Typography, { variant: "body1", fontWeight: "medium", children: data.order_date })] }), jsxs(Stack, { direction: "row", spacing: 2, alignItems: "center", children: [jsx(BusinessIcon, { color: "primary" }), jsx(Typography, { variant: "subtitle1", color: "text.secondary", width: "200px", children: "Supplier" }), jsx(Typography, { variant: "body1", fontWeight: "medium", children: data.vendor_profile?.business_credentials?.company_name })] }), jsxs(Stack, { direction: "row", spacing: 2, alignItems: "center", children: [jsx(UpdateIcon, { color: "primary" }), jsx(Typography, { variant: "subtitle1", color: "text.secondary", width: "200px", children: "Order Status" }), jsx(IpoStatusIndicator, { status: data.internal_status })] })] }) }) }), role === "enduser" && (jsx(Grid, { item: true, xs: 6, children: jsx(Paper, { elevation: 2, sx: { p: 2, height: "100%" }, children: jsxs(Stack, { spacing: 2, children: [(data.internal_status === "placed" ||
|
|
211
213
|
data.internal_status === "released_on_stock") && (jsxs(Fragment, { children: [jsx(Button, { variant: "contained", color: "primary", onClick: () => setConfirmDialogOpen(true), children: "Confirm order" }), jsx(Alert, { severity: "warning", children: "Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher" }), jsx(ConfirmFormDialog, { open: confirmDialogOpen, handleClose: () => setConfirmDialogOpen(false), orderID: data.documentId, currentStatus: data.internal_status, revalidateCallback: revalidateCallback })] })), (data.internal_status === "placed" ||
|
|
212
214
|
data.internal_status === "ordered") && (jsxs(Fragment, { children: [jsx(Button, { variant: "contained", color: "error", onClick: () => setCancelDialogOpen(true), children: "Cancel order" }), jsx(CancelIpoDialog, { open: cancelDialogOpen, handleClose: () => setCancelDialogOpen(false), orderID: data.documentId, revalidateCallback: revalidateCallback })] }))] }) }) })), jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h5", children: "Documents" }), jsx(Paper, { sx: { p: 2 }, children: jsxs(Stack, { spacing: 1, children: [role === "enduser" && (jsx(Fragment, { children: data.order_confirmation ? (jsxs(Fragment, { children: [jsx(Typography, { variant: "h6", children: "Order Confirmation" }), jsx(Typography, { children: data.order_confirmation?.name }), jsx(Button, { variant: "contained", onClick: () => {
|
|
213
|
-
downloadBase64File(`api/ipos/${data.
|
|
215
|
+
downloadBase64File(`api/ipos/${data.documentId}`, "order_confirmation");
|
|
214
216
|
}, children: "Download" })] })) : (jsxs(Fragment, { children: [jsx(Typography, { variant: "h5", children: "Order Confirmation" }), jsx(Typography, { variant: "body1", children: "Here you can upload the the order confirmation for this order" }), jsx(Typography, { variant: "body1", children: "FileUpload" }), jsx(Divider, {}), jsx(UploadBase64MediaForm /* This form manages it's own state internally */, { reference: "api::logistics.ipo", refID: data.documentId, field: "order_confirmation", multiple: false, accept: "text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document", path: "api/ipos", componentName: "order_confirmation", componentReference: "common.base64-encoded-media", revalidateCallback: revalidateCallback })] })) })), data.delivery_note ? (jsxs(Fragment, { children: [jsx(Typography, { variant: "h6", children: "Delivery Note" }), jsx(Typography, { children: data.delivery_note?.name }), jsx(Button, { variant: "contained", onClick: () => {
|
|
215
|
-
downloadBase64File(`api/ipos/${data.
|
|
217
|
+
downloadBase64File(`api/ipos/${data.documentId}`, "delivery_note");
|
|
216
218
|
}, children: "Download" })] })) : (jsxs(Fragment, { children: [jsx(Typography, { variant: "h5", children: "Delivery Note" }), jsx(Typography, { variant: "body1", children: "Here you can upload the the delivery note for this order" }), jsx(Divider, {}), jsx(UploadBase64MediaForm, { reference: "api::logistics.ipo", refID: data.documentId, field: "delivery_note", multiple: false, accept: "text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document", path: "api/ipos", componentName: "delivery_note", componentReference: "common.base64-encoded-media", revalidateCallback: revalidateCallback })] }))] }) })] }) }), data?.notes?.length > 0 && (jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h5", children: "Notes" }), jsx(NotesDisplay, { notes: data.notes }), jsx(Divider, {})] }) })), jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { spacing: 1, children: [jsx(Typography, { variant: "h5", children: "Items" }), jsxs(Stack, { direction: "row", alignItems: "center", justifyContent: "flex-end", spacing: 2, component: Paper, p: 1, sx: {
|
|
217
219
|
bgcolor: "background.default",
|
|
218
220
|
border: "1px solid",
|
|
@@ -36,9 +36,8 @@ const INITIAL_STATE = {
|
|
|
36
36
|
severity: null,
|
|
37
37
|
};
|
|
38
38
|
function EditVendorForm({ data, productNamesArr, revalidateCallback, handleClose, sx, }) {
|
|
39
|
-
const {
|
|
40
|
-
|
|
41
|
-
const [formState, formAction] = useFormState(updateVendorAction, INITIAL_STATE);
|
|
39
|
+
const { documentId, website_url, phone_number, email, business_credentials, address, products, contacts, notes, } = data;
|
|
40
|
+
const [formState, formAction] = useFormState((prevState, formData) => updateVendorAction(documentId, prevState, formData), INITIAL_STATE);
|
|
42
41
|
const { handleAddMessage } = useSnackbar();
|
|
43
42
|
useEffect(() => {
|
|
44
43
|
if (formState?.message) {
|
|
@@ -81,68 +80,50 @@ function EditVendorForm({ data, productNamesArr, revalidateCallback, handleClose
|
|
|
81
80
|
// INFO must utilize the uuid to ensure that the new contacts are unique
|
|
82
81
|
// this is important to use both the deleteCallback and still not have problems with the key
|
|
83
82
|
const [newContacts, setNewContacts] = useState([]);
|
|
84
|
-
return (jsx(Box, { sx: [...(Array.isArray(sx) ? sx : [sx])], children:
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
83
|
+
return (jsx(Box, { sx: [...(Array.isArray(sx) ? sx : [sx])], children: jsx("form", { action: formAction, children: jsxs(Grid, { container: true, spacing: 2, children: [jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { direction: "row", justifyContent: "space-between", children: [jsx(Typography, { variant: "h5", children: "Edit Vendor" }), jsx(NoteTakingComponent, { content: "", related: [
|
|
84
|
+
{
|
|
85
|
+
id: data.documentId,
|
|
86
|
+
__type: "api::logistics.vendor-profile",
|
|
87
|
+
},
|
|
88
|
+
], revalidateCallback: revalidateCallback })] }) }), jsx(Grid, { item: true, xs: 12, children: jsx(ExplanatoryFoldOut, { title: "Vendor", description: "Vendors are businesses that you purchase products from." }) }), jsx(Grid, { item: true, xs: 12, md: 6, children: jsx(BusinessCredentialsFields, { data: business_credentials, componentName: "business_credentials", componentReference: "common.business-credentials" }) }), jsx(Grid, { item: true, xs: 12, md: 6, children: jsxs(Stack, { spacing: 2, children: [jsx(TextField, { id: "website_url", name: "website_url", label: "Website Url", defaultValue: website_url }), jsx(TextField, { id: "phone_number", name: "phone_number", label: "Phone Number", defaultValue: phone_number }), jsx(TextField, { id: "email", name: "email", label: "Email", defaultValue: email })] }) }), jsxs(Grid, { item: true, xs: 12, md: 6, children: [jsx(Typography, { variant: "h6", children: "Address" }), jsx(AddressFields, { data: address, componentName: "address", componentReference: "common.address" })] }), jsxs(Grid, { item: true, xs: 12, sx: { mt: 1 }, children: [jsx(Typography, { variant: "h6", children: "Products" }), jsx(ProductSelector, { productNames: productNamesArr, currentValue: initialProducts.map((prod) => prod.documentId) })] }), jsx(Grid, { item: true, xs: 12, sx: { mt: 1 }, children: jsx(Typography, { variant: "h6", children: "Contacts" }) }), oldContacts?.map((contact, index) => {
|
|
89
|
+
if (contact.data?.id) {
|
|
90
|
+
if (open.includes(contact.data?.id)) {
|
|
91
|
+
return (jsx(Grid, { item: true, xs: 12, sm: 6, md: 4, lg: 3, sx: {
|
|
92
|
+
justifyContent: "center",
|
|
93
|
+
display: "flex",
|
|
94
|
+
alignItems: "center",
|
|
95
|
+
}, children: jsx(Paper, { sx: {
|
|
96
|
+
p: 2,
|
|
97
|
+
width: "100%",
|
|
91
98
|
display: "flex",
|
|
92
|
-
alignItems: "center",
|
|
93
|
-
}, children: jsx(Paper, { sx: {
|
|
94
|
-
p: 2,
|
|
95
|
-
width: "100%",
|
|
96
|
-
display: "flex",
|
|
97
|
-
justifyContent: "center",
|
|
98
|
-
alignItems: "center",
|
|
99
|
-
height: "100%",
|
|
100
|
-
}, children: jsx(ContactsFields, { data: contact.data, componentName: `contacts[${index}]`, componentReference: "logistics-elements.contact", deleteCallback: () => {
|
|
101
|
-
setOldContacts(oldContacts.filter((_, i) => i !== index));
|
|
102
|
-
/* setOpen(
|
|
103
|
-
open.filter((openId) => openId !== contact.data?.id)
|
|
104
|
-
); */
|
|
105
|
-
} }) }) }, contact.data.id));
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
return (jsx(Grid, { item: true, xs: 12, sm: 6, md: 4, lg: 3, sx: {
|
|
109
99
|
justifyContent: "center",
|
|
110
|
-
display: "flex",
|
|
111
100
|
alignItems: "center",
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}, children: [jsx("input", { type: "hidden", name: `contacts[${index}].id`, value: contact.data.id }), jsx("input", { type: "hidden", name: `contacts[${index}].__component`, value: "logistics-elements.contact" }), jsx(Contacts, { data: { ...contact.data, onClick: onClickHandler } })] }) }, contact.data.id));
|
|
120
|
-
}
|
|
101
|
+
height: "100%",
|
|
102
|
+
}, children: jsx(ContactsFields, { data: contact.data, componentName: `contacts[${index}]`, componentReference: "logistics-elements.contact", deleteCallback: () => {
|
|
103
|
+
setOldContacts(oldContacts.filter((_, i) => i !== index));
|
|
104
|
+
/* setOpen(
|
|
105
|
+
open.filter((openId) => openId !== contact.data?.id)
|
|
106
|
+
); */
|
|
107
|
+
} }) }) }, contact.data.id));
|
|
121
108
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
return (jsx(Grid, { item: true, xs: 12, sm: 6, md: 4, lg: 3, sx: {
|
|
125
|
-
justifyContent: "center",
|
|
126
|
-
display: "flex",
|
|
127
|
-
alignItems: "center",
|
|
128
|
-
}, children: jsx(Paper, { sx: {
|
|
129
|
-
p: 2,
|
|
130
|
-
width: "100%",
|
|
131
|
-
display: "flex",
|
|
109
|
+
else {
|
|
110
|
+
return (jsx(Grid, { item: true, xs: 12, sm: 6, md: 4, lg: 3, sx: {
|
|
132
111
|
justifyContent: "center",
|
|
112
|
+
display: "flex",
|
|
133
113
|
alignItems: "center",
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
114
|
+
}, children: jsxs(Paper, { sx: {
|
|
115
|
+
p: 2,
|
|
116
|
+
width: "100%",
|
|
117
|
+
display: "flex",
|
|
118
|
+
justifyContent: "center",
|
|
119
|
+
alignItems: "center",
|
|
120
|
+
height: "100%",
|
|
121
|
+
}, children: [jsx("input", { type: "hidden", name: `contacts[${index}].id`, value: contact.data.id }), jsx("input", { type: "hidden", name: `contacts[${index}].__component`, value: "logistics-elements.contact" }), jsx(Contacts, { data: { ...contact.data, onClick: onClickHandler } })] }) }, contact.data.id));
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return null;
|
|
125
|
+
}), newContacts.map((contact, index) => {
|
|
126
|
+
return (jsx(Grid, { item: true, xs: 12, sm: 6, md: 4, lg: 3, sx: {
|
|
146
127
|
justifyContent: "center",
|
|
147
128
|
display: "flex",
|
|
148
129
|
alignItems: "center",
|
|
@@ -153,23 +134,44 @@ function EditVendorForm({ data, productNamesArr, revalidateCallback, handleClose
|
|
|
153
134
|
justifyContent: "center",
|
|
154
135
|
alignItems: "center",
|
|
155
136
|
height: "100%",
|
|
156
|
-
}, children: jsx(
|
|
157
|
-
setNewContacts(
|
|
158
|
-
|
|
159
|
-
{
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
137
|
+
}, children: jsx(ContactsFields, { data: contact.data, componentName: contact.componentName, componentReference: "logistics-elements.contact", deleteCallback: () => {
|
|
138
|
+
setNewContacts(newContacts
|
|
139
|
+
.filter((_, i) => i !== index)
|
|
140
|
+
.map((_, i) => {
|
|
141
|
+
return {
|
|
142
|
+
..._,
|
|
143
|
+
componentName: `contacts[${i + oldContacts.length}]`,
|
|
144
|
+
};
|
|
145
|
+
}));
|
|
146
|
+
} }) }) }, contact.data?.id || index));
|
|
147
|
+
}), jsx(Grid, { item: true, xs: 12, sm: 6, md: 4, lg: 3, sx: {
|
|
148
|
+
justifyContent: "center",
|
|
149
|
+
display: "flex",
|
|
150
|
+
alignItems: "center",
|
|
151
|
+
}, children: jsx(Paper, { sx: {
|
|
152
|
+
p: 2,
|
|
153
|
+
width: "100%",
|
|
154
|
+
display: "flex",
|
|
155
|
+
justifyContent: "center",
|
|
156
|
+
alignItems: "center",
|
|
157
|
+
height: "100%",
|
|
158
|
+
}, children: jsx(Button, { variant: "contained", startIcon: jsx(AddIcon, {}), onClick: () => {
|
|
159
|
+
setNewContacts([
|
|
160
|
+
...newContacts,
|
|
161
|
+
{
|
|
162
|
+
componentName: `contacts[${oldContacts.length + newContacts.length}]`,
|
|
163
|
+
componentReference: "logistics-elements.contact",
|
|
164
|
+
data: {
|
|
165
|
+
uuid: Math.random(),
|
|
166
|
+
first_name: "",
|
|
167
|
+
last_name: "",
|
|
168
|
+
email: "",
|
|
169
|
+
phone_number: "",
|
|
170
|
+
type: ContactType.Other,
|
|
170
171
|
},
|
|
171
|
-
|
|
172
|
-
|
|
172
|
+
},
|
|
173
|
+
]);
|
|
174
|
+
}, size: "large", children: "Add contact" }) }) }), jsxs(Grid, { item: true, xs: 12, children: [jsx(Typography, { variant: "h6", children: "Notes" }), notes?.data !== undefined ? (jsx(NotesDisplay, { notes: notes.data })) : (jsx(Typography, { children: "No notes to display" }))] }), " ", jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { direction: "row", spacing: 2, justifyContent: "space-between", alignItems: "center", sx: { mt: 2 }, children: [handleClose && (jsx(Button, { onClick: handleClose, variant: "outlined", children: "Cancel" })), jsx(SubmitButton, { text: "Update Vendor", loadingText: "Updating..." })] }) })] }) }) }));
|
|
173
175
|
}
|
|
174
176
|
|
|
175
177
|
export { EditVendorForm };
|
|
@@ -18,7 +18,7 @@ import { ExplanatoryFoldOut } from '../../ExplanatoryFoldOut.js';
|
|
|
18
18
|
import Contacts from '../../common/Contacts.js';
|
|
19
19
|
|
|
20
20
|
function VendorDisplay({ data, sx }) {
|
|
21
|
-
const {
|
|
21
|
+
const { documentId, website_url, phone_number, email, business_credentials, address, products, contacts, } = data;
|
|
22
22
|
console.log(contacts);
|
|
23
23
|
return (jsxs(Box, { sx: [
|
|
24
24
|
// You cannot spread `sx` directly because `SxProps` (typeof sx) can be an array.
|
|
@@ -18,12 +18,13 @@ const VendorSelector = ({ vendorNames, currentValue, onSelectVendor, }) => {
|
|
|
18
18
|
const [selectedValue, setSelectedValue] = useState(currentValue || null);
|
|
19
19
|
const handleVendorChange = (event, value) => {
|
|
20
20
|
// if (!value) return;
|
|
21
|
-
const
|
|
22
|
-
setSelectedValue(
|
|
21
|
+
const documentId = value?.documentId || null;
|
|
22
|
+
setSelectedValue(documentId);
|
|
23
23
|
if (onSelectVendor)
|
|
24
|
-
onSelectVendor(
|
|
24
|
+
onSelectVendor(documentId);
|
|
25
25
|
};
|
|
26
|
-
return (jsxs(Fragment, { children: [jsx(Autocomplete, { options: vendorNames, getOptionLabel: (option) => option?.business_credentials?.company_name, filterSelectedOptions: true, onChange: handleVendorChange, renderInput: (params) => jsx(TextField, { ...params, label: "Vendors" }), value: vendorNames?.find((vendor) => vendor.
|
|
26
|
+
return (jsxs(Fragment, { children: [jsx(Autocomplete, { options: vendorNames, getOptionLabel: (option) => option?.business_credentials?.company_name, filterSelectedOptions: true, onChange: handleVendorChange, renderInput: (params) => jsx(TextField, { ...params, label: "Vendors" }), value: vendorNames?.find((vendor) => vendor.documentId === selectedValue) ||
|
|
27
|
+
null }), jsx("input", { type: "hidden", name: "vendors", value: selectedValue ? selectedValue : "" })] }));
|
|
27
28
|
};
|
|
28
29
|
|
|
29
30
|
export { VendorSelector as default };
|
|
@@ -29,7 +29,7 @@ function CategoryBlock({ data }) {
|
|
|
29
29
|
}, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h4", component: "a", href: `/shop/categories/${data.category.slug}`, sx: { textDecoration: "none", color: "inherit" }, children: data.category.title }), data.category?.description &&
|
|
30
30
|
typeof data.category.description === "string" && (jsx(MarkdownDisplay, { children: data.category.description.substring(0, 150) + "..." })), jsx(Button, { variant: "contained", href: `/shop/categories/${data.category.slug}`, children: "Learn More" }), data.category?.products?.data != undefined && (jsxs(Fragment, { children: [jsx(Divider, { sx: { my: 2 } }), jsx(Stack, { direction: { xs: "column", sm: "row" }, spacing: 2, justifyContent: "space-around", sx: { pt: 2 }, children: data.category.products.data
|
|
31
31
|
.slice(0, previewAmount)
|
|
32
|
-
.map((product) => (jsx(ProductCard, { product: product }, product.
|
|
32
|
+
.map((product) => (jsx(ProductCard, { product: product }, product.documentId))) })] })), jsx(Typography, { variant: "body2", component: "a", href: `/shop/categories/${data.category.slug}`, sx: { textDecoration: "none", color: "inherit" }, children: "Show all" })] }) }) }) }) }));
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
export { CategoryBlock };
|
|
@@ -32,8 +32,8 @@ const INITIAL_STATE = {
|
|
|
32
32
|
message: null,
|
|
33
33
|
};
|
|
34
34
|
function PublicInformationForm({ publicInformation, sx, }) {
|
|
35
|
-
const {
|
|
36
|
-
const [formState, formAction] = useFormState(updatePublicInformationAction, INITIAL_STATE);
|
|
35
|
+
const { documentId, title, description, disclaimer_link, privacypolicy_link, maxWidth, email, phone_number, business_credentials, address, socials, header_logo, footer_logo, } = publicInformation;
|
|
36
|
+
const [formState, formAction] = useFormState((prevState, formData) => updatePublicInformationAction(documentId, prevState, formData), INITIAL_STATE);
|
|
37
37
|
const [open, setOpen] = useState([]);
|
|
38
38
|
const onClickHandler = (event, id) => {
|
|
39
39
|
if (open.includes(id)) {
|
|
@@ -58,48 +58,48 @@ function PublicInformationForm({ publicInformation, sx, }) {
|
|
|
58
58
|
// You cannot spread `sx` directly because `SxProps` (typeof sx) can be an array.
|
|
59
59
|
{ p: 2 },
|
|
60
60
|
...(Array.isArray(sx) ? sx : [sx]),
|
|
61
|
-
], component: Paper, children:
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
return (jsxs(Grid, { item: true, xs: 12, md: 6, lg: 4, children: [jsx("input", { type: "hidden", name: `socials[${index}].id`, value: social.data.id }), jsx("input", { type: "hidden", name: `socials[${index}].__component`, value: "logistics-elements.social" }), jsx(SocialsDisplay, { data: { ...social.data, onClick: onClickHandler } })] }, social.data.id));
|
|
73
|
-
}
|
|
61
|
+
], component: Paper, children: jsx("form", { action: formAction, children: jsxs(Grid, { container: true, spacing: 2, children: [jsx(Grid, { item: true, xs: 12, children: jsx(Typography, { variant: "h5", children: "Edit Public Information" }) }), jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { spacing: 2, children: [jsx(TextField, { id: "title", name: "title", label: "Title", defaultValue: title }), jsx(TextField, { id: "description", name: "description", label: "Description", defaultValue: description }), jsx(TextField, { id: "email", name: "email", label: "email", defaultValue: email }), jsx(TextField, { id: "phone_number", name: "phone_number", label: "phone_number", defaultValue: phone_number })] }) }), jsx(Grid, { item: true, xs: 12, lg: 6, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h6", children: "Company Address" }), jsx(Divider, {}), jsx(AddressFields, { componentName: "address", componentReference: "common.address", data: address })] }) }), jsx(Grid, { item: true, xs: 12, lg: 6, children: jsxs(Stack, { spacing: 2, children: [jsx(Typography, { variant: "h6", children: "Business Credentials" }), jsx(Divider, {}), jsx(BusinessCredentialsFields, { componentName: "business_credentials", componentReference: "business.credentials", data: business_credentials })] }) }), jsx(Grid, { item: true, xs: 12, sx: { mt: 1 }, children: jsx(Typography, { variant: "h6", children: "Socials" }) }), oldSocials.map((social, index) => {
|
|
62
|
+
if (social.data?.id) {
|
|
63
|
+
if (open.includes(social.data?.id)) {
|
|
64
|
+
return (jsx(Grid, { item: true, xs: 12, md: 6, lg: 4, children: jsx(SocialsFields, { data: social.data, componentName: `socials[${index}]`, componentReference: "common.social", deleteCallback: () => {
|
|
65
|
+
setOldSocials(oldSocials.filter((_, i) => i !== index));
|
|
66
|
+
/* setOpen(
|
|
67
|
+
open.filter((openId) => openId !== social.data?.id)
|
|
68
|
+
); */
|
|
69
|
+
} }) }, social.data.id));
|
|
74
70
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
71
|
+
else {
|
|
72
|
+
return (jsxs(Grid, { item: true, xs: 12, md: 6, lg: 4, children: [jsx("input", { type: "hidden", name: `socials[${index}].id`, value: social.data.id }), jsx("input", { type: "hidden", name: `socials[${index}].__component`, value: "logistics-elements.social" }), jsx(SocialsDisplay, { data: { ...social.data, onClick: onClickHandler } })] }, social.data.id));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
76
|
+
}), newSocials.map((social, index) => {
|
|
77
|
+
return (jsx(Grid, { item: true, xs: 12, md: 6, lg: 4, children: jsx(SocialsFields, { data: social.data, componentName: social.componentName, componentReference: "common.social", deleteCallback: () => {
|
|
78
|
+
setNewSocials(newSocials
|
|
79
|
+
.filter((_, i) => i !== index)
|
|
80
|
+
.map((_, i) => {
|
|
81
|
+
return {
|
|
82
|
+
..._,
|
|
83
|
+
componentName: `socials[${i + oldSocials.length}]`,
|
|
84
|
+
};
|
|
85
|
+
}));
|
|
86
|
+
} }) }, social.data?.uuid));
|
|
87
|
+
}), jsx(Grid, { item: true, xs: 12, md: 6, lg: 4, justifyContent: "center", alignItems: "center", children: jsx(IconButton, { onClick: () => {
|
|
88
|
+
setNewSocials([
|
|
89
|
+
...newSocials,
|
|
90
|
+
{
|
|
91
|
+
componentName: `socials[${oldSocials.length + newSocials.length}]`,
|
|
92
|
+
componentReference: "logistics-elements.social",
|
|
93
|
+
data: {
|
|
94
|
+
uuid: Math.random(),
|
|
95
|
+
name: "",
|
|
96
|
+
url: "",
|
|
98
97
|
},
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
98
|
+
},
|
|
99
|
+
]);
|
|
100
|
+
}, children: jsx(AddIcon, {}) }) }), jsx(Grid, { item: true, xs: 12, children: jsxs(Stack, { direction: "row-reverse", spacing: 2, alignItems: "center", sx: {
|
|
101
|
+
py: 1,
|
|
102
|
+
}, children: [jsx(SubmitButton, { text: "save changes", loadingText: "loading" }), formState?.strapiErrors && (jsx(StrapiErrors, { error: formState?.strapiErrors })), formState?.message && (jsx(Alert, { severity: "error", children: formState?.message }))] }) })] }) }) }));
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
export { PublicInformationForm };
|
|
@@ -25,7 +25,7 @@ const CartContext = createContext({
|
|
|
25
25
|
const cartReducer = (state, action) => {
|
|
26
26
|
switch (action.type) {
|
|
27
27
|
case "ADD_ITEM": {
|
|
28
|
-
const existingItemIndex = state.items.findIndex((item) => item.
|
|
28
|
+
const existingItemIndex = state.items.findIndex((item) => item.documentId === action.payload.documentId);
|
|
29
29
|
if (existingItemIndex > -1) {
|
|
30
30
|
const updatedItems = state.items.map((item, index) => index === existingItemIndex
|
|
31
31
|
? { ...item, quantity: item.quantity + action.payload.quantity }
|
|
@@ -35,7 +35,7 @@ const cartReducer = (state, action) => {
|
|
|
35
35
|
return { ...state, items: [...state.items, action.payload] };
|
|
36
36
|
}
|
|
37
37
|
case "REMOVE_ITEM": {
|
|
38
|
-
const existingItemIndex = state.items.findIndex((item) => item.
|
|
38
|
+
const existingItemIndex = state.items.findIndex((item) => item.documentId === action.payload.documentId);
|
|
39
39
|
if (existingItemIndex > -1) {
|
|
40
40
|
const updatedItems = state.items
|
|
41
41
|
.map((item, index) => index === existingItemIndex
|
|
@@ -9,8 +9,8 @@ import { mutateData } from '../../../services/mutate-data.js';
|
|
|
9
9
|
import { flattenAttributes } from '../../../../lib/utils.js';
|
|
10
10
|
import { parseFormData } from '../../../../lib/parseFormData.js';
|
|
11
11
|
|
|
12
|
-
async function updateCategoryAction(prevState, formData) {
|
|
13
|
-
|
|
12
|
+
async function updateCategoryAction(documentId, prevState, formData) {
|
|
13
|
+
Object.fromEntries(formData);
|
|
14
14
|
const parsedFormData = parseFormData(formData);
|
|
15
15
|
/**
|
|
16
16
|
* INFO: The products are JSONStringyfied in the frontend to add them to the hidden input
|
|
@@ -19,7 +19,7 @@ async function updateCategoryAction(prevState, formData) {
|
|
|
19
19
|
if (parsedFormData.data.products) {
|
|
20
20
|
parsedFormData.data.products = JSON.parse(parsedFormData.data.products);
|
|
21
21
|
}
|
|
22
|
-
const responseData = await mutateData("PUT", `/api/product-categories/${
|
|
22
|
+
const responseData = await mutateData("PUT", `/api/product-categories/${documentId}`, parsedFormData);
|
|
23
23
|
if (!responseData) {
|
|
24
24
|
return {
|
|
25
25
|
...prevState,
|
|
@@ -9,9 +9,9 @@ import { mutateData } from '../../../services/mutate-data.js';
|
|
|
9
9
|
import { flattenAttributes } from '../../../../lib/utils.js';
|
|
10
10
|
import { parseFormData } from '../../../../lib/parseFormData.js';
|
|
11
11
|
|
|
12
|
-
async function updateEnduserProfileAction(
|
|
12
|
+
async function updateEnduserProfileAction(documentId, prevState, formData) {
|
|
13
13
|
const parsedFormData = parseFormData(formData);
|
|
14
|
-
const responseData = await mutateData("PUT", `/api/enduser-profiles/${
|
|
14
|
+
const responseData = await mutateData("PUT", `/api/enduser-profiles/${documentId}`, parsedFormData);
|
|
15
15
|
if (!responseData) {
|
|
16
16
|
return {
|
|
17
17
|
...prevState,
|
|
@@ -6,11 +6,10 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { mutateData } from '../../../services/mutate-data.js';
|
|
9
|
-
import { flattenAttributes } from '../../../../lib/utils.js';
|
|
10
9
|
import { parseFormData } from '../../../../lib/parseFormData.js';
|
|
11
10
|
|
|
12
|
-
async function updateProductAction(prevState, formData) {
|
|
13
|
-
|
|
11
|
+
async function updateProductAction(documentId, prevState, formData) {
|
|
12
|
+
Object.fromEntries(formData);
|
|
14
13
|
const parsedFormData = parseFormData(formData);
|
|
15
14
|
/**
|
|
16
15
|
* INFO: The categories are JSONStringyfied in the frontend to add them to the hidden input
|
|
@@ -29,7 +28,7 @@ async function updateProductAction(prevState, formData) {
|
|
|
29
28
|
if (parsedFormData.data.stock_reports) {
|
|
30
29
|
parsedFormData.data.stock_reports = JSON.parse(parsedFormData.data.stock_reports);
|
|
31
30
|
}
|
|
32
|
-
const responseData = await mutateData("PUT", `/api/products/${
|
|
31
|
+
const responseData = await mutateData("PUT", `/api/products/${documentId}`, parsedFormData);
|
|
33
32
|
if (!responseData) {
|
|
34
33
|
return {
|
|
35
34
|
...prevState,
|
|
@@ -46,12 +45,12 @@ async function updateProductAction(prevState, formData) {
|
|
|
46
45
|
message: "Failed to Update Product.",
|
|
47
46
|
};
|
|
48
47
|
}
|
|
49
|
-
const flattenedData = flattenAttributes(responseData);
|
|
48
|
+
// const flattenedData = flattenAttributes(responseData);
|
|
50
49
|
return {
|
|
51
50
|
...prevState,
|
|
52
51
|
severity: "success",
|
|
53
52
|
message: "Product Updated Successfully",
|
|
54
|
-
data:
|
|
53
|
+
data: responseData,
|
|
55
54
|
strapiErrors: null,
|
|
56
55
|
};
|
|
57
56
|
}
|
|
@@ -9,9 +9,9 @@ import { mutateData } from '../../../services/mutate-data.js';
|
|
|
9
9
|
import { flattenAttributes } from '../../../../lib/utils.js';
|
|
10
10
|
import { parseFormData } from '../../../../lib/parseFormData.js';
|
|
11
11
|
|
|
12
|
-
async function updateDispatcherProfileAction(
|
|
12
|
+
async function updateDispatcherProfileAction(documentId, prevState, formData) {
|
|
13
13
|
const parsedFormData = parseFormData(formData);
|
|
14
|
-
const responseData = await mutateData("PUT", `/api/dispatcher-profiles/${
|
|
14
|
+
const responseData = await mutateData("PUT", `/api/dispatcher-profiles/${documentId}`, parsedFormData);
|
|
15
15
|
if (!responseData) {
|
|
16
16
|
return {
|
|
17
17
|
...prevState,
|
|
@@ -9,14 +9,14 @@ import { mutateData } from '../../../services/mutate-data.js';
|
|
|
9
9
|
import { flattenAttributes } from '../../../../lib/utils.js';
|
|
10
10
|
import { parseFormData } from '../../../../lib/parseFormData.js';
|
|
11
11
|
|
|
12
|
-
async function updateVendorAction(prevState, formData) {
|
|
12
|
+
async function updateVendorAction(documentId, prevState, formData) {
|
|
13
13
|
try {
|
|
14
14
|
const rawFormData = Object.fromEntries(formData);
|
|
15
15
|
const parsedFormData = parseFormData(formData);
|
|
16
16
|
if (parsedFormData.data.products) {
|
|
17
17
|
parsedFormData.data.products = JSON.parse(parsedFormData.data.products);
|
|
18
18
|
}
|
|
19
|
-
const responseData = await mutateData("PUT", `/api/vendor-profiles/${
|
|
19
|
+
const responseData = await mutateData("PUT", `/api/vendor-profiles/${documentId}`, parsedFormData);
|
|
20
20
|
if (!responseData) {
|
|
21
21
|
return {
|
|
22
22
|
...prevState,
|
|
@@ -24,7 +24,7 @@ const fileSchema = z.object({
|
|
|
24
24
|
)
|
|
25
25
|
.refine((file) => file.size <= MAX_FILE_SIZE, `Max file size is 5MB.`), */
|
|
26
26
|
});
|
|
27
|
-
async function uploadBase64MediaAction(path,
|
|
27
|
+
async function uploadBase64MediaAction(path, documentId, component_name, prevState, formData) {
|
|
28
28
|
// CONVERT FORM DATA TO OBJECT
|
|
29
29
|
const rawFormData = Object.fromEntries(formData);
|
|
30
30
|
parseFormData(formData);
|
|
@@ -43,7 +43,7 @@ async function uploadBase64MediaAction(path, id, component_name, prevState, form
|
|
|
43
43
|
}
|
|
44
44
|
// UPLOAD NEW IMAGE TO MEDIA LIBRARY
|
|
45
45
|
// const fileUploadResponse = await fileUploadService(formData);
|
|
46
|
-
const url = `${path}/${
|
|
46
|
+
const url = `${path}/${documentId}`;
|
|
47
47
|
// const files = rawFormData.files;
|
|
48
48
|
const files = formData.getAll("files");
|
|
49
49
|
files
|
|
@@ -78,7 +78,7 @@ async function uploadBase64MediaAction(path, id, component_name, prevState, form
|
|
|
78
78
|
}));
|
|
79
79
|
const parsedData = {
|
|
80
80
|
data: {
|
|
81
|
-
|
|
81
|
+
documentId: documentId,
|
|
82
82
|
[component_name]: filesData[0],
|
|
83
83
|
},
|
|
84
84
|
};
|
|
@@ -10,7 +10,7 @@ import { formDataToBlocks } from '../../lib/utils.js';
|
|
|
10
10
|
import { mutateData } from '../services/mutate-data.js';
|
|
11
11
|
|
|
12
12
|
const schemaUpdate = z.object({
|
|
13
|
-
|
|
13
|
+
documentId: z.string(),
|
|
14
14
|
title: z.string().min(3).max(100, {
|
|
15
15
|
message: "Title must be between 3 and 100 characters",
|
|
16
16
|
}),
|
|
@@ -108,7 +108,7 @@ const schemaUpdate = z.object({
|
|
|
108
108
|
async function updatePageAction(prevState, formData) {
|
|
109
109
|
const newBlocks = formDataToBlocks(formData);
|
|
110
110
|
const validatedFields = schemaUpdate.safeParse({
|
|
111
|
-
|
|
111
|
+
documentId: formData.get("documentId"),
|
|
112
112
|
title: formData.get("title"),
|
|
113
113
|
description: formData.get("description"),
|
|
114
114
|
blocks: newBlocks,
|
|
@@ -123,7 +123,7 @@ async function updatePageAction(prevState, formData) {
|
|
|
123
123
|
}
|
|
124
124
|
const { data } = validatedFields;
|
|
125
125
|
// important: the mutate data function expects an object (payload/body) with a data key
|
|
126
|
-
const responseData = await mutateData("PUT", `/api/pages/${data.
|
|
126
|
+
const responseData = await mutateData("PUT", `/api/pages/${data.documentId}`, {
|
|
127
127
|
data: data,
|
|
128
128
|
});
|
|
129
129
|
if (!responseData) {
|