umwd-components 0.1.727 → 0.1.728

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.
@@ -3,4 +3,4 @@
3
3
  * @copyright Jelle Paulus
4
4
  * @license MIT
5
5
  */
6
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),r=require("@mui/material/Autocomplete"),l=require("@mui/material/TextField");const i=({customerLabels:i,currentValue:u,multiple:n=!1,onChangeCallback:s})=>{const[a,o]=t.useState(u||[]);return e.jsxs(e.Fragment,{children:[e.jsx(r,{multiple:n,options:i,getOptionLabel:e=>e.title,filterSelectedOptions:!0,onChange:(e,t,r,l)=>{if(Array.isArray(t)){const e=t.map(e=>e.documentId);o(e),s&&s(e)}else t?(o([t.documentId]),s&&s([t.documentId])):(o([]),s&&s([]))},renderOption:(e,r)=>t.createElement("li",{...e,key:r.id},r.title),renderInput:t=>e.jsx(l,{...t,label:"Customer"}),value:i.filter(e=>a.includes(e.documentId))[0]||null}),e.jsx("input",{type:"hidden",name:"customer",value:n?JSON.stringify(a)||"":a[0]||""})]})};exports.CustomerSelector=i,exports.default=i;
6
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),r=require("@mui/material/Autocomplete"),l=require("@mui/material/TextField");const u=({customerLabels:u,currentValue:n,multiple:i=!1,onChangeCallback:o})=>{const[s,a]=t.useState(n||[]);return e.jsxs(e.Fragment,{children:[e.jsx(r,{multiple:i,options:u,getOptionLabel:e=>e.title,filterSelectedOptions:!0,onChange:(e,t,r,l)=>{if(Array.isArray(t)){const e=t.map(e=>e.documentId);a(e),o&&o(e)}else t?(a([t.documentId]),o&&o([t.documentId])):(a([]),o&&o([]))},renderOption:(e,r)=>t.createElement("li",{...e,key:r.documentId},r.title),renderInput:t=>e.jsx(l,{...t,label:"Customer"}),value:u.filter(e=>s.includes(e.documentId))[0]||null}),e.jsx("input",{type:"hidden",name:"customer",value:i?JSON.stringify(s)||"":s[0]||""})]})};exports.CustomerSelector=u,exports.default=u;
@@ -4,4 +4,4 @@
4
4
  * @copyright Jelle Paulus
5
5
  * @license MIT
6
6
  */
