import{aA as l,aw as E,j as s,az as j,ax as N,G as f,aP as m,o as d,gh as t,aQ as P,g as u,h as r,i as h,cn as w,dv as F}from"./app-BgLa5dit.js";import{F as S}from"./w68yffRy.chunk.js";const v=l.object().shape({name:l.string().trim().max(255,"Name is too long").required("Name is required").default("")}).noUnknown();function L(e){const n=E();return s.jsxs(j,{children:[s.jsx(N,{label:"Name",name:"name",id:"name",value:n.values.name,placeholder:"Enter a name for this person",autoFocus:!0}),s.jsx(S,{isNew:e.isNew})]})}function g(e){return s.jsx(f,{initialValues:e.person,validationSchema:v,onSubmit:e.savePerson,children:s.jsx(L,{isNew:!(e.person&&e.person.id)})})}function O(e){const n=m(),o=d(t.getPerson(e.id)),a=(i,c)=>P(n,t.updatePerson(e.id,i,c));return s.jsx(s.Fragment,{children:!!o.data&&s.jsx(g,{person:o.data,savePerson:a})})}function V(){const e=m(),n=(o,a)=>{const i=c=>{a(),u.trigger({application:h.PEOPLE,action:r.People.EDIT_PERSON,args:[c.id]})};P(e,t.createPerson(o,i,a))};return s.jsx(g,{savePerson:n})}const p=h.PEOPLE,R="/api/domain/v1/search/people/instant/raw",x=e=>({application:p,action:r.People.EDIT_PERSON,args:[e.id]}),b=e=>u.trigger(x(e));function q(e){const n=d(t.getPeople(e.cursor));return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"pb-3 w-50",children:s.jsx(w,{placeholder:"Search for a person",onSuggestionSelected:b,getRemoteUrl:o=>`${R}?q=${o}`,activationLength:2})}),s.jsx(F,{collection:n&&n.data,columns:[{accessor:"name",header:"Name",appLink:x}],collectionAppLink:{application:p,action:r.People.PEOPLE},newObjectAppLink:{application:p,action:r.People.NEW_PERSON},objectName:"Person"})]})}export{O as EditPersonView,V as NewPersonView,q as PeopleView};
//# sourceMappingURL=C4R25YBu.chunk.js.map
