import { t as B } from "./index.esm-0G7eAEV5.js";
import { A as _sfc_main$2, dt as _sfc_main$1 } from "../ssr.js";
import { t as _sfc_main$3 } from "./AdminLayout-eZgRfDMK.js";
import { useForm } from "@inertiajs/vue3";
import { createBlock, createCommentVNode, createTextVNode, createVNode, openBlock, ref, resolveComponent, toDisplayString, unref, useSSRContext, withCtx } from "vue";
import { useI18n } from "vue-i18n";
import { ssrInterpolate, ssrRenderAttr, ssrRenderClass, ssrRenderComponent } from "vue/server-renderer";
//#region resources/js/Pages/Sma/People/Customer/Import.vue
var _sfc_main = /* @__PURE__ */ Object.assign({ layout: _sfc_main$3 }, {
	__name: "Import",
	__ssrInlineRender: true,
	setup(__props) {
		const file = ref(null);
		const { t } = useI18n({});
		const selected = ref(null);
		const form = useForm({
			_method: "POST",
			excel: null
		});
		function updateFile(e) {
			selected.value = e.target.files[0].name;
		}
		function submit() {
			if (file.value) form.excel = file.value.files[0];
			form.post(B("customers.import.save"), { preserveScroll: true });
		}
		return (_ctx, _push, _parent, _attrs) => {
			const _component_Head = resolveComponent("Head");
			const _component_Link = resolveComponent("Link");
			const _component_Icons = resolveComponent("Icons");
			_push(`<!--[-->`);
			_push(ssrRenderComponent(_component_Head, { title: _ctx.$t("Import {x}", { x: unref(t)("Customers") }) }, null, _parent));
			_push(`<div class="px-0 pt-6 pb-0 sm:px-6 sm:py-8 lg:px-8">`);
			_push(ssrRenderComponent(unref(_sfc_main$1), { onSubmitted: submit }, {
				title: withCtx((_, _push, _parent, _scopeId) => {
					if (_push) _push(`${ssrInterpolate(_ctx.$t("Import {x}", { x: unref(t)("Customers") }))}`);
					else return [createTextVNode(toDisplayString(_ctx.$t("Import {x}", { x: unref(t)("Customers") })), 1)];
				}),
				description: withCtx((_, _push, _parent, _scopeId) => {
					if (_push) {
						_push(`<div class="block w-full sm:flex sm:items-start sm:justify-between lg:block"${_scopeId}><div${_scopeId}>${ssrInterpolate(_ctx.$t("Please upload the excel file to import records."))}</div><div class="me-3 mt-6 flex gap-x-8 gap-y-4 sm:mt-0 lg:mt-6"${_scopeId}>`);
						_push(ssrRenderComponent(_component_Link, {
							class: "link",
							href: unref(B)("customers.index")
						}, {
							default: withCtx((_, _push, _parent, _scopeId) => {
								if (_push) _push(`${ssrInterpolate(_ctx.$t("List {x}", { x: _ctx.$t("Customers") }))}`);
								else return [createTextVNode(toDisplayString(_ctx.$t("List {x}", { x: _ctx.$t("Customers") })), 1)];
							}),
							_: 1
						}, _parent, _scopeId));
						if (unref(B)().has("customers.export") && _ctx.$can("export-customers")) _push(`<a class="link"${ssrRenderAttr("href", unref(B)("customers.export", { template: true }))}${_scopeId}>${ssrInterpolate(_ctx.$t("Download {x}", { x: _ctx.$t("Template") }))}</a>`);
						else _push(`<!---->`);
						_push(`</div></div>`);
					} else return [createVNode("div", { class: "block w-full sm:flex sm:items-start sm:justify-between lg:block" }, [createVNode("div", null, toDisplayString(_ctx.$t("Please upload the excel file to import records.")), 1), createVNode("div", { class: "me-3 mt-6 flex gap-x-8 gap-y-4 sm:mt-0 lg:mt-6" }, [createVNode(_component_Link, {
						class: "link",
						href: unref(B)("customers.index")
					}, {
						default: withCtx(() => [createTextVNode(toDisplayString(_ctx.$t("List {x}", { x: _ctx.$t("Customers") })), 1)]),
						_: 1
					}, 8, ["href"]), unref(B)().has("customers.export") && _ctx.$can("export-customers") ? (openBlock(), createBlock("a", {
						key: 0,
						class: "link",
						href: unref(B)("customers.export", { template: true })
					}, toDisplayString(_ctx.$t("Download {x}", { x: _ctx.$t("Template") })), 9, ["href"])) : createCommentVNode("", true)])])];
				}),
				form: withCtx((_, _push, _parent, _scopeId) => {
					if (_push) {
						_push(`<div class="col-span-full"${_scopeId}><label for="file-upload" class="block font-medium"${_scopeId}>${ssrInterpolate(_ctx.$t("Excel File"))}</label><div class="${ssrRenderClass([_ctx.$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"])}"${_scopeId}><div class="space-y-1 text-center"${_scopeId}>`);
						_push(ssrRenderComponent(_component_Icons, {
							name: "doc-text",
							className: "mx-auto h-12 w-12 text-gray-400 dark:text-gray-600"
						}, null, _parent, _scopeId));
						_push(`<div class="flex items-center justify-center py-2 text-gray-600 dark:text-gray-400"${_scopeId}><label for="file-upload" class="link relative cursor-pointer rounded-md font-medium"${_scopeId}>`);
						if (selected.value) _push(`<span class="font-semibold"${_scopeId}>${ssrInterpolate(_ctx.$t("Change file"))}</span>`);
						else _push(`<span class="font-semibold"${_scopeId}>${ssrInterpolate(_ctx.$t("Select file"))}</span>`);
						_push(`<input type="file" class="sr-only" id="file-upload" name="file-upload" accept=".xls,.xlsx,application/vnd.ms-excel"${_scopeId}></label><p class="ps-1"${_scopeId}>${ssrInterpolate(_ctx.$t("or drag and drop"))}</p></div><div class="text-xs text-gray-600 dark:text-gray-400"${_scopeId}><div${_scopeId}>${ssrInterpolate(unref(t)("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."))}</div><div class="mt-2"${_scopeId}>${ssrInterpolate(_ctx.$t("System will update the customer if it has the same name, phone and email otherwise new customer will be added."))}</div></div>`);
						if (selected.value) _push(`<div class="inline-block pt-4"${_scopeId}><div class="rounded-md border px-3 py-1 text-lg font-bold"${_scopeId}>${ssrInterpolate(_ctx.$t("Selected File"))}: ${ssrInterpolate(selected.value)}</div></div>`);
						else _push(`<!---->`);
						if (_ctx.$page.props.errors.excel) _push(`<div class="mt-4 rounded-md pt-2 text-red-600"${_scopeId}>${ssrInterpolate(_ctx.$page.props.errors.excel)}</div>`);
						else _push(`<!---->`);
						_push(`</div></div></div>`);
					} else return [createVNode("div", { class: "col-span-full" }, [createVNode("label", {
						for: "file-upload",
						class: "block font-medium"
					}, toDisplayString(_ctx.$t("Excel File")), 1), createVNode("div", { class: [_ctx.$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"] }, [createVNode("div", { class: "space-y-1 text-center" }, [
						createVNode(_component_Icons, {
							name: "doc-text",
							className: "mx-auto h-12 w-12 text-gray-400 dark:text-gray-600"
						}),
						createVNode("div", { class: "flex items-center justify-center py-2 text-gray-600 dark:text-gray-400" }, [createVNode("label", {
							for: "file-upload",
							class: "link relative cursor-pointer rounded-md font-medium"
						}, [selected.value ? (openBlock(), createBlock("span", {
							key: 0,
							class: "font-semibold"
						}, toDisplayString(_ctx.$t("Change file")), 1)) : (openBlock(), createBlock("span", {
							key: 1,
							class: "font-semibold"
						}, toDisplayString(_ctx.$t("Select file")), 1)), createVNode("input", {
							ref_key: "file",
							ref: file,
							type: "file",
							class: "sr-only",
							id: "file-upload",
							name: "file-upload",
							onChange: updateFile,
							accept: ".xls,.xlsx,application/vnd.ms-excel"
						}, null, 544)]), createVNode("p", { class: "ps-1" }, toDisplayString(_ctx.$t("or drag and drop")), 1)]),
						createVNode("div", { class: "text-xs text-gray-600 dark:text-gray-400" }, [createVNode("div", null, toDisplayString(unref(t)("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), createVNode("div", { class: "mt-2" }, toDisplayString(_ctx.$t("System will update the customer if it has the same name, phone and email otherwise new customer will be added.")), 1)]),
						selected.value ? (openBlock(), createBlock("div", {
							key: 0,
							class: "inline-block pt-4"
						}, [createVNode("div", { class: "rounded-md border px-3 py-1 text-lg font-bold" }, toDisplayString(_ctx.$t("Selected File")) + ": " + toDisplayString(selected.value), 1)])) : createCommentVNode("", true),
						_ctx.$page.props.errors.excel ? (openBlock(), createBlock("div", {
							key: 1,
							class: "mt-4 rounded-md pt-2 text-red-600"
						}, toDisplayString(_ctx.$page.props.errors.excel), 1)) : createCommentVNode("", true)
					])], 2)])];
				}),
				actions: withCtx((_, _push, _parent, _scopeId) => {
					if (_push) _push(ssrRenderComponent(unref(_sfc_main$2), {
						loading: unref(form).processing,
						disabled: unref(form).processing
					}, {
						default: withCtx((_, _push, _parent, _scopeId) => {
							if (_push) _push(`${ssrInterpolate(_ctx.$t("Import"))}`);
							else return [createTextVNode(toDisplayString(_ctx.$t("Import")), 1)];
						}),
						_: 1
					}, _parent, _scopeId));
					else return [createVNode(unref(_sfc_main$2), {
						loading: unref(form).processing,
						disabled: unref(form).processing
					}, {
						default: withCtx(() => [createTextVNode(toDisplayString(_ctx.$t("Import")), 1)]),
						_: 1
					}, 8, ["loading", "disabled"])];
				}),
				_: 1
			}, _parent));
			_push(`</div><!--]-->`);
		};
	}
});
var _sfc_setup = _sfc_main.setup;
_sfc_main.setup = (props, ctx) => {
	const ssrContext = useSSRContext();
	(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("resources/js/Pages/Sma/People/Customer/Import.vue");
	return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
};
//#endregion
export { _sfc_main as default };
