import{An as e,F as t,Ht as n,Lt as r,Nn as i,On as a,Qt as o,Rt as s,_n as c,an as l,bn as u,en as d,jn as f,nn as p,on as m,rn as h,vt as g,wn as _}from"./app-4kCgdoJR.js";import{t as v}from"./AdminLayout-DEe0k-dp.js";var y={class:`px-0 pt-6 pb-0 sm:px-6 sm:py-8 lg:px-8`},b={class:`block w-full sm:flex sm:items-start sm:justify-between lg:block`},x={class:`me-3 mt-6 flex gap-x-8 gap-y-4 sm:mt-0 lg:mt-6`},S=[`href`],C={class:`col-span-full`},w={for:`file-upload`,class:`block font-medium`},T={class:`space-y-1 text-center`},E={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`},O={key:0,class:`font-semibold`},k={key:1,class:`font-semibold`},A={class:`ps-1`},j={class:`text-xs text-gray-600 dark:text-gray-400`},M={class:`mt-2`},N={key:0,class:`inline-block pt-4`},P={class:`rounded-md border px-3 py-1 text-lg font-bold`},F={key:1,class:`mt-4 rounded-md pt-2 text-red-600`},I=Object.assign({layout:v},{__name:`Import`,setup(v){let I=a(null),{t:L}=s({}),R=a(null),z=n({_method:`POST`,excel:null});function B(e){R.value=e.target.files[0].name}function V(){I.value&&(z.excel=I.value.files[0]),z.post(r(`suppliers.import.save`),{preserveScroll:!0})}return(n,a)=>{let s=u(`Head`),v=u(`Link`),H=u(`Icons`);return c(),h(o,null,[m(s,{title:n.$t(`Import {x}`,{x:e(L)(`Suppliers`)})},null,8,[`title`]),d(`div`,y,[m(e(g),{onSubmitted:V},{title:_(()=>[l(i(n.$t(`Import {x}`,{x:e(L)(`Suppliers`)})),1)]),description:_(()=>[d(`div`,b,[d(`div`,null,i(n.$t(`Please upload the excel file to import records.`)),1),d(`div`,x,[m(v,{class:`link`,href:e(r)(`suppliers.index`)},{default:_(()=>[l(i(n.$t(`List {x}`,{x:n.$t(`Suppliers`)})),1)]),_:1},8,[`href`]),e(r)().has(`suppliers.export`)&&n.$can(`export-suppliers`)?(c(),h(`a`,{key:0,class:`link`,href:e(r)(`suppliers.export`,{template:!0})},i(n.$t(`Download {x}`,{x:n.$t(`Template`)})),9,S)):p(``,!0)])])]),form:_(()=>[d(`div`,C,[d(`label`,w,i(n.$t(`Excel File`)),1),d(`div`,{class:f([n.$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`])},[d(`div`,T,[m(H,{name:`doc-text`,className:`mx-auto h-12 w-12 text-gray-400 dark:text-gray-600`}),d(`div`,E,[d(`label`,D,[R.value?(c(),h(`span`,O,i(n.$t(`Change file`)),1)):(c(),h(`span`,k,i(n.$t(`Select file`)),1)),d(`input`,{ref_key:`file`,ref:I,type:`file`,class:`sr-only`,id:`file-upload`,name:`file-upload`,onChange:B,accept:`.xls,.xlsx,application/vnd.ms-excel`},null,544)]),d(`p`,A,i(n.$t(`or drag and drop`)),1)]),d(`div`,j,[d(`div`,null,i(e(L)(`Excel file should have name, phone, email, company, due_limit, lot_no, street, address_line_1, address_line_2, city, postal_code, state and country columns.`)),1),d(`div`,M,i(n.$t(`System will update the supplier if it has the same name, phone and email otherwise new supplier will be added.`)),1)]),R.value?(c(),h(`div`,N,[d(`div`,P,i(n.$t(`Selected File`))+`: `+i(R.value),1)])):p(``,!0),n.$page.props.errors.excel?(c(),h(`div`,F,i(n.$page.props.errors.excel),1)):p(``,!0)])],2)])]),actions:_(()=>[m(e(t),{loading:e(z).processing,disabled:e(z).processing},{default:_(()=>[l(i(n.$t(`Import`)),1)]),_:1},8,[`loading`,`disabled`])]),_:1})])],64)}}});export{I as default};