umwd-components 0.1.619 → 0.1.621

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.
@@ -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 j}from"../../../types/common/Contact.js";import{ExplanatoryFoldOut as N}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(N,{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:j.Other}}],!1))}},a.createElement(_,null))),a.createElement(E,{item:!0,xs:12},void 0!==M?a.createElement(k,{notes:M}):a.createElement(s,null,"No notes")),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,{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};