1import{r as e,c as a,j as i}from"./data-fetching-CRKCmDrk.js";import{d as s,e as n}from"./navigation-B8ibLrS5.js";import{u as r}from"./index.esm-DOi2joLp.js";import{a as l,b as t,B as o,c as d,L as c}from"./index-6CbqZNIj.js";import{P as m,a as h,b as j,C as p}from"./popover-D8_rJGLK.js";import{F as x,a as u,b as g,c as f,d as k,e as b,f as v}from"./form-C2aR2khe.js";import{I as y}from"./input-BmMS8WFV.js";import{S as N,a as w,b as C,c as _,d as P}from"./select-D_096TJB.js";import{T as M}from"./textarea-D2d14r_0.js";import{L as S}from"./Layout-TlVjUOtJ.js";import{S as F}from"./SEOHead-CpiKvBVx.js";import{u as T}from"./useMedicalCheckups-kG7OEvm9.js";import{u as q}from"./localization-DcggPMOc.js";import{C as D}from"./calendar-BNAbbVeY.js";import{f as I}from"./utils-BLrKb8E1.js";import"./chevron-right-4wUEQYad.js";import"./chevron-left-BRIkD08l.js";import"./Combination-Bl5OX9An.js";import"./label-Cwx9hCtk.js";import"./index-D67ZmX20.js";import"./index-CTYzN4tX.js";import"./chevron-down-D6nGwXl1.js";import"./check-DX9r9sC-.js";import"./Footer-RRdaOSV4.js";import"./dropdown-menu-CDASvu2B.js";import"./index-Dm9JFfz9.js";import"./globe-EeHrPFev.js";import"./OptimizedImage-Ckuju9s6.js";import"./clock-CjfHyVUj.js";import"./menu-aZzrGEsn.js";import"./stethoscope-Skk-Zl-X.js"; 2/** 3 * @license lucide-react v0.462.0 - ISC 4 * 5 * This source code is licensed under the ISC license. 6 * See the LICENSE file in the root directory of this source tree. 7 */const U=l("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);function B(){const[l]=s(),B=l.get("package"),L=n(),{toast:V}=t(),{t:E,i18n:K}=q(),O="id"===K.language,{data:z,isLoading:A}=T(),[J,R]=e.useState(!1),H=e.useMemo(()=>(null==z?void 0:z.flatMap(e=>e.packages||[]))||[],[z]),W=r({defaultValues:{package_id:B||"",patient_name:"",patient_email:"",patient_phone:"",patient_id_card:"",patient_gender:"",notes:""}});e.useEffect(()=>{B&&H.length>0&&W.getValues("package_id")!==B&&W.setValue("package_id",B)},[B,H,W]);const G=a({mutationFn:async e=>{const a=await fetch("/api/medical-checkup-bookings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,booking_date:I(e.booking_date,"yyyy-MM-dd"),patient_dob:e.patient_dob?I(e.patient_dob,"yyyy-MM-dd"):null})});if(!a.ok){const e=await a.json();throw new Error(e.message||"Failed to create booking")}return await a.json()},onSuccess:()=>{R(!0),window.scrollTo(0,0)},onError:e=>{V({variant:"destructive",title:"Booking Failed",description:e.message})}}),Y=e=>{const a=new Date;return a.setHours(0,0,0,0),e<=a||0===e.getDay()};return J?i.jsx(S,{children:i.jsx("section",{className:"section-padding",children:i.jsxs("div",{className:"container-healthcare max-w-md mx-auto text-center",children:[i.jsx("div",{className:"mb-6 flex justify-center",children:i.jsx("div",{className:"rounded-full bg-green-100 p-4",children:i.jsx(U,{className:"h-12 w-12 text-green-600"})})}),i.jsx("h1",{className:"mb-4 text-3xl font-bold text-foreground",children:O?"Pemesanan Berhasil!":"Booking Confirmed!"}),i.jsx("p",{className:"mb-8 text-muted-foreground",children:O?"Terima kasih telah memesan Medical Check Up. Kami telah menerima permintaan Anda dan akan menghubungi Anda segera untuk konfirmasi.":"Thank you for booking your Medical Check Up. We have received your request and will contact you shortly for confirmation."}),i.jsx(o,{onClick:()=>L("/"),className:"w-full",children:O?"Kembali ke Beranda":"Back to Home"})]})})}):i.jsxs(S,{children:[i.jsx(F,{title:O?"Pesan Medical Check Up":"Book Medical Check Up",description:"Book your medical check up appointment online."}),i.jsx("section",{className:"bg-primary/5 py-12",children:i.jsx("div",{className:"container-healthcare",children:i.jsx("h1",{className:"text-3xl font-bold text-center md:text-4xl",children:O?"Formulir Pendaftaran Medical Check Up":"Medical Check Up Registration Form"})})}),i.jsx("section",{className:"section-padding",children:i.jsx("div",{className:"container-healthcare max-w-2xl",children:i.jsx(x,{...W,children:i.jsxs("form",{onSubmit:W.handleSubmit(e=>{G.mutate(e)}
7),className:"space-y-6 bg-card p-8 rounded-xl border shadow-sm",children:[i.jsx(u,{control:W.control,name:"package_id",rules:{required:O?"Paket wajib dipilih":"Package is required"},render:({field:e})=>i.jsxs(g,{children:[i.jsx(f,{children:O?"Paket Medical Check Up":"Medical Check Up Package"}),i.jsxs(N,{onValueChange:e.onChange,defaultValue:e.value,value:e.value,children:[i.jsx(k,{children:i.jsx(w,{children:i.jsx(C,{placeholder:O?"Pilih paket":"Select a package"})})}),i.jsx(_,{children:A?i.jsx(P,{value:"loading",disabled:!0,children:"Loading..."}):null==z?void 0:z.map(e=>{var a;return i.jsxs("div",{children:[i.jsxs(P,{value:`cat-${e.id}`,disabled:!0,className:"font-bold opacity-100 bg-muted/50",children:["--- ",O&&e.name_id||e.name," ---"]}),null==(a=e.packages)?void 0:a.map(e=>i.jsxs(P,{value:e.id,className:"pl-6",children:[O&&e.name_id||e.name," - ",new Intl.NumberFormat(O?"id-ID":"en-US",{style:"currency",currency:"IDR",maximumFractionDigits:0}).format(Number(e.price))]},e.id))]},e.id)})})]}),i.jsx(b,{})]})}),i.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[i.jsx(u,{control:W.control,name:"patient_name",rules:{required:O?"Nama wajib diisi":"Name is required"},render:({field:e})=>i.jsxs(g,{children:[i.jsx(f,{children:O?"Nama Lengkap":"Full Name"}),i.jsx(k,{children:i.jsx(y,{placeholder:"John Doe",...e})}),i.jsx(b,{})]})}),i.jsx(u,{control:W.control,name:"patient_id_card",rules:{required:O?"KTP/SIM wajib diisi":"ID Card is required"},render:({field:e})=>i.jsxs(g,{children:[i.jsx(f,{children:O?"Nomor Identitas (KTP/SIM)":"ID Card Number"}),i.jsx(k,{children:i.jsx(y,{placeholder:O?"Contoh: 3201234567890001":"e.g. 1234567890",...e})}),i.jsx(b,{})]})})]}),i.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[i.jsx(u,{control:W.control,name:"patient_gender",rules:{required:O?"Jenis kelamin wajib dipilih":"Gender is required"},render:({field:e})=>i.jsxs(g,{children:[i.jsx(f,{children:O?"Jenis Kelamin":"Gender"}),i.jsxs(N,{onValueChange:e.onChange,defaultValue:e.value,children:[i.jsx(k,{children:i.jsx(w,{children:i.jsx(C,{placeholder:O?"Pilih":"Select"})})}),i.jsxs(_,{children:[i.jsx(P,{value:"male",children:O?"Laki-laki":"Male"}),i.jsx(P,{value:"female",children:O?"Perempuan":"Female"})]})]}),i.jsx(b,{})]})}),i.jsx(u,{control:W.control,name:"patient_dob",render:({field:e})=>i.jsxs(g,{children:[i.jsx(f,{children:O?"Tanggal Lahir":"Date of Birth"}),i.jsx(k,{children:i.jsx(y,{type:"date",...e,value:e.value instanceof Date?I(e.value,"yyyy-MM-dd"):e.value||"",onChange:a=>{const i=a.target.value?new Date(a.target.value):void 0;e.onChange(i)}})}),i.jsx(b,{})]})})]}),i.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[i.jsx(u,{control:W.control,name:"patient_phone",rules:{required:O?"Nomor telepon wajib diisi":"Phone number is required"},render:({field:e})=>i.jsxs(g,{children:[i.jsx(f,{children:O?"Nomor Telepon / WhatsApp":"Phone Number / WhatsApp"}),i.jsx(k,{children:i.jsx(y,{type:"tel",placeholder:"08...",...e})}),i.jsx(b,{})]})}),i.jsx(u,{control:W.control,name:"patient_email",render:({field:e})=>i.jsxs(g,{children:[i.jsxs(f,{children:["Email (",O?"Opsional":"Optional",")"]}),i.jsx(k,{children:i.jsx(y,{type:"email",placeholder:"[email protected]",...e})}),i.jsx(b,{})]})})]}),i.jsx("div",{children:i.jsx(u,{control:W.control,name:"booking_date",rules:{required:O?"Tanggal wajib dipilih":"Date is required"},render:({field:e})=>i.jsxs(g,{children:[i.jsx(f,{children:O?"Tanggal Rencana Check Up":"Preferred Date"}),i.jsxs(m,{children:[i.jsx(h,{asChild:!0,children:i.jsx(k,{children:i.jsxs(o,{variant:"outline",className:d("w-full justify-start text-left font-normal",!e.value&&"text-muted-foreground"),children:[i.jsx(D,{className:"mr-2 h-4 w-4"}),e.value?I(e.value,"PPP"):i.jsx("span",{children:O?"Pilih tanggal":"Pick a date"})]})})}),i.jsx(j,{className:"w-auto p-0",align:"start",children:i.jsx(p,{mode:"single",selected:e.value,onSelect:e.onChange,disabled:Y,initialFocus:!0})})]}),i.jsx(v,{children:O?"Senin - Sabtu. Mulai besok (tidak bisa hari ini) dan tidak termasuk hari libur.":"Mon - Sat. From tomorrow onwards (cannot book today) and public holidays excluded."}),i.jsx(b,{})]})})}),i.jsx(u,{control:W.control,name:"notes",render:({field:e})=>i.jsxs(g,{children:[i.jsx(f,{children:O?"Catatan Tambahan":"Additional Notes"}),i.jsx(k,{children:i.jsx(M,{placeholder:"",...e})}),i.jsx(b,{})]})}),i.jsxs(o,{type:"submit",className:"w-full",size:"lg",disabled:G.isPending,children:[G.isPending&&i.jsx(c,{className:"mr-2 h-4 w-4 animate-spin"}),O?"Kirim Pendaftaran":"Submit Registration"]})]})})})})]})}export{B 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.