umwd-components 0.1.344 → 0.1.346

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.
Files changed (24) hide show
  1. package/dist/src/components/common/media/MediaGrid.js +1 -1
  2. package/dist/src/components/common/media/MediaLibraryDialog.js +1 -1
  3. package/dist/src/components/common/media/UploadMediaForm.js +1 -1
  4. package/dist/src/components/e-commerce/products/AddProductForm.js +1 -1
  5. package/dist/src/components/e-commerce/products/EditProductForm.js +1 -1
  6. package/dist/src/data/loaders/e-commerce/getPaginatedCategories.js +1 -1
  7. package/dist/src/data/loaders/e-commerce-loaders.js +1 -1
  8. package/dist/tsconfig.build.tsbuildinfo +1 -1
  9. package/dist/types/components/common/media/MediaLibraryDialog.d.ts +3 -3
  10. package/dist/types/components/common/media/UploadMediaForm.d.ts +1 -1
  11. package/dist/types/components/e-commerce/products/AddProductForm.d.ts +1 -3
  12. package/dist/types/components/e-commerce/products/EditProductForm.d.ts +1 -3
  13. package/dist/types/data/loaders/e-commerce/getPaginatedCategories.d.ts +1 -1
  14. package/dist/types/types/common/media/types.d.ts +1 -0
  15. package/package.json +1 -1
  16. package/src/components/common/media/MediaGrid.tsx +6 -5
  17. package/src/components/common/media/MediaLibraryDialog.tsx +56 -10
  18. package/src/components/common/media/UploadMediaForm.tsx +9 -2
  19. package/src/components/e-commerce/products/AddProductForm.tsx +23 -32
  20. package/src/components/e-commerce/products/EditProductForm.tsx +9 -8
  21. package/src/data/loaders/common/media/getAllMedia.ts +0 -18
  22. package/src/data/loaders/e-commerce/getPaginatedCategories.ts +9 -7
  23. package/src/data/loaders/e-commerce-loaders.ts +7 -2
  24. package/src/types/common/media/types.ts +1 -0
@@ -4,4 +4,4 @@
4
4
  * @copyright Jelle Paulus
5
5
  * @license MIT
6
6
  */
7
- import{__read as e,__awaiter as t,__generator as n}from"../../../../node_modules/tslib/tslib.es6.js";import r,{useState as i,Fragment as o}from"react";import l from"@mui/material/Grid";import{MediaItem as m}from"./MediaItem.js";import a from"./EditMediaDialog.js";function u(u){var c=this,d=u.mediaArray,s=u.selected,f=void 0===s?[]:s,p=u.handleSelect,E=e(i(!1),2),h=E[0],v=E[1],g=e(i(null),2),x=g[0],j=g[1],I=function(){v(!1),null!==x&&j(null)};return r.createElement(l,{container:!0,spacing:2,sx:{transform:"translateX(-1rem)"}},(null==d?void 0:d.length)>0&&d.map((function(e,i){return console.log(e),r.createElement(o,{key:e.id},r.createElement(l,{item:!0,xs:3},r.createElement(a,{open:h&&x===i,handleClose:I,data:e}),r.createElement(m,{mediaItem:e,isSelected:-1!==f.findIndex((function(t){return t.id===e.id})),onClick:p?function(){return p(e)}:function(){return function(e){return t(c,void 0,void 0,(function(){return n(this,(function(t){return j(e),v(!0),[2]}))}))}(i)}})))})))}export{u as MediaGrid};
7
+ import{__read as e,__awaiter as t,__generator as n}from"../../../../node_modules/tslib/tslib.es6.js";import r,{useState as i,Fragment as o}from"react";import l from"@mui/material/Grid";import{MediaItem as m}from"./MediaItem.js";import a from"./EditMediaDialog.js";function u(u){var c=this,d=u.mediaArray,s=u.selected,f=void 0===s?[]:s,p=u.handleSelect,E=e(i(!1),2),h=E[0],v=E[1],g=e(i(null),2),x=g[0],j=g[1],I=function(){v(!1),null!==x&&j(null)};return r.createElement(l,{container:!0,spacing:2,sx:{transform:"translateX(-1rem)"}},(null==d?void 0:d.length)>0&&d.map((function(e,i){return console.log(e),r.createElement(o,{key:e.id},r.createElement(a,{open:h&&x===i,handleClose:I,data:e}),r.createElement(l,{item:!0,xs:3},r.createElement(m,{mediaItem:e,isSelected:-1!==f.findIndex((function(t){return t.id===e.id})),onClick:p?function(){return p(e)}:function(){return function(e){return t(c,void 0,void 0,(function(){return n(this,(function(t){return j(e),v(!0),[2]}))}))}(i)}})))})))}export{u as MediaGrid};
@@ -4,4 +4,4 @@
4
4
  * @copyright Jelle Paulus
5
5
  * @license MIT
6
6
  */
