PageSourceSearch

https://app.breakline.org/assets/ParticipantStatusesView-CbbkNX0E.js

js breakline.org collected 2026-10-02 15:01:28 UTC 9,038 bytes, 4 lines download raw bytes

1import{r as x,j as e}from"./ui-vendor-CkNOhXZb.js";import{aP as se,a2 as v,dy as Z,X as O,L as ae,aT as U,bk as ne,b9 as re,aR as _,a7 as F,cD as le,Q as P,c$ as Q,d0 as ie,gD as ce,aD as oe,a9 as ue,T as X,aa as z,H as de,q as he,D as I,ch as w,fE as D}from"./index-UzHi5cBL.js";import{B as W}from"./ButtonGroup-2WxKFiws.js";import{D as ee}from"./Date-1olpvYHd.js";import{P as xe}from"./PageTitle-BLGRev9a.js";import{G as S}from"./Grid-TuhHA2SN.js";import{M as J}from"./MultiSelect-CYh8E59n.js";import"./react-vendor-BGDO-lAK.js";import"./aws-vendor-CmeB4pcs.js";import"./pdf-gen-vendor-BF0LdSgo.js";const K=re("id","name"),k={status:{},context:"",other:"",greenFlags:[],redFlags:[]},te=[{value:12,label:"Future Founder"},{value:10,label:"Ready"},{value:11,label:"Not Ready"},{value:1,label:"Hired - Partner"},{value:2,label:"Hired - Non-Partner"},{value:3,label:"Hold"},{value:4,label:"CS Sprint"},{value:5,label:"Top 5"},{value:6,label:"Red Flag"},{value:7,label:"Green Flag"},{value:8,label:"Unsubscribed"},{value:9,label:"Exclude"}],pe=(t,a)=>{let i=t==null?void 0:t.context,u=[],p=[];return[6,7].includes(t==null?void 0:t.statusId)&&(i==null?void 0:i.split(", ")).forEac
1h(g=>{var R;const d=(R=a==null?void 0:a.items)==null?void 0:R.find(C=>C.name===g);d?p.push({value:d==null?void 0:d.id,label:d==null?void 0:d.name}):u.push(g)}),{...(t==null?void 0:t.statusId)===6?{redFlags:p}:{greenFlags:p},status:t!=null&&t.statusId?te.find(j=>j.value===(t==null?void 0:t.statusId)):{},context:i||"",other:(u==null?void 0:u.join(", "))||""}},ge=({modalOpen:t,modalData:a,onRequestClose:i})=>{var B,A;const{handleSubmit:u,control:p,register:j,reset:g,watch:d,formState:{isDirty:R,isSubmitting:C,errors:T}}=se({mode:"onTouched",defaultValues:k,shouldUnregister:!1}),n=d("status"),L=x.useMemo(()=>v.getTableParams(1,100),[]),{data:r,isLoading:m}=v.useGet(["/participant-flags",L]),E=x.useMemo(()=>[6,7].includes(n==null?void 0:n.value),[n==null?void 0:n.value]),N=x.useMemo(()=>![6,7].includes(n==null?void 0:n.value),[n==null?void 0:n.value]),f=async l=>{var y,M,$;const c=le(l);n.value===6&&(c.context=(y=l.redFlags)==null?void 0:y.map(h=>h.label).join(", ")),n.value===7&&(c.context=(M=l.greenFlags)==null?void 0:M.map(h=>h.label).join(", ")),l.other&&(c.context+=`, ${l.other}`),delete c.other,delete c.redFlags,delete c.greenFlags,a!=null&&a.status?(delete c.status,await v.patch(`users/${a==null?void 0:a.userId}/statuses/${($=a==null?void 0:a.status)==null?void 0:$.id}`,c).then(()=>{i(!0),P.success("Status updated")}).catch(()=>{i(!1),P.error("Error updating status")})):await v.save(`users/${a==null?void 0:a.userId}/statuses`,c).then(()=>{i(!0),P.success("Status created")}).catch(h=>{i(!1);const{TEAPOT:G,CONFLICT:H}=ie;if(h instanceof Q&&h.details.code===G.code){P.error("Update failed",{description:"To add the Ready or Not Ready status, you must first remove any of the following statuses: Hired - Partner, Hired - Non-Partner, Exclude, Unsubscribed, Ready, Not Ready"});return}if(h instanceof Q&&h.details.code===H.code){P.error(`The status "${l.status.label}" already exists.`,{description:"Please remove it before creating a new one."});return}P.error("An error occurred while updating the status")})};return x.useEffect(()=>{m||a!=null&&a.status&&g({...k,...pe(a.status,r)})},[m,g,a,r]),x.useEffect(()=>{t||g({...k})},[t,a,g]),e.jsxs(Z,{isOpen:t==="statusModal",onRequestClose:()=>{i(!1)},large:!0,children:[e.jsxs(O,{children:[a.status?`Update ${(A=(B=a==null?void 0:a.status)==null?void 0:B.status)==null?void 0:A.type}`:"Add"," Status"]}),e.jsx("form",{onSubmit:u(f),children:e.jsx(S,{formGrid:!0,children:m?e.jsx(ae,{level:"component"}):e.jsxs(e.Fragment,{children:[a.status?null:e.jsx(S.Item,{span:1,children:e.jsx(U,{render:({field:l})=>e.jsx(ne,{...l,options:te,label:"Status",placeholder:"Select Option",errors:T,span:1,required:!0}),name:"status",control:p,rules:{required:"Please select a status"}})}),(n==null?void 0:n.value)===6?e.jsx(S.Item,{span:3,children:e.jsx(U,{render:({field:l})=>{var c;return e.jsx(J,{...l,options:(c=r==null?void 0:r.items)==null?void 0:c.filter(y=>y.type===!0),label:"Red Flags",placeholder:"Select Red Flag(s)",optionFormatter:K,showToggleButton:!0})},control:p,name:"redFlags"})}):null,(n==null?void 0:n.value)===7?e.jsx(S.Item,{span:3,children:e.jsx(U,{render:({field:l})=>{var c;return e.jsx(J,{...l,options:(c=r==null?void 0:r.items)==null?void 0:c.filter(y=>y.type===!1),label:"Green Flags",placeholder:"Select Green Flag(s)",optionFormatter:K,showToggleButton:!0})},control:p,name:"greenFlags"})}):null,N?null:e.jsx(S.Item,{span:4,children:e.jsx(_,{...j("other"),type:"text",label:"Other",placeholder:"Other",errors:T})}),E?null:e.jsx(S.Item,{span:4,children:e.jsx(_,{...j("context"),type:"text",label:"Context",placeholder:"Context",errors:T})}),e.jsxs(S.Item,{span:2,as:W,children:[e.jsxs(F,{type:"submit",disabled:!R||C,children:[a.status?"Update":"Add"," Context"]}),e.jsx(F,{type:"button",onClick:()=>{i()},variant:"outline",children:"Cancel"})]})]})})})]})},Y=he(xe)`
2  margin: 35px 0 10px;
3`,me=[{name:"Date",selector:"row.date",maxWidth:"200px",sort:!1,cell:t=>e.jsx(I,{name:"Date",children:e.jsx(ee,{date:t.createdAt})})},{name:"Description",cell:t=>{var a,i,u;return e.jsx(I,{name:"Description",children:e.jsxs("p",{children:[t!=null&&t.createdBy?`${(a=t==null?void 0:t.createdBy)==null?void 0:a.firstName} ${(i=t==null?void 0:t.createdBy)==null?void 0:i.lastName}`:"System"," has ",t==null?void 0:t.action,"d the status ",e.jsx(w,{value:(u=t.status)==null?void 0:u.type,options:D})," ",t!=null&&t.context&&["create","update"].includes(t.action)?`with the following context: ${t==null?void 0:t.context}`:null]})})}}];function Re(){var V,q;const{userMutate:t}
3=ce(),[a,i]=x.useState(!1),[u,p]=x.useState(1),[j,g]=x.useState(1),[d,R]=x.useState(10),[C,T]=x.useState(10),{participantId:n}=oe(),{modalOpen:L,modalData:r,toggleModal:m}=ue(),E=x.useMemo(()=>v.getTableParams(u,d),[u,d]),N=x.useMemo(()=>v.getTableParams(j,C),[j,C]),{data:f,isLoading:B,mutate:A}=v.useGet([`users/${n}/statuses`,E]),{data:l,isLoading:c,mutate:y}=v.useGet([`users/${n}/statuses/log`,N]),M=(s,o)=>{s==="status"?p(o):s==="log"&&g(o)},$=(s,o)=>{s==="status"?(R(o),p(1)):s==="log"&&(T(o),g(1))},h=s=>{s&&(A(),y(),t&&t()),m()},G=async()=>{var s;await v.delete(`users/${r.userId}/statuses`,{id:(s=r.status)==null?void 0:s.id}).then(()=>{var o,b;P.success(`${(b=(o=r==null?void 0:r.status)==null?void 0:o.status)==null?void 0:b.type} status has been removed`),h(!0)}).catch(()=>{var o,b;P.error(`There was an error removing the ${(b=(o=r==null?void 0:r.status)==null?void 0:o.status)==null?void 0:b.type} status`),h()})},H=[{name:"Name",selector:"row.type",maxWidth:"150px",cell:s=>{var o;return e.jsx(I,{name:"Status",children:e.jsx(w,{value:(o=s.status)==null?void 0:o.type,options:D})})}},{name:"Created By",selector:"row.createdBy",maxWidth:"170px",sort:!1,cell:s=>{var o,b;return e.jsx(I,{name:"Created By",children:s!=null&&s.createdBy?`${(o=s==null?void 0:s.createdBy)==null?void 0:o.firstName} ${(b=s==null?void 0:s.createdBy)==null?void 0:b.lastName}`:"System"})}},{name:"Last Update",selector:"row.date",maxWidth:"200px",sort:!1,cell:s=>e.jsx(I,{name:"Date",children:e.jsx(ee,{date:s.createdAt})})},{name:"Context",selector:"row.context",sort:!1,cell:s=>e.jsx(I,{name:"Date",children:s==null?void 0:s.context})},{name:"Action",selector:"row.action",sort:!1,cell:s=>e.jsx(I,{name:"Action",children:e.jsxs(W,{children:[e.jsx(F,{variant:"ghost",onClick:()=>{m("statusModal",{userId:n,status:s})},children:"Update"}),e.jsx(F,{variant:"ghost-destructive",onClick:()=>{m("removeStatus",{userId:n,status:s})},children:"Remove"})]})})}];return e.jsxs("div",{style:{padding:"15px 0"},children:[e.jsxs(Y,{children:[e.jsx(O,{as:"h2",children:"Active Statuses"}),e.jsx(F,{onClick:()=>{m("statusModal",{userId:n})},children:"Add Status"})]}),e.jsx(X,{columns:H,data:f==null?void 0:f.items,progressPending:B&&!f,pagination:!1,small:!0}),e.jsx(z,{rowCount:f==null?void 0:f.total,currentPage:u,rowsPerPage:d,onChangePage:s=>{M("status",s)},onChangeRowsPerPage:s=>{$("status",s)}}),e.jsx(Y,{children:e.jsx(O,{as:"h2",children:"Status Log"})}),e.jsx(X,{columns:me,data:l==null?void 0:l.items,progressPending:c&&!l,pagination:!1,small:!0}),e.jsx(z,{rowCount:l==null?void 0:l.total,currentPage:j,rowsPerPage:C,onChangePage:s=>{M("log",s)},onChangeRowsPerPage:s=>{$("log",s)}}),e.jsxs(Z,{isOpen:L==="removeStatus",modalData:r,onRequestClose:m,children:[e.jsxs(de,{children:["Remove ",(V=r.status)==null?void 0:V.type," Status"]}),e.jsxs("p",{children:["Are you sure you want to remove the ",e.jsx("strong",{children:(q=r.status)==null?void 0:q.type})," status?"]}),e.jsxs(W,{children:[e.jsx(F,{onClick:async()=>{i(!0),await G(),i(!1)},disabled:a,variant:"destructive",children:"Remove"}),e.jsx(F,{onClick:()=>{m()},variant:"outline",children:"Cancel"})]})]}),e.jsx(ge,{modalData:r,modalOpen:L,onRequestClose:h})]})}export{Re as ParticipantStatusesView};
4//# sourceMappingURL=ParticipantStatusesView-CbbkNX0E.js.map

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.