PageSourceSearch

https://brainstox-com.vercel.app/_next/static/chunks/7412.db94ebb3279683cc.js

js brainstox-com.vercel.app collected 2026-10-03 06:21:48 UTC 14,020 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7412],{61368:function(e,a,l){l.r(a);var s=l(85893),r=l(67294),c=l(11177),t=l(91444),i=l(16976),d=l(2022),n=l(94504),o=l(49460),m=l(76606),h=l(18214),p=l(58165),u=l(22120);a.default=()=>{var e;let{data:a,error:l}=(0,i.ZP)("/api/product/create",d.gN),x=(0,r.useRef)(),j=(0,r.useRef)(""),b=(0,r.useRef)(""),[N,v]=(0,r.useState)(""),[g,f]=(0,r.useState)([]),[y,S]=(0,r.useState)([]),[w,C]=(0,r.useState)(""),[k,I]=(0,r.useState)(""),[F,q]=(0,r.useState)(""),[P,_]=(0,r.useState)([]),[V,W]=(0,r.useState)(""),[O,J]=(0,r.useState)(""),[A,D]=(0,r.useState)([]),[E,T]=(0,r.useState)([]),[B,M]=(0,r.useState)([]),[z,R]=(0,r.useState)([]),[G,H]=(0,r.useState)([]),[Q,U]=(0,r.useState)(""),[Z,$]=(0,r.useState)(""),[K,L]=(0,r.useState)(""),{t:X}=(0,u.$G)();(0,r.useEffect)(()=>{let e=[];return P.length&&A.length?P.map(a=>{A.map(l=>{let s={color:a.label,attr:l.label,price:"",sku:"",qty:"",imageIndex:0};e.push(s)})}):P.length&&!A.length?P.map(a=>{let l={color:a.label,attr:null,price:"",sku:"",qty:"",imageIndex:0};e.push(l)}):!P.length&&A.length&&A.map(a=>{let l={color:null,attr:a.label,price:"",sku:"",qty:"",imageIndex:0};e.push(l)}),H(e),()=>{H([])}},[P,A]);let changeAttr=e=>{W(e),D([])},handleInputChange=(e,a)=>{let{name:l,value:s}=e.target,r=[...G];r[a][l]=s,H(r)},getEditorStateData=e=>{let a=e.replace(/(<([^>]+)>)/gi,"").length?e:"";return a},formHandler=async e=>{if(e.preventDefault(),0===E.length||0===B.length)return t.toast.warn("Please fill in all the required fields!");L("loading");let a=document.querySelector("#product_form"),l=new FormData(a),s=JSON.stringify(E),r=JSON.stringify(B),c={title:j.current.value.trim(),description:b.current.value.trim(),image:z};l.append("displayImage",s),l.append("galleryImages",r),l.append("type",N),l.append("category",JSON.stringify([w])),l.append("subcategory",JSON.stringify([k])),l.append("childCategory",JSON.stringify([F])),l.append("color",JSON.stringify(P)),l.append("attribute",JSON.stringify(A)),l.append("selectedAttribute",V),l.append("variant",JSON.stringify(G)),l.append("seo",JSON.stringify(c)),l.append("description",getEditorStateData(Z)),await (0,d.qC)("/api/product/create",l).then(e=>{e.success?(t.toast.success("Product Added Successfully"),a.reset(),C(""),I([]),q([]),H([]),v(""),_([]),W([]),U("reset"),$("")):t.toast.error("Something Went Wrong")}).catch(e=>{console.log(e),t.toast.error("Something Went Wrong")}),L("")};if(l)return(0,s.jsx)("div",{children:"failed to load"});if(!a)return(0,s.jsx)(h.default,{});if(!a.success)return(0,s.jsx)("div",{children:"Something Went Wrong..."});let Y=[];return a.color.map(e=>Y.push({label:e.name,value:e.value})),(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("h4",{className:"text-center pt-3 pb-5",children:X("Create New Product")}),(0,s.jsxs)("form",{id:"product_form",encType:"multipart/form-data",onSubmit:formHandler,children:[(0,s.jsxs)("div",{className:"row",children:[(0,s.jsxs)("div",{className:"col-lg-8",children:[(0,s.jsxs)("div",{className:"card mb-5 border-0 shadow",children:[(0,s.jsx)("div",{className:"card-header bg-white py-3 fw-bold",children:X("Product Type")}),(0,s.jsxs)("div",{className:"card-body",children:[(0,s.jsxs)("div",{className:"row",children:[(0,s.jsx)("div",{className:"col-md-4",children:(0,s.jsxs)("div",{className:"py-3",children:[(0,s.jsx)("label",{htmlFor:"inp-110",className:"form-label",children:X("new_product")}),(0,s.jsxs)("div",{className:"form-check form-switch",children:[(0,s.jsx)("input",{className:"form-check-input",type:"checkbox",id:"inp-110",name:"new_product"}),(0,s.jsx)("label",{className:"form-check-label",htmlFor:"inp-110",children:X("Status")})]})]})}),(0,s.jsx)("div",{className:"col-md-4",children:(0,s.jsxs)("div",{className:"py-3",children:[(0,s.jsx)("label",{htmlFor:"inp-11",className:"form-label",children:X("trending_product")}),(0,s.jsxs)("div",{className:"form-check form-switch",children:[(0,s.jsx)("input",{className:"form-check-input",type:"checkbox",id:"inp-11",name:"trending"}),(0,s.jsx)("label",{className:"form-check-label",htmlFor:"inp-11",children:X("Status")})]})]})}),(0,s.jsx)("div",{className:"col-md-4",children:(0,s.jsxs)("div",{className:"py-3",children:[(0,s.jsx)("label",{htmlFor:"inp-111",className:"form-label",children:X("best_selling_product")}),(0,s.jsxs)("div",{className:"form-check form-switch",children:[(0,s.jsx)("input",{className:"form-check-input",type:"checkbox",id:"inp-111",name:"best_selling"}),(0,s.jsx)("label",{className:"form-check-label",htmlFor:"inp-111",children:X("Status")})]})]})})]}),(0,s.jsx)("div",{className:"col-12",children:(0,s.jsxs)("div",{className:"py-3",children:[(0,s.jsxs)("label",{htmlFor:"inp-type",className:"form-label",children:[X("Product Type"),"*"]}),(0,s.jsxs)("select",{id:"inp-type",ref:x,className:"form-control",required:!0,onChange:()=>v(x.current.value),defaultValue:"",children:[(0,s.jsx)("option",{value:"",disabled:!0,children:X("Select Product Type")}),(0,s.jsx)("option",{value:"simple",children:"Simple Product"}),(0,s.jsx)("option",{value:"variable",children:"Variable Product"})]})]})})]})]}),(0,s.jsxs)("div",{className:"card mb-5 border-0 shadow",children:[(0,s.jsx)("div",{className:"card-header bg-white py-3 fw-bold",children:X("Product Image")}),(0,s.jsxs)("div",{className:"card-body",children:[(0,s.jsx)(n.default,{accept:".jpg,.png,.jpeg",label:X("Display Image"),maxFileSizeInBytes:2e6,updateFilesCb:e=>T(e),resetCb:Q}),(0,s.jsx)(n.default,{accept:".jpg,.png,.jpeg",label:X("Gallery Images"),multiple:!0,maxFileSizeInBytes:2e6,updateFilesCb:e=>M(e),resetCb:Q})]})]}),(0,s.jsxs)("div",{className:"card mb-5 border-0 shadow",children:[(0,s.jsx)("div",{className:"card-header bg-white py-3 fw-bold",children:X("Product Information")}),(0,s.jsx)("div",{className:"card-body",children:(0,s.jsxs)("div",{className:"py-3",children:[(0,s.jsxs)("label",{htmlFor:"inp-1",className:"form-label",children:[X("name"),"*"]}),(0,s.jsx)("input",{type:"text",id:"inp-1",className:"form-control",name:"name",required:!0})]})})]}),(0,s.jsxs)("div",{className:"card mb-5 border-0 shadow",children:[(0,s.jsx)("div",{className:"card-header bg-white py-3 fw-bold",children:X("Product Description")}),(0,s.jsxs)("div",{className:"card-body",children:[(0,s.jsxs)("div",{className:"py-3",children:[(0,s.jsxs)("label",{htmlFor:"inp-7",className:"form-label",children:[X("Short Description"),"*"]}),(0,s.jsx)("textarea",{id:"inp-7",className:"form-control",name:"short_description"})]}),(0,s.jsxs)("div",{className:"py-3",children:[(0,s.jsx)("label",{className:"form-label",children:X("description")}),(0,s.jsx)(o.default,{previousValue:Z,updatedValue:e=>{$(e)},height:300})]})]})]}),(0,s.jsxs)("div",{children:["simple"===N&&(0,s.jsxs)("div",{className:"card mb-5 border-0 shadow",children:[(0,s.jsx)("div",{className:"card-header bg-white py-3 fw-bold",children:X("Product Information")}),(0,s.jsx)("div",{className:"card-body",children:(0,s.jsxs)("div",{className:"row",children:[(0,s.jsx)("div",{className:"col-12",children:(0,s.jsxs)("div",{className:"py-3",children:[(0,s.jsxs)("label",{htmlFor:"inp-6",className:"form-label",children:[X("Item Quantity"),"*(",X("Set -1 to make it unlimited"),")"]}),(0,s.jsx)("input",{type:"number",min:"-1",id:"inp-6",className:"form-control",name:"qty",defaultValue:1,required:!0,onWheel:e=>e.target.blur()})]})}),(0,s.jsx)("div",{className:"col-12",children:(0,s.jsxs)("div",{className:"py-3",children:[(0,s.jsxs)("label",{className:"form-label",children:[X("sku"),"*"]}),(0,s.jsx)("input",{type:"text",className:"form-control",name:"sku",required:!0})]})})]})})]}),"variable"===N&&(0,s.jsxs)("div",{className:"card mb-5 border-0 shadow-sm",children:[(0,s.jsx)("div",{className:"card-header bg-white py-3",children:X("Product Variation")}),(0,s.jsxs)("div",{className:"card-body",children:[(0,s.jsxs)("div",{className:"row py-3",children:[(0,s.jsx)("label",{className:"form-label",children:X("Colors")}),(0,s.jsx)(c.NU,{options:Y,onChange:e=>{_(e)},value:P,labelledBy:"Select Color"})]}),(0,s.jsxs)("div",{className:"py-3",children:[(0,s.jsx)("label",{className:"form-label",children:X("Attributes")}),(0,s.jsxs)("select",{className:"form-control",defaultValue:"",onChange:e=>changeAttr(e.target.value),children:[(0,s.jsx)("option",{value:"",disabled:!0,children:X("Select Attribute")}),a.attribute.map((e,a)=>(0,s.jsx)("option",{value:a,children:e.name},a))]})]}),V.length>0&&(0,s.jsxs)("div",{className:"row py-3",children:[(0,s.jsx)("label",{className:"form-label",children:a.attribute[V].name}),(0,s.jsx)(c.NU,{options:(e=>{let l=[];return a.attribute[e].values.map(s=>l.push({label:s.name,value:s.name,for:a.attribute[e].name})),l})(V),onChange:e=>{D(e)},value:A,labelledBy:"Select Item"})]}),G.length>0&&G.map((e,a)=>(0,s.jsxs)("div",{children:[(0,s.jsx)("hr",{}),(0,s.jsxs)("h6",{children:[X("Variant"),":"," ","".concat(e.color?e.color:""," ").concat(e.color&&e.attr?"+":""," ").concat(e.attr?e.attr:"")]}),(0,s.jsxs)("div",{className:"row",children:[(0,s.jsx)("div",{className:"col-12 col-md-3",children:(0,s.jsxs)("div",{className:"py-3",children:[(0,s.jsxs)("label",{className:"form-label",children:[X("Additional Price"),"*"]}),(0,s.jsx)("input",{type:"number",min:"0",step:"0.01",className:"form-control",name:"price",required:!0,value:e.price||"",onChange:e=>handleInputChange(e,a),onWheel:e=>e.target.blur()}),(0,s.jsx)("div",{className:"small text-primary",children:X("Set 0 to make it free")})]})}),(0,s.jsx)("div",{className:"col-12 col-md-3",children:(0,s.jsxs)("div",{className:"py-3",children:[(0,s.jsxs)("label",{className:"form-label",children:[X("sku"),"*"]}),(0,s.jsx)("input",{type:"text",className:"form-control",name:"sku",required:!0,value:e.sku||"",onChange:e=>handleInputChange(e,a)})]})}),(0,s.jsx)("div",{className:"col-12 col-md-3",children:(0,s.jsxs)("div",{className:"py-3",children:[(0,s.jsxs)("label",{className:"form-label",children:[X("Item Quantity"),"*"]}),(0,s.jsx)("input",{type:"number",min:"-1",className:"form-control",name:"qty",required:!0,value:e.qty||"",onChange:e=>handleInputChange(e,a),onWheel:e=>e.target.blur()}),(0,s.jsx)("div",{className:"small text-primary",children:X("Set -1 to make it unlimited")})]})}),(0,s.jsx)("div",{className:"col-12 col-md-3",children:(0,s.jsx)("div",{className:"py-3",children:(0,s.jsx)(p.Z,{list:B||[],dataChange:handleInputChange,rootIndex:a})})})]})]},a))]})]})]}),(0,s.jsxs)("div",{className:"card mb-5 border-0 shadow",children:[(0,s.jsx)("div",{className:"card-header bg-white py-3 fw-bold",children:X("SEO Meta Tags")}),(0,s.jsxs)("div",{className:"card-body",children:[(0,s.jsxs)("div",{className:"py-3",children:[(0,s.jsx)("label",{htmlFor:"inp-122",className:"form-label",children:X("Meta Title")}),(0,s.jsx)("input",{type:"text",ref:j,id:"inp-122",className:"form-control"})]}),(0,s.jsxs)("div",{className:"py-3",children:[(0,s.jsx)("label",{htmlFor:"inp-222",className:"form-label",children:X("Meta Description")}),(0,s.jsx)("textarea",{ref:b,id:"inp-222",className:"form-control"})]}),(0,s.jsx)(n.default,{accept:".jpg,.png,.jpeg",label:X("Meta Image"),maxFileSizeInBytes:2e6,updateFilesCb:R,resetCb:Q})]})]})]}),(0,s.jsxs)("div",{className:"col-lg-4",children:[(0,s.jsxs)("div",{className:"card mb-5 border-0 shadow",children:[(0,s.jsx)("div",{className:"card-header bg-white py-3 fw-bold",children:X("Price Information")}),(0,s.jsxs)("div",{className:"card-body",children:[(0,s.jsx)("div",{className:"col-12",children:(0,s.jsxs)("div",{className:"py-3",children:[(0,s.jsxs)("label",{htmlFor:"inp-4",className:"form-label",children:[X("Main price"),"*"]}),(0,s.jsx)("input",{type:"text",step:"0.01",id:"inp-4",className:"form-control",name:"main_price",placeholder:"main price",required:!0,onWheel:e=>e.target.blur()})]})}),(0,s.jsx)("div",{className:"col-12",children:(0,s.jsxs)("div",{className:"py-3",children:[(0,s.jsxs)("label",{htmlFor:"inp-5",className:"form-label",children:[X("Sale Price"),"*"]}),(0,s.jsx)("input",{type:"text",step:"0.1",id:"inp-5",placeholder:"sale price",className:"form-control",name:"sale_price",required:!0,onWheel:e=>e.target.blur()})]})})]})]}),(0,s.jsxs)("div",{className:"card mb-5 border-0 shadow",children:[(0,s.jsx)("div",{className:"card-header bg-white py-3 fw-bold",children:X("Product Category")}),(0,s.jsxs)("div",{className:"card-body",children:[(0,s.jsx)("div",{className:"col-12",children:(0,s.jsxs)("div",{className:"py-3",children:[(0,s.jsxs)("label",{className:"form-label",children:[X("categories"),"*"]}),(0,s.jsxs)("select",{className:"form-select",onChange:function(e){C(e.target.value),I(""),q("");let l=a.category.find(a=>a.slug===e.target.value);if(l){let e=[],a=[];
1l.subCategories.forEach(l=>{var s;e.push({name:l.name,slug:l.slug}),null===(s=l.child)||void 0===s||s.forEach(e=>{a.push({name:e.name,slug:e.slug})})}),f(e),S(a)}},defaultValue:"",required:!0,children:[(0,s.jsx)("option",{value:"",children:"Select Category"}),null==a?void 0:null===(e=a.category)||void 0===e?void 0:e.map((e,a)=>(0,s.jsx)("option",{value:e.slug,children:e.name},a))]})]})}),(0,s.jsx)("div",{className:"col-12",children:(0,s.jsxs)("div",{className:"py-3",children:[(0,s.jsxs)("label",{className:"form-label",children:[X("Subcategories"),"*"]}),(0,s.jsxs)("select",{className:"form-select",onChange:e=>I(e.target.value),defaultValue:"",children:[(0,s.jsx)("option",{value:"",children:"Select Sub Category"}),g.map((e,a)=>(0,s.jsx)("option",{value:e.slug,children:e.name},a))]})]})}),(0,s.jsx)("div",{className:"col-12",children:(0,s.jsxs)("div",{className:"py-3",children:[(0,s.jsx)("label",{className:"form-label",children:X("Child Categories")}),(0,s.jsxs)("select",{className:"form-select",onChange:e=>q(e.target.value),defaultValue:"",children:[(0,s.jsx)("option",{value:"",children:"Select Child Category"}),y.map((e,a)=>(0,s.jsx)("option",{value:e.slug,children:e.name},a))]})]})})]})]})]})]}),(0,s.jsx)("div",{className:"my-4",children:(0,s.jsx)(m.default,{type:"submit",text:X("Add Product"),state:K})})]})]})}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.