umwd-components 0.1.655 → 0.1.657
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/.ai/form-patterns.md +2 -7
- package/dist/src/components/e-commerce/categories/AddCategoryForm.js +1 -1
- package/dist/src/components/e-commerce/categories/EditCategoryForm.js +1 -1
- package/dist/src/components/e-commerce/opo/TextualManageOpoForm.js +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/components/e-commerce/categories/AddCategoryForm.tsx +33 -20
- package/src/components/e-commerce/categories/CreateCategoryForm.tsx +23 -1
- package/src/components/e-commerce/categories/EditCategoryForm.tsx +30 -14
- package/src/components/e-commerce/opo/TextualManageOpoForm.tsx +1 -1
- package/dist/types/components/e-commerce/categories/CreateCategoryForm.d.ts +0 -9
package/.ai/form-patterns.md
CHANGED
|
@@ -79,11 +79,7 @@ When using this pattern, wrap your form in a Box component with consistent
|
|
|
79
79
|
styling:
|
|
80
80
|
|
|
81
81
|
```typescript
|
|
82
|
-
<Box
|
|
83
|
-
sx={[
|
|
84
|
-
...(Array.isArray(sx) ? sx : [sx]),
|
|
85
|
-
]}
|
|
86
|
-
>
|
|
82
|
+
<Box sx={[...(Array.isArray(sx) ? sx : [sx])]}>
|
|
87
83
|
```
|
|
88
84
|
|
|
89
85
|
### Key Features
|
|
@@ -172,9 +168,8 @@ export default function ExampleForm({
|
|
|
172
168
|
});
|
|
173
169
|
}
|
|
174
170
|
}, [formState?.strapiErrors]);
|
|
175
|
-
|
|
176
171
|
return (
|
|
177
|
-
<Box sx={[
|
|
172
|
+
<Box sx={[...(Array.isArray(sx) ? sx : [sx])]}>
|
|
178
173
|
<form action={formAction}>{/* Form content */}</form>
|
|
179
174
|
</Box>
|
|
180
175
|
);
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
import{__read as e,__spreadArray as r}from"../../../../node_modules/tslib/tslib.es6.js";import t,{useEffect as a}from"react";import o from"@mui/material/Box";import
|
|
7
|
+
import{__read as e,__spreadArray as r}from"../../../../node_modules/tslib/tslib.es6.js";import t,{useEffect as a}from"react";import o from"@mui/material/Box";import i from"@mui/material/Stack";import m from"@mui/material/TextField";import n from"@mui/material/Typography";import{Button as s}from"@mui/material";import{SubmitButton as c}from"../../SubmitButton.js";import{useFormState as l}from"react-dom";import{createCategoryAction as d}from"../../../data/actions/e-commerce/categories/createCategoryAction.js";import u from"@mui/material/Grid";import p from"../products/ProductSelector.js";import E from"../../common/markdown/MarkdownEditor.js";import{useSnackbar as g}from"../../../context/common/SnackbarContext.js";var y={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function f(f){var v=f.productNamesArray,x=f.revalidateCallback,C=f.sx,b=f.handleClose,h=e(l(d,y),2),j=h[0],k=h[1],A=g().handleAddMessage;return a((function(){(null==j?void 0:j.message)&&(A({message:j.message||"Error creating category",severity:j.severity||"error"}),"success"===j.severity&&(x&&x(),b&&b()))}),[null==j?void 0:j.message]),a((function(){(null==j?void 0:j.strapiErrors)&&A({message:j.strapiErrors.message||"Error creating category",severity:j.severity||"error"})}),[null==j?void 0:j.strapiErrors]),t.createElement(o,{sx:r([],e(Array.isArray(C)?C:[C]),!1)},t.createElement("form",{action:k},t.createElement(u,{container:!0,spacing:2},t.createElement(u,{item:!0,xs:12},t.createElement(i,{spacing:2},t.createElement(n,{variant:"h3",component:"h1"},"Add Category"),t.createElement(n,{variant:"body2"},"Create a new category for your products. You can add products to this category later."))),t.createElement(u,{item:!0,xs:12},t.createElement(i,{spacing:2},t.createElement(m,{id:"title",name:"title",label:"Title"}),t.createElement(E,{name:"description",label:"Description"}))),t.createElement(u,{item:!0,xs:12},t.createElement(n,{variant:"h6"},"Products"),t.createElement(p,{productNames:v,currentValue:[]})),t.createElement(u,{item:!0,xs:12},t.createElement(i,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2}},b&&t.createElement(s,{onClick:b,variant:"outlined"},"Cancel"),t.createElement(c,{text:"Create category",loadingText:"Loading...",variant:"contained"}))))))}export{f as AddCategoryForm};
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
import{__read as e,__spreadArray as t}from"../../../../node_modules/tslib/tslib.es6.js";import r,{useEffect as a}from"react";import i from"@mui/material/Box";import o from"@mui/material/Stack";import m from"@mui/material/TextField";import n from"@mui/material/Typography";import{SubmitButton as l}from"../../SubmitButton.js";import{useFormState as s}from"react-dom";import{updateCategoryAction as c}from"../../../data/actions/e-commerce/categories/updateCategoryAction.js";import d from"@mui/material/Grid";import u from"../products/ProductSelector.js";import p from"../../common/markdown/MarkdownEditor.js";import{useSnackbar as
|
|
7
|
+
import{__read as e,__spreadArray as t}from"../../../../node_modules/tslib/tslib.es6.js";import r,{useEffect as a}from"react";import i from"@mui/material/Box";import o from"@mui/material/Stack";import m from"@mui/material/TextField";import n from"@mui/material/Typography";import{SubmitButton as l}from"../../SubmitButton.js";import{useFormState as s}from"react-dom";import{updateCategoryAction as c}from"../../../data/actions/e-commerce/categories/updateCategoryAction.js";import d from"@mui/material/Grid";import u from"../products/ProductSelector.js";import p from"../../common/markdown/MarkdownEditor.js";import{useSnackbar as E}from"../../../context/common/SnackbarContext.js";import{Button as g}from"@mui/material";var f={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function v(v){var y=v.data,x=v.revalidateCallback,h=v.handleClose,b=v.productNamesArray,C=v.sx,j=y.id,k=y.title,A=y.description;y.slug,y.is_archive;var w=y.products,S=(null==w?void 0:w.data)||[],T=e(s(c,f),2),V=T[0],B=T[1],M=E().handleAddMessage;return a((function(){(null==V?void 0:V.message)&&(M({message:V.message,severity:V.severity||"error"}),"success"===V.severity&&(x&&x(),h&&h()))}),[null==V?void 0:V.message]),a((function(){(null==V?void 0:V.strapiErrors)&&M({message:V.strapiErrors.message||"Error updating category",severity:V.severity||"error"})}),[null==V?void 0:V.strapiErrors]),r.createElement(i,{sx:t([],e(Array.isArray(C)?C:[C]),!1)},r.createElement("form",{action:B},j&&r.createElement("input",{id:"id",type:"hidden",name:"id",value:j}),r.createElement(d,{container:!0,spacing:2},r.createElement(d,{item:!0,xs:12},r.createElement(o,{spacing:2},r.createElement(n,{variant:"h3",component:"h1"},"Edit Category"),r.createElement(n,{variant:"body2"},"Edit the category for your products. You can add products to this category later."))),r.createElement(d,{item:!0,xs:12},r.createElement(o,{spacing:2},r.createElement(m,{id:"title",name:"title",label:"Title",defaultValue:k}),r.createElement(p,{name:"description",label:"Description",defaultValue:A}))),r.createElement(d,{item:!0,xs:12},r.createElement(n,{variant:"h6"},"Products"),r.createElement(u,{productNames:b,currentValue:t([],e(S.map((function(e){return e.id}))),!1)})),r.createElement(d,{item:!0,xs:12},r.createElement(o,{direction:"row",justifyContent:"space-between",alignItems:"center"},h&&r.createElement(g,{onClick:h,variant:"outlined"},"Cancel"),r.createElement(l,{text:"Update category",loadingText:"Loading...",variant:"contained"}))))))}export{v as EditCategoryForm};
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* @copyright Jelle Paulus
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
|
-
import{__read as e,__spreadArray as t,__assign as n}from"../../../../node_modules/tslib/tslib.es6.js";import r,{useState as a,useEffect as i}from"react";import{useFormState as o}from"react-dom";import{updateOpoAction as l}from"../../../data/actions/e-commerce/opo/updateOpoAction.js";import{UploadBase64MediaForm as c}from"../../common/media/UploadBase64MediaForm.js";import m from"../../../data/loaders/common/media/downloadBase64File.js";import d from"./TextualOpoItemUpdater.js";import s from"./OpoItemDisplay.js";import u from"../../logistics/note/NotesDisplay.js";import p from"../../logistics/note/NoteTakingComponent.js";import v from"@mui/material/Alert";import E from"@mui/material/Dialog";import f from"@mui/material/DialogActions";import h from"@mui/material/DialogContent";import g from"@mui/material/DialogTitle";import y from"@mui/material/Typography";import x from"@mui/material/Button";import b from"@mui/material/Grid";import C from"@mui/material/Box";import k from"@mui/material/Paper";import _ from"@mui/material/Stack";import w from"@mui/material/Divider";import{confirmationService as I}from"../../../data/services/common/confirmation-service.js";import{cancellationService as D}from"../../../data/services/common/cancellation-service.js";import{FormControlLabel as j,Checkbox as N,List as O,ListItem as q,TextField as A}from"@mui/material";import B from"@mui/icons-material/Numbers";import S from"@mui/icons-material/CalendarToday";import T from"@mui/icons-material/Business";import P from"@mui/icons-material/Description";import U from"@mui/icons-material/Update";import{OpoStatusIndicator as F}from"./OpoStatusIndicator.js";import{SubmitButton as R}from"../../SubmitButton.js";var W={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function M(e){var t=e.open,n=e.handleClose,a=e.orderID,i=e.currentStatus,o=e.revalidateCallback;return r.createElement(E,{open:t},r.createElement(g,null,"Confirm Order"),r.createElement(h,null,r.createElement(_,{spacing:2},r.createElement(y,null,"Are you sure you want to confirm this order?"),r.createElement(y,null,"Current status: ",i))),r.createElement(f,null,r.createElement(x,{variant:"contained",onClick:function(e){I("opos",[a]),o&&o(),n()}},"Yes"),r.createElement(x,{variant:"contained",onClick:n},"No")))}function Y(t){var n=t.open,i=t.handleClose,o=t.orderID,l=t.revalidateCallback,c=e(a(""),2),m=c[0],d=c[1],s=e(a(""),2),u=s[0],p=s[1];return r.createElement("form",null,r.createElement(E,{open:n},r.createElement(g,null,"Cancel Return"),r.createElement(h,null,r.createElement(_,{spacing:2},r.createElement(y,null,"Are you sure you want to cancel this order?"),r.createElement(O,null,r.createElement(q,null,"By cancelling this order you will update it's status from ordered to cancelled"),r.createElement(q,null,"Please provide a reason for the cancellation"),r.createElement(q,null,"The customer will be notified about the cancellation and of the reason for the cancellation")),r.createElement(A,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:m,onChange:function(e){return d(e.target.value)},placeholder:"Please provide a reason for the cancellation",error:!!u,helperText:u}))),r.createElement(f,null,r.createElement(x,{variant:"contained",onClick:function(e){m.length<5?p("Please provide a reason for the cancellation"):(D("opos",o,m),l&&l(),i())}},"Yes"),r.createElement(x,{variant:"contained",onClick:i},"No"))))}function z(E){var f,h,g,I,D,O=E.opo,q=E.sx,A=E.revalidateCallback;E.handleClose;var z=E.role,G=l.bind(O.id),H=e(o(G,W),2),J=H[0],L=H[1],Q=e(a(O.opo_items.data?O.opo_items.data:[]),2),K=Q[0],V=Q[1],X=e(a(!1),2),Z=X[0],$=X[1],ee=e(a(!1),2),te=ee[0],ne=ee[1],re=e(a(["picked","packed","shipped","reports"]),2),ae=re[0],ie=re[1],oe=function(n,r,a){var i=t([],e(K),!1),o=i.findIndex((function(e){return e.id===r}));i[o][a]=n,V(i)},le=function(r,a){var i,o,l,c=t([],e(K),!1),m=c.findIndex((function(e){return e.id===a})),d=(null===(o=null===(i=c[m])||void 0===i?void 0:i.reports)||void 0===o?void 0:o.data)||[],s=t(t([],e(d),!1),[r],!1);null==(null===(l=c[m])||void 0===l?void 0:l.reports)&&(c[m]=n(n({},c[m]),{reports:{data:[]}})),c[m].reports.data=s,V(c)},ce=function(n,r){var a,i,o=t([],e(K),!1),l=o.findIndex((function(e){return e.id===n})),c=(null===(i=null===(a=o[l])||void 0===a?void 0:a.reports)||void 0===i?void 0:i.data)||[],m=c.filter((function(e){return"id"in e})),d=c.filter((function(e){return!("id"in e)}));d.splice(r,1);var s=t(t([],e(m),!1),e(d),!1);o[l].reports.data=s,V(o)};return i((function(){"Ipo Updated"===(null==J?void 0:J.message)&&A&&A()}),[J]),i((function(){var e;(null===(e=O.opo_items)||void 0===e?void 0:e.data)&&V(O.opo_items.data?O.opo_items.data:[])}),[O]),r.createElement(C,{sx:t([{p:2}],e(Array.isArray(q)?q:[q]),!1),component:k},r.createElement(b,{container:!0,spacing:2},r.createElement(b,{item:!0,xs:12},r.createElement(_,{spacing:2},r.createElement(_,{direction:"row",spacing:2,justifyContent:"space-between"},r.createElement(_,{spacing:2},r.createElement(y,{variant:"h3",component:"h1"},"Management Outbound Purchase Order"),r.createElement(y,{variant:"body1"},"Manage picking, packing and shipping of purchase order")),r.createElement(p,{content:"",related:[{id:O.id,__type:"api::e-commerce.opo"}],revalidateCallback:A})),r.createElement(w,null))),r.createElement(b,{item:!0,xs:12},r.createElement(y,{variant:"h5",sx:{py:1}},"Details")),r.createElement(b,{item:!0,xs:6},r.createElement(k,{elevation:2,sx:{p:2,height:"100%"}},r.createElement(_,{spacing:2},r.createElement(_,{direction:"row",spacing:2,alignItems:"center"},r.createElement(B,{color:"primary"}),r.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Purchase Order Number"),r.createElement(y,{variant:"body1",fontWeight:"medium"},O.opo_number)),r.createElement(_,{direction:"row",spacing:2,alignItems:"center"},r.createElement(P,{color:"primary"}),r.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Custom reference"),r.createElement(y,{variant:"body1",fontWeight:"medium"},O.customer_reference)),r.createElement(_,{direction:"row",spacing:2,alignItems:"center"},r.createElement(S,{color:"primary"}),r.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Order Date"),r.createElement(y,{variant:"body1",fontWeight:"medium"},O.order_date)),r.createElement(_,{direction:"row",spacing:2,alignItems:"center"},r.createElement(T,{color:"primary"}),r.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Customer"),r.createElement(y,{variant:"body1",fontWeight:"medium"},null===(h=null===(f=O.customer)||void 0===f?void 0:f.business_credentials)||void 0===h?void 0:h.company_name)),r.createElement(_,{direction:"row",spacing:2,alignItems:"center"},r.createElement(U,{color:"primary"}),r.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Order Status"),r.createElement(F,{status:O.status}))))),"enduser"===z&&r.createElement(b,{item:!0,xs:6},r.createElement(k,{elevation:2,sx:{p:2,height:"100%"}},r.createElement(_,{spacing:2},("placed"===O.status||"external_shipping_process"===O.status)&&r.createElement(r.Fragment,null,r.createElement(x,{variant:"contained",color:"primary",onClick:function(){return $(!0)}},"Confirm order"),r.createElement(v,{severity:"warning"},"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"),r.createElement(M,{open:Z,handleClose:function(){return $(!1)},orderID:O.id,currentStatus:O.status,revalidateCallback:A})),("placed"===O.status||"ordered"===O.status)&&r.createElement(r.Fragment,null,r.createElement(x,{variant:"contained",color:"error",onClick:function(){return ne(!0)}},"Cancel order"),r.createElement(Y,{open:te,handleClose:function(){return ne(!1)},orderID:O.id,revalidateCallback:A}))))),r.createElement(b,{item:!0,xs:12},r.createElement(_,{spacing:2},r.createElement(y,{variant:"h5"},"Documents"),r.createElement(k,{sx:{p:2}},r.createElement(_,{spacing:1},O.delivery_note?r.createElement(r.Fragment,null,r.createElement(y,{variant:"h6"},"Delivery Note"),r.createElement(y,null,null===(g=O.delivery_note)||void 0===g?void 0:g.name),r.createElement(x,{variant:"contained",onClick:function(){m("api/ipos/".concat(O.id),"delivery_note")}},"Download")):r.createElement(r.Fragment,null,r.createElement(y,{variant:"h5"},"Delivery Note"),r.createElement(y,{variant:"body1"},"Here you can upload the the delivery note for this order"),r.createElement(w,null),r.createElement(c,{reference:"api::e-commerce.opo",refID:O.id,field:"delivery_note",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/ipos",componentName:"delivery_note",componentReference:"common.base64-encoded-media",revalidateCallback:A})))))),(null===(D=null===(I=null==O?void 0:O.notes)||void 0===I?void 0:I.data)||void 0===D?void 0:D.length)>0&&r.createElement(b,{item:!0,xs:12},r.createElement(_,{spacing:2},r.createElement(y,{variant:"h5"},"Notes"),r.createElement(u,{notes:O.notes.data}),r.createElement(w,null))),r.createElement(b,{item:!0,xs:12},r.createElement(_,{spacing:1},r.createElement(y,{variant:"h5"},"Items"),r.createElement(_,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:k,p:1},r.createElement(y,{variant:"body1"},"Show:"),["picked","packed","shipped","reports"].map((function(n){return r.createElement(j,{key:n,control:r.createElement(N,{checked:ae.includes(n),onChange:function(r){r.target.checked?ie(t(t([],e(ae),!1),[n],!1)):ie(ae.filter((function(e){return e!==n})))}}),label:n.charAt(0).toUpperCase()+n.slice(1)})}))),"placed"===O.status&&r.createElement(v,{severity:"warning"},"Before confirmation you cannot update the items"),r.createElement(w,null),r.createElement("form",{action:L},r.createElement("input",{name:"id",type:"hidden",value:O.id}),r.createElement("input",{type:"hidden",name:"items",value:JSON.stringify(function(e){return e.map((function(e){var t,n;return{id:e.id,ordered_quantity:e.ordered_quantity,picked_quantity:e.picked_quantity,packed_quantity:e.packed_quantity,shipped_quantity:e.shipped_quantity,reports:(null===(n=null===(t=e.reports)||void 0===t?void 0:t.data)||void 0===n?void 0:n.map((function(e){return{id:"id"in e?e.id:void 0,quantity:e.quantity,content:e.content,type:e.type}})))||[]}}))}(K))}),K&&K.map((function(e,t){var n,a;return r.createElement(k,{sx:{p:2,mb:2},key:t},"placed"===O.status||"external_shipping_process"===O.status||"done"===O.status||"cancelled"===O.status?r.createElement(s,{item:e,index:t,image:null===(n=null==e?void 0:e.product)||void 0===n?void 0:n.image}):r.createElement(d,{item:e,index:t,handleUpdateQuantity:oe,handleAddReport:le,image:null===(a=null==e?void 0:e.product)||void 0===a?void 0:a.image,handleRemoveReportAtIndex:ce,revalidateCallback:A,showing:ae}))})),r.createElement(k,{sx:{p:2}},r.createElement(_,{direction:"row",spacing:2,justifyContent:"end"},r.createElement(R,{text:"Update items",loadingText:"Loading..."}))))))))}export{z as default};
|
|
6
|
+
import{__read as e,__spreadArray as t,__assign as n}from"../../../../node_modules/tslib/tslib.es6.js";import r,{useState as a,useEffect as i}from"react";import{useFormState as o}from"react-dom";import{updateOpoAction as l}from"../../../data/actions/e-commerce/opo/updateOpoAction.js";import{UploadBase64MediaForm as c}from"../../common/media/UploadBase64MediaForm.js";import m from"../../../data/loaders/common/media/downloadBase64File.js";import d from"./TextualOpoItemUpdater.js";import s from"./OpoItemDisplay.js";import u from"../../logistics/note/NotesDisplay.js";import p from"../../logistics/note/NoteTakingComponent.js";import v from"@mui/material/Alert";import E from"@mui/material/Dialog";import f from"@mui/material/DialogActions";import h from"@mui/material/DialogContent";import g from"@mui/material/DialogTitle";import y from"@mui/material/Typography";import x from"@mui/material/Button";import b from"@mui/material/Grid";import C from"@mui/material/Box";import k from"@mui/material/Paper";import _ from"@mui/material/Stack";import w from"@mui/material/Divider";import{confirmationService as I}from"../../../data/services/common/confirmation-service.js";import{cancellationService as D}from"../../../data/services/common/cancellation-service.js";import{FormControlLabel as j,Checkbox as N,List as O,ListItem as q,TextField as A}from"@mui/material";import B from"@mui/icons-material/Numbers";import S from"@mui/icons-material/CalendarToday";import T from"@mui/icons-material/Business";import P from"@mui/icons-material/Description";import U from"@mui/icons-material/Update";import{OpoStatusIndicator as F}from"./OpoStatusIndicator.js";import{SubmitButton as R}from"../../SubmitButton.js";var W={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function M(e){var t=e.open,n=e.handleClose,a=e.orderID,i=e.currentStatus,o=e.revalidateCallback;return r.createElement(E,{open:t},r.createElement(g,null,"Confirm Order"),r.createElement(h,null,r.createElement(_,{spacing:2},r.createElement(y,null,"Are you sure you want to confirm this order?"),r.createElement(y,null,"Current status: ",i))),r.createElement(f,null,r.createElement(x,{variant:"contained",onClick:function(e){I("opos",[a]),o&&o(),n()}},"Yes"),r.createElement(x,{variant:"contained",onClick:n},"No")))}function Y(t){var n=t.open,i=t.handleClose,o=t.orderID,l=t.revalidateCallback,c=e(a(""),2),m=c[0],d=c[1],s=e(a(""),2),u=s[0],p=s[1];return r.createElement("form",null,r.createElement(E,{open:n},r.createElement(g,null,"Cancel Return"),r.createElement(h,null,r.createElement(_,{spacing:2},r.createElement(y,null,"Are you sure you want to cancel this order?"),r.createElement(O,null,r.createElement(q,null,"By cancelling this order you will update it's status from ordered to cancelled"),r.createElement(q,null,"Please provide a reason for the cancellation"),r.createElement(q,null,"The customer will be notified about the cancellation and of the reason for the cancellation")),r.createElement(A,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:m,onChange:function(e){return d(e.target.value)},placeholder:"Please provide a reason for the cancellation",error:!!u,helperText:u}))),r.createElement(f,null,r.createElement(x,{variant:"contained",onClick:function(e){m.length<5?p("Please provide a reason for the cancellation"):(D("opos",o,m),l&&l(),i())}},"Yes"),r.createElement(x,{variant:"contained",onClick:i},"No"))))}function z(E){var f,h,g,I,D,O=E.opo,q=E.sx,A=E.revalidateCallback;E.handleClose;var z=E.role,G=l.bind(O.id),H=e(o(G,W),2),J=H[0],L=H[1],Q=e(a(O.opo_items.data?O.opo_items.data:[]),2),K=Q[0],V=Q[1],X=e(a(!1),2),Z=X[0],$=X[1],ee=e(a(!1),2),te=ee[0],ne=ee[1],re=e(a(["picked","packed","shipped","reports"]),2),ae=re[0],ie=re[1],oe=function(n,r,a){var i=t([],e(K),!1),o=i.findIndex((function(e){return e.id===r}));i[o][a]=n,V(i)},le=function(r,a){var i,o,l,c=t([],e(K),!1),m=c.findIndex((function(e){return e.id===a})),d=(null===(o=null===(i=c[m])||void 0===i?void 0:i.reports)||void 0===o?void 0:o.data)||[],s=t(t([],e(d),!1),[r],!1);null==(null===(l=c[m])||void 0===l?void 0:l.reports)&&(c[m]=n(n({},c[m]),{reports:{data:[]}})),c[m].reports.data=s,V(c)},ce=function(n,r){var a,i,o=t([],e(K),!1),l=o.findIndex((function(e){return e.id===n})),c=(null===(i=null===(a=o[l])||void 0===a?void 0:a.reports)||void 0===i?void 0:i.data)||[],m=c.filter((function(e){return"id"in e})),d=c.filter((function(e){return!("id"in e)}));d.splice(r,1);var s=t(t([],e(m),!1),e(d),!1);o[l].reports.data=s,V(o)};return i((function(){"Ipo Updated"===(null==J?void 0:J.message)&&A&&A()}),[J]),i((function(){var e;(null===(e=O.opo_items)||void 0===e?void 0:e.data)&&V(O.opo_items.data?O.opo_items.data:[])}),[O]),r.createElement(C,{sx:t([],e(Array.isArray(q)?q:[q]),!1)},r.createElement(b,{container:!0,spacing:2},r.createElement(b,{item:!0,xs:12},r.createElement(_,{spacing:2},r.createElement(_,{direction:"row",spacing:2,justifyContent:"space-between"},r.createElement(_,{spacing:2},r.createElement(y,{variant:"h3",component:"h1"},"Management Outbound Purchase Order"),r.createElement(y,{variant:"body1"},"Manage picking, packing and shipping of purchase order")),r.createElement(p,{content:"",related:[{id:O.id,__type:"api::e-commerce.opo"}],revalidateCallback:A})),r.createElement(w,null))),r.createElement(b,{item:!0,xs:12},r.createElement(y,{variant:"h5",sx:{py:1}},"Details")),r.createElement(b,{item:!0,xs:6},r.createElement(k,{elevation:2,sx:{p:2,height:"100%"}},r.createElement(_,{spacing:2},r.createElement(_,{direction:"row",spacing:2,alignItems:"center"},r.createElement(B,{color:"primary"}),r.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Purchase Order Number"),r.createElement(y,{variant:"body1",fontWeight:"medium"},O.opo_number)),r.createElement(_,{direction:"row",spacing:2,alignItems:"center"},r.createElement(P,{color:"primary"}),r.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Custom reference"),r.createElement(y,{variant:"body1",fontWeight:"medium"},O.customer_reference)),r.createElement(_,{direction:"row",spacing:2,alignItems:"center"},r.createElement(S,{color:"primary"}),r.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Order Date"),r.createElement(y,{variant:"body1",fontWeight:"medium"},O.order_date)),r.createElement(_,{direction:"row",spacing:2,alignItems:"center"},r.createElement(T,{color:"primary"}),r.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Customer"),r.createElement(y,{variant:"body1",fontWeight:"medium"},null===(h=null===(f=O.customer)||void 0===f?void 0:f.business_credentials)||void 0===h?void 0:h.company_name)),r.createElement(_,{direction:"row",spacing:2,alignItems:"center"},r.createElement(U,{color:"primary"}),r.createElement(y,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Order Status"),r.createElement(F,{status:O.status}))))),"enduser"===z&&r.createElement(b,{item:!0,xs:6},r.createElement(k,{elevation:2,sx:{p:2,height:"100%"}},r.createElement(_,{spacing:2},("placed"===O.status||"external_shipping_process"===O.status)&&r.createElement(r.Fragment,null,r.createElement(x,{variant:"contained",color:"primary",onClick:function(){return $(!0)}},"Confirm order"),r.createElement(v,{severity:"warning"},"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"),r.createElement(M,{open:Z,handleClose:function(){return $(!1)},orderID:O.id,currentStatus:O.status,revalidateCallback:A})),("placed"===O.status||"ordered"===O.status)&&r.createElement(r.Fragment,null,r.createElement(x,{variant:"contained",color:"error",onClick:function(){return ne(!0)}},"Cancel order"),r.createElement(Y,{open:te,handleClose:function(){return ne(!1)},orderID:O.id,revalidateCallback:A}))))),r.createElement(b,{item:!0,xs:12},r.createElement(_,{spacing:2},r.createElement(y,{variant:"h5"},"Documents"),r.createElement(k,{sx:{p:2}},r.createElement(_,{spacing:1},O.delivery_note?r.createElement(r.Fragment,null,r.createElement(y,{variant:"h6"},"Delivery Note"),r.createElement(y,null,null===(g=O.delivery_note)||void 0===g?void 0:g.name),r.createElement(x,{variant:"contained",onClick:function(){m("api/ipos/".concat(O.id),"delivery_note")}},"Download")):r.createElement(r.Fragment,null,r.createElement(y,{variant:"h5"},"Delivery Note"),r.createElement(y,{variant:"body1"},"Here you can upload the the delivery note for this order"),r.createElement(w,null),r.createElement(c,{reference:"api::e-commerce.opo",refID:O.id,field:"delivery_note",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/ipos",componentName:"delivery_note",componentReference:"common.base64-encoded-media",revalidateCallback:A})))))),(null===(D=null===(I=null==O?void 0:O.notes)||void 0===I?void 0:I.data)||void 0===D?void 0:D.length)>0&&r.createElement(b,{item:!0,xs:12},r.createElement(_,{spacing:2},r.createElement(y,{variant:"h5"},"Notes"),r.createElement(u,{notes:O.notes.data}),r.createElement(w,null))),r.createElement(b,{item:!0,xs:12},r.createElement(_,{spacing:1},r.createElement(y,{variant:"h5"},"Items"),r.createElement(_,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:k,p:1},r.createElement(y,{variant:"body1"},"Show:"),["picked","packed","shipped","reports"].map((function(n){return r.createElement(j,{key:n,control:r.createElement(N,{checked:ae.includes(n),onChange:function(r){r.target.checked?ie(t(t([],e(ae),!1),[n],!1)):ie(ae.filter((function(e){return e!==n})))}}),label:n.charAt(0).toUpperCase()+n.slice(1)})}))),"placed"===O.status&&r.createElement(v,{severity:"warning"},"Before confirmation you cannot update the items"),r.createElement(w,null),r.createElement("form",{action:L},r.createElement("input",{name:"id",type:"hidden",value:O.id}),r.createElement("input",{type:"hidden",name:"items",value:JSON.stringify(function(e){return e.map((function(e){var t,n;return{id:e.id,ordered_quantity:e.ordered_quantity,picked_quantity:e.picked_quantity,packed_quantity:e.packed_quantity,shipped_quantity:e.shipped_quantity,reports:(null===(n=null===(t=e.reports)||void 0===t?void 0:t.data)||void 0===n?void 0:n.map((function(e){return{id:"id"in e?e.id:void 0,quantity:e.quantity,content:e.content,type:e.type}})))||[]}}))}(K))}),K&&K.map((function(e,t){var n,a;return r.createElement(k,{sx:{p:2,mb:2},key:t},"placed"===O.status||"external_shipping_process"===O.status||"done"===O.status||"cancelled"===O.status?r.createElement(s,{item:e,index:t,image:null===(n=null==e?void 0:e.product)||void 0===n?void 0:n.image}):r.createElement(d,{item:e,index:t,handleUpdateQuantity:oe,handleAddReport:le,image:null===(a=null==e?void 0:e.product)||void 0===a?void 0:a.image,handleRemoveReportAtIndex:ce,revalidateCallback:A,showing:ae}))})),r.createElement(k,{sx:{p:2}},r.createElement(_,{direction:"row",spacing:2,justifyContent:"end"},r.createElement(R,{text:"Update items",loadingText:"Loading..."}))))))))}export{z as default};
|