import{r as a,a as le,j as e,B as ie,P as ne,T as oe,e as s,J as ce,K as de,S as ue,M as u,g as m,D as me,N as he,k as pe,O as xe,Q as ge,U as ve}from"./index-B1H8BCL7.js";import{M as je}from"./MainCard-gpFMu7s_.js";import{c as fe,a as c,b as be,u as Ne,o as Se}from"./object-B41Nz7nG.js";import{G as r}from"./Grid-CTEl0Elf.js";import"./Card-Dkp4tDNB.js";import"./CardHeader-iZgIgLbQ.js";import"./CardContent-uvNuWwEy.js";import"./_Uint8Array-bhlbxnrZ.js";function Oe(){var y;const M=fe().shape({FirstName:c().required("*firstname is required"),Place:c().required("place is required"),Mobile:be().required(),Email:c().email().required("email is required"),Gender:c().required("gender is required")}),{register:n,control:q,handleSubmit:E,formState:{errors:i}}=Ne({resolver:Se(M)}),[P,F]=a.useState(!1),O=t=>{F(!0),console.log(se())},[h,T]=a.useState(""),[p,G]=a.useState(""),[x,R]=a.useState(""),[g,W]=a.useState(""),[v,I]=a.useState(""),[j,A]=a.useState(""),[f,B]=a.useState(""),[b,L]=a.useState(""),[N,H]=a.useState(""),[S,k]=a.useState(""),[D,Y]=a.useState(""),[o,w]=a.useState(""),J=t=>{T(t.target.value)},$=t=>{G(t.target.value)},K=t=>{R(t.target.value)},Q=t=>{W(t.target.value)},U=t=>{I(t.target.value)},V=t=>{A(t.target.value)},z=t=>{B(t.target.value)},X=t=>{L(t.target.value)},Z=t=>{H(t.target.value)},_=t=>{k(t.target.value)},ee=t=>{Y(t.target.value)},te=le(),ae=()=>{d(!1),te({pathname:"/master/patient-details",search:ve({id:o.id,firstName:o.firstName,gender:o.gender}).toString()})},C=()=>{d(!1)},[re,d]=a.useState(!1),se=()=>{const t={firstName:h,lastName:p,place:x,gender:g,year:v,month:j,day:f,mobile:b,email:N,hospitalName:S,doctorName:D};fetch("http://localhost:8091/patient/add",{method:"POST",headers:new Headers({Accept:"application/json","Content-Type":"application/json"}),body:JSON.stringify(t)}).then(l=>l.json()).then(l=>{l.code==200&&(console.log(l),w(l.patientDetails),console.log(o),d(!0))}).then(l=>{console.log(l)}).catch(l=>{console.error(l),setLoading(!1),setError("Something went wrong, please try again later.")})};return e.jsxs(je,{title:"REGISTER",children:[e.jsx(ie,{sx:{justifyContent:"center",display:"flex"},children:e.jsxs(ne,{id:"print",variant:"outlined",children:[e.jsx(oe,{variant:"h4",gutterBottom:!0,children:"PATIENT REGISTRATION FORM"}),e.jsx("form",{name:"action",children:e.jsxs(r,{container:!0,spacing:2,children:[e.jsx(r,{item:!0,xs:12,sm:6,children:e.jsx(s,{required:!0,label:"First Name",variant:"outlined",placeholder:(y=i.FirstName)==null?void 0:y.message,fullWidth:!0,value:h,...n("FirstName"),error:!!i.FirstName,onChange:J})}),e.jsx(r,{item:!0,xs:12,sm:6,children:e.jsx(s,{label:"Last Name",variant:"outlined",placeholder:"Last Name Optional",fullWidth:!0,value:p,onChange:$})}),e.jsx(r,{item:!0,xs:12,children:e.jsx(s,{required:!0,label:"Place",variant:"outlined",control:q,placeholder:"Enter Patient Place Or Address",fullWidth:!0,value:x,...n("Place"),error:!!i.Place,onChange:K})}),e.jsx(r,{item:!0,xs:12,sm:3,children:e.jsxs(ce,{fullWidth:!0,children:[e.jsx(de,{id:"demo-simple-select-label",children:"Gender"}),e.jsxs(ue,{required:!0,labelId:"demo-simple-select-label",id:"demo-simple-select",label:"Gender",value:g,...n("Gender"),error:!!i.Gender,onChange:Q,children:[e.jsx(u,{value:1,children:"Male"}),e.jsx(u,{value:2,children:"Female"}),e.jsx(u,{value:3,children:"Other"})]})]})}),e.jsx(r,{item:!0,xs:12,sm:3,children:e.jsx(s,{id:"outlined-required",label:"Age",type:"String",placeholder:"Year",value:v,onChange:U})}),e.jsx(r,{item:!0,xs:12,sm:3,children:e.jsx(s,{id:"outlined-required",label:"Month",type:"String",placeholder:"Birth of Month",value:j,onChange:V})}),e.jsx(r,{item:!0,xs:12,sm:3,children:e.jsx(s,{id:"outlined-required",label:"day",type:"String",placeholder:"Birth of days",value:f,onChange:z})}),e.jsx(r,{item:!0,xs:12,sm:6,children:e.jsx(s,{required:!0,label:"Mobile",variant:"outlined",placeholder:"Enter Valid Mobile Number",fullWidth:!0,value:b,...n("Mobile"),error:!!i.Mobile,onChange:X})}),e.jsx(r,{item:!0,xs:12,sm:6,children:e.jsx(s,{label:"Email",placeholder:"Email is Optional",variant:"outlined",fullWidth:!0,value:N,...n("Email"),error:!!i.Email,onChange:Z})}),e.jsx(r,{item:!0,xs:12,children:e.jsx(s,{label:"Hospital Name",variant:"outlined",placeholder:"Hospital Name Optional",fullWidth:!0,value:S,onChange:_})}),e.jsx(r,{item:!0,xs:12,children:e.jsx(s,{label:"Doctor Name",variant:"outlined",placeholder:"Doctor Name Optional",fullWidth:!0,value:D,onChange:ee})}),e.jsx(r,{item:!0,xs:12,children:e.jsx(m,{variant:"contained",color:"primary",onClick:E(O),disabled:P,fullWidth:!0,children:"Submit"})})]})})]})}),e.jsxs(me,{open:re,onClose:C,children:[e.jsx(he,{children:"Register"}),e.jsx(pe,{children:e.jsx(xe,{children:"Patient Registration successfully, Are you Continue.."})}),e.jsxs(ge,{children:[e.jsx(m,{onClick:ae,color:"primary",children:"Yes"}),e.jsx(m,{onClick:C,color:"primary",children:"No"})]})]})]})}export{Oe as default};
