import{B as $,u as k,r as m,c as a,a as i,g as o,b as t,w as l,d as u,t as s,n as C,o as r,i as f,P as c,F as I,j as g}from"./app-CYVHboi-.js";import{_ as w}from"./FormSection-DWaXENBe.js";import{_ as F}from"./LoadingButton-CH88QwYm.js";import{_ as S}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"},Y={class:"text-xs text-gray-600 dark:text-gray-400"},q={key:0,class:"inline-block pt-4"},A={class:"rounded-md border px-3 py-1 text-lg font-bold"},G={key:1,class:"mt-4 rounded-md pt-2 text-red-600"},oe=Object.assign({layout:S},{__name:"Import",setup(J){const p=g(null),{t:_}=$({}),n=g(null),d=k({_method:"POST",excel:null});function h(e){n.value=e.target.files[0].name}function x(){p.value&&(d.excel=p.value.files[0]),d.post(c("categories.import.save"),{preserveScroll:!0})}return(e,K)=>{const y=m("Head"),v=m("Link"),b=m("Icons");return r(),a(I,null,[i(y,{title:e.$t("Import {x}",{x:o(_)("Categories")})},null,8,["title"]),t("div",j,[i(o(w),{onSubmitted:x},{title:l(()=>[u(s(e.$t("Import {x}",{x:o(_)("Categories")})),1)]),description:l(()=>[t("div",N,[t("div",null,s(e.$t("Please upload the excel file to import records.")),1),t("div",B,[i(v,{class:"link",href:o(c)("categories.index")},{default:l(()=>[u(s(e.$t("List {x}",{x:e.$t("Categories")})),1)]),_:1},8,["href"]),o(c)().has("categories.export")&&e.$can("export-categories")?(r(),a("a",{key:0,class:"link",href:o(c)("categories.export",{template:!0})},s(e.$t("Download {x}",{x:e.$t("Template")})),9,V)):f("",!0)])])]),form:l(()=>[t("div",E,[t("label",L,s(e.$t("Excel File")),1),t("div",{class:C([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"])},[t("div",P,[i(b,{name:"doc-text",className:"mx-auto h-12 w-12 text-gray-400 dark:text-gray-600"}),t("div",T,[t("label",D,[n.value?(r(),a("span",H,s(e.$t("Change file")),1)):(r(),a("span",O,s(e.$t("Select file")),1)),t("input",{ref_key:"file",ref:p,type:"file",class:"sr-only",id:"file-upload",name:"file-upload",onChange:h,accept:".xls,.xlsx,application/vnd.ms-excel"},null,544)]),t("p",z,s(e.$t("or drag and drop")),1)]),t("div",Y,[t("div",null,s(e.$t("Excel file should have name & parent_category columns.")),1),t("div",null,s(e.$t("You must fill the name column."))+" "+s(e.$t("parent_category is the name of the parent category.")),1)]),n.value?(r(),a("div",q,[t("div",A,s(e.$t("Selected File"))+": "+s(n.value),1)])):f("",!0),e.$page.props.errors.excel?(r(),a("div",G,s(e.$page.props.errors.excel),1)):f("",!0)])],2)])]),actions:l(()=>[i(o(F),{loading:o(d).processing,disabled:o(d).processing},{default:l(()=>[u(s(e.$t("Import")),1)]),_:1},8,["loading","disabled"])]),_:1})])],64)}}});export{oe as default};