7
- import e from"react";import{MediaGrid as r}from"./MediaGrid.js";import{UploadMediaForm as t}from"./UploadMediaForm.js";import l from"@mui/material/Dialog";import a from"@mui/material/Button";function m(m){var o=m.mediaArray,i=m.open,n=m.handleClose,d=m.selected,c=m.handleSelect;return e.createElement(l,{open:i,fullWidth:!0,maxWidth:"lg"},e.createElement(a,{onClick:n},"Close"),e.createElement(t,null),e.createElement(r,{mediaArray:o,selected:d,handleSelect:c}))}export{m as MediaLibraryDialog};
7
+ import{__read as e,__awaiter as t,__generator as n}from"../../../../node_modules/tslib/tslib.es6.js";import a,{useState as r,useEffect as i}from"react";import{MediaGrid as o}from"./MediaGrid.js";import{UploadMediaForm as l}from"./UploadMediaForm.js";import m from"@mui/material/Dialog";import c from"@mui/material/Button";import d from"@mui/material/Divider";import s from"@mui/material/Stack";import{Typography as u}from"@mui/material";import{getAllMedia as f}from"../../../data/loaders/common/media/getAllMedia.js";function p(p){var h=this,v=p.open,E=p.handleClose,b=p.handleCancel,g=p.selected,y=p.handleSelect,C=e(r(),2),j=C[0],k=C[1];i((function(){!function(){t(this,void 0,void 0,(function(){var e;return n(this,(function(t){switch(t.label){case 0:return[4,f()];case 1:return e=t.sent(),k(e),[2]}}))}))}()}),[]);return a.createElement(m,{open:v,fullWidth:!0,maxWidth:"lg"},a.createElement(s,{spacing:2,sx:{p:2}},a.createElement(u,{variant:"h5"},"Media Library"),a.createElement(u,{variant:"body2"},"Upload media to use in your content"),a.createElement(l,{revalidateCallback:function(){t(h,void 0,void 0,(function(){var e;return n(this,(function(t){switch(t.label){case 0:return[4,f()];case 1:return e=t.sent(),k(e),[2]}}))}))}}),a.createElement(d,null),a.createElement(u,{variant:"body2"},"Select media to use in your content"),j&&a.createElement(o,{mediaArray:j,selected:g,handleSelect:y}),a.createElement(d,null),a.createElement(s,{direction:"row",spacing:2,justifyContent:"flex-end"},a.createElement(c,{variant:"outlined",onClick:b},"Cancel"),g.length>0&&a.createElement(c,{variant:"contained",onClick:E},"Use selected file".concat(g.length>1?"s":"")))))}export{p as MediaLibraryDialog};
@@ -4,4 +4,4 @@
4
4
  * @copyright Jelle Paulus
5
5
  * @license MIT
6
6
  */
