import{B as k,u as $,r as u,c as l,a as i,g as o,b as s,w as a,d as f,t,n as w,o as r,i as _,P as c,F as C,j as h}from"./app-CYVHboi-.js";import{_ as I}from"./FormSection-DWaXENBe.js";import{_ as S}from"./LoadingButton-CH88QwYm.js";import{_ as F}from"./AdminLayout-dyjRnxvr.js";import"./browser-BwNzv7vE.js";import"./SectionTitle-DAHP_o6O.js";import"./Modal-oUJ1UwGv.js";import"./DropdownLink-DM9xS5m9.js";import"./Loading-C17YK6G3.js";import"./ApplicationLogo-DRGlNRtq.js";const j={class:"px-0 pt-6 pb-0 sm:px-6 sm:py-8 lg:px-8"},N={class:"block w-full sm:flex sm:items-start sm:justify-between lg:block"},B={class:"me-3 mt-6 flex gap-x-8 gap-y-4 sm:mt-0 lg:mt-6"},V=["href"],E={class:"col-span-full"},L={for:"file-upload",class:"block font-medium"},P={class:"space-y-1 text-center"},T={class:"flex items-center justify-center py-2 text-gray-600 dark:text-gray-400"},D={for:"file-upload",class:"link relative cursor-pointer rounded-md font-medium"},H={key:0,class:"font-semibold"},O={key:1,class:"font-semibold"},z={class:"ps-1"},q={class:"text-xs text-gray-600 dark:text-gray-400"},A={class:"mt-2"},G={key:0,class:"inline-block pt-4"},J={class:"rounded-md border px-3 py-1 text-lg font-bold"},K={key:1,class:"mt-4 rounded-md pt-2 text-red-600"},le=Object.assign({layout:F},{__name:"Import",setup(M){const m=h(null),{t:p}=k({}),n=h(null),d=$({_method:"POST",excel:null});function x(e){n.value=e.target.files[0].name}function g(){m.value&&(d.excel=m.value.files[0]),d.post(c("customers.import.save"),{preserveScroll:!0})}return(e,Q)=>{const y=u("Head"),v=u("Link"),b=u("Icons");return r(),l(C,null,[i(y,{title:e.$t("Import {x}",{x:o(p)("Customers")})},null,8,["title"]),s("div",j,[i(o(I),{onSubmitted:g},{title:a(()=>[f(t(e.$t("Import {x}",{x:o(p)("Customers")})),1)]),description:a(()=>[s("div",N,[s("div",null,t(e.$t("Please upload the excel file to import records.")),1),s("div",B,[i(v,{class:"link",href:o(c)("customers.index")},{default:a(()=>[f(t(e.$t("List {x}",{x:e.$t("Customers")})),1)]),_:1},8,["href"]),o(c)().has("customers.export")&&e.$can("export-customers")?(r(),l("a",{key:0,class:"link",href:o(c)("customers.export",{template:!0})},t(e.$t("Download {x}",{x:e.$t("Template")})),9,V)):_("",!0)])])]),form:a(()=>[s("div",E,[s("label",L,t(e.$t("Excel File")),1),s("div",{class:w([e.$page.props.errors.excel?"border-red-500":"border-gray-300 dark:border-gray-700","mt-1 flex justify-center rounded-md border-2 border-dashed px-6 pt-5 pb-6"])},[s("div",P,[i(b,{name:"doc-text",className:"mx-auto h-12 w-12 text-gray-400 dark:text-gray-600"}),s("div",T,[s("label",D,[n.value?(r(),l("span",H,t(e.$t("Change file")),1)):(r(),l("span",O,t(e.$t("Select file")),1)),s("input",{ref_key:"file",ref:m,type:"file",class:"sr-only",id:"file-upload",name:"file-upload",onChange:x,accept:".xls,.xlsx,application/vnd.ms-excel"},null,544)]),s("p",z,t(e.$t("or drag and drop")),1)]),s("div",q,[s("div",null,t(o(p)("Excel file should have name, phone, email, company, due_limit, price_group, customer_group, lot_no, street, address_line_1, address_line_2, city, postal_code, state and country columns.")),1),s("div",A,t(e.$t("System will update the customer if it has the same name, phone and email otherwise new customer will be added.")),1)]),n.value?(r(),l("div",G,[s("div",J,t(e.$t("Selected File"))+": "+t(n.value),1)])):_("",!0),e.$page.props.errors.excel?(r(),l("div",K,t(e.$page.props.errors.excel),1)):_("",!0)])],2)])]),actions:a(()=>[i(o(S),{loading:o(d).processing,disabled:o(d).processing},{default:a(()=>[f(t(e.$t("Import")),1)]),_:1},8,["loading","disabled"])]),_:1})])],64)}}});export{le as default};
