umwd-components 0.1.662 → 0.1.663
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/prompts/update-form-and-actions.prompt.md +18 -3
- package/dist/node_modules/base64-js/index.js +1 -1
- package/dist/node_modules/ieee754/index.js +1 -1
- package/dist/src/components/logistics/ipo/TextualManageIPOForm.js +1 -1
- package/dist/src/components/logistics/vendor/AddVendorForm.js +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/components/logistics/ipo/AddIPOForm.d.ts +4 -2
- package/package.json +1 -1
- package/src/components/logistics/ipo/AddIPOForm.tsx +9 -8
- package/src/components/logistics/ipo/TextualManageIPOForm.tsx +17 -5
- package/src/components/logistics/vendor/AddVendorForm.tsx +13 -2
|
@@ -1,5 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
mode: "agent"
|
|
3
|
+
tools: []
|
|
4
|
+
---
|
|
5
|
+
|
|
1
6
|
# Apply form patterns and actions to update forms in the codebase.
|
|
2
7
|
|
|
3
|
-
Take the documentation from form-patterns.md
|
|
4
|
-
|
|
5
|
-
|
|
8
|
+
Take the documentation from [form-patterns.md](../form-patterns.md) and read it
|
|
9
|
+
carefully. make sure the Form component matches the patterns described there.
|
|
10
|
+
|
|
11
|
+
Then within this Form component find the actions it uses and make sure these are
|
|
12
|
+
updated according to the documentation in
|
|
13
|
+
[action-patterns.md](../action-patterns.md)
|
|
14
|
+
|
|
15
|
+
- Respect comments by previous devs (me) and do not remove them unless they are
|
|
16
|
+
no longer relevant.
|
|
17
|
+
|
|
18
|
+
- Do not change the currently used texts, often they are by the client, you
|
|
19
|
+
might however leave suggestions for improvement in comments, these are
|
|
20
|
+
appriciated.
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* @copyright Jelle Paulus
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
|
-
import{__exports as r}from"../../_virtual/
|
|
6
|
+
import{__exports as r}from"../../_virtual/index7.js";var t;function e(){if(t)return r;t=1,r.byteLength=function(r){var t=i(r),e=t[0],n=t[1];return 3*(e+n)/4-n},r.toByteArray=function(r){var t,e,a=i(r),u=a[0],h=a[1],c=new o(function(r,t,e){return 3*(t+e)/4-e}(0,u,h)),f=0,d=h>0?u-4:u;for(e=0;e<d;e+=4)t=n[r.charCodeAt(e)]<<18|n[r.charCodeAt(e+1)]<<12|n[r.charCodeAt(e+2)]<<6|n[r.charCodeAt(e+3)],c[f++]=t>>16&255,c[f++]=t>>8&255,c[f++]=255&t;2===h&&(t=n[r.charCodeAt(e)]<<2|n[r.charCodeAt(e+1)]>>4,c[f++]=255&t);1===h&&(t=n[r.charCodeAt(e)]<<10|n[r.charCodeAt(e+1)]<<4|n[r.charCodeAt(e+2)]>>2,c[f++]=t>>8&255,c[f++]=255&t);return c},r.fromByteArray=function(r){for(var t,n=r.length,o=n%3,a=[],u=16383,i=0,c=n-o;i<c;i+=u)a.push(h(r,i,i+u>c?c:i+u));1===o?(t=r[n-1],a.push(e[t>>2]+e[t<<4&63]+"==")):2===o&&(t=(r[n-2]<<8)+r[n-1],a.push(e[t>>10]+e[t>>4&63]+e[t<<2&63]+"="));return a.join("")};for(var e=[],n=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=0;u<64;++u)e[u]=a[u],n[a.charCodeAt(u)]=u;function i(r){var t=r.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var e=r.indexOf("=");return-1===e&&(e=t),[e,e===t?0:4-e%4]}function h(r,t,n){for(var o,a,u=[],i=t;i<n;i+=3)o=(r[i]<<16&16711680)+(r[i+1]<<8&65280)+(255&r[i+2]),u.push(e[(a=o)>>18&63]+e[a>>12&63]+e[a>>6&63]+e[63&a]);return u.join("")}return n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63,r}export{e as __require};
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
* @copyright Jelle Paulus
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
6
|
-
import{__exports as a}from"../../_virtual/
|
|
6
|
+
import{__exports as a}from"../../_virtual/index8.js";
|
|
7
7
|
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */var t;function o(){return t||(t=1,a.read=function(a,t,o,r,h){var M,e,i=8*h-r-1,p=(1<<i)-1,f=p>>1,n=-7,w=o?h-1:0,s=o?-1:1,u=a[t+w];for(w+=s,M=u&(1<<-n)-1,u>>=-n,n+=i;n>0;M=256*M+a[t+w],w+=s,n-=8);for(e=M&(1<<-n)-1,M>>=-n,n+=r;n>0;e=256*e+a[t+w],w+=s,n-=8);if(0===M)M=1-f;else{if(M===p)return e?NaN:1/0*(u?-1:1);e+=Math.pow(2,r),M-=f}return(u?-1:1)*e*Math.pow(2,M-r)},a.write=function(a,t,o,r,h,M){var e,i,p,f=8*M-h-1,n=(1<<f)-1,w=n>>1,s=23===h?Math.pow(2,-24)-Math.pow(2,-77):0,u=r?0:M-1,N=r?1:-1,_=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(i=isNaN(t)?1:0,e=n):(e=Math.floor(Math.log(t)/Math.LN2),t*(p=Math.pow(2,-e))<1&&(e--,p*=2),(t+=e+w>=1?s/p:s*Math.pow(2,1-w))*p>=2&&(e++,p/=2),e+w>=n?(i=0,e=n):e+w>=1?(i=(t*p-1)*Math.pow(2,h),e+=w):(i=t*Math.pow(2,w-1)*Math.pow(2,h),e=0));h>=8;a[o+u]=255&i,u+=N,i/=256,h-=8);for(e=e<<h|i,f+=h;f>0;a[o+u]=255&e,u+=N,e/=256,f-=8);a[o+u-N]|=128*_}),a}export{o as __require};
|
|
@@ -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{useSnackbar as m}from"../../../context/common/SnackbarContext.js";import{updateIpoAction as s}from"../../../data/actions/logistics/ipo/updateIpoAction.js";import{confirmationService as d}from"../../../data/services/common/confirmation-service.js";import{cancellationService as u}from"../../../data/services/common/cancellation-service.js";import p from"../../../data/loaders/common/media/downloadBase64File.js";import{UploadBase64MediaForm as v}from"../../common/media/UploadBase64MediaForm.js";import f from"../note/NoteTakingComponent.js";import E from"../note/NotesDisplay.js";import g from"./ItemDisplay.js";import y from"./TextualIPOItemUpdater.js";import{IpoStatusIndicator as h}from"./IpoStatusIndicator.js";import b from"@mui/material/Box";import x from"@mui/material/Stack";import C from"@mui/material/Paper";import w from"@mui/material/Dialog";import I from"@mui/material/DialogActions";import _ from"@mui/material/DialogContent";import k from"@mui/material/DialogTitle";import D from"@mui/material/Typography";import O from"@mui/material/Button";import j from"@mui/material/Grid";import F from"@mui/material/Divider";import P from"@mui/material/TextField";import A from"@mui/material/List";import q from"@mui/material/ListItem";import S from"@mui/material/Alert";import N from"@mui/material/Checkbox";import T from"@mui/material/FormControlLabel";import U from"@mui/icons-material/Numbers";import B from"@mui/icons-material/Description";import R from"@mui/icons-material/CalendarToday";import M from"@mui/icons-material/Business";import W from"@mui/icons-material/Update";import{SubmitButton as L}from"../../SubmitButton.js";var z={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function H(e){var t=this,r=e.open,o=e.handleClose,l=e.orderID,c=e.currentStatus,s=e.revalidateCallback,u=m().handleAddMessage;return i.createElement(w,{open:r},i.createElement(k,null,"Confirm Order"),i.createElement(_,null,i.createElement(x,{spacing:2},i.createElement(D,null,"Are you sure you want to confirm this order?"),i.createElement(D,null,"Current status: ",c),i.createElement(S,{severity:"info"},"Once confirmed, the order will be available for processing."))),i.createElement(I,null,i.createElement(O,{variant:"outlined",onClick:o},"Cancel"),i.createElement(O,{variant:"contained",color:"primary",onClick:function(){return n(t,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,d("ipos",[l])];case 1:return e.sent(),u({message:"IPO confirmed successfully",severity:"success"}),s&&s(),o(),[3,3];case 2:return e.sent(),u({message:"Failed to confirm IPO",severity:"error"}),[3,3];case 3:return[2]}}))}))}},"Confirm Order")))}function G(t){var r=this,l=t.open,c=t.handleClose,s=t.orderID,d=t.revalidateCallback,p=e(o(""),2),v=p[0],f=p[1],E=e(o(""),2),g=E[0],y=E[1],h=m().handleAddMessage;return i.createElement(w,{open:l},i.createElement(k,null,"Cancel Return"),i.createElement(_,null,i.createElement(x,{spacing:2},i.createElement(D,null,"Are you sure you want to cancel this return?"),i.createElement(A,null,i.createElement(q,null,"By cancelling this return order you will update it's status from requested to cancelled"),i.createElement(q,null,"Please provide a reason for the cancellation"),i.createElement(q,null,"The customer will be notified about the cancellation and of the reason for the cancellation")),i.createElement(P,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:v,onChange:function(e){return f(e.target.value)},placeholder:"Please provide a reason for the cancellation",error:!!g,helperText:g}))),i.createElement(I,null,i.createElement(O,{variant:"outlined",onClick:c},"Cancel"),i.createElement(O,{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(v.length<5)return y("Please provide a reason for the cancellation (min 5 characters)"),[2];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,u("ipos",s,v)];case 2:return e.sent(),h({message:"IPO cancelled successfully",severity:"success"}),d&&d(),c(),[3,4];case 3:return e.sent(),h({message:"Failed to cancel IPO",severity:"error"}),[3,4];case 4:return[2]}}))}))}},"Confirm Cancellation")))}function J(n){var a,d,u,w,I,_,k=n.data,P=n.sx,A=n.revalidateCallback,q=n.handleClose,J=n.role,Q=e(c((function(e,t){return s(k.id,e,t)}),z),2),K=Q[0],V=Q[1],X=m().handleAddMessage,Y=e(o(k.items.data?k.items.data:[]),2),Z=Y[0],$=Y[1],ee=e(o(!1),2),te=ee[0],re=ee[1],ne=e(o(!1),2),ae=ne[0],ie=ne[1],oe=e(o(["received","registered","released","reports"]),2),le=oe[0],ce=oe[1];l((function(){(null==K?void 0:K.message)&&(X({message:K.message,severity:K.severity||"error"}),"success"===K.severity&&(A&&A(),q&&q()))}),[null==K?void 0:K.message]),l((function(){(null==K?void 0:K.strapiErrors)&&X({message:K.strapiErrors.message||"Error updating IPO",severity:"error"})}),[null==K?void 0:K.strapiErrors]);var me=function(r,n,a){var i=t([],e(Z),!1),o=i.findIndex((function(e){return e.id===n}));i[o][a]=r,$(i)},se=function(n,a){var i,o,l,c=t([],e(Z),!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,$(c)},de=function(r,n){var a,i,o=t([],e(Z),!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,$(o)};return l((function(){"Ipo Updated"===(null==K?void 0:K.message)&&(X({message:"Ipo Updated",severity:"success"}),q&&q(),A&&A())}),[K]),l((function(){(null==K?void 0:K.strapiErrors)&&X({message:K.strapiErrors.message||"Error updating IPO",severity:"error"})}),[null==K?void 0:K.strapiErrors]),l((function(){var e;console.log("data",k),(null===(e=k.items)||void 0===e?void 0:e.data)&&$(k.items.data?k.items.data:[])}),[k]),i.createElement(b,{sx:t([],e(Array.isArray(P)?P:[P]),!1)},i.createElement(j,{container:!0,spacing:2},i.createElement(j,{item:!0,xs:12},i.createElement(x,{spacing:2},i.createElement(x,{direction:"row",spacing:2,justifyContent:"space-between"},i.createElement(x,{spacing:2},i.createElement(D,{variant:"h3",component:"h1"},"Management Inbound Purchase Order"),i.createElement(D,{variant:"body1"},"Manage arrival, registration and recieval of purchase order")),i.createElement(f,{content:"",related:[{id:k.id,__type:"api::logistics.ipo"}],revalidateCallback:A})),i.createElement(F,null))),i.createElement(j,{item:!0,xs:12},i.createElement(D,{variant:"h5",sx:{py:1}},"Details")),i.createElement(j,{item:!0,xs:6},i.createElement(C,{elevation:2,sx:{p:2,height:"100%"}},i.createElement(x,{spacing:2},i.createElement(x,{direction:"row",spacing:2,alignItems:"center"},i.createElement(U,{color:"primary"}),i.createElement(D,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Purchase Order Number"),i.createElement(D,{variant:"body1",fontWeight:"medium"},k.ipo_number)),i.createElement(x,{direction:"row",spacing:2,alignItems:"center"},i.createElement(B,{color:"primary"}),i.createElement(D,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Custom Reference"),i.createElement(D,{variant:"body1",fontWeight:"medium"},k.customer_reference)),i.createElement(x,{direction:"row",spacing:2,alignItems:"center"},i.createElement(R,{color:"primary"}),i.createElement(D,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Order Date"),i.createElement(D,{variant:"body1",fontWeight:"medium"},k.order_date)),i.createElement(x,{direction:"row",spacing:2,alignItems:"center"},i.createElement(M,{color:"primary"}),i.createElement(D,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Supplier"),i.createElement(D,{variant:"body1",fontWeight:"medium"},null===(d=null===(a=k.vendor_profile)||void 0===a?void 0:a.business_credentials)||void 0===d?void 0:d.company_name)),i.createElement(x,{direction:"row",spacing:2,alignItems:"center"},i.createElement(W,{color:"primary"}),i.createElement(D,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Order Status"),i.createElement(h,{status:k.status}))))),"enduser"===J&&i.createElement(j,{item:!0,xs:6},i.createElement(C,{elevation:2,sx:{p:2,height:"100%"}},i.createElement(x,{spacing:2},("placed"===k.status||"released_on_stock"===k.status)&&i.createElement(i.Fragment,null,i.createElement(O,{variant:"contained",color:"primary",onClick:function(){return re(!0)}},"Confirm order"),i.createElement(S,{severity:"warning"},"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"),i.createElement(H,{open:te,handleClose:function(){return re(!1)},orderID:k.id,currentStatus:k.status,revalidateCallback:A})),("placed"===k.status||"ordered"===k.status)&&i.createElement(i.Fragment,null,i.createElement(O,{variant:"contained",color:"error",onClick:function(){return ie(!0)}},"Cancel order"),i.createElement(G,{open:ae,handleClose:function(){return ie(!1)},orderID:k.id,revalidateCallback:A}))))),i.createElement(j,{item:!0,xs:12},i.createElement(x,{spacing:2},i.createElement(D,{variant:"h5"},"Documents"),i.createElement(C,{sx:{p:2}},i.createElement(x,{spacing:1},"enduser"===J&&i.createElement(i.Fragment,null,k.order_confirmation?i.createElement(i.Fragment,null,i.createElement(D,{variant:"h6"},"Order Confirmation"),i.createElement(D,null,null===(u=k.order_confirmation)||void 0===u?void 0:u.name),i.createElement(O,{variant:"contained",onClick:function(){p("api/ipos/".concat(k.id),"order_confirmation")}},"Download")):i.createElement(i.Fragment,null,i.createElement(D,{variant:"h5"},"Order Confirmation"),i.createElement(D,{variant:"body1"},"Here you can upload the the order confirmation for this order"),i.createElement(D,{variant:"body1"},"FileUpload"),i.createElement(F,null),i.createElement(v,{reference:"api::logistics.ipo",refID:k.id,field:"order_confirmation",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/ipos",componentName:"order_confirmation",componentReference:"common.base64-encoded-media",revalidateCallback:A}))),k.delivery_note?i.createElement(i.Fragment,null,i.createElement(D,{variant:"h6"},"Delivery Note"),i.createElement(D,null,null===(w=k.delivery_note)||void 0===w?void 0:w.name),i.createElement(O,{variant:"contained",onClick:function(){p("api/ipos/".concat(k.id),"delivery_note")}},"Download")):i.createElement(i.Fragment,null,i.createElement(D,{variant:"h5"},"Delivery Note"),i.createElement(D,{variant:"body1"},"Here you can upload the the delivery note for this order"),i.createElement(F,null),i.createElement(v,{reference:"api::logistics.ipo",refID:k.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===(_=null===(I=null==k?void 0:k.notes)||void 0===I?void 0:I.data)||void 0===_?void 0:_.length)>0&&i.createElement(j,{item:!0,xs:12},i.createElement(x,{spacing:2},i.createElement(D,{variant:"h5"},"Notes"),i.createElement(E,{notes:k.notes.data}),i.createElement(F,null))),i.createElement(j,{item:!0,xs:12},i.createElement(x,{spacing:1},i.createElement(D,{variant:"h5"},"Items"),i.createElement(x,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:C,p:1,sx:{bgcolor:"background.default",border:"1px solid",borderColor:"divider",boxShadow:"none"}},i.createElement(D,{variant:"body2",color:"text.secondary"},"Show:"),["received","registered","released","reports"].map((function(r){return i.createElement(T,{key:r,control:i.createElement(N,{size:"small",checked:le.includes(r),onChange:function(n){n.target.checked?ce(t(t([],e(le),!1),[r],!1)):ce(le.filter((function(e){return e!==r})))}}),label:i.createElement(D,{variant:"body2",color:"text.secondary"},r.charAt(0).toUpperCase()+r.slice(1)),sx:{mr:0}})}))),"placed"===k.status&&i.createElement(S,{severity:"warning"},"Before confirmation you cannot update the items"),i.createElement(F,null),i.createElement("form",{action:V},i.createElement("input",{name:"id",type:"hidden",value:k.id}),Z&&Z.map((function(e,t){var r,n;return i.createElement(C,{sx:{p:2,mb:2},key:t},"placed"===k.status||"cancelled"===k.status||"done"===k.status?i.createElement(g,{item:e,index:t,image:null===(r=null==e?void 0:e.product)||void 0===r?void 0:r.image}):i.createElement(y,{item:e,index:t,handleUpdateQuantity:me,handleAddReport:se,image:null===(n=null==e?void 0:e.product)||void 0===n?void 0:n.image,handleRemoveReportAtIndex:de,revalidateCallback:A,showing:le}))})),i.createElement(C,{sx:{p:2}},i.createElement(x,{direction:"row",spacing:2,justifyContent:"end"},i.createElement(L,{text:"Update items",loadingText:"Loading..."}))),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,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_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}})))||[]}}))}(Z))}))))))}export{J 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 i,{useState as o,useEffect as l}from"react";import{useFormState as c}from"react-dom";import{useSnackbar as m}from"../../../context/common/SnackbarContext.js";import{updateIpoAction as s}from"../../../data/actions/logistics/ipo/updateIpoAction.js";import{confirmationService as d}from"../../../data/services/common/confirmation-service.js";import{cancellationService as u}from"../../../data/services/common/cancellation-service.js";import p from"../../../data/loaders/common/media/downloadBase64File.js";import{UploadBase64MediaForm as v}from"../../common/media/UploadBase64MediaForm.js";import f from"../note/NoteTakingComponent.js";import E from"../note/NotesDisplay.js";import g from"./ItemDisplay.js";import y from"./TextualIPOItemUpdater.js";import{IpoStatusIndicator as h}from"./IpoStatusIndicator.js";import b from"@mui/material/Box";import x from"@mui/material/Stack";import C from"@mui/material/Paper";import w from"@mui/material/Dialog";import I from"@mui/material/DialogActions";import _ from"@mui/material/DialogContent";import k from"@mui/material/DialogTitle";import D from"@mui/material/Typography";import O from"@mui/material/Button";import j from"@mui/material/Grid";import F from"@mui/material/Divider";import P from"@mui/material/TextField";import A from"@mui/material/List";import q from"@mui/material/ListItem";import S from"@mui/material/Alert";import N from"@mui/material/Checkbox";import T from"@mui/material/FormControlLabel";import U from"@mui/icons-material/Numbers";import B from"@mui/icons-material/Description";import R from"@mui/icons-material/CalendarToday";import M from"@mui/icons-material/Business";import W from"@mui/icons-material/Update";import{SubmitButton as L}from"../../SubmitButton.js";var z={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function H(e){var t=this,r=e.open,o=e.handleClose,l=e.orderID,c=e.currentStatus,s=e.revalidateCallback,u=m().handleAddMessage;return i.createElement(w,{open:r},i.createElement(k,null,"Confirm Order"),i.createElement(_,null,i.createElement(x,{spacing:2},i.createElement(D,null,"Are you sure you want to confirm this order?"),i.createElement(D,null,"Current status: ",c),i.createElement(S,{severity:"info"},"Once confirmed, the order will be available for processing."))),i.createElement(I,null,i.createElement(O,{variant:"outlined",onClick:o},"Cancel"),i.createElement(O,{variant:"contained",color:"primary",onClick:function(){return n(t,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,d("ipos",[l])];case 1:return e.sent(),u({message:"IPO confirmed successfully",severity:"success"}),s&&s(),o(),[3,3];case 2:return e.sent(),u({message:"Failed to confirm IPO",severity:"error"}),[3,3];case 3:return[2]}}))}))}},"Confirm Order")))}function G(t){var r=this,l=t.open,c=t.handleClose,s=t.orderID,d=t.revalidateCallback,p=e(o(""),2),v=p[0],f=p[1],E=e(o(""),2),g=E[0],y=E[1],h=m().handleAddMessage;return i.createElement(w,{open:l},i.createElement(k,null,"Cancel Return"),i.createElement(_,null,i.createElement(x,{spacing:2},i.createElement(D,null,"Are you sure you want to cancel this return?"),i.createElement(A,null,i.createElement(q,null,"By cancelling this return order you will update it's status from requested to cancelled"),i.createElement(q,null,"Please provide a reason for the cancellation"),i.createElement(q,null,"The customer will be notified about the cancellation and of the reason for the cancellation")),i.createElement(P,{label:"Cancellation reason",name:"reason",multiline:!0,rows:4,fullWidth:!0,variant:"outlined",value:v,onChange:function(e){return f(e.target.value)},placeholder:"Please provide a reason for the cancellation",error:!!g,helperText:g}))),i.createElement(I,null,i.createElement(O,{variant:"outlined",onClick:c},"Cancel"),i.createElement(O,{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(v.length<5)return y("Please provide a reason for the cancellation (min 5 characters)"),[2];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,u("ipos",s,v)];case 2:return e.sent(),h({message:"IPO cancelled successfully",severity:"success"}),d&&d(),c(),[3,4];case 3:return e.sent(),h({message:"Failed to cancel IPO",severity:"error"}),[3,4];case 4:return[2]}}))}))}},"Confirm Cancellation")))}function J(n){var a,d,u,w,I,_,k=n.data,P=n.sx,A=n.revalidateCallback,q=n.handleClose,J=n.role,Q=e(c((function(e,t){return s(k.id,e,t)}),z),2),K=Q[0],V=Q[1],X=m().handleAddMessage,Y=e(o(k.items.data?k.items.data:[]),2),Z=Y[0],$=Y[1],ee=e(o(!1),2),te=ee[0],re=ee[1],ne=e(o(!1),2),ae=ne[0],ie=ne[1],oe=e(o(["received","registered","released","reports"]),2),le=oe[0],ce=oe[1];l((function(){(null==K?void 0:K.message)&&(X({message:K.message,severity:K.severity||"error"}),"success"===K.severity&&(A&&A(),q&&q()))}),[null==K?void 0:K.message]),l((function(){(null==K?void 0:K.strapiErrors)&&X({message:K.strapiErrors.message||"Error updating IPO",severity:"error"})}),[null==K?void 0:K.strapiErrors]);var me=function(r,n,a){var i=t([],e(Z),!1),o=i.findIndex((function(e){return e.id===n}));i[o][a]=r,$(i)},se=function(n,a){var i,o,l,c=t([],e(Z),!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,$(c)},de=function(r,n){var a,i,o=t([],e(Z),!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,$(o)};return l((function(){"Ipo Updated"===(null==K?void 0:K.message)&&(X({message:"Ipo Updated",severity:"success"}),q&&q(),A&&A())}),[K]),l((function(){(null==K?void 0:K.strapiErrors)&&X({message:K.strapiErrors.message||"Error updating IPO",severity:"error"})}),[null==K?void 0:K.strapiErrors]),l((function(){var e;console.log("data",k),(null===(e=k.items)||void 0===e?void 0:e.data)&&$(k.items.data?k.items.data:[])}),[k]),i.createElement(b,{sx:t([],e(Array.isArray(P)?P:[P]),!1)},i.createElement(j,{container:!0,spacing:2},i.createElement(j,{item:!0,xs:12},i.createElement(x,{spacing:2},i.createElement(x,{direction:"row",spacing:2,justifyContent:"space-between"},i.createElement(x,{spacing:2},i.createElement(D,{variant:"h3",component:"h1"},"Management Inbound Purchase Order"),i.createElement(D,{variant:"body1"},"Manage arrival, registration and recieval of purchase order")),i.createElement(f,{content:"",related:[{id:k.id,__type:"api::logistics.ipo"}],revalidateCallback:A})),i.createElement(F,null))),i.createElement(j,{item:!0,xs:12},i.createElement(D,{variant:"h5",sx:{py:1}},"Details")),i.createElement(j,{item:!0,xs:6},i.createElement(C,{elevation:2,sx:{p:2,height:"100%"}},i.createElement(x,{spacing:2},i.createElement(x,{direction:"row",spacing:2,alignItems:"center"},i.createElement(U,{color:"primary"}),i.createElement(D,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Purchase Order Number"),i.createElement(D,{variant:"body1",fontWeight:"medium"},k.ipo_number)),i.createElement(x,{direction:"row",spacing:2,alignItems:"center"},i.createElement(B,{color:"primary"}),i.createElement(D,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Custom Reference"),i.createElement(D,{variant:"body1",fontWeight:"medium"},k.customer_reference)),i.createElement(x,{direction:"row",spacing:2,alignItems:"center"},i.createElement(R,{color:"primary"}),i.createElement(D,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Order Date"),i.createElement(D,{variant:"body1",fontWeight:"medium"},k.order_date)),i.createElement(x,{direction:"row",spacing:2,alignItems:"center"},i.createElement(M,{color:"primary"}),i.createElement(D,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Supplier"),i.createElement(D,{variant:"body1",fontWeight:"medium"},null===(d=null===(a=k.vendor_profile)||void 0===a?void 0:a.business_credentials)||void 0===d?void 0:d.company_name)),i.createElement(x,{direction:"row",spacing:2,alignItems:"center"},i.createElement(W,{color:"primary"}),i.createElement(D,{variant:"subtitle1",color:"text.secondary",width:"200px"},"Order Status"),i.createElement(h,{status:k.status}))))),"enduser"===J&&i.createElement(j,{item:!0,xs:6},i.createElement(C,{elevation:2,sx:{p:2,height:"100%"}},i.createElement(x,{spacing:2},("placed"===k.status||"released_on_stock"===k.status)&&i.createElement(i.Fragment,null,i.createElement(O,{variant:"contained",color:"primary",onClick:function(){return re(!0)}},"Confirm order"),i.createElement(S,{severity:"warning"},"Please confirm the order as soon as possible, only upon confirmation this order will be available to the dispatcher"),i.createElement(H,{open:te,handleClose:function(){return re(!1)},orderID:k.id,currentStatus:k.status,revalidateCallback:A})),("placed"===k.status||"ordered"===k.status)&&i.createElement(i.Fragment,null,i.createElement(O,{variant:"contained",color:"error",onClick:function(){return ie(!0)}},"Cancel order"),i.createElement(G,{open:ae,handleClose:function(){return ie(!1)},orderID:k.id,revalidateCallback:A}))))),i.createElement(j,{item:!0,xs:12},i.createElement(x,{spacing:2},i.createElement(D,{variant:"h5"},"Documents"),i.createElement(C,{sx:{p:2}},i.createElement(x,{spacing:1},"enduser"===J&&i.createElement(i.Fragment,null,k.order_confirmation?i.createElement(i.Fragment,null,i.createElement(D,{variant:"h6"},"Order Confirmation"),i.createElement(D,null,null===(u=k.order_confirmation)||void 0===u?void 0:u.name),i.createElement(O,{variant:"contained",onClick:function(){p("api/ipos/".concat(k.id),"order_confirmation")}},"Download")):i.createElement(i.Fragment,null,i.createElement(D,{variant:"h5"},"Order Confirmation"),i.createElement(D,{variant:"body1"},"Here you can upload the the order confirmation for this order"),i.createElement(D,{variant:"body1"},"FileUpload"),i.createElement(F,null),i.createElement(v,{reference:"api::logistics.ipo",refID:k.id,field:"order_confirmation",multiple:!1,accept:"text/*,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",path:"api/ipos",componentName:"order_confirmation",componentReference:"common.base64-encoded-media",revalidateCallback:A}))),k.delivery_note?i.createElement(i.Fragment,null,i.createElement(D,{variant:"h6"},"Delivery Note"),i.createElement(D,null,null===(w=k.delivery_note)||void 0===w?void 0:w.name),i.createElement(O,{variant:"contained",onClick:function(){p("api/ipos/".concat(k.id),"delivery_note")}},"Download")):i.createElement(i.Fragment,null,i.createElement(D,{variant:"h5"},"Delivery Note"),i.createElement(D,{variant:"body1"},"Here you can upload the the delivery note for this order"),i.createElement(F,null),i.createElement(v,{reference:"api::logistics.ipo",refID:k.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===(_=null===(I=null==k?void 0:k.notes)||void 0===I?void 0:I.data)||void 0===_?void 0:_.length)>0&&i.createElement(j,{item:!0,xs:12},i.createElement(x,{spacing:2},i.createElement(D,{variant:"h5"},"Notes"),i.createElement(E,{notes:k.notes.data}),i.createElement(F,null))),i.createElement(j,{item:!0,xs:12},i.createElement(x,{spacing:1},i.createElement(D,{variant:"h5"},"Items"),i.createElement(x,{direction:"row",alignItems:"center",justifyContent:"flex-end",spacing:2,component:C,p:1,sx:{bgcolor:"background.default",border:"1px solid",borderColor:"divider",boxShadow:"none"}},i.createElement(D,{variant:"body2",color:"text.secondary"},"Show:"),["received","registered","released","reports"].map((function(r){return i.createElement(T,{key:r,control:i.createElement(N,{size:"small",checked:le.includes(r),onChange:function(n){n.target.checked?ce(t(t([],e(le),!1),[r],!1)):ce(le.filter((function(e){return e!==r})))}}),label:i.createElement(D,{variant:"body2",color:"text.secondary"},r.charAt(0).toUpperCase()+r.slice(1)),sx:{mr:0}})}))),"placed"===k.status&&i.createElement(S,{severity:"warning"},"Before confirmation you cannot update the items"),i.createElement(F,null),i.createElement("form",{action:V},i.createElement("input",{name:"id",type:"hidden",value:k.id}),Z&&Z.map((function(e,t){var r,n;return i.createElement(C,{sx:{p:2,mb:2},key:t},"placed"===k.status||"cancelled"===k.status||"done"===k.status?i.createElement(g,{item:e,index:t,image:null===(r=null==e?void 0:e.product)||void 0===r?void 0:r.image}):i.createElement(y,{item:e,index:t,handleUpdateQuantity:me,handleAddReport:se,image:null===(n=null==e?void 0:e.product)||void 0===n?void 0:n.image,handleRemoveReportAtIndex:de,revalidateCallback:A,showing:le}))})),i.createElement(x,{direction:"row",spacing:2,justifyContent:"space-between"},q&&i.createElement(O,{onClick:q,variant:"outlined"},"Cancel"),i.createElement(L,{variant:"contained",text:"Update items",loadingText:"Loading..."})),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,received_quantity:e.received_quantity,registered_quantity:e.registered_quantity,released_quantity:e.released_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}})))||[]}}))}(Z))}))))))}export{J as default};
|
|
@@ -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,{useState as n,useEffect as m}from"react";import a from"@mui/material/Box";import o from"@mui/material/Stack";import
|
|
7
|
+
import{__read as e,__spreadArray as t}from"../../../../node_modules/tslib/tslib.es6.js";import r,{useState as n,useEffect as m}from"react";import a from"@mui/material/Box";import o from"@mui/material/Stack";import i from"@mui/material/Button";import s from"@mui/material/TextField";import c from"@mui/material/Typography";import{SubmitButton as l}from"../../SubmitButton.js";import{useFormState as d}from"react-dom";import{useSnackbar as u}from"../../../context/common/SnackbarContext.js";import{createVendorAction as p}from"../../../data/actions/logistics/vendor/createVendorAction.js";import E from"@mui/material/Grid";import{BusinessCredentialsFields as f}from"../../e-commerce/customer/BusinessCredentials.js";import{AddressFields as x}from"../../common/Address.js";import g from"../../e-commerce/products/ProductSelector.js";import{ContactsFields as v}from"../../common/Contacts.js";import b from"@mui/icons-material/Add";import{ContactType as y}from"../../../types/common/Contact.js";import{ExplanatoryFoldOut as h}from"../../ExplanatoryFoldOut.js";var C={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function j(j){var A=j.productNamesArr,_=j.revalidateCallback,k=j.handleClose,N=j.sx,V=e(d(p,C),2),w=V[0],B=V[1],R=u().handleAddMessage,S=e(n([]),2),P=S[0],T=S[1];return m((function(){(null==w?void 0:w.message)&&(R({message:w.message,severity:w.severity||"error"}),"success"===w.severity&&(_&&_(),k&&k()))}),[null==w?void 0:w.message]),m((function(){(null==w?void 0:w.strapiErrors)&&R({message:w.strapiErrors.message||"Error creating vendor",severity:"error"})}),[null==w?void 0:w.strapiErrors]),r.createElement(a,{sx:t([],e(Array.isArray(N)?N:[N]),!1)},r.createElement("form",{action:B},r.createElement(E,{container:!0,spacing:2},r.createElement(E,{item:!0,xs:12},r.createElement(o,{spacing:2},r.createElement(c,{variant:"h3",component:"h1"},"Add Vendor"),r.createElement(c,{variant:"body1"},"Create a new vendor for your business"))),r.createElement(E,{item:!0,xs:12},r.createElement(h,{title:"Vendor",description:"Vendors are businesses that you purchase products from."})),r.createElement(E,{item:!0,xs:12,md:6},r.createElement(f,{componentName:"business_credentials",componentReference:"common.business-credentials"})),r.createElement(E,{item:!0,xs:12,md:6},r.createElement(o,{spacing:1,sx:{pt:1}},r.createElement(s,{id:"website_url",name:"website_url",label:"Website Url"}),r.createElement(s,{id:"phone_number",name:"phone_number",label:"Phone Number"}),r.createElement(s,{id:"email",name:"email",label:"Email"}))),r.createElement(E,{item:!0,xs:12,md:6},r.createElement(c,{variant:"h6"},"Address"),r.createElement(x,{componentName:"address",componentReference:"common.address"})),r.createElement(E,{item:!0,xs:12,sx:{mt:1}},r.createElement(c,{variant:"h6"},"Products"),r.createElement(g,{productNames:A,currentValue:[]})),r.createElement(E,{item:!0,xs:12,sx:{mt:1}},r.createElement(c,{variant:"h6"},"Contacts"),r.createElement(E,{container:!0,spacing:2},P.map((function(e,t){return r.createElement(E,{item:!0,xs:12,sm:6,md:4,lg:3,key:t},r.createElement(v,{key:t,data:e.data,componentName:e.componentName,componentReference:"logistics-elements.contact",deleteCallback:function(){!function(e){var t=P.filter((function(t,r){return r!==e}));T(t)}(t)}}))})),r.createElement(E,{item:!0,xs:12,sm:6,md:4,lg:3,sx:{justifyContent:"center",display:"flex",alignItems:"center"}},r.createElement(i,{variant:"contained",startIcon:r.createElement(b,null),onClick:function(){T(t(t([],e(P),!1),[{componentName:"contacts[".concat(P.length,"]"),componentReference:"logistics-elements.contact",data:{first_name:"",last_name:"",email:"",phone_number:"",type:y.Other}}],!1))},size:"large"},"Add contact"))))," ",r.createElement(E,{item:!0,xs:12},r.createElement(o,{direction:"row",spacing:2,justifyContent:"flex-end",sx:{mt:2}},k&&r.createElement(i,{onClick:k,variant:"outlined"},"Cancel"),r.createElement(l,{text:"Create Vendor",loadingText:"Creating...",variant:"contained"}))))))}export{j as AddVendorForm};
|