7
- import{__read as e}from"../../../../node_modules/tslib/tslib.es6.js";import t,{useState as r,useRef as n}from"react";import l from"@mui/material/Stack";import i from"@mui/material/Typography";import a from"@mui/material/Box";import{useFormState as o}from"react-dom";import{uploadMediaAction as m}from"../../../data/actions/media/uploadMediaAction.js";import{StrapiErrors as c}from"../../StrapiErrors.js";import{ZodErrors as u}from"../../ZodErrors.js";import s from"@mui/material/Alert";import{SubmitButton as p}from"../../SubmitButton.js";var d={zodErrors:null,strapiErrors:null,data:null,message:null};function f(f){var E,y=f.reference,v=f.refID,g=f.field,x=f.multiple,h=void 0===x||x,b=f.accept,j=void 0===b?"image/*":b;f.fileData;var k=e(r(null),2),w=k[0],C=k[1],I=e(r(null),2),O=I[0],S=I[1],z=e(o(m,d),2),A=z[0],B=z[1],D=n(null);return t.createElement("form",{action:B},t.createElement(l,{spacing:1,sx:{flex:1}},y&&t.createElement("input",{type:"text",name:"ref",value:y,style:{display:"none"},readOnly:!0}),v&&t.createElement("input",{type:"text",name:"refId",value:v,style:{display:"none"},readOnly:!0}),g&&t.createElement("input",{type:"text",name:"field",value:g,style:{display:"none"},readOnly:!0}),null!==w?t.createElement(a,{onClick:function(){var e;return null===(e=D.current)||void 0===e?void 0:e.click()},sx:{p:2,width:"100%",border:"1px dashed white",minHeight:"100px"}},void 0===j||"image/*"===j?t.createElement(l,{direction:"row",spacing:1,justifyContent:"flex-end"},w.map((function(e,r){return t.createElement("img",{key:r,src:e.url,alt:e.name,style:{width:"100px"}})}))):t.createElement(l,{spacing:1,justifyContent:"flex-end"},w.map((function(e,r){return t.createElement(i,{key:r},e.name)})))):t.createElement(a,{onClick:function(){var e;return null===(e=D.current)||void 0===e?void 0:e.click()},sx:{p:2,width:"100%",border:"1px dashed white",minHeight:"100px"}},t.createElement(i,null,"No file","".concat(h?"s":"")," selected")),t.createElement(l,{direction:"column",spacing:2,alignItems:"center",justifyContent:"space-between"},t.createElement(c,{error:A.strapiErrors}),t.createElement(u,{error:null===(E=A.zodErrors)||void 0===E?void 0:E.image}),(null==A?void 0:A.message)&&t.createElement(s,{severity:"error"},null==A?void 0:A.message),t.createElement(a,null,t.createElement("label",{htmlFor:"pictureInput"},t.createElement("input",{id:"pictureInput",accept:j,multiple:h,type:"file",name:"files",ref:D,onChange:function(e){console.log(e.target.files);var t=e.target.files;if(null!==t){var r=Object.keys(t).map((function(e,r){return{url:URL.createObjectURL(t[r]),name:t[r].name}}));S(t),C(r)}},style:{display:"none"}})),null!==O&&t.createElement(p,{text:"submit",loadingText:"loading"})))))}export{f as UploadMediaForm};
7
+ import{__read as e}from"../../../../node_modules/tslib/tslib.es6.js";import t,{useState as r,useRef as n,useEffect as l}from"react";import a from"@mui/material/Stack";import i from"@mui/material/Typography";import o from"@mui/material/Box";import{useFormState as m}from"react-dom";import{uploadMediaAction as c}from"../../../data/actions/media/uploadMediaAction.js";import{StrapiErrors as u}from"../../StrapiErrors.js";import{ZodErrors as s}from"../../ZodErrors.js";import p from"@mui/material/Alert";import{SubmitButton as d}from"../../SubmitButton.js";var f={zodErrors:null,strapiErrors:null,data:null,message:null};function E(E){var y,v=E.reference,g=E.refID,x=E.field,h=E.multiple,b=void 0===h||h,j=E.accept,k=void 0===j?"image/*":j;E.fileData;var w=E.revalidateCallback,C=e(r(null),2),I=C[0],O=C[1],S=e(r(null),2),z=S[0],A=S[1],B=e(m(c,f),2),D=B[0],H=B[1],L=n(null);return l((function(){D.data&&(null==w||w())}),[D.data]),t.createElement("form",{action:H},t.createElement(a,{spacing:1,sx:{flex:1}},v&&t.createElement("input",{type:"text",name:"ref",value:v,style:{display:"none"},readOnly:!0}),g&&t.createElement("input",{type:"text",name:"refId",value:g,style:{display:"none"},readOnly:!0}),x&&t.createElement("input",{type:"text",name:"field",value:x,style:{display:"none"},readOnly:!0}),null!==I?t.createElement(o,{onClick:function(){var e;return null===(e=L.current)||void 0===e?void 0:e.click()},sx:{p:2,width:"100%",border:"1px dashed white",minHeight:"100px"}},void 0===k||"image/*"===k?t.createElement(a,{direction:"row",spacing:1,justifyContent:"flex-end"},I.map((function(e,r){return t.createElement("img",{key:r,src:e.url,alt:e.name,style:{width:"100px"}})}))):t.createElement(a,{spacing:1,justifyContent:"flex-end"},I.map((function(e,r){return t.createElement(i,{key:r},e.name)})))):t.createElement(o,{onClick:function(){var e;return null===(e=L.current)||void 0===e?void 0:e.click()},sx:{p:2,width:"100%",border:"1px dashed white",minHeight:"100px"}},t.createElement(i,null,"No file","".concat(b?"s":"")," selected")),t.createElement(a,{direction:"column",spacing:2,alignItems:"center",justifyContent:"space-between"},t.createElement(u,{error:D.strapiErrors}),t.createElement(s,{error:null===(y=D.zodErrors)||void 0===y?void 0:y.image}),(null==D?void 0:D.message)&&t.createElement(p,{severity:"error"},null==D?void 0:D.message),t.createElement(o,null,t.createElement("label",{htmlFor:"pictureInput"},t.createElement("input",{id:"pictureInput",accept:k,multiple:b,type:"file",name:"files",ref:L,onChange:function(e){console.log(e.target.files);var t=e.target.files;if(null!==t){var r=Object.keys(t).map((function(e,r){return{url:URL.createObjectURL(t[r]),name:t[r].name}}));A(t),O(r)}},style:{display:"none"}})),null!==z&&t.createElement(d,{text:"upload",loadingText:"loading"})))))}export{E as UploadMediaForm};
@@ -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 i}from"react";import n from"@mui/material/Paper";import a from"@mui/material/Box";import m from"@mui/material/Stack";import l from"@mui/material/Alert";import o from"@mui/material/TextField";import c from"@mui/material/Typography";import{SubmitButton as s}from"../../SubmitButton.js";import{useFormState as d}from"react-dom";import{StrapiErrors as u}from"../../StrapiErrors.js";import{createProductAction as p}from"../../../data/actions/e-commerce/product/createProductAction.js";import{MediaLibraryDialog as E}from"../../common/media/MediaLibraryDialog.js";import g from"@mui/material/Button";import f from"@mui/material/Grid";import{StrapiImage as h}from"../../StrapiImage.js";import{PriceFields as v}from"./PriceFields.js";import x from"../categories/CategorySelectorV2.js";import{DimensionsFields as y}from"../../common/Dimensions.js";import j from"../../logistics/vendor/VendorSelector.js";var w={zodErrors:null,strapiErrors:null,data:null,message:null};function b(b){var S=b.mediaArray,C=b.vendorArr,T=b.categories,k=e(d(p,w),2),A=k[0],P=k[1],V=e(i(null),2),D=V[0],I=V[1],N=e(i(null),2),R=N[0],B=N[1],O=e(i([]),2),F=O[0],G=O[1];return r.createElement(a,{component:n,sx:{p:2}},r.createElement("form",{action:P},r.createElement(f,{container:!0,spacing:2},r.createElement(f,{item:!0,xs:12},r.createElement(m,{direction:"row-reverse",spacing:2,alignItems:"center",sx:{backgroundColor:"secondary.dark",px:2,py:1}},r.createElement(s,{text:"create new product",loadingText:"loading",sx:{color:"secondary.contrastText"}}),r.createElement(u,{error:null==A?void 0:A.strapiErrors}),(null==A?void 0:A.message)&&r.createElement(l,{severity:"error"},null==A?void 0:A.message))),r.createElement(f,{item:!0,xs:12},r.createElement(m,{spacing:2},r.createElement(o,{id:"title",name:"title",label:"Title"}),r.createElement(o,{id:"description",name:"description",label:"Description",multiline:!0,minRows:4,maxRows:8}))),r.createElement(f,{item:!0,xs:6},r.createElement(c,{variant:"h6"},"Product Image"),r.createElement("input",{id:"image",type:"hidden",name:"image",value:null==R?void 0:R.id}),r.createElement(h,{id:(null==R?void 0:R.id)||"",url:(null==R?void 0:R.url)||"",alternativeText:"product image",width:(null==R?void 0:R.width)&&(null==R?void 0:R.height)?R.width/R.height*200:200,height:200}),r.createElement(g,{onClick:function(){return I("image")}},"open media library"),r.createElement(E,{mediaArray:S,open:"image"===D,handleClose:function(){return I(null)},handleSelect:function(e){B(e)},selected:R?[R]:[]})),r.createElement(f,{item:!0,xs:6},r.createElement(c,{variant:"h6"},"Image Gallery"),r.createElement("input",{id:"gallery",type:"hidden",name:"gallery",value:JSON.stringify(F.map((function(e){return e.id})))}),r.createElement(m,{direction:"row",spacing:2},F.map((function(e){return r.createElement(h,{key:e.id,id:e.id,url:e.url,alternativeText:"gallery image",width:e.width/e.height*100,height:100})}))),r.createElement(g,{onClick:function(){return I("gallery")}},"open media library"),r.createElement(E,{mediaArray:S,open:"gallery"===D,handleClose:function(){return I(null)},handleSelect:function(r){if(F.indexOf(r)>-1){var i=t([],e(F),!1);i.splice(F.indexOf(r),1),G(i)}else F.length>=5?G(t([],e(F),!1)):G(t(t([],e(F),!1),[r],!1))},selected:F})),r.createElement(f,{item:!0,xs:12},r.createElement(c,{variant:"h6"},"Price"),r.createElement(v,{componentName:"price",componentReference:"e-commerce-elements.price"})),r.createElement(f,{item:!0,xs:12},r.createElement(c,{variant:"h6"},"Categories"),r.createElement(x,{categories:T,currentValue:[]})),r.createElement(f,{item:!0,xs:12},r.createElement(c,{variant:"h6"},"Dimensions"),r.createElement(y,{componentName:"dimensions",componentReference:"e-commerce-elements.dimensions"})),r.createElement(f,{item:!0,xs:12},r.createElement(c,{variant:"h6"},"Vendors"),r.createElement(j,{vendorNames:C,currentValue:null})))))}export{b as AddProductForm};
7
+ import{__read as e,__spreadArray as t}from"../../../../node_modules/tslib/tslib.es6.js";import r,{useState as n}from"react";import i from"@mui/material/Paper";import m from"@mui/material/Box";import a from"@mui/material/Stack";import l from"@mui/material/Alert";import o from"@mui/material/TextField";import c from"@mui/material/Typography";import{SubmitButton as s}from"../../SubmitButton.js";import{useFormState as d}from"react-dom";import{StrapiErrors as u}from"../../StrapiErrors.js";import{createProductAction as p}from"../../../data/actions/e-commerce/product/createProductAction.js";import{MediaLibraryDialog as E}from"../../common/media/MediaLibraryDialog.js";import g from"@mui/material/Button";import f from"@mui/material/Grid";import{StrapiImage as h}from"../../StrapiImage.js";import{PriceFields as v}from"./PriceFields.js";import x from"../categories/CategorySelectorV2.js";import{DimensionsFields as y}from"../../common/Dimensions.js";import j from"../../logistics/vendor/VendorSelector.js";var w={zodErrors:null,strapiErrors:null,data:null,message:null};function S(S){var b=S.vendorArr,C=S.categories,T=e(d(p,w),2),P=T[0],V=T[1],k=e(n(null),2),D=k[0],I=k[1],N=e(n(null),2),R=N[0],A=N[1],B=e(n([]),2),O=B[0],F=B[1];return r.createElement(m,{component:i,sx:{p:2}},r.createElement("form",{action:V},r.createElement(f,{container:!0,spacing:2},r.createElement(f,{item:!0,xs:12},r.createElement(a,{spacing:2},r.createElement(o,{id:"title",name:"title",label:"Title"}),r.createElement(o,{id:"description",name:"description",label:"Description",multiline:!0,minRows:4,maxRows:8}))),r.createElement(f,{item:!0,xs:6},r.createElement(c,{variant:"h6"},"Product Image"),r.createElement("input",{id:"image",type:"hidden",name:"image",value:null==R?void 0:R.id}),r.createElement(h,{id:(null==R?void 0:R.id)||"",url:(null==R?void 0:R.url)||"",alternativeText:"product image",width:(null==R?void 0:R.width)&&(null==R?void 0:R.height)?R.width/R.height*200:200,height:200}),r.createElement(g,{onClick:function(){return I("image")}},"open media library"),r.createElement(E,{open:"image"===D,handleClose:function(){return I(null)},handleCancel:function(){A(null),I(null)},handleSelect:function(e){A(e)},selected:R?[R]:[]})),r.createElement(f,{item:!0,xs:6},r.createElement(c,{variant:"h6"},"Image Gallery"),r.createElement("input",{id:"gallery",type:"hidden",name:"gallery",value:JSON.stringify(O.map((function(e){return e.id})))}),r.createElement(a,{direction:"row",spacing:2},O.map((function(e){return r.createElement(h,{key:e.id,id:e.id,url:e.url,alternativeText:"gallery image",width:e.width/e.height*100,height:100})}))),r.createElement(g,{onClick:function(){return I("gallery")}},"open media library"),r.createElement(E,{open:"gallery"===D,handleClose:function(){return I(null)},handleCancel:function(){F([]),I(null)},handleSelect:function(r){if(O.indexOf(r)>-1){var n=t([],e(O),!1);n.splice(O.indexOf(r),1),F(n)}else O.length>=5?F(t([],e(O),!1)):F(t(t([],e(O),!1),[r],!1))},selected:O})),r.createElement(f,{item:!0,xs:12},r.createElement(c,{variant:"h6"},"Price"),r.createElement(v,{componentName:"price",componentReference:"e-commerce-elements.price"})),r.createElement(f,{item:!0,xs:12},r.createElement(c,{variant:"h6"},"Categories"),r.createElement(x,{categories:C,currentValue:[]})),r.createElement(f,{item:!0,xs:12},r.createElement(c,{variant:"h6"},"Dimensions"),r.createElement(y,{componentName:"dimensions",componentReference:"e-commerce-elements.dimensions"})),r.createElement(f,{item:!0,xs:12},r.createElement(c,{variant:"h6"},"Vendors"),r.createElement(j,{vendorNames:b,currentValue:null}))),r.createElement(f,{item:!0,xs:12},r.createElement(a,{direction:"row-reverse",spacing:2,alignItems:"center",sx:{py:2}},r.createElement(s,{text:"create new product",loadingText:"loading"}),r.createElement(u,{error:null==P?void 0:P.strapiErrors}),(null==P?void 0:P.message)&&r.createElement(l,{severity:"error"},null==P?void 0:P.message)))))}export{S as AddProductForm};
@@ -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 i}from"react";import a from"@mui/material/Paper";import n from"@mui/material/Box";import l from"@mui/material/Stack";import m from"@mui/material/Alert";import o from"@mui/material/TextField";import c from"@mui/material/Typography";import{SubmitButton as d}from"../../SubmitButton.js";import{useFormState as s}from"react-dom";import{StrapiErrors as u}from"../../StrapiErrors.js";import{updateProductAction as p}from"../../../data/actions/e-commerce/product/updateProductAction.js";import{MediaLibraryDialog as g}from"../../common/media/MediaLibraryDialog.js";import E from"@mui/material/Button";import f from"@mui/material/Grid";import{StrapiImage as v}from"../../StrapiImage.js";import{PriceFields as h}from"./PriceFields.js";import y from"../categories/CategorySelectorV2.js";import{DimensionsFields as x}from"../../common/Dimensions.js";import j from"../../logistics/vendor/VendorSelector.js";var w={zodErrors:null,strapiErrors:null,data:null,message:null};function b(b){var S=b.data,A=b.mediaArray,C=b.vendorArr,T=b.categoriesArray,V=S.id,k=S.title,I=S.description,P=S.image,D=S.gallery,N=S.price,R=S.dimensions,B=S.categories;console.log("data",S);var F=(null==D?void 0:D.data)||[],G=(null==B?void 0:B.data)||[],z=e(s(p,w),2),J=z[0],L=z[1],M=e(i(null),2),O=M[0],_=M[1],q=e(i(P||null),2),H=q[0],K=q[1],Q=e(i(t([],e(F),!1)),2),U=Q[0],W=Q[1];return r.createElement(n,{component:a,sx:{p:2}},r.createElement("form",{action:L},V&&r.createElement("input",{id:"id",type:"hidden",name:"id",value:V}),r.createElement(f,{container:!0,spacing:2},r.createElement(f,{item:!0,xs:12},r.createElement(l,{direction:"row-reverse",spacing:2,alignItems:"center",sx:{backgroundColor:"secondary.dark",px:2,py:1}},r.createElement(d,{text:"update product",loadingText:"loading",sx:{color:"secondary.contrastText"}}),(null==J?void 0:J.strapiErrors)&&r.createElement(u,{error:null==J?void 0:J.strapiErrors}),(null==J?void 0:J.message)&&r.createElement(m,{severity:"error"},null==J?void 0:J.message))),r.createElement(f,{item:!0,xs:12},r.createElement(l,{spacing:2},r.createElement(o,{id:"title",name:"title",label:"Title",defaultValue:k}),r.createElement(o,{id:"description",name:"description",label:"Description",multiline:!0,minRows:4,maxRows:8,defaultValue:I}))),r.createElement(f,{item:!0,xs:6},r.createElement(c,{variant:"h6"},"Product Image"),r.createElement("input",{id:"image",type:"hidden",name:"image",value:null==H?void 0:H.id}),r.createElement(v,{id:(null==H?void 0:H.id)||"",url:(null==H?void 0:H.url)||"",alternativeText:"product image",width:(null==H?void 0:H.width)&&(null==H?void 0:H.height)?H.width/H.height*200:200,height:200}),r.createElement(E,{onClick:function(){return _("image")}},"open media library"),r.createElement(g,{mediaArray:A,open:"image"===O,handleClose:function(){return _(null)},handleSelect:function(e){K(e)},selected:H?[H]:[]})),r.createElement(f,{item:!0,xs:6},r.createElement(c,{variant:"h6"},"Image Gallery"),r.createElement("input",{id:"gallery",type:"hidden",name:"gallery",value:JSON.stringify(U.map((function(e){return e.id})))}),r.createElement(l,{direction:"row",spacing:2},U.map((function(e){return r.createElement(v,{key:e.id,id:e.id,url:e.url,alternativeText:"gallery image",width:(null==e?void 0:e.width)&&(null==e?void 0:e.height)?e.width/e.height*100:100,height:100})}))),r.createElement(E,{onClick:function(){return _("gallery")}},"open media library"),r.createElement(g,{mediaArray:A,open:"gallery"===O,handleClose:function(){return _(null)},handleSelect:function(r){var i=U.findIndex((function(e){return e.id===r.id}));if(i>-1){var a=t([],e(U),!1);a.splice(i,1),W(a)}else U.length>=5?W(t([],e(U),!1)):W(t(t([],e(U),!1),[r],!1))},selected:U})),r.createElement(f,{item:!0,xs:12},r.createElement(c,{variant:"h6"},"Price"),r.createElement(h,{componentName:"price",componentReference:"e-commerce-elements.price",data:N})),r.createElement(f,{item:!0,xs:12},r.createElement(c,{variant:"h6"},"Categories"),r.createElement(y,{categories:T,currentValue:t([],e(G.map((function(e){return e.id}))),!1)})),r.createElement(f,{item:!0,xs:12},r.createElement(c,{variant:"h6"},"Dimensions"),r.createElement(x,{componentName:"dimensions",componentReference:"e-commerce-elements.dimensions",data:R})),r.createElement(f,{item:!0,xs:12},r.createElement(c,{variant:"h6"},"Vendors"),r.createElement(j,{vendorNames:C,currentValue:null})))))}export{b as EditProductForm};
7
+ import{__read as e,__spreadArray as t}from"../../../../node_modules/tslib/tslib.es6.js";import r,{useState as i}from"react";import n from"@mui/material/Paper";import a from"@mui/material/Box";import l from"@mui/material/Stack";import o from"@mui/material/Alert";import m from"@mui/material/TextField";import c from"@mui/material/Typography";import{SubmitButton as d}from"../../SubmitButton.js";import{useFormState as s}from"react-dom";import{StrapiErrors as u}from"../../StrapiErrors.js";import{updateProductAction as p}from"../../../data/actions/e-commerce/product/updateProductAction.js";import{MediaLibraryDialog as g}from"../../common/media/MediaLibraryDialog.js";import E from"@mui/material/Button";import f from"@mui/material/Grid";import{StrapiImage as h}from"../../StrapiImage.js";import{PriceFields as v}from"./PriceFields.js";import y from"../categories/CategorySelectorV2.js";import{DimensionsFields as x}from"../../common/Dimensions.js";import j from"../../logistics/vendor/VendorSelector.js";var w={zodErrors:null,strapiErrors:null,data:null,message:null};function b(b){var C=b.data,S=b.vendorArr,T=b.categoriesArray,V=C.id,k=C.title,I=C.description,P=C.image,A=C.gallery,D=C.price,N=C.dimensions,R=C.categories;console.log("data",C);var B=(null==A?void 0:A.data)||[],F=(null==R?void 0:R.data)||[],G=e(s(p,w),2),z=G[0],J=G[1],L=e(i(null),2),M=L[0],O=L[1],_=e(i(P||null),2),q=_[0],H=_[1],K=e(i(t([],e(B),!1)),2),Q=K[0],U=K[1];return r.createElement(a,{component:n,sx:{p:2}},r.createElement("form",{action:J},V&&r.createElement("input",{id:"id",type:"hidden",name:"id",value:V}),r.createElement(f,{container:!0,spacing:2},r.createElement(f,{item:!0,xs:12},r.createElement(l,{direction:"row-reverse",spacing:2,alignItems:"center",sx:{backgroundColor:"secondary.dark",px:2,py:1}},r.createElement(d,{text:"update product",loadingText:"loading",sx:{color:"secondary.contrastText"}}),(null==z?void 0:z.strapiErrors)&&r.createElement(u,{error:null==z?void 0:z.strapiErrors}),(null==z?void 0:z.message)&&r.createElement(o,{severity:"error"},null==z?void 0:z.message))),r.createElement(f,{item:!0,xs:12},r.createElement(l,{spacing:2},r.createElement(m,{id:"title",name:"title",label:"Title",defaultValue:k}),r.createElement(m,{id:"description",name:"description",label:"Description",multiline:!0,minRows:4,maxRows:8,defaultValue:I}))),r.createElement(f,{item:!0,xs:6},r.createElement(c,{variant:"h6"},"Product Image"),r.createElement("input",{id:"image",type:"hidden",name:"image",value:null==q?void 0:q.id}),r.createElement(h,{id:(null==q?void 0:q.id)||"",url:(null==q?void 0:q.url)||"",alternativeText:"product image",width:(null==q?void 0:q.width)&&(null==q?void 0:q.height)?q.width/q.height*200:200,height:200}),r.createElement(E,{onClick:function(){return O("image")}},"open media library"),r.createElement(g,{open:"image"===M,handleClose:function(){return O(null)},handleCancel:function(){H(null),O(null)},handleSelect:function(e){H(e)},selected:q?[q]:[]})),r.createElement(f,{item:!0,xs:6},r.createElement(c,{variant:"h6"},"Image Gallery"),r.createElement("input",{id:"gallery",type:"hidden",name:"gallery",value:JSON.stringify(Q.map((function(e){return e.id})))}),r.createElement(l,{direction:"row",spacing:2},Q.map((function(e){return r.createElement(h,{key:e.id,id:e.id,url:e.url,alternativeText:"gallery image",width:(null==e?void 0:e.width)&&(null==e?void 0:e.height)?e.width/e.height*100:100,height:100})}))),r.createElement(E,{onClick:function(){return O("gallery")}},"open media library"),r.createElement(g,{open:"gallery"===M,handleClose:function(){return O(null)},handleCancel:function(){U([]),O(null)},handleSelect:function(r){var i=Q.findIndex((function(e){return e.id===r.id}));if(i>-1){var n=t([],e(Q),!1);n.splice(i,1),U(n)}else Q.length>=5?U(t([],e(Q),!1)):U(t(t([],e(Q),!1),[r],!1))},selected:Q})),r.createElement(f,{item:!0,xs:12},r.createElement(c,{variant:"h6"},"Price"),r.createElement(v,{componentName:"price",componentReference:"e-commerce-elements.price",data:D})),r.createElement(f,{item:!0,xs:12},r.createElement(c,{variant:"h6"},"Categories"),r.createElement(y,{categories:T,currentValue:t([],e(F.map((function(e){return e.id}))),!1)})),r.createElement(f,{item:!0,xs:12},r.createElement(c,{variant:"h6"},"Dimensions"),r.createElement(x,{componentName:"dimensions",componentReference:"e-commerce-elements.dimensions",data:N})),r.createElement(f,{item:!0,xs:12},r.createElement(c,{variant:"h6"},"Vendors"),r.createElement(j,{vendorNames:S,currentValue:null})))))}export{b as EditProductForm};
@@ -4,4 +4,4 @@
4
4
  * @copyright Jelle Paulus
