import{jsxs as r,jsx as e}from"react/jsx-runtime";import{A as P}from"./layout-CssQHtfO.js";import{useForm as k,Head as H,router as h}from"@inertiajs/react";import{C as M,b as R,c as j,d as B,a as O}from"./card-Zg0WOx-j.js";import{B as $}from"./button-BvFBRYHq.js";import{T as I,a as L,b as U,c as a,d as q}from"./table-BrXe3s2z.js";import{CalendarDays as z,Plus as G}from"lucide-react";import{A as J,a as K,b as Q,c as V,d as W,e as X,f as Y,g as Z}from"./alert-dialog-xorwy8s8.js";import{useState as d}from"react";import{EventFormDialog as D}from"./EventFormDialog-BtEX-0bn.js";import{EventTableRow as ee}from"./EventTableRow-BjAFkEC1.js";import{EventEmptyState as te}from"./EventEmptyState-Bf0sXq7Z.js";import{EventPagination as re}from"./EventPagination-omfOb3as.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"clsx";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"@radix-ui/react-alert-dialog";import"./dialog-BfGkTFdF.js";import"./EventFormFields-CNf7621s.js";import"./label-DMnntKPk.js";import"@radix-ui/react-label";import"./input-qMvM9qch.js";import"./switch-C-6z1FXy.js";import"@radix-ui/react-switch";import"./MaskSelect-db8-mWU9.js";import"./select-DfhewM4T.js";import"@radix-ui/react-select";import"./TemplateSelect-DfGd1_U3.js";import"./badge-CFi7bqqA.js";import"./progress-DBZY2s3y.js";import"@radix-ui/react-progress";function C(i){const n=k({name:"",type:"registration",milestone:"",min_level:"1",item_id:"",item_name:"",item_count:"1",protect_type:"0",octet:"",mask:"0",is_active:!0});return{form:n,resetForm:()=>{n.reset()},setEventData:o=>{n.setData({name:o.name,type:o.type,milestone:String(o.milestone),min_level:String(o.min_level),item_id:String(o.item_id),item_name:o.item_name,item_count:String(o.item_count),protect_type:String(o.protect_type),octet:o.octet||"",mask:String(o.mask),is_active:o.is_active})}}}function Xe({events:i,currentRegistrationCount:v,masks:n}){const[g,l]=d(!1),[o,c]=d(!1),[E,p]=d(!1),[m,s]=d(null),{form:u,resetForm:S}=C(),{form:f,setEventData:_}=C(),b=t=>new Intl.NumberFormat("id-ID").format(t),w=t=>{t.preventDefault(),u.post("/admin/event",{onSuccess:()=>{l(!1),S()}})},A=t=>{s(t),_(t),c(!0)},y=t=>{t.preventDefault(),m&&f.put(`/admin/event/${m.id}`,{onSuccess:()=>{c(!1),s(null)}})},x=t=>{s(t),p(!0)},F=()=>{m&&h.delete(`/admin/event/${m.id}`,{onSuccess:()=>{p(!1),s(null)}})},N=t=>{h.post(`/admin/event/${t.id}/toggle`)},T=t=>{t<1||t>i.last_page||h.get("/admin/event",{page:t},{preserveState:!0})};return r(P,{children:[e(H,{title:"Event Management"}),r("div",{className:"space-y-6",children:[r("div",{className:"flex flex-col gap-4 md:flex-row md:items-center md:justify-between",children:[r("div",{children:[r("h2",{className:"text-2xl font-bold tracking-tight flex items-center gap-2",children:[e(z,{className:"w-6 h-6 text-primary"}),"Event Management"]}),e("p",{className:"text-muted-foreground",children:"Manage registration milestone events and rewards"})]}),r($,{onClick:()=>l(!0),children:[e(G,{className:"w-4 h-4 mr-2"}),"Create Event"]})]}),r(M,{children:[r(R,{children:[e(j,{children:"All Events"}),r(B,{children:["Showing ",i.from," - ",i.to," of ",i.total," events"]})]}),r(O,{children:[e("div",{className:"rounded-md border overflow-x-auto",children:r(I,{children:[e(L,{children:r(U,{children:[e(a,{children:"Name"}),e(a,{children:"Milestone"}),e(a,{children:"Progress"}),e(a,{children:"Reward"}),e(a,{children:"Claims"}),e(a,{children:"Status"}),e(a,{className:"text-right",children:"Actions"})]})}),e(q,{children:i.data.length>0?i.data.map(t=>e(ee,{event:t,onEdit:A,onDelete:x,onToggle:N,formatNumber:b},t.id)):e(te,{})})]})}),e(re,{pagination:i,onPageChange:T})]})]})]}),e(D,{open:g,onOpenChange:l,mode:"create",form:u,onSubmit:w,masks:n}),e(D,{open:o,onOpenChange:c,mode:"edit",form:f,onSubmit:y,masks:n}),e(J,{open:E,onOpenChange:p,children:r(K,{children:[r(Q,{children:[e(V,{children:"Delete Event"}),r(W,{children:['Are you sure you want to delete "',m?.name,'"? This action cannot be undone.']})]}),r(X,{children:[e(Y,{children:"Cancel"}),e(Z,{onClick:F,className:"bg-destructive text-destructive-foreground",children:"Delete"})]})]})})]})}export{Xe as default};
