umwd-components 0.1.707 → 0.1.709
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/src/components/common/EnhancedTable/EnhancedTable.js +1 -1
- package/dist/src/components/common/EnhancedTable/EnhancedTableFilterRow.js +1 -1
- package/dist/src/components/e-commerce/opo/TextualManageOpoForm.js +1 -1
- package/dist/src/components/logistics/note/NoteTakingComponent.js +1 -1
- package/dist/src/data/actions/logistics/note/createNoteAction.js +1 -1
- package/dist/src/data/loaders/e-commerce/getAllOpos.js +1 -1
- package/dist/src/data/loaders/e-commerce/getSingleOpo.js +1 -1
- package/dist/src/lib/processFilters.js +6 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/data/loaders/e-commerce/getAllOpos.d.ts +4 -1
- package/dist/types/data/loaders/e-commerce/getSingleOpo.d.ts +1 -1
- package/dist/types/lib/processFilters.d.ts +11 -0
- package/package.json +1 -1
- package/src/components/common/EnhancedTable/EnhancedTable.tsx +44 -30
- package/src/components/common/EnhancedTable/EnhancedTableFilterRow.tsx +42 -19
- package/src/components/common/TextualAmountUpdater.tsx +1 -7
- package/src/components/e-commerce/opo/TextualManageOpoForm.tsx +11 -6
- package/src/components/logistics/note/NoteTakingComponent.tsx +6 -6
- package/src/data/actions/logistics/note/createNoteAction.ts +2 -1
- package/src/data/loaders/e-commerce/getAllOpos.ts +5 -1
- package/src/data/loaders/e-commerce/getSingleOpo.ts +3 -2
- package/src/data/loaders/e-commerce/getTableProducts.ts +1 -0
- package/src/lib/processFilters.ts +43 -0
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* @copyright Jelle Paulus
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
|
-
import{__read as e,__assign as t}from"../../../../node_modules/tslib/tslib.es6.js";import n,{useState as o,useEffect as l}from"react";import i from"@mui/material/Box";import a from"@mui/material/Table";import r from"@mui/material/TableBody";import c from"@mui/material/TableCell";import m from"@mui/material/TableContainer";import s from"@mui/material/TablePagination";import u from"@mui/material/TableRow";import d from"@mui/material/Paper";import f from"@mui/material/FormControlLabel";import
|
|
6
|
+
import{__read as e,__assign as t}from"../../../../node_modules/tslib/tslib.es6.js";import n,{useState as o,useEffect as l}from"react";import i from"@mui/material/Box";import a from"@mui/material/Table";import r from"@mui/material/TableBody";import c from"@mui/material/TableCell";import m from"@mui/material/TableContainer";import s from"@mui/material/TablePagination";import u from"@mui/material/TableRow";import d from"@mui/material/Paper";import f from"@mui/material/FormControlLabel";import g from"@mui/material/Switch";import h from"./EnhancedTableHead.js";import p from"./EnhancedTableToolbar.js";import b from"./EnhancedTableRow.js";import v from"./EnhancedTableFilterRow.js";import{useRouter as w,usePathname as S,useSearchParams as E}from"next/navigation";function C(C){var P,T,R,F,x=C.data,y=C.meta,j=C.headCells,k=C.subHeadCells,B=C.withSelection,H=C.title,L=C.subTitle,O=C.functions,U=C.selectFunctions,q=w().replace,z=S(),A=E(),D=e(o("asc"),2),I=D[0],W=D[1],_=e(o("id"),2),G=_[0],J=_[1],K=e(o([]),2),M=K[0],N=K[1],Q=e(o(0),2),V=Q[0],X=Q[1],Y=e(o(!1),2),Z=Y[0],$=Y[1],ee=e(o(5),2),te=ee[0],ne=ee[1],oe=e(o(!1),2),le=oe[0],ie=oe[1],ae=e(o((function(){var e=new URLSearchParams(null==A?void 0:A.toString()),t={};return j.forEach((function(n){if(n.filterable){var o=e.get("filter[".concat(n.id,"]"));o&&(t[n.id]=o)}})),t})),2),re=ae[0],ce=ae[1],me=j.some((function(e){return e.filterable})),se=function(e,t){var n=M.indexOf(t),o=[];-1===n?o=o.concat(M,t):0===n?o=o.concat(M.slice(1)):n===M.length-1?o=o.concat(M.slice(0,-1)):n>0&&(o=o.concat(M.slice(0,n),M.slice(n+1))),N(o)},ue=V+1===(null===(P=null==y?void 0:y.pagination)||void 0===P?void 0:P.pageCount)?(null===(T=null==y?void 0:y.pagination)||void 0===T?void 0:T.total)-(null===(R=null==y?void 0:y.pagination)||void 0===R?void 0:R.pageCount)*te:0;return l((function(){if(A){console.log("Search Params:",A.toString());var t=new URLSearchParams(A);console.log(t),I?t.set("order",I):t.delete("order"),G?t.set("orderBy",G):t.delete("orderBy"),V?t.set("page",V.toString()):t.delete("page"),te?t.set("rowsPerPage",te.toString()):t.delete("rowsPerPage"),Object.entries(re).forEach((function(n){var o=e(n,2),l=o[0],i=o[1];i?t.set("filter[".concat(l,"]"),i):t.delete("filter[".concat(l,"]"))})),q("".concat(z,"?").concat(t.toString()))}}),[I,G,V,te,re]),n.createElement(i,{sx:{width:"100%"}},n.createElement(d,{sx:{width:"100%",mb:2}},n.createElement(p,{selected:M,setSelected:N,title:H,functions:O,selectFunctions:U,showFilters:le,onToggleFilters:function(){return ie(!le)},hasFilterableColumns:me}),n.createElement(m,null,n.createElement(a,{sx:{minWidth:750},"aria-labelledby":"tableTitle",size:Z?"small":"medium"},n.createElement(h,{numSelected:M.length,order:I,orderBy:G,onSelectAllClick:function(e){if(e.target.checked){var t=x.map((function(e){return e.id}));N(t)}else N([])},onRequestSort:function(e,t){W(G===t&&"asc"===I?"desc":"asc"),J(t)},rowCount:x.length,headCells:j,withSelection:B,withSubRows:!!k}),n.createElement(r,null,le&&n.createElement(v,{headCells:j,filters:re,onFilterChange:function(e,n){ce((function(o){var l;return t(t({},o),((l={})[e]=n,l))})),X(0)},withSelection:B,withSubRows:!!k}),x.map((function(e,t){return n.createElement(b,{key:e.id,row:e,headCells:j,subHeadCells:k,withSelection:B,isSelected:M.includes(e.id),handleSelectClick:se,subTitle:L})})),ue>0&&n.createElement(u,{style:{height:(Z?33:53)*ue}},n.createElement(c,{colSpan:j.length+(B?1:0)+(k?1:0)}))))),n.createElement(s,{rowsPerPageOptions:[5,10,25],component:"div",count:null===(F=null==y?void 0:y.pagination)||void 0===F?void 0:F.total,rowsPerPage:te,page:V,onPageChange:function(e,t){X(t)},onRowsPerPageChange:function(e){ne(parseInt(e.target.value,10)),X(0)}})),n.createElement(f,{control:n.createElement(g,{checked:Z,onChange:function(e){$(e.target.checked)}}),label:"Dense padding"}))}export{C as default};
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* @copyright Jelle Paulus
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
|
-
import{__read as e,__assign as t}from"../../../../node_modules/tslib/tslib.es6.js";import
|
|
6
|
+
import{__read as e,__assign as t}from"../../../../node_modules/tslib/tslib.es6.js";import l from"react";import r from"@mui/material/TableRow";import a from"@mui/material/TableCell";import n from"@mui/material/TextField";import i from"@mui/material/Select";import o from"@mui/material/MenuItem";import u from"@mui/material/Box";function m(m){var c=m.headCells,d=m.filters,f=m.onFilterChange,s=m.withSelection,p=m.withSubRows,v=e(l.useState(d),2),h=v[0],g=v[1],E=function(e,t){f(e,t)};return l.createElement(r,null,s&&l.createElement(a,{padding:"checkbox"}),p&&l.createElement(a,null),c.map((function(r){return l.createElement(a,{key:r.id,align:r.numeric?"right":"left",padding:r.disablePadding?"none":"normal"},r.filterable&&function(){var a,m=h[r.id]||"";switch(r.filterType){case"select":return l.createElement(i,{size:"small",value:m,onChange:function(e){var l=e.target.value;g((function(e){var a;return t(t({},e),((a={})[r.id]=l,a))})),E(r.id,l)},fullWidth:!0},l.createElement(o,{value:""},"All"),null===(a=r.filterOptions)||void 0===a?void 0:a.map((function(e){return l.createElement(o,{key:e,value:e},e)})));case"date":var c=e(m?m.split(","):["",""],2),d=c[0],f=c[1];return l.createElement(u,{sx:{display:"flex",gap:1}},l.createElement(n,{type:"date",size:"small",placeholder:"Start date",value:d,onChange:function(e){var l=[e.target.value,f].filter(Boolean).join(",");g((function(e){var a;return t(t({},e),((a={})[r.id]=l,a))})),E(r.id,l)},sx:{flex:1}}),l.createElement(n,{type:"date",size:"small",placeholder:"End date",value:f,onChange:function(e){var l=e.target.value,a=[d,l].filter(Boolean).join(",");g((function(e){var l;return t(t({},e),((l={})[r.id]=a,l))})),E(r.id,a)},sx:{flex:1}}));default:return l.createElement(n,{size:"small",placeholder:"Filter ".concat(r.label),value:m,onChange:function(e){return g((function(l){var a;return t(t({},l),((a={})[r.id]=e.target.value,a))}))},onBlur:function(){return E(r.id,m)},onKeyPress:function(e){"Enter"===e.key&&E(r.id,m)},fullWidth:!0})}}())})))}export{m as default};
|
|
@@ -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 r,__awaiter as n,__generator as a}from"../../../../node_modules/tslib/tslib.es6.js";import i,{useState as o,useEffect as l}from"react";import{useFormState as c}from"react-dom";import{updateOpoAction as m}from"../../../data/actions/e-commerce/opo/updateOpoAction.js";import{UploadBase64MediaForm as s}from"../../common/media/UploadBase64MediaForm.js";import d from"../../../data/loaders/common/media/downloadBase64File.js";import u from"./TextualOpoItemUpdater.js";import p from"./OpoItemDisplay.js";import v from"../../logistics/note/NotesDisplay.js";import f from"../../logistics/note/NoteTakingComponent.js";import E from"@mui/material/Alert";import g from"@mui/material/Dialog";import h from"@mui/material/DialogActions";import y from"@mui/material/DialogContent";import C from"@mui/material/DialogTitle";import x from"@mui/material/Typography";import b from"@mui/material/Button";import k from"@mui/material/Grid";import w from"@mui/material/Box";import _ from"@mui/material/Paper";import I from"@mui/material/Stack";import D from"@mui/material/Divider";import{confirmationService as j}from"../../../data/services/common/confirmation-service.js";import{cancellationService as O}from"../../../data/services/common/cancellation-service.js";import{FormControlLabel as A,Checkbox as q,List as N,ListItem as S,TextField as B}from"@mui/material";import P from"@mui/icons-material/Numbers";import T from"@mui/icons-material/CalendarToday";import F from"@mui/icons-material/Business";import U from"@mui/icons-material/Description";import M from"@mui/icons-material/Update";import{OpoStatusIndicator as R}from"./OpoStatusIndicator.js";import{useSnackbar as W}from"../../../context/common/SnackbarContext.js";import{SubmitButton as z}from"../../SubmitButton.js";var G={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null},H=["picked","packed","shipped","reports"];function J(e){var t=e.open,r=e.handleClose,n=e.orderID,a=e.currentStatus,o=e.revalidateCallback;return i.createElement(g,{open:t,onClose:r},i.createElement(C,null,"Confirm Order"),i.createElement(y,null,i.createElement(I,{spacing:2},i.createElement(x,null,"Are you sure you want to confirm this order?"),i.createElement(x,null,"Current status: ",a))),i.createElement(h,null,i.createElement(b,{variant:"contained",onClick:function(e){j("opos",[n]),o&&o(),r()}},"Yes"),i.createElement(b,{variant:"contained",onClick:r},"No")))}function Q(t){var r=this,l=t.open,c=t.handleClose,m=t.orderID,s=t.revalidateCallback,d=e(o(""),2),u=d[0],p=d[1],v=e(o(""),2),f=v[0],E=v[1],k=W().handleAddMessage;return i.createElement(g,{open:l,onClose:c},i.createElement(C,null,"Cancel Return"),i.createElement(y,null,i.createElement(I,{spacing:2},i.createElement(x,null,"Are you sure you want to cancel this order?"),i.createElement(N,null,i.createElement(S,null,"By cancelling this order you will update it's status from ordered to cancelled"),i.createElement(S,null,"Please provide a reason for the cancellation"),i.createElement(S,null,"The customer will be notified about the cancellation and of the reason for the cancellation")),i.createElement(B,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:u,onChange:function(e){return p(e.target.value)},placeholder:"Please provide a reason for the cancellation",error:!!f,helperText:f}))),i.createElement(h,null,i.createElement(b,{variant:"outlined",onClick:c},"Close"),i.createElement(b,{variant:"contained",color:"error",onClick:function(){return n(r,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:if(u.length<5)return E("Please provide a reason for the cancellation (min 5 characters)"),[2];E(""),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,O("opos",m,u)];case 2:return e.sent(),k({message:"Order cancelled successfully",severity:"success"}),s&&s(),c(),[3,4];case 3:return e.sent(),k({message:"Failed to cancel order",severity:"error"}),[3,4];case 4:return[2]}}))}))}},"Confirm Cancellation")))}function Y(n){var a,g,h,y,C,j=n.opo,O=n.sx,N=n.revalidateCallback,S=n.handleClose,B=n.role,Y=m.bind(null,j.id),K=e(c(Y,G),2),L=K[0],V=K[1],X=W().handleAddMessage,Z=e(o(j.opo_items.data?j.opo_items.data:[]),2),$=Z[0],ee=Z[1],te=e(o(!1),2),re=te[0],ne=te[1],ae=e(o(!1),2),ie=ae[0],oe=ae[1],le=e(o(["picked","packed","shipped","reports"]),2),ce=le[0],me=le[1];l((function(){(null==L?void 0:L.message)&&(X({message:L.message,severity:L.severity||"info"}),"success"===L.severity&&(null==N||N(),null==S||S()))}),[null==L?void 0:L.message]),l((function(){(null==L?void 0:L.strapiErrors)&&X({message:L.strapiErrors.message||"Error updating OPO",severity:"error"})}),[null==L?void 0:L.strapiErrors]),l((function(){var e;(null===(e=j.opo_items)||void 0===e?void 0:e.data)&&ee(j.opo_items.data?j.opo_items.data:[])}),[j]);var se=function(r,n,a){var i=t([],e($),!1),o=i.findIndex((function(e){return e.id===n}));i[o][a]=r,ee(i)},de=function(n,a){var i,o,l,c=t([],e($),!1),m=c.findIndex((function(e){return e.id===a})),s=(null===(o=null===(i=c[m])||void 0===i?void 0:i.reports)||void 0===o?void 0:o.data)||[],d=t(t([],e(s),!1),[n],!1);null==(null===(l=c[m])||void 0===l?void 0:l.reports)&&(c[m]=r(r({},c[m]),{reports:{data:[]}})),c[m].reports.data=d,ee(c)},ue=function(r,n){var a,i,o=t([],e($),!1),l=o.findIndex((function(e){return e.id===r})),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})),s=c.filter((function(e){return!("id"in e)}));s.splice(n,1);var d=t(t([],e(m),!1),e(s),!1);o[l].reports.data=d,ee(o)};return i.createElement(w,{sx:t([],e(Array.isArray(O)?O:[O]),!1)},i.createElement(k,{container:!0,spacing:2},i.createElement(k,{item:!0,xs:12},i.createElement(I,{spacing:2},i.createElement(I,{direction:"row",spacing:2,justifyContent:"space-between"},i.createElement(I,{spacing:2},i.createElement(x,{variant:"h3",component:"h1"},"Management Outbound Purchase Order"),i.createElement(x,{variant:"body1"},"Manage picking, packing and shipping of purchase order")),i.createElement(f,{content:"",related:[{id:j.id,__type:"api::e-commerce.opo"}],revalidateCallback:N})),i.createElement(D,null))),i.createElement(k,{item:!0,xs:12},i.createElement(x,{variant:"h5",sx:{py:1}},"Details")),i.createElement(k,{item:!0,xs:6},i.createElement(_,{elevation:2,sx:{p:2,height:"100%"}},i.createElement(I,{spacing:2},i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(P,{color:"primary"}),i.createElement(x,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Purchase Order Number"),i.createElement(x,{variant:"body1",fontWeight:"medium"},j.opo_number)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(U,{color:"primary"}),i.createElement(x,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Custom reference"),i.createElement(x,{variant:"body1",fontWeight:"medium"},j.customer_reference)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(T,{color:"primary"}),i.createElement(x,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Order Date"),i.createElement(x,{variant:"body1",fontWeight:"medium"},j.order_date)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(F,{color:"primary"}),i.createElement(x,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Customer"),i.createElement(x,{variant:"body1",fontWeight:"medium"},null===(g=null===(a=j.customer)||void 0===a?void 0:a.business_credentials)||void 0===g?void 0:g.company_name)),i.createElement(I,{direction:"row",spacing:2,alignItems:"center"},i.createElement(M,{color:"primary"}),i.createElement(x,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Order Status"),i.createElement(R,{status:j.status}))))),"enduser"===B&&i.createElement(k,{item:!0,xs:6},i.createElement(_,{elevation:2,sx:{p:2,height:"100%"}},i.createElement(I,{spacing:2},("placed"===j.status||"external_shipping_process"===j.status)&&i.createElement(i.Fragment,null,i.createElement(b,{variant:"contained",color:"primary",onClick:function(){return ne(!0)}},"Confirm order"),i.createElement(E,{severity:"warning"},"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"),i.createElement(J,{open:re,handleClose:function(){return ne(!1)},orderID:j.id,currentStatus:j.status,revalidateCallback:N})),("placed"===j.status||"ordered"===j.status)&&i.createElement(i.Fragment,null,i.createElement(b,{variant:"contained",color:"error",onClick:function(){return oe(!0)}},"Cancel order"),i.createElement(Q,{open:ie,handleClose:function(){return oe(!1)},orderID:j.id,revalidateCallback:N}))))),i.createElement(k,{item:!0,xs:12},i.createElement(I,{spacing:2},i.createElement(x,{variant:"h5"},"Documents"),i.createElement(_,{sx:{p:2}},i.createElement(I,{spacing:1},j.delivery_note?i.createElement(i.Fragment,null,i.createElement(x,{variant:"h6"},"Delivery Note"),i.createElement(x,null,null===(h=j.delivery_note)||void 0===h?void 0:h.name),i.createElement(b,{variant:"contained",onClick:function(){d("api/ipos/".concat(j.id),"delivery_note")}},"Download")):i.createElement(i.Fragment,null,i.createElement(x,{variant:"h5"},"Delivery Note"),i.createElement(x,{variant:"body1"},"Here you can upload the the delivery note for this order"),i.createElement(D,null),i.createElement(s,{reference:"api::e-commerce.opo",refID:j.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:N})))))),(null===(C=null===(y=null==j?void 0:j.notes)||void 0===y?void 0:y.data)||void 0===C?void 0:C.length)>0&&i.createElement(k,{item:!0,xs:12},i.createElement(I,{spacing:2},i.createElement(x,{variant:"h5"},"Notes"),i.createElement(v,{notes:j.notes.data}),i.createElement(D,null))),i.createElement(k,{item:!0,xs:12},i.createElement(I,{spacing:1},i.createElement(x,{variant:"h5"},"Items"),i.createElement(I,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:_,p:1},i.createElement(x,{variant:"body1"},"Show:"),H.map((function(r){return i.createElement(A,{key:r,control:i.createElement(q,{checked:ce.includes(r),onChange:function(n){n.target.checked?me(t(t([],e(ce),!1),[r],!1)):me(ce.filter((function(e){return e!==r})))}}),label:r.charAt(0).toUpperCase()+r.slice(1)})}))),"placed"===j.status&&i.createElement(E,{severity:"warning"},"Before confirmation you cannot update the items"),i.createElement(D,null),i.createElement("form",{action:V},i.createElement("input",{type:"hidden",name:"items",value:JSON.stringify(function(e){return e.map((function(e){var t,r;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===(r=null===(t=e.reports)||void 0===t?void 0:t.data)||void 0===r?void 0:r.map((function(e){return{id:"id"in e?e.id:void 0,quantity:e.quantity,content:e.content,type:e.type}})))||[]}}))}($))}),$&&$.map((function(e,t){var r,n;return i.createElement(_,{sx:{p:2,mb:2},key:t},"placed"===j.status||"external_shipping_process"===j.status||"done"===j.status||"cancelled"===j.status?i.createElement(p,{item:e,index:t,image:null===(r=null==e?void 0:e.product)||void 0===r?void 0:r.image}):i.createElement(u,{item:e,index:t,handleUpdateQuantity:se,handleAddReport:de,image:null===(n=null==e?void 0:e.product)||void 0===n?void 0:n.image,handleRemoveReportAtIndex:ue,revalidateCallback:N,showing:ce}))}))," ",i.createElement(I,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2}},S&&i.createElement(b,{onClick:S,variant:"outlined"},"Cancel"),i.createElement(z,{text:"Update items",loadingText:"Saving...",variant:"contained"})))))))}export{Y as default};
|
|
6
|
+
import{__read as e,__spreadArray as t,__assign as r,__awaiter as n,__generator as a}from"../../../../node_modules/tslib/tslib.es6.js";import o,{useState as i,useEffect as l}from"react";import{useFormState as c}from"react-dom";import{updateOpoAction as m}from"../../../data/actions/e-commerce/opo/updateOpoAction.js";import{UploadBase64MediaForm as s}from"../../common/media/UploadBase64MediaForm.js";import d from"../../../data/loaders/common/media/downloadBase64File.js";import u from"./TextualOpoItemUpdater.js";import p from"./OpoItemDisplay.js";import v from"../../logistics/note/NotesDisplay.js";import f from"../../logistics/note/NoteTakingComponent.js";import E from"@mui/material/Alert";import g from"@mui/material/Dialog";import h from"@mui/material/DialogActions";import y from"@mui/material/DialogContent";import x from"@mui/material/DialogTitle";import C from"@mui/material/Typography";import b from"@mui/material/Button";import k from"@mui/material/Grid";import _ from"@mui/material/Box";import w from"@mui/material/Paper";import I from"@mui/material/Stack";import D from"@mui/material/Divider";import{confirmationService as j}from"../../../data/services/common/confirmation-service.js";import{cancellationService as O}from"../../../data/services/common/cancellation-service.js";import{FormControlLabel as A,Checkbox as q,List as N,ListItem as S,TextField as B}from"@mui/material";import P from"@mui/icons-material/Numbers";import T from"@mui/icons-material/CalendarToday";import F from"@mui/icons-material/Business";import U from"@mui/icons-material/Description";import M from"@mui/icons-material/Update";import{OpoStatusIndicator as R}from"./OpoStatusIndicator.js";import{useSnackbar as W}from"../../../context/common/SnackbarContext.js";import{SubmitButton as z}from"../../SubmitButton.js";var G={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null},H=["picked","packed","shipped","reports"];function J(e){var t=e.open,r=e.handleClose,n=e.orderID,a=e.currentStatus,i=e.revalidateCallback;return o.createElement(g,{open:t,onClose:r},o.createElement(x,null,"Confirm Order"),o.createElement(y,null,o.createElement(I,{spacing:2},o.createElement(C,null,"Are you sure you want to confirm this order?"),o.createElement(C,null,"Current status: ",a))),o.createElement(h,null,o.createElement(b,{variant:"contained",onClick:function(e){j("opos",[n]),i&&i(),r()}},"Yes"),o.createElement(b,{variant:"contained",onClick:r},"No")))}function Q(t){var r=this,l=t.open,c=t.handleClose,m=t.orderID,s=t.revalidateCallback,d=e(i(""),2),u=d[0],p=d[1],v=e(i(""),2),f=v[0],E=v[1],k=W().handleAddMessage;return o.createElement(g,{open:l,onClose:c},o.createElement(x,null,"Cancel Return"),o.createElement(y,null,o.createElement(I,{spacing:2},o.createElement(C,null,"Are you sure you want to cancel this order?"),o.createElement(N,null,o.createElement(S,null,"By cancelling this order you will update it's status from ordered to cancelled"),o.createElement(S,null,"Please provide a reason for the cancellation"),o.createElement(S,null,"The customer will be notified about the cancellation and of the reason for the cancellation")),o.createElement(B,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:u,onChange:function(e){return p(e.target.value)},placeholder:"Please provide a reason for the cancellation",error:!!f,helperText:f}))),o.createElement(h,null,o.createElement(b,{variant:"outlined",onClick:c},"Close"),o.createElement(b,{variant:"contained",color:"error",onClick:function(){return n(r,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:if(u.length<5)return E("Please provide a reason for the cancellation (min 5 characters)"),[2];E(""),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,O("opos",m,u)];case 2:return e.sent(),k({message:"Order cancelled successfully",severity:"success"}),s&&s(),c(),[3,4];case 3:return e.sent(),k({message:"Failed to cancel order",severity:"error"}),[3,4];case 4:return[2]}}))}))}},"Confirm Cancellation")))}function Y(n){var a,g,h,y,x,j=n.opo,O=n.sx,N=n.revalidateCallback,S=n.handleClose,B=n.role,Y=m.bind(null,j.id),K=e(c(Y,G),2),L=K[0],V=K[1],X=W().handleAddMessage,Z=e(i(j.opo_items.data?j.opo_items.data:[]),2),$=Z[0],ee=Z[1],te=e(i(!1),2),re=te[0],ne=te[1],ae=e(i(!1),2),oe=ae[0],ie=ae[1],le=e(i(["picked","packed","shipped","reports"]),2),ce=le[0],me=le[1];l((function(){(null==L?void 0:L.message)&&(X({message:L.message,severity:L.severity||"info"}),"success"===L.severity&&(null==N||N(),null==S||S()))}),[null==L?void 0:L.message]),l((function(){(null==L?void 0:L.strapiErrors)&&X({message:L.strapiErrors.message||"Error updating OPO",severity:"error"})}),[null==L?void 0:L.strapiErrors]),l((function(){var e;(null===(e=j.opo_items)||void 0===e?void 0:e.data)&&ee(j.opo_items.data?j.opo_items.data:[])}),[j]);var se=function(r,n,a){var o=t([],e($),!1),i=o.findIndex((function(e){return e.id===n}));o[i][a]=r,ee(o)},de=function(n,a){var o,i,l,c=t([],e($),!1),m=c.findIndex((function(e){return e.id===a})),s=(null===(i=null===(o=c[m])||void 0===o?void 0:o.reports)||void 0===i?void 0:i.data)||[],d=t(t([],e(s),!1),[n],!1);null==(null===(l=c[m])||void 0===l?void 0:l.reports)&&(c[m]=r(r({},c[m]),{reports:{data:[]}})),c[m].reports.data=d,ee(c)},ue=function(r,n){var a,o,i=t([],e($),!1),l=i.findIndex((function(e){return e.id===r})),c=(null===(o=null===(a=i[l])||void 0===a?void 0:a.reports)||void 0===o?void 0:o.data)||[],m=c.filter((function(e){return"id"in e})),s=c.filter((function(e){return!("id"in e)}));s.splice(n,1);var d=t(t([],e(m),!1),e(s),!1);i[l].reports.data=d,ee(i)};return o.createElement(_,{sx:t([],e(Array.isArray(O)?O:[O]),!1)},o.createElement(k,{container:!0,spacing:2},o.createElement(k,{item:!0,xs:12},o.createElement(I,{spacing:2},o.createElement(I,{direction:"row",spacing:2,justifyContent:"space-between"},o.createElement(I,{spacing:2},o.createElement(C,{variant:"h3",component:"h1"},"Management Outbound Purchase Order"),o.createElement(C,{variant:"body1"},"Manage picking, packing and shipping of purchase order")),o.createElement(f,{content:"",related:[{id:j.id,__type:"api::e-commerce.opo"}],revalidateCallback:N})),o.createElement(D,null))),o.createElement(k,{item:!0,xs:12},o.createElement(C,{variant:"h5",sx:{py:1}},"Details")),o.createElement(k,{item:!0,xs:6},o.createElement(w,{elevation:2,sx:{p:2,height:"100%"}},o.createElement(I,{spacing:2},o.createElement(I,{direction:"row",spacing:2,alignItems:"center"},o.createElement(P,{color:"primary"}),o.createElement(C,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Purchase Order Number"),o.createElement(C,{variant:"body1",fontWeight:"medium"},j.opo_number)),o.createElement(I,{direction:"row",spacing:2,alignItems:"center"},o.createElement(U,{color:"primary"}),o.createElement(C,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Custom reference"),o.createElement(C,{variant:"body1",fontWeight:"medium"},j.customer_reference)),o.createElement(I,{direction:"row",spacing:2,alignItems:"center"},o.createElement(T,{color:"primary"}),o.createElement(C,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Order Date"),o.createElement(C,{variant:"body1",fontWeight:"medium"},j.order_date)),o.createElement(I,{direction:"row",spacing:2,alignItems:"center"},o.createElement(F,{color:"primary"}),o.createElement(C,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Customer"),o.createElement(C,{variant:"body1",fontWeight:"medium"},null===(g=null===(a=j.customer)||void 0===a?void 0:a.business_credentials)||void 0===g?void 0:g.company_name)),o.createElement(I,{direction:"row",spacing:2,alignItems:"center"},o.createElement(M,{color:"primary"}),o.createElement(C,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Order Status"),o.createElement(R,{status:j.status}))))),"enduser"===B&&o.createElement(k,{item:!0,xs:6},o.createElement(w,{elevation:2,sx:{p:2,height:"100%"}},o.createElement(I,{spacing:2},("placed"===j.status||"external_shipping_process"===j.status)&&o.createElement(o.Fragment,null,o.createElement(b,{variant:"contained",color:"primary",onClick:function(){return ne(!0)}},"Confirm order"),o.createElement(E,{severity:"warning"},"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"),o.createElement(J,{open:re,handleClose:function(){return ne(!1)},orderID:j.id,currentStatus:j.status,revalidateCallback:N})),("placed"===j.status||"ordered"===j.status)&&o.createElement(o.Fragment,null,o.createElement(b,{variant:"contained",color:"error",onClick:function(){return ie(!0)}},"Cancel order"),o.createElement(Q,{open:oe,handleClose:function(){return ie(!1)},orderID:j.id,revalidateCallback:N}))))),o.createElement(k,{item:!0,xs:12},o.createElement(I,{spacing:2},o.createElement(C,{variant:"h5"},"Documents"),o.createElement(w,{sx:{p:2}},o.createElement(I,{spacing:1},j.delivery_note?o.createElement(o.Fragment,null,o.createElement(C,{variant:"h6"},"Delivery Note"),o.createElement(C,null,null===(h=j.delivery_note)||void 0===h?void 0:h.name),o.createElement(b,{variant:"contained",onClick:function(){d("api/ipos/".concat(j.id),"delivery_note")}},"Download")):o.createElement(o.Fragment,null,o.createElement(C,{variant:"h5"},"Delivery Note"),o.createElement(C,{variant:"body1"},"Here you can upload the the delivery note for this order"),o.createElement(D,null),o.createElement(s,{reference:"api::e-commerce.opo",refID:j.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:N})))))),(null===(x=null===(y=null==j?void 0:j.notes)||void 0===y?void 0:y.data)||void 0===x?void 0:x.length)>0&&o.createElement(k,{item:!0,xs:12},o.createElement(I,{spacing:2},o.createElement(C,{variant:"h5"},"Notes"),o.createElement(v,{notes:j.notes.data}),o.createElement(D,null))),o.createElement(k,{item:!0,xs:12},o.createElement(I,{spacing:1},o.createElement(C,{variant:"h5"},"Items"),o.createElement(I,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:w,p:1},o.createElement(C,{variant:"body1"},"Show:"),H.map((function(r){return o.createElement(A,{key:r,control:o.createElement(q,{checked:ce.includes(r),onChange:function(n){n.target.checked?me(t(t([],e(ce),!1),[r],!1)):me(ce.filter((function(e){return e!==r})))}}),label:r.charAt(0).toUpperCase()+r.slice(1)})}))),"placed"===j.status&&o.createElement(E,{severity:"warning"},"Before confirmation you cannot update the items"),o.createElement(D,null),o.createElement("form",{action:V},o.createElement("input",{type:"hidden",name:"items",value:JSON.stringify(function(e){return e.map((function(e){var t,r;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===(r=null===(t=e.reports)||void 0===t?void 0:t.data)||void 0===r?void 0:r.map((function(e){return{id:"id"in e?e.id:void 0,quantity:e.quantity,content:e.content,type:e.type}})))||[]}}))}($))}),$&&$.map((function(e,t){var r,n;return o.createElement(w,{sx:{p:2,mb:2},key:t},"placed"===j.status||"external_shipping_process"===j.status||"done"===j.status||"cancelled"===j.status?o.createElement(p,{item:e,index:t,image:null===(r=null==e?void 0:e.product)||void 0===r?void 0:r.image}):o.createElement(u,{item:e,index:t,handleUpdateQuantity:se,handleAddReport:de,image:null===(n=null==e?void 0:e.product)||void 0===n?void 0:n.image,handleRemoveReportAtIndex:ue,revalidateCallback:N,showing:ce}))}))," ",o.createElement(I,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{pt:2}},S&&o.createElement(b,{onClick:S,variant:"outlined"},"Close"),"placed"!==j.status&&"external_shipping_process"!==j.status&&"done"!==j.status&&"cancelled"!==j.status&&o.createElement(z,{text:"Update items",loadingText:"Saving...",variant:"contained"})))))))}export{Y as default};
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* @copyright Jelle Paulus
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
|
-
import{__read as e}from"../../../../node_modules/tslib/tslib.es6.js";import t,{useState as r,useEffect as o}from"react";import l from"@mui/material/IconButton";import i from"@mui/material/Dialog";import n from"@mui/material/DialogContent";import a from"@mui/material/DialogActions";import m from"@mui/material/Button";import c from"@mui/material/Typography";import s from"@mui/material/Paper";import u from"@mui/material/Stack";import f from"../../../../node_modules/dayjs/dayjs.min.js";import d from"@mui/icons-material/NoteAlt";import{SubmitButton as p}from"../../SubmitButton.js";import{useFormState as g}from"react-dom";import{createNoteAction as v}from"../../../data/actions/logistics/note/createNoteAction.js";import E from"../../common/markdown/MarkdownEditor.js";import{useSnackbar as b}from"../../../context/common/SnackbarContext.js";var x={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function k(k){var h,y,j=k.content,C=k.related,w=k.revalidateCallback,D=e(r(!1),2),A=D[0],S=D[1],z=v.bind(null,C),M=e(g(z,x),2),T=M[0],Y=M[1],B=b().handleAddMessage;return o((function(){(null==T?void 0:T.strapiErrors)&&B({message:T.strapiErrors,severity:T.severity||"error"}),(null==T?void 0:T.message)&&
|
|
6
|
+
import{__read as e}from"../../../../node_modules/tslib/tslib.es6.js";import t,{useState as r,useEffect as o}from"react";import l from"@mui/material/IconButton";import i from"@mui/material/Dialog";import n from"@mui/material/DialogContent";import a from"@mui/material/DialogActions";import m from"@mui/material/Button";import c from"@mui/material/Typography";import s from"@mui/material/Paper";import u from"@mui/material/Stack";import f from"../../../../node_modules/dayjs/dayjs.min.js";import d from"@mui/icons-material/NoteAlt";import{SubmitButton as p}from"../../SubmitButton.js";import{useFormState as g}from"react-dom";import{createNoteAction as v}from"../../../data/actions/logistics/note/createNoteAction.js";import E from"../../common/markdown/MarkdownEditor.js";import{useSnackbar as b}from"../../../context/common/SnackbarContext.js";var x={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function k(k){var h,y,j=k.content,C=k.related,w=k.revalidateCallback,D=e(r(!1),2),A=D[0],S=D[1],z=v.bind(null,C),M=e(g(z,x),2),T=M[0],Y=M[1],B=b().handleAddMessage;return o((function(){(null==T?void 0:T.strapiErrors)&&B({message:T.strapiErrors,severity:T.severity||"error"}),(null==T?void 0:T.message)&&B({message:T.message,severity:T.severity||"error"}),"success"===(null==T?void 0:T.severity)&&(S(!1),w&&w())}),[T]),t.createElement(t.Fragment,null,t.createElement(l,{onClick:function(){return S(!0)},sx:{width:50,height:50,color:"#ffff88"}},t.createElement(d,{fontSize:"large"})),t.createElement(i,{open:A,fullWidth:!0,maxWidth:"lg",onClose:function(){return S(!1)}},t.createElement("form",{action:Y},t.createElement(n,{sx:{p:1}},t.createElement(s,{elevation:4,sx:{background:"linear-gradient(135deg, #ffff88 81%,#ffff88 82%,#ffff88 82%,#ffffc6 100%)",color:"black",p:1}},t.createElement(u,{spacing:2},t.createElement(c,{variant:"body1",textAlign:"right"},f(Date.now()).format("DD-MM-YYYY")),t.createElement(E,{name:"content",label:"The note",defaultValue:j,sx:{color:"black",label:{color:"black"},input:{color:"black"},div:{color:"black"}},textfieldProps:{id:"content",placeholder:"Write your note here...",multiline:!0,minRows:5,maxRows:10,error:null!=(null===(h=null==T?void 0:T.zodErrors)||void 0===h?void 0:h.content),helperText:(null===(y=null==T?void 0:T.zodErrors)||void 0===y?void 0:y.content)||""}})))),t.createElement(a,null,t.createElement(m,{onClick:function(){return S(!1)}},"Cancel"),t.createElement(p,{text:"Submit",loadingText:"Loading..."})))))}export{k as default};
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
import{__awaiter as r,__generator as e,__assign as t}from"../../../../../node_modules/tslib/tslib.es6.js";import{z as s}from"zod";import{mutateData as o}from"../../../services/mutate-data.js";import{flattenAttributes as a}from"../../../../lib/utils.js";var n=s.object({content:s.string().min(10,"Description must be at least 10 characters long").max(5e3,"Description cannot be more than 5000 characters long")});function i(s,i,l){return r(this,void 0,void 0,(function(){var r,u,c,m,d;return e(this,(function(e){switch(e.label){case 0:return null==s?[2,t(t({},i),{zodErrors:null,strapiErrors:null,message:"Failed to Create Note. Related entity is missing.",severity:"error"})]:(r=n.safeParse({content:l.get("content")})).success?(u=r.data,c={data:t(t({},u),{related:s})},[4,o("POST","/api/notes",c)]):[2,t(t({},i),{zodErrors:r.error.flatten().fieldErrors,strapiErrors:null,message:
|
|
7
|
+
import{__awaiter as r,__generator as e,__assign as t}from"../../../../../node_modules/tslib/tslib.es6.js";import{z as s}from"zod";import{mutateData as o}from"../../../services/mutate-data.js";import{flattenAttributes as a}from"../../../../lib/utils.js";var n=s.object({content:s.string().min(10,"Description must be at least 10 characters long").max(5e3,"Description cannot be more than 5000 characters long")});function i(s,i,l){return r(this,void 0,void 0,(function(){var r,u,c,m,d;return e(this,(function(e){switch(e.label){case 0:return null==s?[2,t(t({},i),{zodErrors:null,strapiErrors:null,message:"Failed to Create Note. Related entity is missing.",severity:"error"})]:(r=n.safeParse({content:l.get("content")})).success?(u=r.data,c={data:t(t({},u),{related:s})},[4,o("POST","/api/notes",c)]):[2,t(t({},i),{zodErrors:r.error.flatten().fieldErrors,strapiErrors:null,message:null,severity:null})];case 1:return(m=e.sent())?m.error?[2,t(t({},i),{zodErrors:null,strapiErrors:m.error,message:"Failed to Create Note.",severity:"error"})]:(d=a(m),[2,t(t({},i),{zodErrors:null,message:"New Note Created",severity:"success",data:d,strapiErrors:null})]):[2,t(t({},i),{zodErrors:null,strapiErrors:null,message:"Ops! Something went wrong. Please try again.",severity:"error"})]}}))}))}export{i as createNoteAction};
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
import{__awaiter as e,__generator as s}from"../../../../node_modules/tslib/tslib.es6.js";import
|
|
7
|
+
import{__awaiter as e,__generator as s,__assign as r}from"../../../../node_modules/tslib/tslib.es6.js";import i from"../../../../node_modules/qs/lib/index.js";import{fetchData as o}from"../loaders.js";import{getStrapiURL as t}from"../../../lib/utils.js";import{unstable_noStore as d}from"next/cache";import{getUserRole as n}from"../../services/get-user-me-loader.js";import{processFilters as a}from"../../../lib/processFilters.js";var l=t();function p(t,p,u,c){return e(this,arguments,void 0,(function(e,t,p,u,c,m){var _,b,v,f,y,g,h;return void 0===c&&(c=[!1]),void 0===m&&(m={}),s(this,(function(s){switch(s.label){case 0:return d(),[4,n()];case 1:return _=s.sent(),b=null===(h=null===(g=null==_?void 0:_.data)||void 0===g?void 0:g.role)||void 0===h?void 0:h.type,v="enduser"===b,f=new URL("/api/opos",l),y=a(m),f.search=i.stringify({filters:r({is_archive:{$in:c}},y),sort:"".concat(u||"id",":").concat(p||"desc"),populate:{opo_items:{populate:{product:{populate:{price:!0}},reports:!0}},customer:!!v&&{populate:{company_address:!0,delivery_address:!0,billing_address:!0,business_credentials:!0}},payments:!0,invoice:{populate:{seller_business_credentials:!0,seller_company_address:!0,buyer_company_address:!0,buyer_delivery_address:!0,buyer_billing_address:!0,buyer_business_credentials:!0,items:!0,admin_items:!0}},iros:{fields:["id","uuid","status"]}},pagination:{pageSize:t||10,page:e?e+1:1}}),[4,o(f.href)];case 2:return[2,s.sent()]}}))}))}export{p as getAllOpos};
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
import{__awaiter as e,__generator as o}from"../../../../node_modules/tslib/tslib.es6.js";import
|
|
7
|
+
import{__awaiter as e,__generator as o,__assign as t}from"../../../../node_modules/tslib/tslib.es6.js";import r from"../../../../node_modules/qs/lib/index.js";import{fetchData as s}from"../loaders.js";import{getStrapiURL as p}from"../../../lib/utils.js";import{unstable_noStore as i}from"next/cache";var a=p();function u(p,u){return e(this,void 0,void 0,(function(){var e;return o(this,(function(o){switch(o.label){case 0:return i(),(e=new URL("/api/opos/".concat(p),a)).search=r.stringify({populate:{opo_items:{populate:{product:{populate:{price:!0,image:!0}},picked_reports:!0,packed_reports:!0,shipped_reports:!0,reports:{populate:{author:!0}}}},customer:{populate:["business_credentials"]},notes:{populate:{author:{populate:!0}}}},filters:t({},u)}),[4,s(e.href)];case 1:return[2,o.sent()]}}))}))}export{u as getSingleOpo};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* UMWD-Components
|
|
3
|
+
* @copyright Jelle Paulus
|
|
4
|
+
* @license MIT
|
|
5
|
+
*/
|
|
6
|
+
import{__read as e}from"../../node_modules/tslib/tslib.es6.js";function t(t){return Object.entries(t).reduce((function(t,r){var i=e(r,2),n=i[0],s=i[1];if(!s)return t;if(s.includes(",")){var l=e(s.split(","),2),o=l[0],u=l[1];o&&u?t[n]={$gte:o,$lte:u}:o?t[n]={$gte:o}:u&&(t[n]={$lte:u})}else t[n]={$containsi:s};return t}),{})}export{t as processFilters};
|