1import{j as s,r as p,R as b}from"./index-ClpuwTcw.js";import{D as f}from"./types-CTAfpEhF.js";import{D as P}from"./dropdown-as-select-BT-4ojL8.js";import{d as C}from"./deepClone-0NmcocxP.js";import{L as O}from"./fa-spinner-DQ2wk8ds.js";const R=e=>{const l=()=>e.imageUrl?s.jsx("img",{src:e.imageUrl,alt:e.fullName}):"";return s.jsxs("article",{className:"fa-employees__card",children:[s.jsx("div",{className:"fa-employees__card-image",children:l()}),s.jsxs("div",{className:"fa-employees__card-content-container",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"fa-employees__card-title fa-theme-color",children:e.fullName}),s.jsx("p",{className:"fa-employees__card-job-title",children:e.jobTitle})]}),s.jsxs("div",{children:[s.jsxs("p",{className:"fa-employees__card-text",children:[s.jsx("span",{children:"Phone:"}),s.jsxs("a",{className:"fa-employees__link",href:`tel:${e.phone}`,children:[" ",e.phone]})]}),s.jsxs("p",{className:"fa-employees__card-text",children:[s.jsx("span",{children:"Email:"}),s.jsxs("a",{className:"fa-employees__link",href:`mailto:${e.email}`,children:[" ",e.email]})]})]})]})]})};function G(e){return Object.keys(e).map(l=>`${l.charAt(0).toUpperCase()+l.slice(1)}=${e[l]}`).join("&")}const D=e=>{const l={staffContacts:e.staffContacts.map(t=>({fullName:t.fullName,imageUrl:t.imageUrl,jobTitle:t.jobTitle,phone:t.phone,email:t.email})),facets:e.facets.map(t=>({key:t.key,name:t.name,values:t.values.map(m=>({key:m.key,count:m.count,name:m.name,available:!0}))})),usedFilters:{BlockContentGuid:e.usedFilters.blockContentGuid??"",PageContentGuid:e.usedFilters.pageContentGuid??"",BusinessUnits:e.usedFilters.businessUnits?e.usedFilters.businessUnits[0]??null:null,Locations:e.usedFilters.locations?e.usedFilters.locations[0]??null:null,Offices:e.usedFilters.offices?e.usedFilters.offices[0]??null:null,Professions:e.usedFilters.professions?e.usedFilters.professions[0]??null:null}};return l.facets.map(t=>t.values.unshift({key:"",count:1,name:t.name,available:!0})),l},U=(e,l)=>{const{type:t,payload:m}=l;switch(t){case f.SET_NEW_EMPLOYEE_DATA:return{...e,...m};case f.SET_NEW_ORIGINAL_EMPLOYEE_DATA:return{...e,originalEmployeeFacets:m};default:throw new Error}},Y=e=>{const{pageContentGuid:l,blockContentGuid:t,heading:m}=e,[o,y]=p.useReducer(U,void 0),[N,j]=p.useState(!1),[_,v]=p.useState({pageContentGuid:l,blockContentGuid:t}),[g,k]=p.useState(!1);p.useEffect(()=>{x().then(n=>{y({type:f.SET_NEW_EMPLOYEE_DATA,payload:n}),y({type:f.SET_NEW_ORIGINAL_EMPLOYEE_DATA,payload:n.facets})}),k(!0)},[]),p.useEffect(()=>{x().then(n=>{y({type:f.SET_NEW_EMPLOYEE_DATA,payload:n}),g&&A(n)})},[_]);const A=n=>{var r;const i=(r=o.originalEmployeeFacets)==null?void 0:r.map((c,d)=>{const u=n.facets[d],h=c==null?void 0:c.values.map(E=>(u.values.find(S=>S.name==E.name)===void 0?E.available=!1:E.available=!0,E));return c.values=h,{...c,values:c.values}});y({type:f.SET_NEW_ORIGINAL_EMPLOYEE_DATA,payload:i})},x=async()=>{j(!0);let n,a="/[language]/api/staff/search?";const i=document.documentElement.lang;a=`${a==null?void 0:a.replace("[language]",i)}${G(_)}`;try{const r=await fetch(a);if(!r.ok)throw new Error(r.statusText);j(!1),n=await r.json()}catch(r){console.log(r)}return D(n)},F=async(n,a,i)=>{var c;const r=C(_);(c=o.originalEmployeeFacets)==null||c.forEach(d=>{a===d.key&&(r[`${d.key.toLocaleLowerCase()}`]=i,v(u=>({...u,...r})))})},T=()=>{var n;return(n=o==null?void 0:o.staffContacts)==null?void 0:n.map((a,i)=>s.jsx(R,{...a},i))},L=()=>{var n;return(n=o==null?void 0:o.originalEmployeeFacets)==null?void 0:n.map((a,i)=>{var u;const c=(o==null?void 0:o.usedFilters)[a.key],d=(u=a.values.find(h=>h.key===c))==null?void 0:u.name;return s.jsx(P,{currentSelectedValue:d,dropdownType:a.key,items:a.values,defaultSelectedPropName:a.name,callback:F},i)})};return s.jsxs("section",{className:"fa-employees",children:[s.jsx("h2",{className:"fa-employees__title fa-theme-color",children:m}),N?s.jsx("article",{className:"fa-spinner__container",children:s.jsx(O,{})}):s.jsxs(b.Fragment,{children:[s.jsx("div",{className:"fa-employees__filter",children:L()}),s.jsx("div",{className:"fa-employees__cards",children:T()})]})]})};export{Y as Employees}; 2//# sourceMappingURL=fa-employees-ocFtrS9B.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.