import{aT as N,aU as b,j as e}from"./react-vendor-xYZnmIII.js";import{C}from"./combobox-BOClc6J1.js";import{I as n}from"./input-error-_LAmvivg.js";import{L as E}from"./loading-button-D7aXR3K4.js";import{a as S,E as l,L as r,R as p,f as d,F as m,H as u,I as x,C as I}from"./ui-components-CQM92IK3.js";import{c as F}from"./course-durations-B0f021Xm.js";import"./inertia-vendor-cBbDTmhJ.js";import"./ui-vendor-Ds9iwIxa.js";import"./interactive-vendor-B1OgcAgP.js";const B=()=>{const{props:h}=N(),{tab:j,exam:a,translate:g}=h,{input:o}=g,{data:i,setData:c,post:y,errors:t,processing:_}=b({tab:j,pricing_type:a.pricing_type||"paid",price:a.price||"",discount:!!a.discount||!1,discount_price:a.discount_price||"",expiry_type:a.expiry_type||"",expiry_duration:a.expiry_duration||""}),v=s=>{s.preventDefault(),y(route("exams.update",{exam:a.id}))},f=["free","paid"];return e.jsx(S,{className:"container p-4 sm:p-6",children:e.jsxs("form",{onSubmit:v,className:"space-y-4",children:[e.jsxs(l,{collapsible:!0,type:"single",value:i.pricing_type,children:[e.jsxs("div",{children:[e.jsx(r,{children:"Pricing Type *"}),e.jsx(p,{defaultValue:i.pricing_type,className:"flex items-center space-x-4 pt-2 pb-1",onValueChange:s=>c("pricing_type",s),children:f.map(s=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(d,{className:"cursor-pointer",id:s,value:s}),e.jsx(r,{htmlFor:s,className:"cursor-pointer capitalize",children:s})]},s))}),e.jsx(n,{message:t.pricing_type})]}),e.jsx(m,{value:"paid",className:"border-none",children:e.jsxs(u,{className:"space-y-4 p-0.5",children:[e.jsxs("div",{className:"pt-3",children:[e.jsx(r,{children:"Price *"}),e.jsx(x,{type:"number",name:"price",value:i.price.toString(),onChange:s=>c("price",s.target.value),placeholder:"Enter your exam price ($0)"}),e.jsx(n,{message:t.price})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(I,{id:"discount",name:"discount",checked:i.discount,onCheckedChange:s=>{c("discount",s===!0)}}),e.jsx(r,{htmlFor:"discount",className:"cursor-pointer",children:"Exam Discount"})]}),i.discount&&e.jsxs("div",{children:[e.jsx(x,{type:"number",name:"discount_price",value:i.discount_price.toString(),onChange:s=>c("discount_price",s.target.value),placeholder:"Enter discount price"}),e.jsx(n,{message:t.discount_price})]})]})]})})]}),e.jsxs(l,{collapsible:!0,type:"single",value:i.expiry_type,children:[e.jsxs("div",{children:[e.jsx(r,{children:"Expiry period type"}),e.jsx(p,{defaultValue:i.expiry_type,className:"flex items-center space-x-4 pt-2 pb-1",onValueChange:s=>c("expiry_type",s),children:["lifetime","limited_time"].map(s=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(d,{className:"cursor-pointer",id:s,value:s}),e.jsx(r,{htmlFor:s,className:"capitalize",children:s.replace("_"," ")})]},s))}),e.jsx(n,{message:t.expiry_type})]}),e.jsx(m,{value:"limited_time",className:"border-none",children:e.jsx(u,{className:"space-y-4 p-0.5",children:e.jsxs("div",{className:"pt-3",children:[e.jsx(r,{children:o.expiry_duration}),e.jsx(C,{defaultValue:i.expiry_duration,data:F,placeholder:o.expiry_duration_placeholder||"Select duration",onSelect:s=>c("expiry_duration",s.value)}),e.jsx(n,{message:t.expiry_duration})]})})})]}),e.jsx("div",{className:"mt-8",children:e.jsx(E,{loading:_,children:"Save Changes"})})]})})};export{B as default};
