1(function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{};e.SENTRY_RELEASE={id:`614cbdfe72fe6b8bfd380ef709c9090931b06028`};var t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`5ac9c127-9603-4a70-a8f3-be4e49b0de29`,e._sentryDebugIdIdentifier=`sentry-dbid-5ac9c127-9603-4a70-a8f3-be4e49b0de29`)}catch{}})();import{o as e}from"./rolldown-runtime-CUEP_bMB.js";import{t}from"./_contacts2-Dv7_ARcu.js";import{i as n}from"./_contracts-D51afho_.js";import{t as r}from"./Log-CUOXzJ2K.js";import{Or as i,kr as a}from"./_assets-BXYq3ErI.js";import{$n as o,A as s,Bn as c,G as l,X as u,at as d,lr as f,or as p,t as m,wr as h}from"./_hawky_core-Ob8DUexl.js";import{T as g}from"./_react--meeYkmF.js";import{ES as _,Gn as v,Jn as y,Kn as b,qn as x,tC as S}from"./navigation-CfeAx0HE.js";import{G as C}from"./payhawk-CZN5mU73.js";import{n as w}from"./StoreContext-B-zI9lUD.js";import{l as T}from"./_mobx-B2Mzvzey.js";import{t as E}from"./icon-CbH4aDip.js";var D=n(),O=e(a(),1),k=t(),A={note:`_note_b9ea11`,"close-icon":`_close-icon_b9ea11`,closeIcon:`_close-icon_b9ea11`,employee:`_employee_b9ea11`},j=i(),M=`YYYY-MM-DD`,N=`UTC`,P=(e,t)=>{let n=e.format(S(t)??e.now(),M),r=new Date(n),i=r.getTimezoneOffset();return new Date(e.add(r,i,D.DatePart.Minute))},F=({availableSubstitutes:e,vacationData:t,onUpdate:n,isSaveInProgress:r,canUpdateVacation:i})=>{let{t:a}=g([`user`,`common`]),s=(0,O.useId)(),[l,f]=(0,O.useState)(!1),m=t?.timezone??Intl.DateTimeFormat().resolvedOptions().timeZone??N,h=(0,O.useMemo)(()=>(0,D.createDateProvider)(m),[m]),[v,y]=(0,O.useState)(P(h,t?.startDate)),[b,x]=(0,O.useState)(P(h,t?.endDate)),[S,w]=(0,O.useState)(()=>e.filter(e=>t?.substituteIds.includes(e.id))),T=e=>{e&&(w(t=>t.find(({id:t,label:n})=>t===e.id&&n===e.label)?t:[...t,{id:e.id,label:e.label}]),f(!0))},E=e=>{w(t=>{let n=[...t];return n.splice(e,1),[...n]})},k=async()=>{v&&b&&v.getTime()<=b.getTime()&&(0,D.isNonEmptyArray)(S)&&n?.(h.format(v,M),h.format(b,M),m,S)},F=(e,t)=>{e===`from`&&y(t),e===`to`&&x(t)},I=e=>t=>F(e,t),R=e=>()=>E(e),z=()=>{if(!v)return a(`user:manageProfile.fromDateIsRequired`);if(!V(v,b))return a(`user:manageProfile.fromDateShouldBeBeforeToDate`)},B=()=>{if(!b)return a(`user:manageProfile.toDateIsRequired`);if(!H(v,b))return a(`user:manageProfile.toDateShouldBeAfterFromDate`)},V=(e,t)=>e?!t||e.getTime()<=t.getTime():!1,H=(e,t)=>t?!e||e.getTime()<=t.getTime():!1;return(0,j.jsx)(C,{dataTestId:`profile-user-vacation-form`,onSubmit:k,children:(0,j.jsxs)(o.List,{children:[(0,j.jsx)(d,{value:v,onChange:I(`from`),label:a(`common:from`),state:!V(v,b)&&z()?p.Error:p.None,stateText:z()}),(0,j.jsx)(d,{value:b,onChange:I(`to`),label:a(`common:to`),state:!H(v,b)&&B()?p.Error:p.None,stateText:B(),minDate:v??void 0}),(0,j.jsx)(u,{id:s,label:a(`user:manageProfile.outOfOfficeSelectInputLabel`),placeholder:a(`user:manageProfile.pickA
1nEmployee`),items:e,model:{idField:`value`,subtitleLabelField:`subtitle`},dataType:`array`,isNoneValueSelectable:!1,selectedItem:null,onSelect:T,state:l&&S.length===0?p.Error:p.None,stateText:a(`user:manageProfile.pickAnEmployee`)}),(0,j.jsx)(o.List,{gap:`8`,children:S.map(({label:e,id:t},n)=>(0,j.jsx)(L,{label:e,onClick:R(n)},`${t}-${e}`))}),(0,j.jsx)(`p`,{className:A.note,children:a(`user:manageProfile.outOfOfficeNote`,{date:_(v,`DD/MM/YYYY`)})}),(0,j.jsx)(c,{type:`submit`,label:a(`common:saveChanges`),className:`align-self-start`,skin:`primary`,size:`large`,isLoading:!!r,isDisabled:!S.length||!i})]})})},I=[12],L=({onClick:e,label:t})=>(0,j.jsxs)(`div`,{className:(0,m.default)(A.note,A.employee,[`align-items-center`,`justify-content-between`,`d-flex`]),children:[(0,j.jsx)(`div`,{className:`pl-16`,onClick:e,children:t}),(0,j.jsx)(`div`,{className:(0,m.default)(A[`close-icon`],`align-items-center justify-content-center d-none`),onClick:e,children:(0,j.jsx)(E,{name:`icon-close`,size:I})})]}),R=({className:e,availableSubstitutes:t,vacationData:n,onDelete:r,onUpdate:i,isUpsertSuccessful:a,hasUpsertServerError:o,isSaveInProgress:c,userId:u})=>{let{t:d}=g([`common`,`user`]),{accessControlStore:f,groupAccountsStore:p,userStore:m}=w(),_=(n?.userId??u)===m.user?.sub,v=p.group?.id?f.can(k.GroupPolicy.Members_Modify):f.can(k.Policy.EmployeesAdd),y=_||v,[b,x]=(0,O.useState)(()=>!!n),[S,C]=(0,O.useState)(!1),T=()=>{if(b){C(!0);return}x(!0)},E=()=>{n?.id&&r?.(n.id),x(!1),C(!1)},D=()=>{C(!1)};return(0,j.jsxs)(`div`,{className:e,children:[a&&!o&&(0,j.jsx)(h,{type:`success`,description:d(`common:changesSuccessfullySaved`),className:`mb-24`}),o&&(0,j.jsx)(h,{type:`error`,description:d(`common:unexpectedError`),className:`mb-24`}),(0,j.jsx)(l,{className:`pb-24`,onChange:T,isInitialChecked:b,label:d(`user:manageProfile.enableOutOfOffice`)}),b&&(0,j.jsx)(F,{availableSubstitutes:t,onUpdate:i,isSaveInProgress:c,vacationData:n,canUpdateVacation:y}),(0,j.jsx)(s,{isOpen:S,title:d(`common:actionConfirmationRequest`),onClose:D,primaryAction:{label:d(`common:confirm`),onClick:E,isDisabled:!y},secondaryAction:{label:d(`common:cancel`),onClick:D},children:d(`user:manageProfile.deleteOutOfOfficeConfiguration`)})]})},z=T(({className:e,...t})=>{let{userStore:n}=w(),i=t.userId??n.user?.sub,a=t.useUserVacationHook??x,o=t.usePotentialSubstitutesHook??y,s=t.useUpsertUserVacationHook??v,c=a(i),l=b(),u=o(i,t.entityParams),d=s(t.entityParams),p=(0,O.useMemo)(()=>u.data?.map(({id:e,name:t,email:n})=>({id:e,label:t||n,subtitle:t?n:void 0}))??[],[u]),m=(0,O.useCallback)((e,t,n,a)=>{if(i){let o=a.map(({id:e})=>e);if(!(0,D.isNonEmptyArray)(o))return;let s={substitutes:o,vacation:{userId:i,startDate:e,endDate:t,timezone:n}};try{d.mutate({payload:s,userId:i})}catch(e){r.createIssue({error:e,title:`Failed to create/update vacation for user`,extraData:{vacationPayload:s,userId:i}})}}},[d,i]),h=(0,O.useCallback)(e=>{i&&l.delete({userId:i,vacationId:e})},[i,l]);return c.isLoading||u.isLoading?(0,j.jsx)(`div`,{className:e,children:(0,j.jsx)(f,{size:`large`})}):(0,j.jsx)(R,{onUpdate:m,onDelete:h,className:e,vacationData:c.data,isSaveInProgress:d.isPending,hasUpsertServerError:d.isError,isUpsertSuccessful:d.isSuccess,availableSubstitutes:p,userId:i})});export{z as t}; 2//# sourceMappingURL=user-vacation-t5JYRMdl.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.