(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,18566,(e,t,n)=>{t.exports=e.r(76562)},43188,e=>{"use strict";var t=e.i(43476),n=e.i(71645),s=e.i(18566);e.s(["default",0,function({trahId:e}){let r=(0,s.useRouter)(),[a,l]=(0,n.useState)(""),[i,o]=(0,n.useState)("UNKNOWN"),[d,u]=(0,n.useState)("UNKNOWN"),[h,c]=(0,n.useState)(null),[p,j]=(0,n.useState)(!1);async function x(t){t.preventDefault(),c(null),j(!0);try{let t=await fetch(`/api/trahs/${e}/persons`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({displayName:a,gender:i,lifeStatus:d})}),n=await t.json().catch(()=>null);if(t.ok&&n?.personId)return void r.push(`/trahs/${e}/persons/${n.personId}/edit`);n?.error==="INVALID_INPUT"?c("Please enter a name."):n?.error==="FORBIDDEN"?c("You don't have permission to add a person to this Trah."):c("Something went wrong. Please try again.")}catch{c("Something went wrong. Please try again.")}finally{j(!1)}}return(0,t.jsxs)("form",{onSubmit:x,children:[h&&(0,t.jsx)("p",{role:"alert",style:{color:"crimson"},children:h}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{htmlFor:"displayName",children:"Name"}),(0,t.jsx)("br",{}),(0,t.jsx)("input",{id:"displayName",type:"text",value:a,onChange:e=>l(e.target.value),required:!0})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{htmlFor:"gender",children:"Gender"}),(0,t.jsx)("br",{}),(0,t.jsxs)("select",{id:"gender",value:i,onChange:e=>o(e.target.value),children:[(0,t.jsx)("option",{value:"UNKNOWN",children:"Unknown"}),(0,t.jsx)("option",{value:"MALE",children:"Male"}),(0,t.jsx)("option",{value:"FEMALE",children:"Female"})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{htmlFor:"lifeStatus",children:"Life status"}),(0,t.jsx)("br",{}),(0,t.jsxs)("select",{id:"lifeStatus",value:d,onChange:e=>u(e.target.value),children:[(0,t.jsx)("option",{value:"UNKNOWN",children:"Unknown"}),(0,t.jsx)("option",{value:"ALIVE",children:"Alive"}),(0,t.jsx)("option",{value:"DECEASED",children:"Deceased"})]})]}),(0,t.jsx)("button",{type:"submit",disabled:p,children:p?"Saving…":"Add person"})]})}])}]);