1import{r as n,u as w,j as e,H as S,L as D,c as P}from"./app-rigfn0yw.js";import{A as F}from"./AuthenticatedLayout-3LCJg2oC.js";import{P as U}from"./PrimaryButton-CbuENB1H.js";import{I as c}from"./InputError-Cnp0OAW6.js";import{I as o}from"./InputLabel-E0bYR7O3.js";import{T as l}from"./TextInput-D8Vk84At.js";import"./transition-CVfiuB3g.js";import"./ApplicationLogo-Bm3XSjxx.js";import"./toast-BXZozn88.js";import"./clsx-B-dksMZM.js";function K({auth:h,courses:f,coursePackages:y,countries:j}){const[I,d]=n.useState(""),[O,m]=n.useState(""),[g,u]=n.useState(""),[v,q]=n.useState(y),{data:a,setData:s,post:_,processing:p,errors:t,reset:C}=w({course_id:"",course_package_id:"",country_id:"",currency:"",price:"",offer_price:"",status:"1"}),b=r=>{d(r),s("course_id",r),s("course_package_id","")},N=async r=>{m(r),s("country_id",r);try{const i=await P.get(route("course-pricing.country-currency"),{params:{country_id:r}});if(i.data.success){const x=i.data.data;u(x.Currency||"USD"),s("currency",x.Currency||"USD")}}catch(i){console.error("Error fetching country currency:",i),u("USD"),s("currency","USD")}},k=r=>{r.preventDefault(),_(route("course-pricing.store"),{onSuccess:()=>{C(),d(""),m(""),u("")}})};return e.jsxs(F,{user:h.user,header:e.jsx("h2",{className:"font-semibold text-xl text-gray-800 leading-tight",children:"Create Course Pricing"}),children:[e.jsx(S,{title:"Create Course Pricing"}),e.jsx("div",{className:"py-12",children:e.jsx("div",{className:"max-w-2xl mx-auto sm:px-6 lg:px-8",children:e.jsx("div",{className:"bg-white overflow-hidden shadow-sm sm:rounded-lg",children:e.jsx("div",{className:"p-6 text-gray-900",children:e.jsxs("form",{onSubmit:k,className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx(o,{htmlFor:"course_id",value:"Course"}),e.jsxs("select",{id:"course_id",name:"course_id",value:a.course_id,onChange:r=>b(r.target.value),className:"mt-1 block w-full border-gray-300 focus:border-indigo-500 focus:ring-indigo-500 rounded-md shadow-sm",required:!0,children:[e.jsx("option",{value:"",children:"Select a course"}),f.map(r=>e.jsx("option",{value:r.CO_ID,children:r.Name},r.CO_ID))]}),e.jsx(c,{message:t.course_id,className:"mt-2"})]}),e.jsxs("div",{children:[e.jsx(o,{htmlFor:"course_package_id",value:"Course Package"}),e.jsxs("select",{id:"course_package_id",name:"course_package_id",value:a.course_package_id,onChange:r=>s("course_package_id",r.target.value),className:"mt-1 block w-full border-gray-300 focus:border-indigo-500 focus:ring-indigo-500 rounded-md shadow-sm",required:!0,children:[e.jsx("option",{value:"",children:"Select a package"}),v.map(r=>e.jsx("option",{value:r.id,children:r.name},r.id))]}),e.jsx(c,{message:t.course_package_id,className:"mt-2"})]}),e.jsxs("div",{children:[e.jsx(o,{htmlFor:"country_id",value:"Country"}),e.jsxs("select",{id:"country_id",name:"country_id",value:a.country_id,onChange:r=>N(r.target.value),className:"mt-1 block w-full border-gray-300 focus:border-indigo-500 focus:ring-indigo-500 rounded-md shadow-sm",required:!0,children:[e.jsx("option",{value:"",children:"Select a country"}),j.map(r=>e.jsxs("option",{value:r.COU_ID,children:[r.Name," (",r.Two_Code,")"]},r.COU_ID))]}),e.jsx(c,{message:t.country_id,className:"mt-2"})]}),e.jsxs("div",{children:[e.jsx(o,{htmlFor:"currency",value:"Currency"}),e.jsx(l,{id:"currency",type:"text",name:"currency",value:a.currency,onChange:r=>s("currency",r.target.value),className:"mt-1 block w-full",placeholder:"e.g., USD, EUR, INR",required:!0}),e.jsx(c,{message:t.currency,className:"mt-2"}),g&&e.jsxs("p",{className:"mt-1 text-sm text-gray-500",children:["Suggested currency: ",g]})]}),e.jsxs("div",{children:[e.jsx(o,{htmlFor:"price",value:"Price"}),e.jsx(l,{id:"price",type:"number",name:"price",value:a.price,onChange:r=>s("price",r.target.value),className:"mt-1 block w-full",placeholder:"0.00",step:"0.01",min:"0",required:!0}),e.jsx(c,{message:t.price,className:"mt-2"})]}),e.jsxs("div",{children:[e.jsx(o,{htmlFor:"offer_price",value:"Offer Price (Optional)"}),e.jsx(l,{id:"offer_price",type:"number",name:"offer_price",value:a.offer_price,onChange:r=>s("offer_price",r.target.value),className:"mt-1 block w-full",placeholder:"0.00",step:"0.01",min:"0"}),e.jsx(c,{message:t.offer_price,className:"mt-2"}),e.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"If not provided, it will default to the regular price"})]}),e.jsxs("div",{children:[e.jsx(o,{htmlFor:"status",value:"Status"}),e.jsxs("select",{id:"status",name:"status",value:a.status,onChange:r=>s("status",r.target.value),className:"mt-1 block w-full border-gray-300 focus:border-indigo-500 focus:ring-indigo-500 rounded-md shadow-sm",children:[e.jsx("option",{value:"1",children:"Active"}),e.jsx("option",{value:"0",children:"Inactive"})]}),e.jsx(c,{message:t.status,className:"mt-2"})]}),e.jsxs("div",{className:"flex items-center justify-end space-x-4",children:[e.jsx(D,{href:route("course-pricing.index"),className:"inline-flex items-center px-4 py-2 bg-gray-300 border border-transparent roun
1ded-md font-semibold text-xs text-gray-700 uppercase tracking-widest hover:bg-gray-400 focus:bg-gray-400 active:bg-gray-500 focus:outline-none focus:ring-2 focus:ring-gray-500 focus:ring-offset-2 transition ease-in-out duration-150",children:"Cancel"}),e.jsx(U,{disabled:p,children:p?"Creating...":"Create Pricing"})]})]})})})})})]})}export{K as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.