umwd-components 0.1.616 → 0.1.617

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 C}from"../../ExplanatoryFoldOut.js";import N from"../note/NoteTakingComponent.js";var k={zodErrors:null,strapiErrors:null,data:null,message:null};function A(A){var V=A.data,w=A.productNamesArr,R=A.revalidateCallback,B=A.sx,P=V.id,S=V.website_url,T=V.phone_number,I=V.email,F=V.business_credentials,O=V.address,z=V.products,G=V.contacts;console.log("data",V);var M=e(u(f,k),2),U=M[0],W=M[1],q=(null==z?void 0:z.data)||[],D=e(r([]),2),H=D[0],J=D[1],K=function(n,a){H.includes(a)?J(H.filter((function(e){return e!==a}))):J(t(t([],e(H),!1),[a],!1))},L=e(r(G.reduce((function(e,t,n){return e.push({componentName:"contacts[".concat(n,"]"),componentReference:"logistics-elements.contact",data:t}),e}),[])),2),Q=L[0],X=L[1],Y=e(r([]),2),Z=Y[0],$=Y[1];return a.createElement(m,{sx:t([{p:2}],e(Array.isArray(B)?B:[B]),!1),component:o},a.createElement("form",{action:W},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:V.id,__type:"api::logistics.vendor"}],revalidateCallback:R}))),a.createElement(E,{item:!0,xs:12},a.createElement(C,{title:"Vendor",description:"Vendors are businesses that you purchase products from."})),a.createElement(E,{item:!0,xs:12,md:6},a.createElement(v,{data:F,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:S}),a.createElement(l,{id:"phone_number",name:"phone_number",label:"Phone Number",defaultValue:T}),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(b,{productNames:w,currentValue:q.map((function(e){return e.id}))})),a.createElement(E,{item:!0,xs:12,sx:{mt:1}},a.createElement(s,{variant:"h6"},"Contacts")),null==Q?void 0:Q.map((function(e,t){var r,o;return(null===(r=e.data)||void 0===r?void 0:r.id)?H.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(){X(Q.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:K})})):null})),Z.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(){$(Z.filter((function(e,n){return n!==t})).map((function(e,t){return n(n({},e),{componentName:"contacts[".concat(t+Q.length,"]")})})))}}))})),a.createElement(E,{item:!0,xs:12,md:6,lg:4,justifyContent:"center",alignItems:"center"},a.createElement(y,{onClick:function(){$(t(t([],e(Z),!1),[{componentName:"contacts[".concat(Q.length+Z.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},a.createElement(i,{direction:"row-reverse",spacing:2,alignItems:"center",sx:{py:1}},a.createElement(d,{text:"update vendor",loadingText:"loading"}),(null==U?void 0:U.strapiErrors)&&a.createElement(p,{error:null==U?void 0:U.strapiErrors}),(null==U?void 0:U.message)&&a.createElement(c,{severity:"error"},null==U?void 0:U.message))))))}export{A 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 j}from"../../../types/common/Contact.js";import{ExplanatoryFoldOut as C}from"../../ExplanatoryFoldOut.js";import N from"../note/NoteTakingComponent.js";var k={zodErrors:null,strapiErrors:null,data:null,message:null};function A(A){var V=A.data,w=A.productNamesArr,R=A.revalidateCallback,B=A.sx,P=V.id,S=V.website_url,T=V.phone_number,I=V.email,F=V.business_credentials,O=V.address,z=V.products,G=V.contacts;console.log("data",V);var M=e(u(f,k),2),U=M[0],W=M[1],q=(null==z?void 0:z.data)||[],D=e(r([]),2),H=D[0],J=D[1],K=function(n,a){H.includes(a)?J(H.filter((function(e){return e!==a}))):J(t(t([],e(H),!1),[a],!1))},L=e(r(G.reduce((function(e,t,n){return e.push({componentName:"contacts[".concat(n,"]"),componentReference:"logistics-elements.contact",data:t}),e}),[])),2),Q=L[0],X=L[1],Y=e(r([]),2),Z=Y[0],$=Y[1];return a.createElement(m,{sx:t([{p:2}],e(Array.isArray(B)?B:[B]),!1),component:o},a.createElement("form",{action:W},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:V.id,__type:"api::logistics.vendor-profile"}],revalidateCallback:R}))),a.createElement(E,{item:!0,xs:12},a.createElement(C,{title:"Vendor",description:"Vendors are businesses that you purchase products from."})),a.createElement(E,{item:!0,xs:12,md:6},a.createElement(v,{data:F,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:S}),a.createElement(l,{id:"phone_number",name:"phone_number",label:"Phone Number",defaultValue:T}),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(b,{productNames:w,currentValue:q.map((function(e){return e.id}))})),a.createElement(E,{item:!0,xs:12,sx:{mt:1}},a.createElement(s,{variant:"h6"},"Contacts")),null==Q?void 0:Q.map((function(e,t){var r,o;return(null===(r=e.data)||void 0===r?void 0:r.id)?H.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(){X(Q.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:K})})):null})),Z.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(){$(Z.filter((function(e,n){return n!==t})).map((function(e,t){return n(n({},e),{componentName:"contacts[".concat(t+Q.length,"]")})})))}}))})),a.createElement(E,{item:!0,xs:12,md:6,lg:4,justifyContent:"center",alignItems:"center"},a.createElement(y,{onClick:function(){$(t(t([],e(Z),!1),[{componentName:"contacts[".concat(Q.length+Z.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},a.createElement(i,{direction:"row-reverse",spacing:2,alignItems:"center",sx:{py:1}},a.createElement(d,{text:"update vendor",loadingText:"loading"}),(null==U?void 0:U.strapiErrors)&&a.createElement(p,{error:null==U?void 0:U.strapiErrors}),(null==U?void 0:U.message)&&a.createElement(c,{severity:"error"},null==U?void 0:U.message))))))}export{A as EditVendorForm};