7
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),s=require("react-dom"),i=require("../../../data/actions/e-commerce/opo/createOpoAction.js"),t=require("../../SubmitButton.js"),n=require("../customer/CustomerSelector.js"),a=require("./OPOItemFields.js"),o=require("../../../context/common/SnackbarContext.js"),c=require("@mui/material/Typography"),l=require("@mui/material/Grid"),u=require("@mui/material/Box"),d=require("@mui/material/TextField"),m=require("@mui/material/Checkbox"),h=require("@mui/material/Stack"),x=require("@mui/material/Button");const j={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};exports.default=function({sx:p,revalidateCallback:f,handleClose:g,customerLabels:v,productLabels:y}){const[C,q]=r.useState(!1),[b,w]=s.useFormState(i.createOpoAction,j),{handleAddMessage:S}=o.useSnackbar();return r.useEffect(()=>{b?.message&&(S({message:b.message,severity:b.severity||"error"}),"success"===b.severity&&(f&&f(),g&&g()))},[b?.message]),r.useEffect(()=>{b?.strapiErrors&&S({message:b.strapiErrors.message||"Error creating order",severity:b.severity||"error"})},[b?.strapiErrors]),e.jsx(u,{sx:[...Array.isArray(p)?p:[p]],children:e.jsx("form",{action:w,children:e.jsxs(l,{container:!0,spacing:2,children:[e.jsx(l,{item:!0,xs:12,children:e.jsx(h,{spacing:2,children:e.jsx(c,{variant:"h3",component:"h1",children:"Create new order"})})}),e.jsx(l,{item:!0,xs:12,children:e.jsxs(h,{spacing:2,children:[e.jsx(c,{variant:"h6",children:"Choose a customer"}),e.jsx(n.CustomerSelector,{customerLabels:v})]})}),e.jsx(l,{item:!0,xs:12,children:e.jsxs(h,{spacing:2,children:[e.jsx(c,{variant:"h6",children:"Customer reference"}),e.jsx(c,{children:"If the customer utilizes a custom reference for inbound order management it should be left here"}),e.jsx(d,{id:"customer_reference",name:"customer_reference",sx:{width:"100%"}})]})}),e.jsxs(l,{item:!0,xs:12,children:[e.jsx(c,{variant:"h6",children:"Choose products for this order"}),e.jsx(a.OPOItemFields,{productsArr:y})]}),e.jsxs(l,{item:!0,xs:12,children:[e.jsx(c,{variant:"h6",children:"Confirm Order"}),e.jsx(c,{children:"Are you sure you want to confirm this order? Creating a order this way will not create a shipping label nor will it invoke a payment. It does however create an invoice which you can find under invoices"}),e.jsxs(h,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(m,{value:C,checked:C,onChange:()=>q(!C)}),C&&e.jsx(c,{color:"primary",children:"I am sure I want to confirm this order"})]}),e.jsx("input",{name:"internal_status",type:"hidden",value:C?"ordered":"placed"})]}),e.jsx(l,{item:!0,xs:12,children:e.jsxs(h,{direction:"row",justifyContent:"space-between",children:[g&&e.jsx(x,{onClick:g,variant:"outlined",children:"Cancel"}),e.jsx(t.SubmitButton,{text:"Confirm",loadingText:"Loading...",variant:"contained"})]})})]})})})};
7
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),s=require("react-dom"),i=require("../../../data/actions/e-commerce/opo/createOpoAction.js"),t=require("../../SubmitButton.js"),n=require("../customer/CustomerSelector.js"),a=require("./OPOItemFields.js"),o=require("../../../context/common/SnackbarContext.js"),c=require("@mui/material/Typography"),l=require("@mui/material/Grid"),u=require("@mui/material/Box"),d=require("@mui/material/TextField"),m=require("@mui/material/Checkbox"),h=require("@mui/material/Stack"),x=require("@mui/material/Button");const j={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};exports.default=function({sx:p,revalidateCallback:g,handleClose:f,customerLabels:v,productLabels:y}){const[C,q]=r.useState(!1),[b,w]=s.useFormState(i.createOpoAction,j),{handleAddMessage:S}=o.useSnackbar();return console.log(v,y),r.useEffect(()=>{b?.message&&(S({message:b.message,severity:b.severity||"error"}),"success"===b.severity&&(g&&g(),f&&f()))},[b?.message]),r.useEffect(()=>{b?.strapiErrors&&S({message:b.strapiErrors.message||"Error creating order",severity:b.severity||"error"})},[b?.strapiErrors]),e.jsx(u,{sx:[...Array.isArray(p)?p:[p]],children:e.jsx("form",{action:w,children:e.jsxs(l,{container:!0,spacing:2,children:[e.jsx(l,{item:!0,xs:12,children:e.jsx(h,{spacing:2,children:e.jsx(c,{variant:"h3",component:"h1",children:"Create new order"})})}),e.jsx(l,{item:!0,xs:12,children:e.jsxs(h,{spacing:2,children:[e.jsx(c,{variant:"h6",children:"Choose a customer"}),e.jsx(n.CustomerSelector,{customerLabels:v})]})}),e.jsx(l,{item:!0,xs:12,children:e.jsxs(h,{spacing:2,children:[e.jsx(c,{variant:"h6",children:"Customer reference"}),e.jsx(c,{children:"If the customer utilizes a custom reference for inbound order management it should be left here"}),e.jsx(d,{id:"customer_reference",name:"customer_reference",sx:{width:"100%"}})]})}),e.jsxs(l,{item:!0,xs:12,children:[e.jsx(c,{variant:"h6",children:"Choose products for this order"}),e.jsx(a.OPOItemFields,{productsArr:y})]}),e.jsxs(l,{item:!0,xs:12,children:[e.jsx(c,{variant:"h6",children:"Confirm Order"}),e.jsx(c,{children:"Are you sure you want to confirm this order? Creating a order this way will not create a shipping label nor will it invoke a payment. It does however create an invoice which you can find under invoices"}),e.jsxs(h,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(m,{value:C,checked:C,onChange:()=>q(!C)}),C&&e.jsx(c,{color:"primary",children:"I am sure I want to confirm this order"})]}),e.jsx("input",{name:"internal_status",type:"hidden",value:C?"ordered":"placed"})]}),e.jsx(l,{item:!0,xs:12,children:e.jsxs(h,{direction:"row",justifyContent:"space-between",children:[f&&e.jsx(x,{onClick:f,variant:"outlined",children:"Cancel"}),e.jsx(t.SubmitButton,{text:"Confirm",loadingText:"Loading...",variant:"contained"})]})})]})})})};
@@ -4,4 +4,4 @@
4
4
  * @copyright Jelle Paulus
5
5
  * @license MIT
6
6
  */
7
- "use strict";var e=require("../../../../node_modules/qs/lib/index.js"),a=require("../loaders.js");const i=require("../../../lib/utils.js").getStrapiURL();exports.getCustomerLabels=async function(){const t=new URL("/api/customer-profiles",i);return t.search=e.default.stringify({fields:["id","first_name","last_name","email"],pagination:{pageSize:100,page:1}}),(await a.fetchData(t.href)).data.map(e=>({id:e.id,title:e.first_name&&e.last_name?`${e.first_name} ${e.last_name}`:`${e.email}`}))};
7
+ "use strict";var e=require("../../../../node_modules/qs/lib/index.js"),a=require("../loaders.js");const t=require("../../../lib/utils.js").getStrapiURL();exports.getCustomerLabels=async function(){const s=new URL("/api/customer-profiles",t);s.search=e.default.stringify({fields:["id","first_name","last_name","email"],pagination:{pageSize:100,page:1}});const i=await a.fetchData(s.href);return console.log("Fetched customer labels:",i.data[0],i.data[1],i.data[2]),i&&i.data?0===i.data.length?(console.warn("No customer labels available"),[]):i.data.map(e=>({id:e.id,documentId:e.documentId,title:e.first_name&&e.last_name?`${e.first_name} ${e.last_name}`:`${e.email}`})):(console.error("No customer labels found"),[])};
@@ -4,4 +4,4 @@
4
4
  * @copyright Jelle Paulus
5
5
  * @license MIT
6
6
  */
7
- "use strict";var e=require("../../../../node_modules/qs/lib/index.js"),t=require("../loaders.js");const i=require("../../../lib/utils.js").getStrapiURL();exports.getProductNames=async function(){const r=new URL("/api/products",i);return r.search=e.default.stringify({fields:["id","title","slug","product_number"],pagination:{pageSize:100,page:1}}),await t.fetchData(r.href)};
7
+ "use strict";var e=require("../../../../node_modules/qs/lib/index.js"),t=require("../loaders.js");const i=require("../../../lib/utils.js").getStrapiURL();exports.getProductNames=async function(){const r=new URL("/api/products",i);return r.search=e.default.stringify({fields:["id","title","slug","product_number"],pagination:{pageSize:100,page:1}}),(await t.fetchData(r.href)).data};