umwd-components 0.1.661 → 0.1.662

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.
@@ -0,0 +1,5 @@
1
+ # Apply form patterns and actions to update forms in the codebase.
2
+
3
+ Take the documentation from form-patterns.md for the form patterns and
4
+ documentation from action-patterns.md for actions found in the form and apply
5
+ them to the forms in the codebase.
@@ -3,4 +3,4 @@
3
3
  * @copyright Jelle Paulus
4
4
  * @license MIT
5
5
  */
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};
6
+ import{__exports as r}from"../../_virtual/index8.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/index8.js";
6
+ import{__exports as a}from"../../_virtual/index7.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};
@@ -4,4 +4,4 @@
4
4
  * @copyright Jelle Paulus
5
5
  * @license MIT
6
6
  */
7
- import{__read as e,__spreadArray as r,__awaiter as t,__generator as a}from"../../../../node_modules/tslib/tslib.es6.js";import o,{useState as i,useEffect as n}from"react";import m from"@mui/material/Paper";import l from"@mui/material/Box";import s from"@mui/material/Stack";import c from"@mui/material/TextField";import d from"@mui/material/Typography";import u from"@mui/material/Divider";import p from"@mui/material/Button";import{SubmitButton as f}from"../../SubmitButton.js";import{useFormState as v}from"react-dom";import{createIPOAction as E}from"../../../data/actions/logistics/ipo/createIPOAction.js";import g from"@mui/material/Grid";import x from"../vendor/VendorSelector.js";import{getSingleVendor as y}from"../../../data/loaders/logistics/getSingleVendor.js";import{IPOItemFields as h}from"./IPOItemFields.js";import{AdapterDayjs as b}from"@mui/x-date-pickers/AdapterDayjs";import{LocalizationProvider as C}from"@mui/x-date-pickers/LocalizationProvider";import{DatePicker as j}from"@mui/x-date-pickers/DatePicker";import{useSnackbar as A}from"../../../context/common/SnackbarContext.js";var k={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function P(P){var I=this,D=P.vendorNamesArr,O=P.sx,S=P.revalidateCallback,w=P.handleClose,T=e(v(E,k),2),V=T[0],_=T[1],B=e(i([]),2),N=B[0],z=B[1],F=e(i(null),2),G=F[0],L=F[1],M=A().handleAddMessage;n((function(){(null==V?void 0:V.message)&&(M({message:V.message,severity:V.severity||"error"}),"success"===V.severity&&(S&&S(),w&&w()))}),[null==V?void 0:V.message]),n((function(){(null==V?void 0:V.strapiErrors)&&M({message:V.strapiErrors.message||"Error performing action",severity:"error"})}),[null==V?void 0:V.strapiErrors]);return o.createElement(l,{sx:r([{p:2}],e(Array.isArray(O)?O:[O]),!1),component:m},o.createElement("form",{action:_},o.createElement(g,{container:!0,spacing:2},o.createElement(g,{item:!0,xs:12},o.createElement(s,{spacing:2},o.createElement(d,{variant:"h3",component:"h1"},"Add IPO"),o.createElement(d,{variant:"body1"},"Create a new incoming purchase order"))),o.createElement(g,{item:!0,xs:12,md:6,sx:{mt:1}},D?o.createElement(x,{vendorNames:D,currentValue:null,onSelectVendor:function(e){return t(I,void 0,void 0,(function(){var r,t;return a(this,(function(a){switch(a.label){case 0:return L(e),e?[4,y(e)]:(z([]),[2]);case 1:return r=a.sent(),z(null===(t=null==r?void 0:r.products)||void 0===t?void 0:t.data),[2]}}))}))}}):o.createElement(d,null,"No vendors on file, you need to create a vendor first before you are able to create incoming purchase orders")),o.createElement(g,{item:!0,xs:12},o.createElement(s,{spacing:2},o.createElement(d,{variant:"h5"},"Order Details"),o.createElement(d,{variant:"body1"},"The orderdate should be the official date of the order, don't worry, you can also set days in the past or future"),o.createElement(C,{dateAdapter:b},o.createElement(j,{name:"order_date",label:"Order Date"})),o.createElement(d,{variant:"body1"},"Please enter a custom reference for this order"),o.createElement(c,{id:"customer_reference",name:"customer_reference",type:"text",label:"Custom Reference"}),o.createElement(u,null))),o.createElement(g,{item:!0,xs:12},o.createElement(h,{productsArr:N,vendorID:G})),o.createElement(g,{item:!0,xs:12},o.createElement(s,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mt:2}},w&&o.createElement(p,{onClick:w,variant:"outlined"},"Cancel"),o.createElement(f,{text:"Create IPO",loadingText:"Creating...",variant:"contained"}))))))}export{P as AddIPOForm};
7
+ import{__read as e,__spreadArray as r,__awaiter as t,__generator as a}from"../../../../node_modules/tslib/tslib.es6.js";import o,{useState as n,useEffect as i}from"react";import m from"@mui/material/Box";import l from"@mui/material/Stack";import s from"@mui/material/TextField";import c from"@mui/material/Typography";import d from"@mui/material/Divider";import u from"@mui/material/Button";import{SubmitButton as p}from"../../SubmitButton.js";import{useFormState as f}from"react-dom";import{createIPOAction as v}from"../../../data/actions/logistics/ipo/createIPOAction.js";import E from"@mui/material/Grid";import g from"../vendor/VendorSelector.js";import{getSingleVendor as x}from"../../../data/loaders/logistics/getSingleVendor.js";import{IPOItemFields as y}from"./IPOItemFields.js";import{AdapterDayjs as h}from"@mui/x-date-pickers/AdapterDayjs";import{LocalizationProvider as b}from"@mui/x-date-pickers/LocalizationProvider";import{DatePicker as C}from"@mui/x-date-pickers/DatePicker";import{useSnackbar as j}from"../../../context/common/SnackbarContext.js";var A={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function k(k){var I=this,P=k.vendorNamesArr,D=k.sx,O=k.revalidateCallback,S=k.handleClose,w=e(f(v,A),2),T=w[0],V=w[1],_=e(n([]),2),B=_[0],N=_[1],z=e(n(null),2),F=z[0],G=z[1],L=j().handleAddMessage;i((function(){(null==T?void 0:T.message)&&(L({message:T.message,severity:T.severity||"error"}),"success"===T.severity&&(O&&O(),S&&S()))}),[null==T?void 0:T.message]),i((function(){(null==T?void 0:T.strapiErrors)&&L({message:T.strapiErrors.message||"Error performing action",severity:"error"})}),[null==T?void 0:T.strapiErrors]);return o.createElement(m,{sx:r([],e(Array.isArray(D)?D:[D]),!1)},o.createElement("form",{action:V},o.createElement(E,{container:!0,spacing:2},o.createElement(E,{item:!0,xs:12},o.createElement(l,{spacing:2},o.createElement(c,{variant:"h3",component:"h1"},"Add IPO"),o.createElement(c,{variant:"body1"},"Create a new incoming purchase order"))),o.createElement(E,{item:!0,xs:12,md:6,sx:{mt:1}},P?o.createElement(g,{vendorNames:P,currentValue:null,onSelectVendor:function(e){return t(I,void 0,void 0,(function(){var r,t;return a(this,(function(a){switch(a.label){case 0:return G(e),e?[4,x(e)]:(N([]),[2]);case 1:return r=a.sent(),N(null===(t=null==r?void 0:r.products)||void 0===t?void 0:t.data),[2]}}))}))}}):o.createElement(c,null,"No vendors on file, you need to create a vendor first before you are able to create incoming purchase orders")),o.createElement(E,{item:!0,xs:12},o.createElement(l,{spacing:2},o.createElement(c,{variant:"h5"},"Order Details"),o.createElement(c,{variant:"body1"},"The orderdate should be the official date of the order, don't worry, you can also set days in the past or future"),o.createElement(b,{dateAdapter:h},o.createElement(C,{name:"order_date",label:"Order Date"})),o.createElement(c,{variant:"body1"},"Please enter a custom reference for this order"),o.createElement(s,{id:"customer_reference",name:"customer_reference",type:"text",label:"Custom Reference"}),o.createElement(d,null))),o.createElement(E,{item:!0,xs:12},o.createElement(y,{productsArr:B,vendorID:F})),o.createElement(E,{item:!0,xs:12},o.createElement(l,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{mt:2}},S&&o.createElement(u,{onClick:S,variant:"outlined"},"Cancel"),o.createElement(p,{text:"Create IPO",loadingText:"Creating...",variant:"contained"}))))))}export{k as AddIPOForm};
@@ -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 m,useEffect as n}from"react";import a from"@mui/material/Paper";import o from"@mui/material/Box";import i from"@mui/material/Stack";import c from"@mui/material/Alert";import l from"@mui/material/TextField";import s from"@mui/material/Typography";import{SubmitButton as d}from"../../SubmitButton.js";import{useFormState as p}from"react-dom";import{StrapiErrors as u}from"../../StrapiErrors.js";import{createVendorAction as E}from"../../../data/actions/logistics/vendor/createVendorAction.js";import f from"@mui/material/Grid";import{BusinessCredentialsFields as x}from"../../e-commerce/customer/BusinessCredentials.js";import{AddressFields as g}from"../../common/Address.js";import b from"../../e-commerce/products/ProductSelector.js";import{ContactsFields as v}from"../../common/Contacts.js";import h from"@mui/material/Button";import y from"@mui/icons-material/Add";import{ContactType as j}from"../../../types/common/Contact.js";import{ExplanatoryFoldOut as _}from"../../ExplanatoryFoldOut.js";var A={zodErrors:null,strapiErrors:null,data:null,message:null};function C(C){var N=C.productNamesArr,k=C.revalidateCallback,V=e(p(E,A),2),w=V[0],B=V[1],P=e(m([]),2),R=P[0],S=P[1];return n((function(){(null==w?void 0:w.data)&&k&&k()}),[w.data]),r.createElement(o,{component:a,sx:{p:2}},r.createElement("form",{action:B},r.createElement(f,{container:!0,spacing:2},r.createElement(f,{item:!0,xs:12},r.createElement(s,{variant:"h5"},"Add Vendor")),r.createElement(f,{item:!0,xs:12},r.createElement(_,{title:"Vendor",description:"Vendors are businesses that you purchase products from."})),r.createElement(f,{item:!0,xs:12,md:6},r.createElement(x,{componentName:"business_credentials",componentReference:"common.business-credentials"})),r.createElement(f,{item:!0,xs:12,md:6},r.createElement(i,{spacing:1,sx:{pt:1}},r.createElement(l,{id:"website_url",name:"website_url",label:"Website Url"}),r.createElement(l,{id:"phone_number",name:"phone_number",label:"Phone Number"}),r.createElement(l,{id:"email",name:"email",label:"Email"}))),r.createElement(f,{item:!0,xs:12,md:6},r.createElement(s,{variant:"h6"},"Address"),r.createElement(g,{componentName:"address",componentReference:"common.address"})),r.createElement(f,{item:!0,xs:12,sx:{mt:1}},r.createElement(s,{variant:"h6"},"Products"),r.createElement(b,{productNames:N,currentValue:[]})),r.createElement(f,{item:!0,xs:12,sx:{mt:1}},r.createElement(s,{variant:"h6"},"Contacts"),r.createElement(f,{container:!0,spacing:2},R.map((function(e,t){return r.createElement(f,{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){console.log("delete",e);var t=R.filter((function(t,r){return r!==e}));S(t)}(t)}}))})),r.createElement(f,{item:!0,xs:12,sm:6,md:4,lg:3,sx:{justifyContent:"center",display:"flex",alignItems:"center"}},r.createElement(h,{variant:"contained",startIcon:r.createElement(y,null),onClick:function(){S(t(t([],e(R),!1),[{componentName:"contacts[".concat(R.length,"]"),componentReference:"logistics-elements.contact",data:{first_name:"",last_name:"",email:"",phone_number:"",type:j.Other}}],!1))},size:"large"},"Add contact")))),r.createElement(f,{item:!0,xs:12},r.createElement(i,{direction:"row-reverse",spacing:2,alignItems:"center",sx:{py:1}},r.createElement(d,{text:"create new vendor",loadingText:"loading"}),(null==w?void 0:w.strapiErrors)&&r.createElement(u,{error:null==w?void 0:w.strapiErrors}),(null==w?void 0:w.message)&&r.createElement(c,{severity:"error"},null==w?void 0:w.message))))))}export{C as AddVendorForm};
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 s from"@mui/material/Button";import i 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),B=V[0],R=V[1],S=u().handleAddMessage,w=e(n([]),2),P=w[0],T=w[1];return m((function(){(null==B?void 0:B.message)&&(S({message:B.message,severity:B.severity||"error"}),"success"===B.severity&&(_&&_(),k&&k()))}),[null==B?void 0:B.message]),m((function(){(null==B?void 0:B.strapiErrors)&&S({message:B.strapiErrors.message||"Error creating vendor",severity:"error"})}),[null==B?void 0:B.strapiErrors]),r.createElement(a,{sx:t([],e(Array.isArray(N)?N:[N]),!1)},r.createElement("form",{action:R},r.createElement(E,{container:!0,spacing:2},r.createElement(E,{item:!0,xs:12},r.createElement(c,{variant:"h5"},"Add Vendor")),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(i,{id:"website_url",name:"website_url",label:"Website Url"}),r.createElement(i,{id:"phone_number",name:"phone_number",label:"Phone Number"}),r.createElement(i,{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(s,{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(s,{onClick:k,variant:"outlined"},"Cancel"),r.createElement(l,{text:"Create Vendor",loadingText:"Creating..."}))))))}export{j as AddVendorForm};
@@ -4,4 +4,4 @@
4
4
  * @copyright Jelle Paulus
5
5
  * @license MIT
6
6
  */
7
- import{__read as e,__spreadArray as t,__assign as n}from"../../../../node_modules/tslib/tslib.es6.js";import a,{useState as r}from"react";import o from"@mui/material/Paper";import m from"@mui/material/Box";import i from"@mui/material/Stack";import c from"@mui/material/Alert";import l from"@mui/material/TextField";import s from"@mui/material/Typography";import{SubmitButton as d}from"../../SubmitButton.js";import{useFormState as u}from"react-dom";import{StrapiErrors as p}from"../../StrapiErrors.js";import{updateVendorAction as f}from"../../../data/actions/logistics/vendor/updateVendorAction.js";import E from"@mui/material/Grid";import{BusinessCredentialsFields as v}from"../../e-commerce/customer/BusinessCredentials.js";import{AddressFields as g}from"../../common/Address.js";import b from"../../e-commerce/products/ProductSelector.js";import x,{ContactsFields as h}from"../../common/Contacts.js";import y from"@mui/material/IconButton";import _ from"@mui/icons-material/Add";import{ContactType as N}from"../../../types/common/Contact.js";import{ExplanatoryFoldOut as j}from"../../ExplanatoryFoldOut.js";import C from"../note/NoteTakingComponent.js";import k from"../note/NotesDisplay.js";var A={zodErrors:null,strapiErrors:null,data:null,message:null};function V(V){var w=V.data,R=V.productNamesArr,B=V.revalidateCallback,P=V.sx,S=w.id,T=w.website_url,I=w.phone_number,F=w.email,O=w.business_credentials,z=w.address,D=w.products,G=w.contacts,M=w.notes;console.log("data",w);var U=e(u(f,A),2),W=U[0],q=U[1],H=(null==D?void 0:D.data)||[],J=e(r([]),2),K=J[0],L=J[1],Q=function(n,a){K.includes(a)?L(K.filter((function(e){return e!==a}))):L(t(t([],e(K),!1),[a],!1))},X=e(r(G.reduce((function(e,t,n){return e.push({componentName:"contacts[".concat(n,"]"),componentReference:"logistics-elements.contact",data:t}),e}),[])),2),Y=X[0],Z=X[1],$=e(r([]),2),ee=$[0],te=$[1];return a.createElement(m,{sx:t([{p:2}],e(Array.isArray(P)?P:[P]),!1),component:o},a.createElement("form",{action:q},S&&a.createElement("input",{id:"id",type:"hidden",name:"id",value:S}),a.createElement(E,{container:!0,spacing:2},a.createElement(E,{item:!0,xs:12},a.createElement(i,{direction:"row",justifyContent:"space-between"},a.createElement(s,{variant:"h5"},"Edit Vendor"),a.createElement(C,{content:"",related:[{id:w.id,__type:"api::logistics.vendor-profile"}],revalidateCallback:B}))),a.createElement(E,{item:!0,xs:12},a.createElement(j,{title:"Vendor",description:"Vendors are businesses that you purchase products from."})),a.createElement(E,{item:!0,xs:12,md:6},a.createElement(v,{data:O,componentName:"business_credentials",componentReference:"common.business-credentials"})),a.createElement(E,{item:!0,xs:12,md:6},a.createElement(i,{spacing:2},a.createElement(l,{id:"website_url",name:"website_url",label:"Website Url",defaultValue:T}),a.createElement(l,{id:"phone_number",name:"phone_number",label:"Phone Number",defaultValue:I}),a.createElement(l,{id:"email",name:"email",label:"Email",defaultValue:F}))),a.createElement(E,{item:!0,xs:12,md:6},a.createElement(s,{variant:"h6"},"Address"),a.createElement(g,{data:z,componentName:"address",componentReference:"common.address"})),a.createElement(E,{item:!0,xs:12,sx:{mt:1}},a.createElement(s,{variant:"h6"},"Products"),a.createElement(b,{productNames:R,currentValue:H.map((function(e){return e.id}))})),a.createElement(E,{item:!0,xs:12,sx:{mt:1}},a.createElement(s,{variant:"h6"},"Contacts")),null==Y?void 0:Y.map((function(e,t){var r,o;return(null===(r=e.data)||void 0===r?void 0:r.id)?K.includes(null===(o=e.data)||void 0===o?void 0:o.id)?a.createElement(E,{item:!0,xs:12,md:6,lg:4,key:e.data.id},a.createElement(h,{data:e.data,componentName:"contacts[".concat(t,"]"),componentReference:"logistics-elements.contact",deleteCallback:function(){Z(Y.filter((function(e,n){return n!==t})))}})):a.createElement(E,{item:!0,xs:12,md:6,lg:4,key:e.data.id},a.createElement("input",{type:"hidden",name:"contacts[".concat(t,"].id"),value:e.data.id}),a.createElement("input",{type:"hidden",name:"contacts[".concat(t,"].__component"),value:"logistics-elements.contact"}),a.createElement(x,{data:n(n({},e.data),{onClick:Q})})):null})),ee.map((function(e,t){var r;return a.createElement(E,{item:!0,xs:12,md:6,lg:4,key:null===(r=e.data)||void 0===r?void 0:r.uuid},a.createElement(h,{data:e.data,componentName:e.componentName,componentReference:"logistics-elements.contact",deleteCallback:function(){te(ee.filter((function(e,n){return n!==t})).map((function(e,t){return n(n({},e),{componentName:"contacts[".concat(t+Y.length,"]")})})))}}))})),a.createElement(E,{item:!0,xs:12,md:6,lg:4,justifyContent:"center",alignItems:"center"},a.createElement(y,{onClick:function(){te(t(t([],e(ee),!1),[{componentName:"contacts[".concat(Y.length+ee.length,"]"),componentReference:"logistics-elements.contact",data:{uuid:Math.random(),first_name:"",last_name:"",email:"",phone_number:"",type:N.Other}}],!1))}},a.createElement(_,null))),a.createElement(E,{item:!0,xs:12},a.createElement(s,{variant:"h6"},"Notes"),void 0!==(null==M?void 0:M.data)?a.createElement(k,{notes:M.data}):a.createElement(s,null,"No notes to display")),a.createElement(E,{item:!0,xs:12},a.createElement(i,{direction:"row-reverse",spacing:2,alignItems:"center",sx:{py:1}},a.createElement(d,{text:"update vendor",loadingText:"loading"}),(null==W?void 0:W.strapiErrors)&&a.createElement(p,{error:null==W?void 0:W.strapiErrors}),(null==W?void 0:W.message)&&a.createElement(c,{severity:"error"},null==W?void 0:W.message))))))}export{V as EditVendorForm};
7
+ import{__read as e,__spreadArray as t,__assign as n}from"../../../../node_modules/tslib/tslib.es6.js";import a,{useEffect as r,useState as o}from"react";import m from"@mui/material/Box";import i from"@mui/material/Stack";import c from"@mui/material/Button";import l from"@mui/material/TextField";import s from"@mui/material/Typography";import{SubmitButton as d}from"../../SubmitButton.js";import{useFormState as u}from"react-dom";import{useSnackbar as p}from"../../../context/common/SnackbarContext.js";import{updateVendorAction as f}from"../../../data/actions/logistics/vendor/updateVendorAction.js";import E from"@mui/material/Grid";import{BusinessCredentialsFields as v}from"../../e-commerce/customer/BusinessCredentials.js";import{AddressFields as g}from"../../common/Address.js";import x from"../../e-commerce/products/ProductSelector.js";import b,{ContactsFields as y}from"../../common/Contacts.js";import h from"@mui/material/IconButton";import C from"@mui/icons-material/Add";import{ContactType as _}from"../../../types/common/Contact.js";import{ExplanatoryFoldOut as j}from"../../ExplanatoryFoldOut.js";import N from"../note/NoteTakingComponent.js";import k from"../note/NotesDisplay.js";var V={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};function A(A){var w=A.data,R=A.productNamesArr,B=A.revalidateCallback,S=A.handleClose,T=A.sx,P=w.id,U=w.website_url,F=w.phone_number,I=w.email,M=w.business_credentials,O=w.address,z=w.products,D=w.contacts,G=w.notes;console.log("data",w);var W=e(u(f,V),2),q=W[0],H=W[1],J=p().handleAddMessage;r((function(){(null==q?void 0:q.message)&&(J({message:q.message,severity:q.severity||"error"}),"success"===q.severity&&(B&&B(),S&&S()))}),[null==q?void 0:q.message]),r((function(){(null==q?void 0:q.strapiErrors)&&J({message:q.strapiErrors.message||"Error updating vendor",severity:"error"})}),[null==q?void 0:q.strapiErrors]);var K=(null==z?void 0:z.data)||[],L=e(o([]),2),Q=L[0],X=L[1],Y=function(n,a){Q.includes(a)?X(Q.filter((function(e){return e!==a}))):X(t(t([],e(Q),!1),[a],!1))},Z=e(o(D.reduce((function(e,t,n){return e.push({componentName:"contacts[".concat(n,"]"),componentReference:"logistics-elements.contact",data:t}),e}),[])),2),$=Z[0],ee=Z[1],te=e(o([]),2),ne=te[0],ae=te[1];return a.createElement(m,{sx:t([],e(Array.isArray(T)?T:[T]),!1)},a.createElement("form",{action:H},P&&a.createElement("input",{id:"id",type:"hidden",name:"id",value:P}),a.createElement(E,{container:!0,spacing:2},a.createElement(E,{item:!0,xs:12},a.createElement(i,{direction:"row",justifyContent:"space-between"},a.createElement(s,{variant:"h5"},"Edit Vendor"),a.createElement(N,{content:"",related:[{id:w.id,__type:"api::logistics.vendor-profile"}],revalidateCallback:B}))),a.createElement(E,{item:!0,xs:12},a.createElement(j,{title:"Vendor",description:"Vendors are businesses that you purchase products from."})),a.createElement(E,{item:!0,xs:12,md:6},a.createElement(v,{data:M,componentName:"business_credentials",componentReference:"common.business-credentials"})),a.createElement(E,{item:!0,xs:12,md:6},a.createElement(i,{spacing:2},a.createElement(l,{id:"website_url",name:"website_url",label:"Website Url",defaultValue:U}),a.createElement(l,{id:"phone_number",name:"phone_number",label:"Phone Number",defaultValue:F}),a.createElement(l,{id:"email",name:"email",label:"Email",defaultValue:I}))),a.createElement(E,{item:!0,xs:12,md:6},a.createElement(s,{variant:"h6"},"Address"),a.createElement(g,{data:O,componentName:"address",componentReference:"common.address"})),a.createElement(E,{item:!0,xs:12,sx:{mt:1}},a.createElement(s,{variant:"h6"},"Products"),a.createElement(x,{productNames:R,currentValue:K.map((function(e){return e.id}))})),a.createElement(E,{item:!0,xs:12,sx:{mt:1}},a.createElement(s,{variant:"h6"},"Contacts")),null==$?void 0:$.map((function(e,t){var r,o;return(null===(r=e.data)||void 0===r?void 0:r.id)?Q.includes(null===(o=e.data)||void 0===o?void 0:o.id)?a.createElement(E,{item:!0,xs:12,md:6,lg:4,key:e.data.id},a.createElement(y,{data:e.data,componentName:"contacts[".concat(t,"]"),componentReference:"logistics-elements.contact",deleteCallback:function(){ee($.filter((function(e,n){return n!==t})))}})):a.createElement(E,{item:!0,xs:12,md:6,lg:4,key:e.data.id},a.createElement("input",{type:"hidden",name:"contacts[".concat(t,"].id"),value:e.data.id}),a.createElement("input",{type:"hidden",name:"contacts[".concat(t,"].__component"),value:"logistics-elements.contact"}),a.createElement(b,{data:n(n({},e.data),{onClick:Y})})):null})),ne.map((function(e,t){var r;return a.createElement(E,{item:!0,xs:12,md:6,lg:4,key:null===(r=e.data)||void 0===r?void 0:r.uuid},a.createElement(y,{data:e.data,componentName:e.componentName,componentReference:"logistics-elements.contact",deleteCallback:function(){ae(ne.filter((function(e,n){return n!==t})).map((function(e,t){return n(n({},e),{componentName:"contacts[".concat(t+$.length,"]")})})))}}))})),a.createElement(E,{item:!0,xs:12,md:6,lg:4,justifyContent:"center",alignItems:"center"},a.createElement(h,{onClick:function(){ae(t(t([],e(ne),!1),[{componentName:"contacts[".concat($.length+ne.length,"]"),componentReference:"logistics-elements.contact",data:{uuid:Math.random(),first_name:"",last_name:"",email:"",phone_number:"",type:_.Other}}],!1))}},a.createElement(C,null))),a.createElement(E,{item:!0,xs:12},a.createElement(s,{variant:"h6"},"Notes"),void 0!==(null==G?void 0:G.data)?a.createElement(k,{notes:G.data}):a.createElement(s,null,"No notes to display"))," ",a.createElement(E,{item:!0,xs:12},a.createElement(i,{direction:"row",spacing:2,justifyContent:"flex-end",sx:{mt:2}},S&&a.createElement(c,{onClick:S,variant:"outlined"},"Cancel"),a.createElement(d,{text:"Update Vendor",loadingText:"Updating..."}))))))}export{A as EditVendorForm};
@@ -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{mutateData as s}from"../../../services/mutate-data.js";import{flattenAttributes as o}from"../../../../lib/utils.js";import{parseFormData as a}from"../../../../lib/parseFormData.js";function i(i,n){return r(this,void 0,void 0,(function(){var r,d,l;return e(this,(function(e){switch(e.label){case 0:return Object.fromEntries(n),(r=a(n)).data.products&&(r.data.products=JSON.parse(r.data.products)),[4,s("POST","/api/vendor-profiles",r)];case 1:return d=e.sent(),console.dir(d,{depth:null}),d?d.error?[2,t(t({},i),{strapiErrors:d.error,message:"Failed to Create Vendor."})]:(l=o(d),[2,t(t({},i),{message:"New Vendor Created",data:l,strapiErrors:null})]):[2,t(t({},i),{strapiErrors:null,message:"Ops! Something went wrong. Please try again."})]}}))}))}export{i as createVendorAction};
7
+ import{__awaiter as r,__generator as e,__assign as s}from"../../../../../node_modules/tslib/tslib.es6.js";import{mutateData as t}from"../../../services/mutate-data.js";import{flattenAttributes as o}from"../../../../lib/utils.js";import{parseFormData as a}from"../../../../lib/parseFormData.js";function n(n,i){return r(this,void 0,void 0,(function(){var r,l,u,d;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),(r=a(i)).data.products&&(r.data.products=JSON.parse(r.data.products)),[4,t("POST","/api/vendor-profiles",r)];case 1:return(l=e.sent())?l.error?[2,s(s({},n),{strapiErrors:l.error,zodErrors:null,message:"Failed to create vendor. Please check the form and try again.",severity:"error"})]:(u=o(l),[2,s(s({},n),{data:u,strapiErrors:null,zodErrors:null,message:"Vendor created successfully!",severity:"success"})]):[2,s(s({},n),{strapiErrors:null,zodErrors:null,message:"Something went wrong while creating the vendor. Please try again.",severity:"error"})];case 2:return d=e.sent(),console.error("Error creating vendor:",d),[2,s(s({},n),{data:null,strapiErrors:null,zodErrors:null,message:"An unexpected error occurred. Please try again later.",severity:"error"})];case 3:return[2]}}))}))}export{n as createVendorAction};
@@ -4,4 +4,4 @@
4
4
  * @copyright Jelle Paulus
