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