Files
crater/public/build/assets/Create.71646428.js
Mohit Panjwani 3a1f5a417f new build 506
2021-12-10 17:48:34 +05:30

2 lines
15 KiB
JavaScript

var ee=Object.defineProperty;var q=Object.getOwnPropertySymbols;var te=Object.prototype.hasOwnProperty,ne=Object.prototype.propertyIsEnumerable;var D=(C,t,c)=>t in C?ee(C,t,{enumerable:!0,configurable:!0,writable:!0,value:c}):C[t]=c,j=(C,t)=>{for(var c in t||(t={}))te.call(t,c)&&D(C,c,t[c]);if(q)for(var c of q(t))ne.call(t,c)&&D(C,c,t[c]);return C};import{g as oe,C as le,u as re,i as G,k as h,m as b,n as N,p as P,a2 as se,a3 as ae,a4 as B,q as ie,r as m,o as $,s as S,w as a,t as p,b as o,z as T,v as A,x as _,y as e,A as w,c as E,B as ue}from"./vendor.e9042f2c.js";import{k as de,l as me,m as ce}from"./main.f55cd568.js";import{_ as pe}from"./CreateCustomFields.31e45d63.js";const ge=["onSubmit"],be={class:"flex items-center justify-end"},Ce={class:"grid grid-cols-5 gap-4 mb-8"},_e={class:"col-span-5 text-lg font-semibold text-left lg:col-span-1"},fe={class:"grid grid-cols-5 gap-4 mb-8"},$e={class:"col-span-5 text-lg font-semibold text-left lg:col-span-1"},Ve={class:"space-y-6"},ye={class:"flex items-center justify-start mb-6 md:justify-end md:mb-0"},ve={class:"p-1"},he={key:0,class:"grid grid-cols-5 gap-4 mb-8"},Be={class:"col-span-5 text-lg font-semibold text-left lg:col-span-1"},we={class:"space-y-6"},Me={class:"grid grid-cols-5 gap-2 mb-8"},Ie={key:0,class:"col-span-5 text-lg font-semibold text-left lg:col-span-1"},Ue={class:"col-span-5 lg:col-span-4"},Fe={setup(C){const t=de(),c=me(),M=ce(),k="customFields",{t:g}=oe(),H=le(),R=re();let r=G(!1);const V=G(!1),f=h(()=>R.name==="customers.edit");let J=h(()=>t.isFetchingInitialSettings);const z=h(()=>f.value?g("customers.edit_customer"):g("customers.new_customer")),K=h(()=>({currentCustomer:{name:{required:b.withMessage(g("validation.required"),N),minLength:b.withMessage(g("validation.name_min_length",{count:3}),P(3))},prefix:{minLength:b.withMessage(g("validation.name_min_length",{count:3}),P(3))},currency_id:{required:b.withMessage(g("validation.required"),N)},email:{email:b.withMessage(g("validation.email_incorrect"),se)},website:{url:b.withMessage(g("validation.invalid_url"),ae)},billing:{address_street_1:{maxLength:b.withMessage(g("validation.address_maxlength",{count:255}),B(255))},address_street_2:{maxLength:b.withMessage(g("validation.address_maxlength",{count:255}),B(255))}},shipping:{address_street_1:{maxLength:b.withMessage(g("validation.address_maxlength",{count:255}),B(255))},address_street_2:{maxLength:b.withMessage(g("validation.address_maxlength",{count:255}),B(255))}}}})),i=ie(K,t,{$scope:k});t.resetCurrentCustomer(),t.fetchCustomerInitialSettings(f.value);async function O(){if(i.value.$touch(),i.value.$invalid)return!0;V.value=!0;let s=j({},t.currentCustomer),n=null;try{n=await(f.value?t.updateCustomer:t.addCustomer)(s)}catch{V.value=!1;return}H.push(`/admin/customers/${n.data.data.id}/view`)}return(s,n)=>{const y=m("BaseBreadcrumbItem"),Q=m("BaseBreadcrumb-item"),W=m("BaseBreadcrumb"),F=m("BaseIcon"),L=m("BaseButton"),X=m("BasePageHeader"),d=m("BaseInput"),u=m("BaseInputGroup"),I=m("BaseMultiselect"),U=m("BaseInputGrid"),x=m("BaseDivider"),v=m("BaseTextarea"),Y=m("BaseCard"),Z=m("BasePage");return $(),S(Z,null,{default:a(()=>[p("form",{onSubmit:ue(O,["prevent"])},[o(X,{title:e(z)},{actions:a(()=>[p("div",be,[o(L,{type:"submit",loading:V.value,disabled:V.value},{left:a(l=>[o(F,{name:"SaveIcon",class:T(l.class)},null,8,["class"])]),default:a(()=>[A(" "+_(e(f)?s.$t("customers.update_customer"):s.$t("customers.save_customer")),1)]),_:1},8,["loading","disabled"])])]),default:a(()=>[o(W,null,{default:a(()=>[o(y,{title:s.$t("general.home"),to:"dashboard"},null,8,["title"]),o(y,{title:s.$tc("customers.customer",2),to:"/admin/customers"},null,8,["title"]),o(Q,{title:e(z),to:"#",active:""},null,8,["title"])]),_:1})]),_:1},8,["title"]),o(Y,{class:"mt-5"},{default:a(()=>[p("div",Ce,[p("h6",_e,_(s.$t("customers.basic_info")),1),o(U,{class:"col-span-5 lg:col-span-4"},{default:a(()=>[o(u,{label:s.$t("customers.display_name"),required:"",error:e(i).currentCustomer.name.$error&&e(i).currentCustomer.name.$errors[0].$message,"content-loading":e(r)},{default:a(()=>[o(d,{modelValue:e(t).currentCustomer.name,"onUpdate:modelValue":n[0]||(n[0]=l=>e(t).currentCustomer.name=l),"content-loading":e(r),type:"text",name:"name",class:"",invalid:e(i).currentCustomer.name.$error,onInput:n[1]||(n[1]=l=>e(i).currentCustomer.name.$touch())},null,8,["modelValue","content-loading","invalid"])]),_:1},8,["label","error","content-loading"]),o(u,{label:s.$t("customers.primary_contact_name"),"content-loading":e(r)},{default:a(()=>[o(d,{modelValue:e(t).currentCustomer.contact_name,"onUpdate:modelValue":n[2]||(n[2]=l=>e(t).currentCustomer.contact_name=l),modelModifiers:{trim:!0},"content-loading":e(r),type:"text"},null,8,["modelValue","content-loading"])]),_:1},8,["label","content-loading"]),o(u,{error:e(i).currentCustomer.email.$error&&e(i).currentCustomer.email.$errors[0].$message,"content-loading":e(r),label:s.$t("customers.email")},{default:a(()=>[o(d,{modelValue:e(t).currentCustomer.email,"onUpdate:modelValue":n[3]||(n[3]=l=>e(t).currentCustomer.email=l),modelModifiers:{trim:!0},"content-loading":e(r),type:"text",name:"email",invalid:e(i).currentCustomer.email.$error,onInput:n[4]||(n[4]=l=>e(i).currentCustomer.email.$touch())},null,8,["modelValue","content-loading","invalid"])]),_:1},8,["error","content-loading","label"]),o(u,{label:s.$t("customers.phone"),"content-loading":e(r)},{default:a(()=>[o(d,{modelValue:e(t).currentCustomer.phone,"onUpdate:modelValue":n[5]||(n[5]=l=>e(t).currentCustomer.phone=l),modelModifiers:{trim:!0},"content-loading":e(r),type:"text",name:"phone"},null,8,["modelValue","content-loading"])]),_:1},8,["label","content-loading"]),o(u,{label:s.$t("customers.primary_currency"),"content-loading":e(r),error:e(i).currentCustomer.currency_id.$error&&e(i).currentCustomer.currency_id.$errors[0].$message,required:""},{default:a(()=>[o(I,{modelValue:e(t).currentCustomer.currency_id,"onUpdate:modelValue":n[6]||(n[6]=l=>e(t).currentCustomer.currency_id=l),"value-prop":"id",label:"name","track-by":"name","content-loading":e(r),options:e(M).currencies,searchable:"","can-deselect":!1,placeholder:s.$t("customers.select_currency"),invalid:e(i).currentCustomer.currency_id.$error,class:"w-full"},null,8,["modelValue","content-loading","options","placeholder","invalid"])]),_:1},8,["label","content-loading","error"]),o(u,{error:e(i).currentCustomer.website.$error&&e(i).currentCustomer.website.$errors[0].$message,label:s.$t("customers.website"),"content-loading":e(r)},{default:a(()=>[o(d,{modelValue:e(t).currentCustomer.website,"onUpdate:modelValue":n[7]||(n[7]=l=>e(t).currentCustomer.website=l),"content-loading":e(r),type:"url",onInput:n[8]||(n[8]=l=>e(i).currentCustomer.website.$touch())},null,8,["modelValue","content-loading"])]),_:1},8,["error","label","content-loading"]),o(u,{label:s.$t("customers.prefix"),error:e(i).currentCustomer.prefix.$error&&e(i).currentCustomer.prefix.$errors[0].$message,"content-loading":e(r)},{default:a(()=>[o(d,{modelValue:e(t).currentCustomer.prefix,"onUpdate:modelValue":n[9]||(n[9]=l=>e(t).currentCustomer.prefix=l),"content-loading":e(r),type:"text",name:"name",class:"",invalid:e(i).currentCustomer.prefix.$error,onInput:n[10]||(n[10]=l=>e(i).currentCustomer.prefix.$touch())},null,8,["modelValue","content-loading","invalid"])]),_:1},8,["label","error","content-loading"])]),_:1})]),o(x,{class:"mb-5 md:mb-8"}),p("div",fe,[p("h6",$e,_(s.$t("customers.billing_address")),1),e(t).currentCustomer.billing?($(),S(U,{key:0,class:"col-span-5 lg:col-span-4"},{default:a(()=>[o(u,{label:s.$t("customers.name"),"content-loading":e(r)},{default:a(()=>[o(d,{modelValue:e(t).currentCustomer.billing.name,"onUpdate:modelValue":n[11]||(n[11]=l=>e(t).currentCustomer.billing.name=l),modelModifiers:{trim:!0},"content-loading":e(r),type:"text",class:"w-full",name:"address_name"},null,8,["modelValue","content-loading"])]),_:1},8,["label","content-loading"]),o(u,{label:s.$t("customers.country"),"content-loading":e(r)},{default:a(()=>[o(I,{modelValue:e(t).currentCustomer.billing.country_id,"onUpdate:modelValue":n[12]||(n[12]=l=>e(t).currentCustomer.billing.country_id=l),"value-prop":"id",label:"name","track-by":"name","resolve-on-load":"",searchable:"","content-loading":e(r),options:e(M).countries,placeholder:s.$t("general.select_country"),class:"w-full"},null,8,["modelValue","content-loading","options","placeholder"])]),_:1},8,["label","content-loading"]),o(u,{label:s.$t("customers.state"),"content-loading":e(r)},{default:a(()=>[o(d,{modelValue:e(t).currentCustomer.billing.state,"onUpdate:modelValue":n[13]||(n[13]=l=>e(t).currentCustomer.billing.state=l),"content-loading":e(r),name:"billing.state",type:"text"},null,8,["modelValue","content-loading"])]),_:1},8,["label","content-loading"]),o(u,{"content-loading":e(r),label:s.$t("customers.city")},{default:a(()=>[o(d,{modelValue:e(t).currentCustomer.billing.city,"onUpdate:modelValue":n[14]||(n[14]=l=>e(t).currentCustomer.billing.city=l),"content-loading":e(r),name:"billing.city",type:"text"},null,8,["modelValue","content-loading"])]),_:1},8,["content-loading","label"]),o(u,{label:s.$t("customers.address"),error:e(i).currentCustomer.billing.address_street_1.$error&&e(i).currentCustomer.billing.address_street_1.$errors[0].$message||e(i).currentCustomer.billing.address_street_2.$error&&e(i).currentCustomer.billing.address_street_2.$errors[0].$message,"content-loading":e(r)},{default:a(()=>[o(v,{modelValue:e(t).currentCustomer.billing.address_street_1,"onUpdate:modelValue":n[15]||(n[15]=l=>e(t).currentCustomer.billing.address_street_1=l),modelModifiers:{trim:!0},"content-loading":e(r),placeholder:s.$t("general.street_1"),type:"text",name:"billing_street1","container-class":"mt-3",onInput:n[16]||(n[16]=l=>e(i).currentCustomer.billing.address_street_1.$touch())},null,8,["modelValue","content-loading","placeholder"]),o(v,{modelValue:e(t).currentCustomer.billing.address_street_2,"onUpdate:modelValue":n[17]||(n[17]=l=>e(t).currentCustomer.billing.address_street_2=l),modelModifiers:{trim:!0},"content-loading":e(r),placeholder:s.$t("general.street_2"),type:"text",class:"mt-3",name:"billing_street2","container-class":"mt-3",onInput:n[18]||(n[18]=l=>e(i).currentCustomer.billing.address_street_2.$touch())},null,8,["modelValue","content-loading","placeholder"])]),_:1},8,["label","error","content-loading"]),p("div",Ve,[o(u,{"content-loading":e(r),label:s.$t("customers.phone"),class:"text-left"},{default:a(()=>[o(d,{modelValue:e(t).currentCustomer.billing.phone,"onUpdate:modelValue":n[19]||(n[19]=l=>e(t).currentCustomer.billing.phone=l),modelModifiers:{trim:!0},"content-loading":e(r),type:"text",name:"phone"},null,8,["modelValue","content-loading"])]),_:1},8,["content-loading","label"]),o(u,{label:s.$t("customers.zip_code"),"content-loading":e(r),class:"mt-2 text-left"},{default:a(()=>[o(d,{modelValue:e(t).currentCustomer.billing.zip,"onUpdate:modelValue":n[20]||(n[20]=l=>e(t).currentCustomer.billing.zip=l),modelModifiers:{trim:!0},"content-loading":e(r),type:"text",name:"zip"},null,8,["modelValue","content-loading"])]),_:1},8,["label","content-loading"])])]),_:1})):w("",!0)]),o(x,{class:"mb-5 md:mb-8"}),p("div",ye,[p("div",ve,[o(L,{type:"button","content-loading":e(r),size:"sm",variant:"primary-outline",onClick:n[21]||(n[21]=l=>e(t).copyAddress(!0))},{left:a(l=>[o(F,{name:"DocumentDuplicateIcon",class:T(l.class)},null,8,["class"])]),default:a(()=>[A(" "+_(s.$t("customers.copy_billing_address")),1)]),_:1},8,["content-loading"])])]),e(t).currentCustomer.shipping?($(),E("div",he,[p("h6",Be,_(s.$t("customers.shipping_address")),1),o(U,{class:"col-span-5 lg:col-span-4"},{default:a(()=>[o(u,{"content-loading":e(r),label:s.$t("customers.name")},{default:a(()=>[o(d,{modelValue:e(t).currentCustomer.shipping.name,"onUpdate:modelValue":n[22]||(n[22]=l=>e(t).currentCustomer.shipping.name=l),modelModifiers:{trim:!0},"content-loading":e(r),type:"text",name:"address_name"},null,8,["modelValue","content-loading"])]),_:1},8,["content-loading","label"]),o(u,{label:s.$t("customers.country"),"content-loading":e(r)},{default:a(()=>[o(I,{modelValue:e(t).currentCustomer.shipping.country_id,"onUpdate:modelValue":n[23]||(n[23]=l=>e(t).currentCustomer.shipping.country_id=l),"value-prop":"id",label:"name","track-by":"name","resolve-on-load":"",searchable:"","content-loading":e(r),options:e(M).countries,placeholder:s.$t("general.select_country"),class:"w-full"},null,8,["modelValue","content-loading","options","placeholder"])]),_:1},8,["label","content-loading"]),o(u,{label:s.$t("customers.state"),"content-loading":e(r)},{default:a(()=>[o(d,{modelValue:e(t).currentCustomer.shipping.state,"onUpdate:modelValue":n[24]||(n[24]=l=>e(t).currentCustomer.shipping.state=l),"content-loading":e(r),name:"shipping.state",type:"text"},null,8,["modelValue","content-loading"])]),_:1},8,["label","content-loading"]),o(u,{"content-loading":e(r),label:s.$t("customers.city")},{default:a(()=>[o(d,{modelValue:e(t).currentCustomer.shipping.city,"onUpdate:modelValue":n[25]||(n[25]=l=>e(t).currentCustomer.shipping.city=l),"content-loading":e(r),name:"shipping.city",type:"text"},null,8,["modelValue","content-loading"])]),_:1},8,["content-loading","label"]),o(u,{label:s.$t("customers.address"),"content-loading":e(r),error:e(i).currentCustomer.shipping.address_street_1.$error&&e(i).currentCustomer.shipping.address_street_1.$errors[0].$message||e(i).currentCustomer.shipping.address_street_2.$error&&e(i).currentCustomer.shipping.address_street_2.$errors[0].$message},{default:a(()=>[o(v,{modelValue:e(t).currentCustomer.shipping.address_street_1,"onUpdate:modelValue":n[26]||(n[26]=l=>e(t).currentCustomer.shipping.address_street_1=l),modelModifiers:{trim:!0},"content-loading":e(r),type:"text",placeholder:s.$t("general.street_1"),name:"shipping_street1",onInput:n[27]||(n[27]=l=>e(i).currentCustomer.shipping.address_street_1.$touch())},null,8,["modelValue","content-loading","placeholder"]),o(v,{modelValue:e(t).currentCustomer.shipping.address_street_2,"onUpdate:modelValue":n[28]||(n[28]=l=>e(t).currentCustomer.shipping.address_street_2=l),modelModifiers:{trim:!0},"content-loading":e(r),type:"text",placeholder:s.$t("general.street_2"),name:"shipping_street2",class:"mt-3","container-class":"mt-3",onInput:n[29]||(n[29]=l=>e(i).currentCustomer.shipping.address_street_2.$touch())},null,8,["modelValue","content-loading","placeholder"])]),_:1},8,["label","content-loading","error"]),p("div",we,[o(u,{"content-loading":e(r),label:s.$t("customers.phone"),class:"text-left"},{default:a(()=>[o(d,{modelValue:e(t).currentCustomer.shipping.phone,"onUpdate:modelValue":n[30]||(n[30]=l=>e(t).currentCustomer.shipping.phone=l),modelModifiers:{trim:!0},"content-loading":e(r),type:"text",name:"phone"},null,8,["modelValue","content-loading"])]),_:1},8,["content-loading","label"]),o(u,{label:s.$t("customers.zip_code"),"content-loading":e(r),class:"mt-2 text-left"},{default:a(()=>[o(d,{modelValue:e(t).currentCustomer.shipping.zip,"onUpdate:modelValue":n[31]||(n[31]=l=>e(t).currentCustomer.shipping.zip=l),modelModifiers:{trim:!0},"content-loading":e(r),type:"text",name:"zip"},null,8,["modelValue","content-loading"])]),_:1},8,["label","content-loading"])])]),_:1})])):w("",!0),e(c).customFields.length>0?($(),S(x,{key:1,class:"mb-5 md:mb-8"})):w("",!0),p("div",Me,[e(c).customFields.length>0?($(),E("h6",Ie,_(s.$t("settings.custom_fields.title")),1)):w("",!0),p("div",Ue,[o(pe,{type:"Customer",store:e(t),"store-prop":"currentCustomer","is-edit":e(f),"is-loading":e(J),"custom-field-scope":k},null,8,["store","is-edit","is-loading"])])])]),_:1})],40,ge)]),_:1})}}};export{Fe as default};