umwd-components 0.1.803 → 0.1.804
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.
- package/dist/cjs/src/components/logistics/note/NoteTakingComponent.js +1 -1
- package/dist/cjs/src/data/actions/logistics/note/createNoteAction.js +1 -1
- package/dist/cjs/tsconfig.build.tsbuildinfo +1 -1
- package/dist/esm/src/components/logistics/note/NoteTakingComponent.js +7 -1
- package/dist/esm/src/data/actions/logistics/note/createNoteAction.js +1 -1
- package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
- package/dist/esm/types/types/logistics/Note.d.ts +1 -0
- package/package.json +1 -1
|
@@ -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"),r=require("react"),t=require("@mui/material/IconButton"),i=require("@mui/material/Dialog"),
|
|
6
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("@mui/material/IconButton"),i=require("@mui/material/Dialog"),o=require("@mui/material/DialogContent"),a=require("@mui/material/DialogActions"),l=require("@mui/material/Button"),n=require("@mui/material/Typography"),s=require("@mui/material/Paper"),c=require("@mui/material/Stack"),u=require("../../../../node_modules/dayjs/dayjs.min.js"),d=require("@mui/icons-material/NoteAlt"),m=require("../../SubmitButton.js"),f=require("../../../data/actions/logistics/note/createNoteAction.js"),x=require("../../common/markdown/MarkdownEditor.js"),h=require("../../../context/common/SnackbarContext.js");const g={zodErrors:null,strapiErrors:null,data:null,message:null,severity:null};exports.default=function({content:j,related:b,revalidateCallback:p}){const[q,y]=r.useState(!1),k=f.createNoteAction.bind(null,b||null),[v,S]=r.useActionState(k,g),{handleAddMessage:A}=h.useSnackbar();return r.useEffect(()=>{v?.strapiErrors&&A({message:v.strapiErrors,severity:v.severity||"error"}),v?.message&&A({message:v.message,severity:v.severity||"error"}),"success"===v?.severity&&(y(!1),p&&p())},[v]),e.jsxs(e.Fragment,{children:[e.jsx(t,{onClick:()=>y(!0),sx:{width:50,height:50,color:"#ffff88"},children:e.jsx(d,{fontSize:"large"})}),e.jsx(i,{open:q,fullWidth:!0,maxWidth:"lg",onClose:()=>y(!1),children:e.jsxs("form",{action:S,children:[e.jsx(o,{sx:{p:1},children:e.jsx(s,{elevation:4,sx:{background:"linear-gradient(135deg, #ffff88 81%,#ffff88 82%,#ffff88 82%,#ffffc6 100%)",color:"black",p:1},children:e.jsxs(c,{spacing:2,children:[e.jsxs(n,{variant:"body1",textAlign:"right",children:["related to:"," ",e.jsx("span",{style:{fontWeight:"bold"},children:b&&b.length>0?b.map(e=>e.id).join(", "):"No Relation Provided"})]}),e.jsxs(n,{variant:"body1",textAlign:"right",children:["date:"," ",e.jsx("span",{style:{fontWeight:"bold"},children:u.default(Date.now()).format("DD-MM-YYYY")})]}),e.jsx(x.default,{name:"content",label:"The note",defaultValue:j,sx:{color:"black",label:{color:"black"},input:{color:"black"},div:{color:"black"}},textfieldProps:{id:"content",placeholder:"Write your note here...",multiline:!0,minRows:5,maxRows:10,error:null!=v?.zodErrors?.content,helperText:v?.zodErrors?.content||""}})]})})}),e.jsxs(a,{children:[e.jsx(l,{onClick:()=>y(!1),children:"Cancel"}),e.jsx(m.SubmitButton,{text:"Submit",loadingText:"Loading..."})]})]})})]})};
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @copyright Jelle Paulus
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
"use strict";var r=require("zod"),e=require("../../../services/mutate-data.js"),t=require("../../../../lib/utils.js");const s=r.z.object({content:r.z.string().min(10,"Description must be at least 10 characters long").max(5e3,"Description cannot be more than 5000 characters long")});exports.createNoteAction=async function(r,o
|
|
7
|
+
"use strict";var r=require("zod"),e=require("../../../services/mutate-data.js"),t=require("../../../../lib/utils.js");const s=r.z.object({content:r.z.string().min(10,"Description must be at least 10 characters long").max(5e3,"Description cannot be more than 5000 characters long")});exports.createNoteAction=async function(r,a,o){if(null==r)return{...a,zodErrors:null,strapiErrors:null,message:"Failed to Create Note. Related entity is missing.",severity:"error"};const n=s.safeParse({content:o.get("content")});if(!n.success)return{...a,zodErrors:n.error.flatten().fieldErrors,strapiErrors:null,message:null,severity:null};const{data:i}=n,l={data:{...i,related:r}};console.log("notedata",l.data.related);const c=await e.mutateData("POST","/api/notes",l);if(console.log("responseData",c),!c)return{...a,zodErrors:null,strapiErrors:null,message:"Ops! Something went wrong. Please try again.",severity:"error"};if(c.error)return{...a,zodErrors:null,strapiErrors:c.error,message:"Failed to Create Note.",severity:"error"};const u=t.flattenAttributes(c);return{...a,zodErrors:null,message:"New Note Created",severity:"success",data:u,strapiErrors:null}};
|