5
5
  * @license MIT
6
6
  */
7
- import{__awaiter as r,__generator as t,__assign as e}from"../../../../../node_modules/tslib/tslib.es6.js";import{mutateData as s}from"../../../services/mutate-data.js";import{flattenAttributes as o}from"../../../../lib/utils.js";import{parseFormData as a}from"../../../../lib/parseFormData.js";function i(i,n){return r(this,void 0,void 0,(function(){var r,d,p,m;return t(this,(function(t){switch(t.label){case 0:return r=Object.fromEntries(n),(d=a(n)).data.products&&(d.data.products=JSON.parse(d.data.products)),[4,s("PUT","/api/vendor-profiles/".concat(r.id),d)];case 1:return(p=t.sent())?p.error?[2,e(e({},i),{strapiErrors:p.error,message:"Failed to Update Vendor."})]:(m=o(p),[2,e(e({},i),{message:"Vendor Updated",data:m,strapiErrors:null})]):[2,e(e({},i),{strapiErrors:null,message:"Ops! Something went wrong. Please try again."})]}}))}))}export{i as updateVendorAction};
7
+ import{__awaiter as r,__generator as e,__assign as s}from"../../../../../node_modules/tslib/tslib.es6.js";import{mutateData as t}from"../../../services/mutate-data.js";import{flattenAttributes as o}from"../../../../lib/utils.js";import{parseFormData as a}from"../../../../lib/parseFormData.js";function n(n,i){return r(this,void 0,void 0,(function(){var r,l,u,d,c;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),r=Object.fromEntries(i),(l=a(i)).data.products&&(l.data.products=JSON.parse(l.data.products)),[4,t("PUT","/api/vendor-profiles/".concat(r.id),l)];case 1:return(u=e.sent())?u.error?[2,s(s({},n),{data:null,strapiErrors:u.error,zodErrors:null,message:"Failed to update vendor. Please check the form and try again.",severity:"error"})]:(d=o(u),[2,s(s({},n),{data:d,strapiErrors:null,zodErrors:null,message:"Vendor updated successfully!",severity:"success"})]):[2,s(s({},n),{data:null,strapiErrors:null,zodErrors:null,message:"Something went wrong while updating the vendor. Please try again.",severity:"error"})];case 2:return c=e.sent(),console.error("Error updating vendor:",c),[2,s(s({},n),{data:null,strapiErrors:null,zodErrors:null,message:"An unexpected error occurred. Please try again later.",severity:"error"})];case 3:return[2]}}))}))}export{n as updateVendorAction};