umwd-components 0.1.830 → 0.1.831

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
- "use strict";var e=require("../../../../lib/utils.js"),r=require("../../../../lib/parseFormData.js");exports.contactFormAction=async function(t,s){Object.fromEntries(s);const a=r.parseFormData(s),o=await fetch(`${process.env.NEXT_PUBLIC_STRAPI_URL}/api/leads/createFromContactform`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}).then(e=>e.json());if(console.log("responseData",o),!o)return{...t,severity:"error",strapiErrors:null,message:"Ops! Something went wrong. Please try again."};if(o.error)return{...t,severity:"error",strapiErrors:o.error,message:"Failed to Create Lead."};const n=e.flattenAttributes(o);return{...t,severity:"success",message:"Lead Created Successfully",data:n,strapiErrors:null}};
7
+ "use strict";var e=require("zod"),r=require("../../../../lib/utils.js"),s=require("../../../../lib/parseFormData.js");const t=e.z.object({email:e.z.string().email(),name:e.z.string().min(2).max(100),subject:e.z.string().min(2).max(100),message:e.z.string().min(2).max(1e3)});exports.contactFormAction=async function(e,a){Object.fromEntries(a);const o=s.parseFormData(a);console.log("parsedFormData",o);const i=t.safeParse(o);if(!i.success)return{...e,severity:"error",strapiErrors:i.error.format(),message:"Validation Error. Please check your input."};console.log("validatedFields",i);const{data:n}=i,c=await fetch(`${process.env.NEXT_PUBLIC_STRAPI_URL}/api/leads/createFromContactform`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}).then(e=>e.json());if(console.log("responseData",c),!c)return{...e,severity:"error",strapiErrors:null,message:"Ops! Something went wrong. Please try again."};if(c.error)return{...e,severity:"error",strapiErrors:c.error,message:"Failed to Create Lead."};const l=r.flattenAttributes(c);return{...e,severity:"success",message:"Lead Created Successfully",data:l,strapiErrors:null}};