import{jsxs as r,jsx as e}from"react/jsx-runtime";import{A as b}from"./layout-CssQHtfO.js";import{Head as C,Link as n,router as g}from"@inertiajs/react";import{useState as o}from"react";import{B as a}from"./button-BvFBRYHq.js";import{C as N,b as w,c as L,d as x,a as V}from"./card-Zg0WOx-j.js";import{ArrowLeft as y,Loader2 as D}from"lucide-react";import"clsx";import{VoucherFormFields as I}from"./VoucherFormFields-hsRlnR0-.js";import{u as F}from"./useItemName-E4cepDO_.js";import"./app-sidebar-header-BX2s-HO_.js";import"@radix-ui/react-collapsible";import"./dropdown-menu-BP80qPHw.js";import"@radix-ui/react-dropdown-menu";import"./utils-CMbmcP35.js";import"tailwind-merge";import"./app-logo-icon-beRg1XGs.js";import"./fonts-CqawFh47.js";import"@radix-ui/react-slot";import"class-variance-authority";import"@radix-ui/react-dialog";import"@radix-ui/react-tooltip";import"@radix-ui/react-avatar";import"../app.js";/* empty css     */import"axios";import"sonner";import"react-dom/client";import"./toaster-DuLpwsc2.js";import"./input-qMvM9qch.js";import"./label-DMnntKPk.js";import"@radix-ui/react-label";import"./select-DfhewM4T.js";import"@radix-ui/react-select";import"./checkbox-DXBO59MA.js";import"@radix-ui/react-checkbox";import"./MaskSelect-db8-mWU9.js";import"./TemplateSelect-DfGd1_U3.js";const S=[{title:"Dashboard",href:"/admin"},{title:"Voucher Management",href:"/admin/vouchers"},{title:"Create Voucher",href:"/admin/vouchers/create"}];function fe({masks:c}){const[t,m]=o(!1),[d,s]=o({}),{itemName:l,isLoading:p,fetchItemName:h}=F(),[i,u]=o({item_id:"",count:"1",proctype:"0",octet:"0",duration:"",mask:"0",ip_restricted:!0,usage_limit:"10"});return r(b,{breadcrumbs:S,children:[e(C,{title:"Create Voucher"}),r("div",{className:"space-y-6",children:[r("div",{className:"flex items-center gap-4",children:[e(n,{href:"/admin/vouchers",children:e(a,{variant:"outline",size:"icon",children:e(y,{className:"h-4 w-4"})})}),r("div",{children:[e("h1",{className:"text-2xl font-bold",children:"Create Voucher"}),e("p",{className:"text-muted-foreground",children:"Create a new voucher code. The code will be generated automatically."})]})]}),r(N,{children:[r(w,{children:[e(L,{children:"Voucher Details"}),e(x,{children:"Fill in the details below to create a new voucher"})]}),e(V,{children:r("form",{onSubmit:f=>{f.preventDefault(),m(!0),s({}),g.post(route("admin.vouchers.store"),i,{preserveScroll:!0,onError:v=>{s(v)},onFinish:()=>{m(!1)}})},className:"space-y-6",children:[e(I,{formData:i,setFormData:u,errors:d,masks:c,itemName:l,isLoadingItemName:p,onItemIdBlur:()=>h(i.item_id),showUsageLimit:!0,showDuration:!0,showIpRestricted:!0}),r("div",{className:"flex gap-4",children:[e(n,{href:"/admin/vouchers",children:e(a,{type:"button",variant:"outline",disabled:t,children:"Cancel"})}),r(a,{type:"submit",disabled:t,children:[t&&e(D,{className:"mr-2 h-4 w-4 animate-spin"}),"Create Voucher"]})]})]})})]})]})]})}export{fe as default};