5
5
  * @license MIT
6
6
  */
7
- import{__awaiter as e,__generator as i}from"../../../../node_modules/tslib/tslib.es6.js";import r from"../../../../node_modules/qs/lib/index.js";import{fetchData as t}from"../loaders.js";import{getStrapiURL as o}from"../../../lib/utils.js";var s=o();function n(o){return e(this,void 0,void 0,(function(){var e;return i(this,(function(i){switch(i.label){case 0:return 4,(e=new URL("/api/product-categories",s)).search=r.stringify({populate:{products:{populate:{image:!0,price:!0}}},pagination:{pageSize:4,page:o}}),[4,t(e.href)];case 1:return[2,i.sent()]}}))}))}export{n as getPaginatedCategories};
7
+ import{__awaiter as e,__generator as t}from"../../../../node_modules/tslib/tslib.es6.js";import i from"../../../../node_modules/qs/lib/index.js";import{fetchData as o}from"../loaders.js";import{getStrapiURL as r}from"../../../lib/utils.js";var s=r();function n(r,n,a,c){return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return(e=new URL("/api/product-categories",s)).search=i.stringify({populate:{products:{populate:{image:!0,price:!0}}},sort:"".concat(c||"id",":").concat(a||"desc"),pagination:{pageSize:n||4,page:r?r+1:1}}),[4,o(e.href)];case 1:return[2,t.sent()]}}))}))}export{n as getPaginatedCategories};
@@ -4,4 +4,4 @@
4
4
  * @copyright Jelle Paulus
