import{j as e,r as m,m as S}from"./app-Ba0W75t8.js";import{c as A,a as o,B as p}from"./createLucideIcon-B8lpabTL.js";import{L as b,I as f}from"./label-FsyLi_rt.js";import{u as M,R as T,m as g}from"./useWindowSize-DiEstpVX.js";import{t as j}from"./index-CZsJ6L7B.js";import"./index-avNvMDmS.js";/**
 * @license lucide-react v0.475.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const K=[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M13 8H7",key:"14i4kc"}],["path",{d:"M17 12H7",key:"16if0g"}]],H=A("MessageSquareText",K);function I({className:t,...s}){return e.jsx("div",{"data-slot":"card",className:o("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",t),...s})}function R({className:t,...s}){return e.jsx("div",{"data-slot":"card-header",className:o("flex flex-col gap-1.5 px-6",t),...s})}function q({className:t,...s}){return e.jsx("div",{"data-slot":"card-title",className:o("leading-none font-semibold",t),...s})}function z({className:t,...s}){return e.jsx("div",{"data-slot":"card-description",className:o("text-muted-foreground text-sm",t),...s})}function E({className:t,...s}){return e.jsx("div",{"data-slot":"card-content",className:o("px-6",t),...s})}function P({questions:t,success:s}){const{width:w,height:N}=M(),[l,c]=m.useState(!1),{data:d,setData:u,post:y,processing:x,errors:r,reset:v}=S({phone_number:"",answers:[]}),_=(a,i)=>{const n=[...d.answers],h=n.findIndex(C=>C.question_id===a);h!==-1?n[h].answer=i:n.push({question_id:a,answer:i}),u("answers",n)},k=a=>{if(a.preventDefault(),d.answers.length<t.length){j.error("Harap isi semua pertanyaan sebelum submit.");return}y("/kuisioner")};return m.useEffect(()=>{s&&(c(!0),j.success(s),v())},[s]),m.useEffect(()=>{if(l){const a=setTimeout(()=>c(!1),5e3);return()=>clearTimeout(a)}},[l]),e.jsxs("div",{className:"flex min-h-screen items-center justify-center bg-gradient-to-br from-indigo-100 to-blue-50 p-4",children:[l&&e.jsx(T,{width:w,height:N,numberOfPieces:200}),e.jsx(g.div,{initial:{opacity:0,y:30},animate:{opacity:1,y:0},transition:{duration:.8},className:"w-full max-w-lg",children:e.jsxs(I,{className:"rounded-3xl border-none bg-white/90 shadow-xl backdrop-blur-md",children:[e.jsxs(R,{className:"space-y-4 text-center",children:[e.jsx("img",{src:"/images/logo_rs.jpeg",alt:"Logo RS",className:"mx-auto h-28 w-28 object-contain"}),e.jsx(q,{className:"text-3xl font-extrabold text-blue-900",children:"🩺 Kuisioner Pelayanan RS"}),e.jsx(z,{className:"text-lg text-gray-500",children:"Kami ingin mendengar pendapat Anda. Jawaban Anda sangat berarti bagi kami dalam meningkatkan kualitas pelayanan."})]}),e.jsx(E,{className:"space-y-6 px-6 py-6",children:e.jsxs("form",{onSubmit:k,className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"phone_number",className:"text-lg font-medium text-gray-700",children:"Nomor WhatsApp"}),e.jsx(f,{id:"phone_number",value:d.phone_number,onChange:a=>u("phone_number",a.target.value),placeholder:"Contoh: 08xxxxxxxxxx",className:`w-full rounded-md p-3 text-base transition duration-300 ease-in-out ${r.phone_number?"border-red-500 ring-2 ring-red-400":"focus:border-blue-500 focus:ring-2 focus:ring-blue-500"}`,required:!0}),r.phone_number&&e.jsx("p",{className:"mt-1 text-sm text-red-500",children:r.phone_number})]}),t.map(a=>{var i;return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(b,{htmlFor:`q-${a.id}`,className:"flex items-center gap-2 text-lg font-medium text-gray-700",children:[e.jsx(H,{className:"h-5 w-5 text-blue-600"}),a.question_text]}),e.jsx(f,{id:`q-${a.id}`,type:"text",placeholder:"Ketik jawaban Anda di sini",value:((i=d.answers.find(n=>n.question_id===a.id))==null?void 0:i.answer)||"",onChange:n=>_(a.id,n.target.value),className:`w-full rounded-md p-3 transition-all ease-in-out focus:border-blue-500 focus:ring-2 focus:ring-blue-500 ${r.answers?"border-red-500 ring-2 ring-red-400":""}`,required:!0})]},a.id)}),r.answers&&e.jsx("p",{className:"mt-1 text-sm text-red-500",children:r.answers}),e.jsx(p,{type:"submit",disabled:x,className:"w-full rounded-md bg-blue-600 py-3 text-base font-semibold text-white transition-all ease-in-out hover:bg-blue-700",children:x?e.jsx("div",{className:"flex items-center justify-center",children:e.jsx("div",{className:"h-5 w-5 animate-spin rounded-full border-4 border-t-4 border-white"})}):"Kirim Jawaban"})]})})]})}),l&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:e.jsxs(g.div,{initial:{scale:.8,opacity:0},animate:{scale:1,opacity:1},transition:{duration:.3},className:"rounded-xl bg-white p-6 text-center shadow-xl",children:[e.jsx("h2",{className:"mb-4 text-2xl font-bold text-green-600",children:"🎉 Terima Kasih!"}),e.jsx("p",{className:"text-gray-700",children:"Jawaban Anda telah berhasil dikirim."}),e.jsx(p,{className:"mt-6 bg-green-600 hover:bg-green-700",onClick:()=>c(!1),children:"Tutup"})]})})]})}export{P as default};