5
5
  * @license MIT
6
6
  */
7
- import{__awaiter as e,__generator as t}from"../../../node_modules/tslib/tslib.es6.js";import r from"../../../node_modules/qs/lib/index.js";import{fetchData as i}from"./loaders.js";import{getStrapiURL as n}from"../../lib/utils.js";import{unstable_noStore as o}from"next/cache";var s=n();function a(n){return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return 4,(e=new URL("/api/products",s)).search=r.stringify({populate:{price:!0,image:!0,gallery:!0,dimensions:!0,categories:!0,brand:!0},pagination:{pageSize:4,page:n}}),[4,i(e.href)];case 1:return[2,t.sent()]}}))}))}function c(){return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return console.log("getCustomerProfile"),o(),(e=new URL("/api/users/me",s)).search=r.stringify({populate:{customer_profile:!0}}),[4,i(e.href)];case 1:return[2,t.sent()]}}))}))}function u(r){return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return console.log("getSingleOrder",r),o(),e=new URL("/api/opos/".concat(r),s),[4,i(e.href)];case 1:return[2,t.sent()]}}))}))}function p(n,a,c,u,p){return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return o(),(e=new URL("/api/opos",s)).search=r.stringify({filters:{is_archive:{$in:p}},sort:"".concat(u||"id",":").concat(c||"desc"),populate:{opo_items:{populate:{product:{populate:{price:!0}}}},customer:!0,payments:!0},pagination:{pageSize:a||10,page:n?n+1:1}}),[4,i(e.href)];case 1:return[2,t.sent()]}}))}))}export{p as getAllOrders,a as getAllProducts,c as getCustomerProfile,u as getSingleOrder};
7
+ import{__awaiter as e,__generator as r}from"../../../node_modules/tslib/tslib.es6.js";import t from"../../../node_modules/qs/lib/index.js";import{fetchData as i}from"./loaders.js";import{getStrapiURL as o}from"../../lib/utils.js";import{unstable_noStore as n}from"next/cache";import{getUserRole as s}from"../services/get-user-me-loader.js";var a=o();function c(o){return e(this,void 0,void 0,(function(){var e;return r(this,(function(r){switch(r.label){case 0:return 4,(e=new URL("/api/products",a)).search=t.stringify({populate:{price:!0,image:!0,gallery:!0,dimensions:!0,categories:!0,brand:!0},pagination:{pageSize:4,page:o}}),[4,i(e.href)];case 1:return[2,r.sent()]}}))}))}function u(){return e(this,void 0,void 0,(function(){var e;return r(this,(function(r){switch(r.label){case 0:return console.log("getCustomerProfile"),n(),(e=new URL("/api/users/me",a)).search=t.stringify({populate:{customer_profile:!0}}),[4,i(e.href)];case 1:return[2,r.sent()]}}))}))}function l(t){return e(this,void 0,void 0,(function(){var e;return r(this,(function(r){switch(r.label){case 0:return console.log("getSingleOrder",t),n(),e=new URL("/api/opos/".concat(t),a),[4,i(e.href)];case 1:return[2,r.sent()]}}))}))}function p(o,c,u,l,p){return e(this,void 0,void 0,(function(){var e,d,f,m,h,v;return r(this,(function(r){switch(r.label){case 0:return n(),[4,s()];case 1:return e=r.sent(),d=null===(v=null===(h=null==e?void 0:e.data)||void 0===h?void 0:h.role)||void 0===v?void 0:v.type,f="enduser"===d,(m=new URL("/api/opos",a)).search=t.stringify({filters:{is_archive:{$in:p}},sort:"".concat(l||"id",":").concat(u||"desc"),populate:{opo_items:{populate:{product:{populate:{price:!0}}}},customer:f,payments:f},pagination:{pageSize:c||10,page:o?o+1:1}}),[4,i(m.href)];case 2:return[2,r.sent()]}}))}))}export{p as getAllOrders,c as getAllProducts,u as getCustomerProfile,l as getSingleOrder};