mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-27 14:20:58 +00:00
17 lines
55 KiB
JavaScript
17 lines
55 KiB
JavaScript
import{y as Ke,d as Ue,m as Ee,az as He,r as d,o as b,v as t,j as e,bn as Te,B as U,aK as Ae,aL as Be,aM as Pe,aN as Fe,bo as Nt,I as _a,ba as Ct,l as Le,w as De,u as Ga,k as Ja,n as Xa,t as C,aF as We,b7 as Za,bp as xt,b6 as es,A as ts}from"./index-7T7TTikv.js";import{S as Z,a as ee,b as te,c as ae,d as f}from"./select--i8koVXg.js";import{u as Me}from"./useUnit-CRt6YBLp.js";import{u as Qe,p as N,E as le}from"./useUnitConfiguration-BYTU44Fr.js";import{T as ze,a as Ye,b as p,c as T,d as Ve,e as n}from"./table-D_B7hhqb.js";import{u as as}from"./usePosition-B4V039Jv.js";import{C as ss,d as ns}from"./card-_ldW-koX.js";import{S as g}from"./switch-D9hx8CZw.js";import{F as ht,b as E,c as H,a as Q,d as z,e as Oe}from"./form-lLGtsTgY.js";import{B as we}from"./badge-D4t6Wb1T.js";import{A as is,a as rs}from"./alert-CCWXLU2U.js";import{A as ls,h as ds,a as os,b as cs,c as us,d as ms,e as xs,f as hs,g as gs}from"./alert-dialog-DwppaTz4.js";import{u as fs}from"./index.esm-BRNlF2G3.js";import{u as bs,o as js,e as ps,b as Ie,s as Ns}from"./zod-D-9d3Txu.js";import{C as gt}from"./circle-alert-HVqsZpe-.js";import{P as Cs}from"./plus-CC3ol2sL.js";import{M as ft}from"./message-square-BDJ0WXpX.js";import{M as bt}from"./mail-q8lHlEPt.js";import{S as vs}from"./square-pen-Dh1zj83N.js";import{L as jt}from"./label-CABYEcfW.js";import{S as ks}from"./shield-check-CfyQTFAv.js";import"./unitService-DTtkt-Pb.js";import"./positionService-BwPU5sNe.js";import"./Switch-ByfhjkDo.js";import"./InputsGroupFieldset-B16dMH0P.js";import"./use-uncontrolled-tg0LIUAX.js";/**
|
|
* @license lucide-react v0.513.0 - ISC
|
|
*
|
|
* This source code is licensed under the ISC license.
|
|
* See the LICENSE file in the root directory of this source tree.
|
|
*/const Ss=[["path",{d:"M12 20h9",key:"t2du7b"}],["path",{d:"M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z",key:"1ykcvy"}]],ys=Ke("pen-line",Ss);/**
|
|
* @license lucide-react v0.513.0 - ISC
|
|
*
|
|
* This source code is licensed under the ISC license.
|
|
* See the LICENSE file in the root directory of this source tree.
|
|
*/const Rs=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],vt=Ke("pen",Rs);/**
|
|
* @license lucide-react v0.513.0 - ISC
|
|
*
|
|
* This source code is licensed under the ISC license.
|
|
* See the LICENSE file in the root directory of this source tree.
|
|
*/const ws=[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]],pt=Ke("workflow",ws),Is="relative overflow-hidden rounded-2xl border border-slate-200/80 bg-gradient-to-br from-white via-slate-50 to-slate-100/60 p-4 shadow-sm sm:p-6 dark:border-slate-700/80 dark:bg-gradient-to-br dark:from-slate-950 dark:via-slate-900 dark:to-slate-900",As=()=>{var ie,y,q,X,S,W,o;const{user:x}=Ue(),c=Ee(),Y=((y=(ie=x==null?void 0:x.employee)==null?void 0:ie[0])==null?void 0:y.organizationId)||"",B=He(),{getList:L}=Me(),{data:u,isLoading:R}=L(Y,{take:1e3}),[r,I]=d.useState(""),[P,v]=d.useState(!1),[k,h]=d.useState(null),[V,_]=d.useState(0);d.useEffect(()=>{var j,O,re;((O=(j=u==null?void 0:u.data)==null?void 0:j.items)==null?void 0:O.length)>0&&!r&&I((re=u==null?void 0:u.data)==null?void 0:re.items[0].id)},[u]);const{data:F,isLoading:G,error:$}=Qe(r),m=(X=(q=F==null?void 0:F.data)==null?void 0:q.items)==null?void 0:X[0],{mutate:se,isPending:D}=b({mutationFn:({id:j,key:O,value:re})=>N.updateInternalPrefixSuffix({[O]:re,unitId:r},j),onSuccess:()=>{c.invalidateQueries({queryKey:["unitConfig",r]}),v(!1),h(null)},onError:j=>{}}),M=(j,O)=>{h(j),_(O),v(!0)},ne=()=>{!(m!=null&&m.id)||!k||se({id:m.id,key:k,value:V})},J=[{key:"escalationHour",label:t("setting.escalationHour"),value:m==null?void 0:m.escalationHour},{key:"urgentLetterEscalationHour",label:t("setting.urgentLetterEscalationHour"),value:m==null?void 0:m.urgentLetterEscalationHour},{key:"onReviewLetterEscalationHour",label:t("setting.onReviewLetterEscalationHour"),value:m==null?void 0:m.onReviewLetterEscalationHour},{key:"urgentOnReviewLetterEscalationHour",label:t("setting.urgentOnReviewLetterEscalationHour"),value:m==null?void 0:m.urgentOnReviewLetterEscalationHour}];return e.jsxs("div",{className:Is,children:[e.jsxs("div",{className:"mb-5 flex flex-col gap-4 border-b border-slate-200 pb-4 dark:border-slate-700 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("h1",{className:"flex items-center gap-2 text-2xl font-bold text-slate-900 sm:text-3xl dark:text-slate-100",children:[e.jsx(Te,{className:"h-8 w-8 text-primary"}),t("setting.escalationTitle")]}),e.jsx("p",{className:"text-sm text-slate-600 dark:text-slate-400",children:t("setting.escalationDescription")})]}),e.jsx("div",{className:"w-full sm:ml-auto sm:w-auto",children:e.jsxs(Z,{value:r,onValueChange:j=>I(j),children:[e.jsx(ee,{className:"h-10 w-full bg-white/90 dark:border-slate-700 dark:bg-slate-900 sm:w-56",children:e.jsx(te,{placeholder:"Select a unit"})}),e.jsx(ae,{className:"dark:border-slate-700 dark:bg-slate-900",children:R?e.jsx(f,{value:"loading",disabled:!0,children:t("setting.loading")}):((W=(S=u==null?void 0:u.data)==null?void 0:S.items)==null?void 0:W.length)>0?(o=u==null?void 0:u.data)==null?void 0:o.items.map(j=>e.jsx(f,{value:j.id,children:B(j.name)},j.id)):e.jsx(f,{value:"no-units",disabled:!0,children:t("setting.noUnit")})})]})})]}),e.jsxs("div",{className:"space-y-3",children:[G&&e.jsx("p",{className:"text-sm text-slate-600 dark:text-slate-300",children:t("setting.loadingConfig")}),$&&e.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",children:t("setting.loadError")}),!m&&!G&&!$&&e.jsx("p",{className:"text-sm text-slate-600 dark:text-slate-300",children:t("setting.noConfigFound")}),m&&e.jsx("div",{className:"overflow-x-auto rounded-xl border border-slate-200 bg-white/90 dark:border-slate-700 dark:bg-slate-900/70",children:e.jsxs(ze,{children:[e.jsx(Ye,{children:e.jsxs(p,{className:"dark:border-slate-700",children:[e.jsx(T,{className:"text-slate-600 dark:text-slate-300",children:t("setting.Name")}),e.jsx(T,{className:"text-slate-600 dark:text-slate-300",children:t("setting.Value")}),e.jsx(T,{className:"text-right text-slate-600 dark:text-slate-300",children:t("setting.Action")})]})}),e.jsx(Ve,{children:J.map(j=>e.jsxs(p,{className:"dark:border-slate-700",children:[e.jsx(n,{className:"text-slate-900 dark:text-slate-100",children:j.label}),e.jsx(n,{className:"text-slate-700 dark:text-slate-300",children:j.value??"-"}),e.jsx(n,{className:"text-right",children:e.jsx(U,{onClick:()=>M(j.key,j.value),variant:"outline",size:"sm",className:"dark:border-slate-700 dark:bg-slate-900 dark:hover:bg-slate-800",children:e.jsx(vt,{className:"h-4 w-4"})})})]},j.key))})]})})]}),e.jsx(Ae,{open:P,onOpenChange:v,children:e.jsxs(Be,{className:"dark:border-slate-700 dark:bg-slate-900",children:[e.jsxs(Pe,{children:[e.jsxs(Fe,{className:"dark:text-slate-100",children:[t("setting.edit")," ",k&&t(`setting.${k}`)]}),e.jsx(Nt,{className:"dark:text-slate-400",children:t("setting.updateEscalationMsg")})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"text-sm font-medium text-slate-700 dark:text-slate-300",children:k&&t(`setting.${k}`)}),e.jsx(_a,{type:"number",value:V??"",onChange:j=>_(Number(j.target.value)),className:"dark:border-slate-700 dark:bg-slate-900 dark:text-slate-100"})]}),e.jsxs(Ct,{className:"flex justify-end gap-2 mt-4",children:[e.jsx(U,{variant:"secondary",onClick:()=>v(!1),className:"dark:bg-slate-800 dark:text-slate-100 dark:hover:bg-slate-700",children:t("common.Cancel")}),e.jsx(U,{onClick:ne,disabled:D,className:"bg-primary hover:bg-primary/90 text-primary-foreground",children:D?t("setting.saving"):t("setting.saveChanges")})]})]})})]})},Bs=async x=>Le.post("/position-configurations",x,{headers:De()}),Ps=async x=>Le.get(`/position-configurations/list/${x}`,{headers:De()}),Fs=async(x,c)=>Le.put(`/position-configurations/${x}`,c,{headers:De()}),Us=async x=>Le.delete(`/position-configurations/${x}`,{headers:De()}),Es=x=>{const c=Ee(),{t:Y}=Ga(),{handleError:B}=Ja(Y),{data:L,isLoading:u,isError:R,error:r,refetch:I}=Xa({queryKey:["position-configurations",x],queryFn:()=>Ps(x),select:h=>h&&h.data&&typeof h.data=="object"&&!Array.isArray(h.data)&&"items"in h.data?h.data.items:Array.isArray(h==null?void 0:h.data)?h.data:Array.isArray(h)?h:[],enabled:!!x}),P=b({mutationFn:Bs,onSuccess:()=>{c.invalidateQueries({queryKey:["position-configurations",x]}),C.success("Position configuration created successfully")},onError:h=>{B(h)}}),v=b({mutationFn:({id:h,payload:V})=>Fs(h,V),onSuccess:()=>{c.invalidateQueries({queryKey:["position-configurations",x]}),C.success("Position configuration updated successfully")},onError:h=>{B(h)}}),k=b({mutationFn:Us,onSuccess:()=>{c.invalidateQueries({queryKey:["position-configurations",x]}),C.success("Position configuration deleted successfully")},onError:h=>{B(h)}});return{configurations:L||[],isLoading:u,isError:R,error:r,refetch:I,createConfiguration:P.mutate,updateConfiguration:v.mutate,deleteConfiguration:k.mutate,isCreating:P.isPending,isUpdating:v.isPending,isDeleting:k.isPending}},kt=["all","immediate_child","parallel_with_immediate_child"],Hs=js({positionId:Ns().min(1,"Position is required"),smsNotificationWhenRecordSubmitted:Ie(),emailNotificationWhenRecordSubmitted:Ie(),inboxNotificationWhenRecordSubmitted:Ie(),skipWorkflowIfNotAssigned:Ie(),positionScopeToFetch:ps(kt)}),Ts=()=>{var ce,ue,me,xe,he,ge,fe,be,je,pe;const{user:x}=Ue(),c=((ue=(ce=x==null?void 0:x.employee)==null?void 0:ce[0])==null?void 0:ue.unitId)||"",Y=((xe=(me=x==null?void 0:x.employee)==null?void 0:me[0])==null?void 0:xe.organizationId)||"",B=He(),[L,u]=d.useState(!1),[R,r]=d.useState(null),[I,P]=d.useState(!1),[v,k]=d.useState(""),{configurations:h,isLoading:V,isError:_,error:F,refetch:G,createConfiguration:$,updateConfiguration:m,deleteConfiguration:se,isCreating:D,isUpdating:M,isDeleting:ne}=Es(c),J=Array.isArray(h)?h:[],{getList:ie}=Me(),{data:y,isLoading:q}=ie(Y,{take:1e3}),{usePositionListByUnitId:X}=as(),{data:S,isLoading:W}=X(v,{take:1e3}),o=fs({resolver:bs(Hs),defaultValues:{positionId:"",smsNotificationWhenRecordSubmitted:!0,emailNotificationWhenRecordSubmitted:!0,inboxNotificationWhenRecordSubmitted:!0,skipWorkflowIfNotAssigned:!1,positionScopeToFetch:"all"}}),j=i=>{$(i,{onSuccess:()=>{u(!1),k(""),o.reset()}})},O=i=>{R!=null&&R.id&&m({id:R==null?void 0:R.id,payload:i},{onSuccess:()=>{P(!1),r(null),k(""),o.reset()}})},re=i=>{var K;r(i);const w=(K=S==null?void 0:S.items)==null?void 0:K.find(de=>de.id===i.positionId),A=(w==null?void 0:w.unitId)||"";k(A),o.reset({positionId:i.positionId,smsNotificationWhenRecordSubmitted:i.smsNotificationWhenRecordSubmitted,emailNotificationWhenRecordSubmitted:i.emailNotificationWhenRecordSubmitted,inboxNotificationWhenRecordSubmitted:i.inboxNotificationWhenRecordSubmitted,skipWorkflowIfNotAssigned:i.skipWorkflowIfNotAssigned}),P(!0)},ve=i=>{se(i)},ke=i=>{var A;const w=(A=S==null?void 0:S.items)==null?void 0:A.find(K=>K.id===i);return B(w==null?void 0:w.name)||"Unknown Position"},Se=i=>{var de,Ne,Ce;const w=(de=S==null?void 0:S.items)==null?void 0:de.find(oe=>oe.id===i),A=w==null?void 0:w.unitId;if(!A)return"Unknown Unit";const K=(Ce=(Ne=y==null?void 0:y.data)==null?void 0:Ne.items)==null?void 0:Ce.find(oe=>oe.id===A);return B(K==null?void 0:K.name)||"Unknown Unit"};return Y?V?e.jsx("div",{className:"p-6 flex items-center justify-center h-64",children:e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(We,{className:"h-8 w-8 animate-spin text-primary"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:t("setting.msg2")})]})}):e.jsxs("div",{className:"relative overflow-hidden rounded-2xl border border-slate-200/80 bg-gradient-to-br from-white via-slate-50 to-slate-100/60 p-4 shadow-sm sm:p-6 dark:border-slate-700/80 dark:bg-gradient-to-br dark:from-slate-950 dark:via-slate-900 dark:to-slate-900",children:[e.jsxs("div",{className:"mb-5 flex flex-col gap-4 border-b border-slate-200 pb-4 dark:border-slate-700 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("h1",{className:"flex items-center gap-2 text-2xl font-bold text-slate-900 sm:text-3xl dark:text-slate-100",children:[e.jsx(Te,{className:"h-8 w-8 text-primary"}),t("setting.positionConfig")]}),e.jsx("p",{className:"text-sm text-slate-600 dark:text-slate-400",children:t("setting.positionConfigMsg")})]}),e.jsxs(Ae,{open:L,onOpenChange:u,children:[e.jsx(Za,{asChild:!0,children:e.jsxs(U,{className:"bg-primary hover:bg-primary/90 text-primary-foreground",children:[e.jsx(Cs,{className:"h-4 w-4 mr-2"}),t("setting.add")]})}),e.jsxs(Be,{className:"max-w-2xl max-h-[90vh] overflow-y-auto bg-white shadow-2xl border-2 dark:bg-gray-900 dark:border-gray-700",children:[e.jsx(Pe,{className:"sticky top-0 bg-white z-10 pb-4 border-b dark:bg-gray-900 dark:border-gray-700",children:e.jsx(Fe,{className:"dark:text-gray-100",children:t("setting.create")})}),e.jsx("div",{className:"flex-1 overflow-y-auto px-1",children:e.jsx(ht,{...o,children:e.jsxs("form",{onSubmit:o.handleSubmit(j),className:"space-y-6 pb-4",children:[e.jsxs(E,{children:[e.jsx(H,{className:"dark:text-gray-200",children:"Unit"}),e.jsxs(Z,{onValueChange:i=>{k(i)},value:v,children:[e.jsx(ee,{children:e.jsx(te,{placeholder:"Select a unit"})}),e.jsx(ae,{children:q?e.jsx(f,{value:"loading",disabled:!0,children:"Loading units..."}):((ge=(he=y==null?void 0:y.data)==null?void 0:he.items)==null?void 0:ge.length)>0?(be=(fe=y==null?void 0:y.data)==null?void 0:fe.items)==null?void 0:be.map(i=>e.jsx(f,{value:i.id,children:B(i.name)},i.id)):e.jsx(f,{value:"no-units",disabled:!0,children:"No units found"})})]})]}),e.jsx(Q,{control:o.control,name:"positionId",render:({field:i})=>{var w;return e.jsxs(E,{children:[e.jsx(H,{className:"dark:text-gray-200",children:t("setting.position")}),e.jsxs(Z,{onValueChange:i.onChange,value:i.value,disabled:!v,children:[e.jsx(z,{children:e.jsx(ee,{children:e.jsx(te,{placeholder:v?t("setting.select"):t("setting.select2")})})}),e.jsx(ae,{children:v?W?e.jsx(f,{value:"loading",disabled:!0,children:"Loading positions..."}):((w=S==null?void 0:S.items)==null?void 0:w.length)>0?S.items.map(A=>e.jsx(f,{value:A.id,children:B(A.name)},A.id)):e.jsx(f,{value:"no-positions",disabled:!0,children:"No positions found in this unit"}):e.jsx(f,{value:"no-unit-selected",disabled:!0,children:t("setting.select2")})})]}),e.jsx(Oe,{}),!v&&e.jsx("p",{className:"text-sm text-muted-foreground",children:t("setting.plsSelect")})]})}}),e.jsx(Q,{control:o.control,name:"positionScopeToFetch",render:({field:i})=>e.jsxs(E,{children:[e.jsx(H,{className:"dark:text-gray-200",children:t("setting.positionScope")}),e.jsxs(Z,{onValueChange:i.onChange,value:i.value,children:[e.jsx(z,{children:e.jsx(ee,{children:e.jsx(te,{placeholder:t("setting.positionScope")})})}),e.jsxs(ae,{children:[e.jsx(f,{value:"all",children:t("setting.all")}),e.jsx(f,{value:"immediate_child",children:t("setting.immediateChild")}),e.jsx(f,{value:"parallel_with_immediate_child",children:t("setting.parallel")})]})]}),e.jsx(Oe,{})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold",children:t("setting.notification")}),e.jsx(Q,{control:o.control,name:"smsNotificationWhenRecordSubmitted",render:({field:i})=>e.jsxs(E,{className:"flex flex-row items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs(H,{className:"flex items-center gap-2",children:[e.jsx(ft,{className:"h-4 w-4"}),t("setting.sms")]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:t("setting.smsMsg")})]}),e.jsx(z,{children:e.jsx(g,{checked:i.value,onCheckedChange:i.onChange})})]})}),e.jsx(Q,{control:o.control,name:"emailNotificationWhenRecordSubmitted",render:({field:i})=>e.jsxs(E,{className:"flex flex-row items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs(H,{className:"flex items-center gap-2",children:[e.jsx(bt,{className:"h-4 w-4"}),t("setting.email")]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:t("setting.emailMsg")})]}),e.jsx(z,{children:e.jsx(g,{checked:i.value,onCheckedChange:i.onChange})})]})}),e.jsx(Q,{control:o.control,name:"inboxNotificationWhenRecordSubmitted",render:({field:i})=>e.jsxs(E,{className:"flex flex-row items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs(H,{className:"flex items-center gap-2",children:[e.jsx(xt,{className:"h-4 w-4"}),t("setting.inbox")]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:t("setting.inboxMsg")})]}),e.jsx(z,{children:e.jsx(g,{checked:i.value,onCheckedChange:i.onChange})})]})}),e.jsx("h3",{className:"text-lg font-semibold",children:t("setting.workflow")}),e.jsx(Q,{control:o.control,name:"skipWorkflowIfNotAssigned",render:({field:i})=>e.jsxs(E,{className:"flex flex-row items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs(H,{className:"flex items-center gap-2",children:[e.jsx(pt,{className:"h-4 w-4"}),t("setting.workflowMsg")]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:t("setting.workflowMsg1")})]}),e.jsx(z,{children:e.jsx(g,{checked:i.value,onCheckedChange:i.onChange})})]})})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4",children:[e.jsx(U,{type:"button",variant:"outline",onClick:()=>{u(!1),k(""),o.reset()},disabled:D,children:t("common.Cancel")}),e.jsx(U,{type:"submit",disabled:D,className:"bg-primary hover:bg-primary/90",children:D?e.jsxs(e.Fragment,{children:[e.jsx(We,{className:"h-4 w-4 mr-2 animate-spin"}),t("setting.creating")]}):t("setting.createConfig")})]})]})})})]})]})]}),e.jsx(ss,{className:"border-slate-200 bg-white/90 dark:border-slate-700 dark:bg-slate-900/70",children:e.jsxs(ns,{className:"pt-6",children:[_&&e.jsxs(is,{variant:"destructive",className:"mb-4",children:[e.jsx(gt,{className:"h-4 w-4"}),e.jsxs(rs,{children:[t("setting.error")," ",(F==null?void 0:F.message)||"Unknown error",e.jsx(U,{variant:"outline",size:"sm",onClick:()=>G(),className:"ml-2",children:t("setting.retry")})]})]}),J.length===0?e.jsx("div",{className:"text-center py-8"}):e.jsx("div",{className:"overflow-x-auto rounded-xl border border-slate-200 dark:border-slate-700",children:e.jsxs(ze,{children:[e.jsx(Ye,{children:e.jsxs(p,{className:"dark:border-slate-700",children:[e.jsx(T,{className:"text-slate-600 dark:text-slate-300",children:t("setting.position")}),e.jsx(T,{className:"text-center text-slate-600 dark:text-slate-300",children:t("contentManagement.unit")}),e.jsx(T,{className:"text-center text-slate-600 dark:text-slate-300",children:t("setting.SMS")}),e.jsx(T,{className:"text-center text-slate-600 dark:text-slate-300",children:t("organization.email")}),e.jsx(T,{className:"text-center text-slate-600 dark:text-slate-300",children:t("setting.Inbox")}),e.jsx(T,{className:"text-center text-slate-600 dark:text-slate-300",children:t("setting.skipWF")}),e.jsx(T,{className:"text-center text-slate-600 dark:text-slate-300",children:t("setting.Action")})]})}),e.jsx(Ve,{children:J.map(i=>e.jsxs(p,{className:"dark:border-slate-700",children:[e.jsx(n,{className:"font-medium text-slate-900 dark:text-slate-100",children:ke(i.positionId)}),e.jsx(n,{className:"text-center text-slate-700 dark:text-slate-300",children:Se(i.positionId)}),e.jsx(n,{className:"text-center",children:e.jsx(we,{variant:i.smsNotificationWhenRecordSubmitted?"default":"secondary",className:i.smsNotificationWhenRecordSubmitted?"bg-primary-100 text-primary-800":"",children:i.smsNotificationWhenRecordSubmitted?"Enabled":"Disabled"})}),e.jsx(n,{className:"text-center",children:e.jsx(we,{variant:i.emailNotificationWhenRecordSubmitted?"default":"secondary",className:i.emailNotificationWhenRecordSubmitted?"bg-primary-100 text-primary-800":"",children:i.emailNotificationWhenRecordSubmitted?"Enabled":"Disabled"})}),e.jsx(n,{className:"text-center",children:e.jsx(we,{variant:i.inboxNotificationWhenRecordSubmitted?"default":"secondary",className:i.inboxNotificationWhenRecordSubmitted?"bg-primary-100 text-primary-800":"",children:i.inboxNotificationWhenRecordSubmitted?"Enabled":"Disabled"})}),e.jsx(n,{className:"text-center",children:e.jsx(we,{variant:i.skipWorkflowIfNotAssigned?"destructive":"secondary",children:i.skipWorkflowIfNotAssigned?"Skip":"Process"})}),e.jsx(n,{className:"text-center",children:e.jsxs("div",{className:"flex justify-center gap-2",children:[e.jsx(U,{variant:"outline",size:"sm",onClick:()=>re(i),disabled:M||ne,className:"dark:border-slate-700 dark:bg-slate-900 dark:hover:bg-slate-800",children:e.jsx(vs,{className:"h-4 w-4"})}),e.jsxs(ls,{children:[e.jsx(ds,{asChild:!0,children:e.jsx(U,{variant:"outline",size:"sm",disabled:ne,className:"dark:border-slate-700 dark:bg-slate-900 dark:hover:bg-slate-800",children:e.jsx(es,{className:"h-4 w-4 text-red-500"})})}),e.jsxs(os,{className:"dark:border-slate-700 dark:bg-slate-900",children:[e.jsxs(cs,{children:[e.jsx(us,{className:"dark:text-slate-100",children:t("setting.delete")}),e.jsx(ms,{className:"dark:text-slate-400",children:t("setting.deleteMsg")})]}),e.jsxs(xs,{children:[e.jsx(hs,{className:"dark:border-slate-700 dark:bg-slate-800 dark:text-slate-100 dark:hover:bg-slate-700",children:"Cancel"}),e.jsx(gs,{onClick:()=>i.id&&ve(i.id),className:"bg-red-600 hover:bg-red-700",children:t("userRecord.Delete")})]})]})]})]})})]},i.id))})]})})]})}),e.jsx(Ae,{open:I,onOpenChange:P,children:e.jsxs(Be,{className:"max-w-2xl max-h-[90vh] overflow-y-auto bg-white shadow-2xl border-2 dark:bg-slate-900 dark:border-slate-700",children:[e.jsx(Pe,{className:"sticky top-0 bg-white z-10 pb-4 border-b dark:bg-slate-900 dark:border-slate-700",children:e.jsx(Fe,{className:"dark:text-slate-100",children:t("setting.edit")})}),e.jsx("div",{className:"flex-1 overflow-y-auto px-1",children:e.jsx(ht,{...o,children:e.jsxs("form",{onSubmit:o.handleSubmit(O),className:"space-y-6 pb-4",children:[e.jsxs(E,{children:[e.jsx(H,{children:t("contentManagement.unit")}),e.jsxs(Z,{onValueChange:i=>{k(i)},value:v,children:[e.jsx(ee,{children:e.jsx(te,{placeholder:"Select a unit"})}),e.jsx(ae,{children:q?e.jsx(f,{value:"loading",disabled:!0,children:"Loading units..."}):((pe=(je=y==null?void 0:y.data)==null?void 0:je.items)==null?void 0:pe.length)>0?y==null?void 0:y.data.items.map(i=>e.jsx(f,{value:i.id,children:B(i.name)},i.id)):e.jsx(f,{value:"no-units",disabled:!0,children:"No units found"})})]})]}),e.jsx(Q,{control:o.control,name:"positionId",render:({field:i})=>{var w;return e.jsxs(E,{children:[e.jsx(H,{children:t("setting.position")}),e.jsxs(Z,{onValueChange:i.onChange,value:i.value,disabled:!v,children:[e.jsx(z,{children:e.jsx(ee,{children:e.jsx(te,{placeholder:v?t("setting.select"):t("setting.select2")})})}),e.jsx(ae,{children:v?W?e.jsx(f,{value:"loading",disabled:!0,children:"Loading positions..."}):((w=S==null?void 0:S.items)==null?void 0:w.length)>0?S.items.map(A=>e.jsx(f,{value:A.id,children:B(A.name)},A.id)):e.jsx(f,{value:"no-positions",disabled:!0,children:"No positions found in this unit"}):e.jsx(f,{value:"no-unit-selected",disabled:!0,children:t("setting.select2")})})]}),e.jsx(Oe,{}),!v&&e.jsx("p",{className:"text-sm text-muted-foreground",children:t("setting.plsSelect")})]})}}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold",children:t("setting.notification")}),e.jsx(Q,{control:o.control,name:"smsNotificationWhenRecordSubmitted",render:({field:i})=>e.jsxs(E,{className:"flex flex-row items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs(H,{className:"flex items-center gap-2",children:[e.jsx(ft,{className:"h-4 w-4"}),t("setting.sms")]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:t("setting.smsMsg")})]}),e.jsx(z,{children:e.jsx(g,{checked:i.value,onCheckedChange:i.onChange})})]})}),e.jsx(Q,{control:o.control,name:"emailNotificationWhenRecordSubmitted",render:({field:i})=>e.jsxs(E,{className:"flex flex-row items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs(H,{className:"flex items-center gap-2",children:[e.jsx(bt,{className:"h-4 w-4"}),t("setting.email")]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:t("setting.emailMsg")})]}),e.jsx(z,{children:e.jsx(g,{checked:i.value,onCheckedChange:i.onChange})})]})}),e.jsx(Q,{control:o.control,name:"inboxNotificationWhenRecordSubmitted",render:({field:i})=>e.jsxs(E,{className:"flex flex-row items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs(H,{className:"flex items-center gap-2",children:[e.jsx(xt,{className:"h-4 w-4"}),t("setting.inbox")]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:t("setting.inboxMsg")})]}),e.jsx(z,{children:e.jsx(g,{checked:i.value,onCheckedChange:i.onChange})})]})}),e.jsxs("h3",{className:"text-lg font-semibold",children:[" ",t("setting.workflow")]}),e.jsx(Q,{control:o.control,name:"skipWorkflowIfNotAssigned",render:({field:i})=>e.jsxs(E,{className:"flex flex-row items-center justify-between rounded-lg border p-4",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsxs(H,{className:"flex items-center gap-2",children:[e.jsx(pt,{className:"h-4 w-4"}),t("setting.workflowMsg")]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:t("setting.workflowMsg1")})]}),e.jsx(z,{children:e.jsx(g,{checked:i.value,onCheckedChange:i.onChange})})]})})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-4",children:[e.jsx(U,{type:"button",variant:"outline",onClick:()=>{P(!1),r(null),k(""),o.reset()},disabled:M,children:t("common.Cancel")}),e.jsx(U,{type:"submit",disabled:M,className:"bg-primary hover:bg-primary/90",children:M?e.jsxs(e.Fragment,{children:[e.jsx(We,{className:"h-4 w-4 mr-2 animate-spin"}),t("setting.updating")]}):t("setting.UpdateConfig")})]})]})})})]})})]}):e.jsx("div",{className:"p-6 flex items-center justify-center h-64",children:e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(gt,{className:"h-8 w-8 text-red-500"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:t("setting.msg1")})]})})},Ls="relative overflow-hidden rounded-2xl border border-slate-200/80 bg-gradient-to-br from-white via-slate-50 to-slate-100/60 p-4 shadow-sm sm:p-6 dark:border-slate-700/80 dark:bg-gradient-to-br dark:from-slate-950 dark:via-slate-900 dark:to-slate-900",Ds=()=>{var it,rt,lt,dt,ot,ct,ut,mt;const{user:x}=Ue(),c=Ee(),Y=((rt=(it=x==null?void 0:x.employee)==null?void 0:it[0])==null?void 0:rt.organizationId)||"",B=He(),{getList:L}=Me(),{data:u,isLoading:R}=L(Y,{take:1e3}),[r,I]=d.useState(""),[P,v]=d.useState(!1),[k,h]=d.useState(""),[V,_]=d.useState(le.NAME),[F,G]=d.useState(!1),[$,m]=d.useState(!1),[se,D]=d.useState(!1),[M,ne]=d.useState(!1),[J,ie]=d.useState(!1),[y,q]=d.useState(!1),[X,S]=d.useState(!1),[W,o]=d.useState(!1),[j,O]=d.useState(!1),[re,ve]=d.useState(!1),[ke,Se]=d.useState(!1),[ce,ue]=d.useState(!1),[me,xe]=d.useState(!1),[he,ge]=d.useState(!1),[fe,be]=d.useState(!1),[je,pe]=d.useState(!1),[i,w]=d.useState(!1),[A,K]=d.useState(!1),[de,Ne]=d.useState(!1),[Ce,oe]=d.useState(!1),[_e,Ge]=d.useState(!1),[Je,Xe]=d.useState(!1),[Ze,et]=d.useState(!1),[tt,at]=d.useState(!1);d.useEffect(()=>{var a,l;if(((l=(a=u==null?void 0:u.data)==null?void 0:a.items)==null?void 0:l.length)>0){const Va=u==null?void 0:u.data.items[0];I(Va.id)}},[u]);const{data:$e,isLoading:ye,error:Re}=Qe(r,{enabled:!!r}),s=(dt=(lt=$e==null?void 0:$e.data)==null?void 0:lt.items)==null?void 0:dt[0],[$s,qs]=d.useState(!1);d.useEffect(()=>{s&&(G(s.canAssignCustomReferenceNumber||!1),_(s.recordSenderInformationScope||le.NAME),m(s.canInternalMemosHaveSenderInformation||!1),ie(s.canRecordDateLabelHasLocalization||!1),q(s.canRecordDateHaveTime||!1),S(s.forwardWithTeeterSignature||!1),o(s.waitAllCollaboratorsBeforeAction||!1),O(s.shouldCollaboratorAlwaysSign||!1),ve(s.shouldIncludeForYourReferenceInCC||!1),Se(s.canCollaborationBeCreatedForAll||!1),ue(s.canCreateDirectRecord||!1),xe(s.canPositionBasedRecordsBeCreated||!1),ge(s.canPositionBasedReferenceBeUsedForAllTypes||!1),pe(s.shouldDirectRecordHaveHeaderAndFooter||!1),be(s.canInternalMemoRequirePositionBasedReferenceNumber||!1),w(s.canRecordBeEditedByCollaborators||!1),K(s.canRecordHaveCollaboratorsName||!1),Ne(s.canRecordBeEditedOnWorkflow||!1),oe(s.canIncomingAssignmentsBeSeparated||!1),Ge(s.canROReturn||!1),Xe(s.internalMemoHasReferenceNumber||!1),et(s.isMultipleDelegationAllowed||!1),at(s.attachSignatureOnAttachment||!1),D(s.canHaveTagBasedReferenceNumber||!1),ne(s.canUserSkipLevel||!1))},[s]);const St=a=>{s!=null&&s.id&&(D(a),Rt({id:s.id,value:a}))},yt=a=>{s!=null&&s.id&&(ne(a),It({id:s.id,value:a}))},{mutate:Rt,isPending:wt}=b({mutationFn:({id:a,value:l})=>N.updateInternalPrefixSuffix({canHaveTagBasedReferenceNumber:l,unitId:r},a),onSuccess:()=>{c.invalidateQueries({queryKey:["unitConfig",r]}),C.success(`${t("setting.canHaveTagBasedReferenceNumber","Can Have Tag Based Reference Number")} ${se?"enabled":"disabled"}`)},onError:a=>{}}),{mutate:It,isPending:At}=b({mutationFn:({id:a,value:l})=>N.updateInternalPrefixSuffix({canUserSkipLevel:l,unitId:r},a),onSuccess:()=>{c.invalidateQueries({queryKey:["unitConfig",r]}),C.success(`${t("setting.canUserSkipLevel","User Can Skip Level")} ${M?"enabled":"disabled"}`)},onError:a=>{}}),{mutate:Bt,isPending:Pt}=b({mutationFn:({id:a,scope:l})=>N.updateInternalPrefixSuffix({recordSenderInformationScope:l,unitId:r},a),onSuccess:()=>{c.invalidateQueries({queryKey:["unitConfig",r]}),C.success(`${t("setting.recordSenderInformationScope","Record Sender Information Scope")} updated`)},onError:a=>{}}),{mutate:Ft,isPending:Ut}=b({mutationFn:({id:a,value:l})=>N.updateInternalPrefixSuffix({canAssignCustomReferenceNumber:l,unitId:r},a),onSuccess:()=>{c.invalidateQueries({queryKey:["unitConfig",r]}),C.success(`${t("setting.canAssignCustomReferenceNumber")} ${F?"enabled":"disabled"}`)},onError:a=>{}}),{mutate:Et,isPending:Ht}=b({mutationFn:({id:a,value:l})=>N.updateInternalPrefixSuffix({canInternalMemosHaveSenderInformation:l,unitId:r},a),onSuccess:()=>{c.invalidateQueries({queryKey:["unitConfig",r]}),C.success(`${t("setting.canUseNewInternalMemoFormat")} ${$?"enabled":"disabled"}`)},onError:a=>{}}),{mutate:Tt,isPending:Lt}=b({mutationFn:({id:a,value:l})=>N.updateInternalPrefixSuffix({canRecordDateLabelHasLocalization:l,unitId:r},a),onSuccess:()=>{c.invalidateQueries({queryKey:["unitConfig",r]}),C.success(`${t("setting.canRecordDateLabelHasLocalization")} ${J?"enabled":"disabled"}`)},onError:a=>{}}),{mutate:Dt,isPending:Mt}=b({mutationFn:({id:a,value:l})=>N.updateInternalPrefixSuffix({canRecordDateHaveTime:l,unitId:r},a),onSuccess:()=>{c.invalidateQueries({queryKey:["unitConfig",r]}),C.success(`${t("setting.canRecordDateHaveTime","Record Date Can Have Time")} ${y?"enabled":"disabled"}`)},onError:a=>{}}),{mutate:$t,isPending:st}=b({mutationFn:({id:a,scope:l})=>N.updateInternalPrefixSuffix({positionScopeToFetch:l,unitId:r},a),onSuccess:()=>{c.invalidateQueries({queryKey:["unitConfig",r]}),v(!1)},onError:a=>{}}),{mutate:qt,isPending:Wt}=b({mutationFn:({id:a,signature:l})=>N.updateInternalPrefixSuffix({forwardWithTeeterSignature:l,unitId:r},a),onSuccess:()=>{c.invalidateQueries({queryKey:["unitConfig",r]}),C.success(`Signature & Teeter ${X?"enabled":"disabled"}`)},onError:a=>{}}),{mutate:Ot,isPending:Kt}=b({mutationFn:({id:a,wait:l})=>N.updateInternalPrefixSuffix({waitAllCollaboratorsBeforeAction:l,unitId:r},a),onSuccess:()=>{c.invalidateQueries({queryKey:["unitConfig",r]}),C.success(`${t("setting.title6")} ${W?"enabled":"disabled"}`)},onError:a=>{}}),Qt=()=>{s!=null&&s.id&&(h(s.positionScopeToFetch),v(!0))},zt=()=>{s!=null&&s.id&&k&&k!==s.positionScopeToFetch&&$t({id:s.id,scope:k})},Yt=a=>{s!=null&&s.id&&(S(a),qt({id:s.id,signature:a}))},Vt=a=>{s!=null&&s.id&&(G(a),Ft({id:s.id,value:a}))},_t=a=>{s!=null&&s.id&&(m(a),Et({id:s.id,value:a}))},Gt=a=>{s!=null&&s.id&&(ie(a),Tt({id:s.id,value:a}))},Jt=a=>{s!=null&&s.id&&(q(a),Dt({id:s.id,value:a}))},Xt=a=>{s!=null&&s.id&&(o(a),Ot({id:s.id,wait:a}))},{mutate:Zt,isPending:ea}=b({mutationFn:({id:a,value:l})=>N.updateInternalPrefixSuffix({shouldCollaboratorAlwaysSign:l,unitId:r},a),onSuccess:()=>{c.invalidateQueries({queryKey:["unitConfig",r]}),C.success(`${t("setting.shouldCollaboratorAlwaysSign")} ${j?"enabled":"disabled"}`)},onError:a=>{}}),{mutate:ta,isPending:aa}=b({mutationFn:({id:a,value:l})=>N.updateInternalPrefixSuffix({shouldIncludeForYourReferenceInCC:l,unitId:r},a),onSuccess:()=>{c.invalidateQueries({queryKey:["unitConfig",r]}),C.success(`${t("setting.shouldIncludeForYourReferenceInCC")} ${re?"enabled":"disabled"}`)},onError:a=>{}}),sa=a=>{s!=null&&s.id&&(O(a),Zt({id:s.id,value:a}))},na=a=>{s!=null&&s.id&&(_(a),Bt({id:s.id,scope:a}))},ia=a=>{s!=null&&s.id&&(ve(a),ta({id:s.id,value:a}))},{mutate:ra,isPending:la}=b({mutationFn:({id:a,value:l})=>N.updateInternalPrefixSuffix({canCollaborationBeCreatedForAll:l,unitId:r},a),onSuccess:()=>{c.invalidateQueries({queryKey:["unitConfig",r]}),C.success(`${t("setting.canCollaborationBeCreatedForAll")} ${ke?"enabled":"disabled"}`)},onError:a=>{}}),da=a=>{s!=null&&s.id&&(Se(a),ra({id:s.id,value:a}))},{mutate:oa,isPending:ca}=b({mutationFn:({id:a,value:l})=>N.updateInternalPrefixSuffix({canCreateDirectRecord:l,unitId:r},a),onSuccess:()=>{c.invalidateQueries({queryKey:["unitConfig",r]}),C.success(`${t("setting.canCreateDirectRecord")} ${ce?"enabled":"disabled"}`)},onError:a=>{}}),ua=a=>{s!=null&&s.id&&(ue(a),oa({id:s.id,value:a}))},{mutate:ma,isPending:xa}=b({mutationFn:({id:a,value:l})=>N.updateInternalPrefixSuffix({canPositionBasedRecordsBeCreated:l,unitId:r},a),onSuccess:()=>{c.invalidateQueries({queryKey:["unitConfig",r]}),C.success(`${t("setting.canPositionBasedRecordsBeCreated")} ${me?"enabled":"disabled"}`)},onError:a=>{}}),ha=a=>{s!=null&&s.id&&(xe(a),ma({id:s.id,value:a}))},{mutate:ga,isPending:fa}=b({mutationFn:({id:a,value:l})=>N.updateInternalPrefixSuffix({canPositionBasedReferenceBeUsedForAllTypes:l,unitId:r},a),onSuccess:()=>{c.invalidateQueries({queryKey:["unitConfig",r]}),C.success(`${t("setting.canPositionBasedReferenceBeUsedForAllTypes")} ${he?"enabled":"disabled"}`)},onError:a=>{}}),ba=a=>{s!=null&&s.id&&(ge(a),ga({id:s.id,value:a}))},{mutate:ja,isPending:pa}=b({mutationFn:({id:a,value:l})=>N.updateInternalPrefixSuffix({shouldDirectRecordHaveHeaderAndFooter:l,unitId:r},a),onSuccess:()=>{c.invalidateQueries({queryKey:["unitConfig",r]}),C.success(`${t("setting.shouldDirectRecordHaveHeaderAndFooter")} ${je?t("setting.enabled"):t("setting.disabled")}`)},onError:a=>{}}),Na=a=>{s!=null&&s.id&&(pe(a),ja({id:s.id,value:a}))},{mutate:Ca,isPending:va}=b({mutationFn:({id:a,value:l})=>N.updateInternalPrefixSuffix({canRecordBeEditedByCollaborators:l,unitId:r},a),onSuccess:()=>{c.invalidateQueries({queryKey:["unitConfig",r]}),C.success(`${t("setting.canRecordBeEditedByCollaborators")} ${i?"enabled":"disabled"}`)},onError:a=>{}}),ka=a=>{s!=null&&s.id&&(w(a),Ca({id:s.id,value:a}))},{mutate:Sa,isPending:ya}=b({mutationFn:({id:a,value:l})=>N.updateInternalPrefixSuffix({canRecordHaveCollaboratorsName:l,unitId:r},a),onSuccess:()=>{c.invalidateQueries({queryKey:["unitConfig",r]}),C.success(`${t("setting.canRecordHaveCollaboratorsName")} ${A?"enabled":"disabled"}`)},onError:a=>{}}),Ra=a=>{s!=null&&s.id&&(K(a),Sa({id:s.id,value:a}))},{mutate:wa,isPending:Ia}=b({mutationFn:({id:a,value:l})=>N.updateInternalPrefixSuffix({canRecordBeEditedOnWorkflow:l,unitId:r},a),onSuccess:()=>{c.invalidateQueries({queryKey:["unitConfig",r]}),C.success(`${t("setting.canRecordBeEditedOnWorkflow")} ${de?"enabled":"disabled"}`)},onError:a=>{}}),{mutate:Aa,isPending:Ba}=b({mutationFn:({id:a,value:l})=>N.updateInternalPrefixSuffix({canIncomingAssignmentsBeSeparated:l,unitId:r},a),onSuccess:()=>{c.invalidateQueries({queryKey:["unitConfig",r]}),C.success(`${t("setting.canIncomingAssignmentsBeSeparated")} ${Ce?"enabled":"disabled"}`)},onError:a=>{}}),Pa=a=>{s!=null&&s.id&&(Ne(a),wa({id:s.id,value:a}))},Fa=a=>{s!=null&&s.id&&(oe(a),Aa({id:s.id,value:a}))},{mutate:Ua,isPending:Ea}=b({mutationFn:({id:a,value:l})=>N.updateInternalPrefixSuffix({canROReturn:l,unitId:r},a),onSuccess:()=>{c.invalidateQueries({queryKey:["unitConfig",r]}),C.success(`${t("setting.canROReturn")} ${_e?"enabled":"disabled"}`)},onError:a=>{}}),Ha=a=>{s!=null&&s.id&&(Ge(a),Ua({id:s.id,value:a}))},{mutate:Ta,isPending:La}=b({mutationFn:({id:a,value:l})=>N.updateInternalPrefixSuffix({internalMemoHasReferenceNumber:l,unitId:r},a),onSuccess:()=>{c.invalidateQueries({queryKey:["unitConfig",r]}),C.success(`${t("setting.internalMemoHasReferenceNumber")} ${Je?"enabled":"disabled"}`)},onError:a=>{}}),{mutate:Da,isPending:Ma}=b({mutationFn:({id:a,value:l})=>N.updateInternalPrefixSuffix({canInternalMemoRequirePositionBasedReferenceNumber:l,unitId:r},a),onSuccess:()=>{c.invalidateQueries({queryKey:["unitConfig",r]}),C.success(`${t("setting.canInternalMemoRequirePositionBasedReferenceNumber","Internal Memo Require Position Based Reference Number")} ${fe?"enabled":"disabled"}`)},onError:a=>{}}),$a=a=>{s!=null&&s.id&&(be(a),Da({id:s.id,value:a}))},qa=a=>{s!=null&&s.id&&(Xe(a),Ta({id:s.id,value:a}))},{mutate:Wa,isPending:Oa}=b({mutationFn:({id:a,value:l})=>N.updateInternalPrefixSuffix({isMultipleDelegationAllowed:l,unitId:r},a),onSuccess:()=>{c.invalidateQueries({queryKey:["unitConfig",r]}),C.success(`${t("setting.isMultipleDelegationAllowed","Multiple Delegation Allowed")} ${Ze?"enabled":"disabled"}`)},onError:a=>{}}),Ka=a=>{s!=null&&s.id&&(et(a),Wa({id:s.id,value:a}))},{mutate:Qa,isPending:za}=b({mutationFn:({id:a,value:l})=>N.updateInternalPrefixSuffix({attachSignatureOnAttachment:l,unitId:r},a),onSuccess:()=>{c.invalidateQueries({queryKey:["unitConfig",r]}),C.success(`${t("setting.attachSignatureOnAttachment","Attach Signature On Attachment")} ${tt?"enabled":"disabled"}`)},onError:a=>{}}),Ya=a=>{s!=null&&s.id&&(at(a),Qa({id:s.id,value:a}))},{mutate:nt,isPending:qe}=b({mutationFn:a=>N.createInternalPrefixSuffix({unitId:a}),onSuccess:()=>{c.invalidateQueries({queryKey:["unitConfig",r]})},onError:a=>{}});return d.useEffect(()=>{!s&&!ye&&!Re&&r&&!qe&&nt(r)},[s,ye,Re,r,qe,nt]),e.jsxs("div",{className:Ls,children:[e.jsxs("div",{className:"mb-5 flex flex-col gap-4 border-b border-slate-200 pb-4 dark:border-slate-700 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("h1",{className:"flex items-center gap-2 text-2xl font-bold text-slate-900 sm:text-3xl dark:text-slate-100",children:[e.jsx(Te,{className:"h-8 w-8 text-primary"}),t("setting.title1")]}),e.jsx("p",{className:"text-sm text-slate-600 dark:text-slate-400",children:t("setting.title2")})]}),e.jsx("div",{className:"w-full sm:ml-auto sm:w-auto",children:e.jsxs(Z,{value:r,onValueChange:a=>I(a),children:[e.jsx(ee,{className:"h-10 w-full bg-white/90 dark:border-slate-700 dark:bg-slate-900 sm:w-56",children:e.jsx(te,{placeholder:"Select a unit"})}),e.jsx(ae,{className:"dark:border-slate-700 dark:bg-slate-900",children:R?e.jsx(f,{value:"loading",disabled:!0,children:t("setting.loading")}):((ct=(ot=u==null?void 0:u.data)==null?void 0:ot.items)==null?void 0:ct.length)>0?(mt=(ut=u==null?void 0:u.data)==null?void 0:ut.items)==null?void 0:mt.map(a=>e.jsx(f,{value:a.id,children:B(a.name)},a.id)):e.jsx(f,{value:"no-units",disabled:!0,children:t("setting.noUnit")})})]})})]}),e.jsxs("div",{className:"space-y-3",children:[ye&&e.jsx("p",{className:"text-sm text-slate-600 dark:text-slate-300",children:"Loading configuration..."}),Re&&e.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",children:"Failed to load configuration"}),!s&&!ye&&!Re&&e.jsx("p",{className:"text-sm text-slate-600 dark:text-slate-300",children:qe?t("setting.preparingDefaults","Preparing default configuration..."):t("setting.loading","Loading...")}),s&&e.jsx("div",{className:"max-h-128 overflow-x-auto overflow-y-auto rounded-xl border border-slate-200 bg-white/90 dark:border-slate-700 dark:bg-slate-900/70",children:e.jsxs(ze,{children:[e.jsx(Ye,{className:"sticky top-0 z-10 bg-white/95 backdrop-blur dark:bg-slate-900/95",children:e.jsxs(p,{className:"dark:border-slate-700",children:[e.jsx(T,{className:"text-slate-600 dark:text-slate-300",children:t("setting.Name")}),e.jsx(T,{className:"text-slate-600 dark:text-slate-300",children:t("setting.Value")}),e.jsx(T,{className:"text-right text-slate-600 dark:text-slate-300",children:t("setting.Action")})]})}),e.jsxs(Ve,{children:[e.jsxs(p,{className:"dark:border-slate-700",children:[e.jsx(n,{className:"font-medium text-slate-900 dark:text-slate-100",children:t("setting.title3")}),e.jsx(n,{className:"text-slate-700 dark:text-slate-300",children:s.positionScopeToFetch}),e.jsx(n,{className:"text-right",children:e.jsx(U,{onClick:Qt,variant:"outline",size:"sm",className:"dark:border-slate-700 dark:bg-slate-900 dark:hover:bg-slate-800",children:e.jsx(vt,{className:"h-4 w-4"})})})]}),e.jsxs(p,{className:"dark:border-slate-700",children:[e.jsx(n,{className:"font-medium text-slate-900 dark:text-slate-100",children:t("setting.title5")}),e.jsx(n,{className:"text-slate-700 dark:text-slate-300",children:s.forwardWithTeeterSignature?"Yes":"No"}),e.jsx(n,{className:"text-right",children:e.jsx(g,{id:"add-teeter-assign",checked:X,onCheckedChange:Yt,disabled:Wt})})]}),e.jsxs(p,{className:"dark:border-slate-700",children:[e.jsx(n,{className:"font-medium text-slate-900 dark:text-slate-100",children:t("setting.title6")}),e.jsx(n,{className:"text-slate-700 dark:text-slate-300",children:s.waitAllCollaboratorsBeforeAction?"Yes":"No"}),e.jsx(n,{className:"text-right",children:e.jsx(g,{id:"wait-for-all-collaborators-before-action",checked:W,onCheckedChange:Xt,disabled:Kt})})]}),e.jsxs(p,{children:[e.jsx(n,{className:"font-medium",children:t("setting.canAssignCustomReferenceNumber","Can Assign Custom Reference Number")}),e.jsx(n,{children:s.canAssignCustomReferenceNumber?"Yes":"No"}),e.jsx(n,{className:"text-right",children:e.jsx(g,{id:"can-assign-custom-reference-number",checked:F,onCheckedChange:Vt,disabled:Ut})})]}),e.jsxs(p,{children:[e.jsx(n,{className:"font-medium",children:t("setting.canUseNewInternalMemoFormat","New Internal Memo Format")}),e.jsx(n,{children:s.canInternalMemosHaveSenderInformation?"Yes":"No"}),e.jsx(n,{className:"text-right",children:e.jsx(g,{id:"can-use-new-internal-memo-format",checked:$,onCheckedChange:_t,disabled:Ht})})]}),$&&e.jsxs(p,{children:[e.jsx(n,{className:"font-medium",children:t("setting.recordSenderInformationScope","Record Sender Information Scope")}),e.jsx(n,{children:s.recordSenderInformationScope||"NAME"}),e.jsx(n,{className:"text-right",children:e.jsxs(Z,{value:V,onValueChange:a=>na(a),disabled:Pt,children:[e.jsx(ee,{className:"w-40 dark:border-slate-700 dark:bg-slate-900",children:e.jsx(te,{})}),e.jsxs(ae,{className:"dark:border-slate-700 dark:bg-slate-900",children:[e.jsx(f,{value:le.NAME,children:"Name"}),e.jsx(f,{value:le.SIGNATURE,children:"Signature"}),e.jsx(f,{value:le.STAMP,children:"Stamp"}),e.jsx(f,{value:le.NAME_AND_SIGNATURE,children:"Name & Signature"}),e.jsx(f,{value:le.NAME_AND_STAMP,children:"Name & Stamp"}),e.jsx(f,{value:le.ALL,children:"All"})]})]})})]}),e.jsxs(p,{children:[e.jsx(n,{className:"font-medium",children:t("setting.canRecordDateLabelHasLocalization","Does Record Date Label Have Localization?")}),e.jsx(n,{children:s.canRecordDateLabelHasLocalization?"Yes":"No"}),e.jsx(n,{className:"text-right",children:e.jsx(g,{id:"can-record-date-label-has-localization",checked:J,onCheckedChange:Gt,disabled:Lt})})]}),e.jsxs(p,{children:[e.jsx(n,{className:"font-medium",children:t("setting.canRecordDateHaveTime","Record Date Can Have Time")}),e.jsx(n,{children:s.canRecordDateHaveTime?"Yes":"No"}),e.jsx(n,{className:"text-right",children:e.jsx(g,{id:"can-record-date-have-time",checked:y,onCheckedChange:Jt,disabled:Mt})})]}),e.jsxs(p,{children:[e.jsx(n,{className:"font-medium",children:t("setting.canCreateDirectRecord")}),e.jsx(n,{children:s.canCreateDirectRecord?t("common.yes"):t("common.no")}),e.jsx(n,{className:"text-right",children:e.jsx(g,{id:"can-create-direct-record",checked:ce,onCheckedChange:ua,disabled:ca})})]}),e.jsxs(p,{children:[e.jsx(n,{className:"font-medium",children:t("setting.canPositionBasedRecordsBeCreated")}),e.jsx(n,{children:s.canPositionBasedRecordsBeCreated?t("common.yes"):t("common.no")}),e.jsx(n,{className:"text-right",children:e.jsx(g,{id:"can-position-based-records-be-created",checked:me,onCheckedChange:ha,disabled:xa})})]}),e.jsxs(p,{children:[e.jsx(n,{className:"font-medium",children:t("setting.canPositionBasedReferenceBeUsedForAllTypes")}),e.jsx(n,{children:s.canPositionBasedReferenceBeUsedForAllTypes?t("common.yes"):t("common.no")}),e.jsx(n,{className:"text-right",children:e.jsx(g,{id:"can-position-based-reference-be-used-for-all-types",checked:he,onCheckedChange:ba,disabled:fa})})]}),e.jsxs(p,{children:[e.jsx(n,{className:"font-medium",children:t("setting.canInternalMemoRequirePositionBasedReferenceNumber","Internal Memo Require Position Based Reference Number")}),e.jsx(n,{children:s.canInternalMemoRequirePositionBasedReferenceNumber?"Yes":"No"}),e.jsx(n,{className:"text-right",children:e.jsx(g,{id:"can-internal-memo-require-position-based-reference-number",checked:fe,onCheckedChange:$a,disabled:Ma})})]}),e.jsxs(p,{children:[e.jsx(n,{className:"font-medium",children:t("setting.shouldDirectRecordHaveHeaderAndFooter")}),e.jsx(n,{children:s.shouldDirectRecordHaveHeaderAndFooter?t("common.yes"):t("common.no")}),e.jsx(n,{className:"text-right",children:e.jsx(g,{id:"should-direct-record-have-header-and-footer",checked:je,onCheckedChange:Na,disabled:pa})})]}),e.jsxs(p,{children:[e.jsx(n,{className:"font-medium",children:t("setting.shouldCollaboratorAlwaysSign")}),e.jsx(n,{children:s.shouldCollaboratorAlwaysSign?"Yes":"No"}),e.jsx(n,{className:"text-right",children:e.jsx(g,{id:"should-collaborator-always-sign",checked:j,onCheckedChange:sa,disabled:ea})})]}),e.jsxs(p,{children:[e.jsx(n,{className:"font-medium",children:t("setting.shouldIncludeForYourReferenceInCC")}),e.jsx(n,{children:s.shouldIncludeForYourReferenceInCC?"Yes":"No"}),e.jsx(n,{className:"text-right",children:e.jsx(g,{id:"should-include-for-your-reference",checked:re,onCheckedChange:ia,disabled:aa})})]}),e.jsxs(p,{children:[e.jsx(n,{className:"font-medium",children:t("setting.canCollaborationBeCreatedForAll")}),e.jsx(n,{children:s.canCollaborationBeCreatedForAll?"Yes":"No"}),e.jsx(n,{className:"text-right",children:e.jsx(g,{id:"can-collaboration-be-created-for-all",checked:ke,onCheckedChange:da,disabled:la})})]}),e.jsxs(p,{children:[e.jsx(n,{className:"font-medium",children:t("setting.canRecordBeEditedByCollaborators")}),e.jsx(n,{children:s.canRecordBeEditedByCollaborators?"Yes":"No"}),e.jsx(n,{className:"text-right",children:e.jsx(g,{id:"can-record-be-edited-by-collaborators",checked:i,onCheckedChange:ka,disabled:va})})]}),e.jsxs(p,{children:[e.jsx(n,{className:"font-medium",children:t("setting.canRecordHaveCollaboratorsName")}),e.jsx(n,{children:s.canRecordHaveCollaboratorsName?"Yes":"No"}),e.jsx(n,{className:"text-right",children:e.jsx(g,{id:"can-record-have-collaborators-name",checked:A,onCheckedChange:Ra,disabled:ya})})]}),e.jsxs(p,{children:[e.jsx(n,{className:"font-medium",children:t("setting.canRecordBeEditedOnWorkflow")}),e.jsx(n,{children:s.canRecordBeEditedOnWorkflow?"Yes":"No"}),e.jsx(n,{className:"text-right",children:e.jsx(g,{id:"can-record-be-edited-on-workflow",checked:de,onCheckedChange:Pa,disabled:Ia})})]}),e.jsxs(p,{children:[e.jsx(n,{className:"font-medium",children:t("setting.canIncomingAssignmentsBeSeparated")}),e.jsx(n,{children:s.canIncomingAssignmentsBeSeparated?"Yes":"No"}),e.jsx(n,{className:"text-right",children:e.jsx(g,{id:"can-incoming-assignements-be-separated",checked:Ce,onCheckedChange:Fa,disabled:Ba})})]}),e.jsxs(p,{children:[e.jsx(n,{className:"font-medium",children:t("setting.canROReturn")}),e.jsx(n,{children:s.canROReturn?"Yes":"No"}),e.jsx(n,{className:"text-right",children:e.jsx(g,{id:"can-ro-return",checked:_e,onCheckedChange:Ha,disabled:Ea})})]}),e.jsxs(p,{children:[e.jsx(n,{className:"font-medium",children:t("setting.internalMemoHasReferenceNumber")}),e.jsx(n,{children:s.internalMemoHasReferenceNumber?"Yes":"No"}),e.jsx(n,{className:"text-right",children:e.jsx(g,{id:"internal-memo-has-reference-number",checked:Je,onCheckedChange:qa,disabled:La})})]}),e.jsxs(p,{children:[e.jsx(n,{className:"font-medium",children:t("setting.isMultipleDelegationAllowed","Multiple Delegation Allowed")}),e.jsx(n,{children:s.isMultipleDelegationAllowed?"Yes":"No"}),e.jsx(n,{className:"text-right",children:e.jsx(g,{id:"is-multiple-delegation-allowed",checked:Ze,onCheckedChange:Ka,disabled:Oa})})]}),e.jsxs(p,{children:[e.jsx(n,{className:"font-medium",children:t("setting.attachSignatureOnAttachment","Attach Signature On Attachment")}),e.jsx(n,{children:s.attachSignatureOnAttachment?"Yes":"No"}),e.jsx(n,{className:"text-right",children:e.jsx(g,{id:"attach-signature-on-attachment",checked:tt,onCheckedChange:Ya,disabled:za})})]}),e.jsxs(p,{children:[e.jsx(n,{className:"font-medium",children:t("setting.canHaveTagBasedReferenceNumber","Can Have Tag Based Reference Number")}),e.jsx(n,{children:s.canHaveTagBasedReferenceNumber?"Yes":"No"}),e.jsx(n,{className:"text-right",children:e.jsx(g,{id:"can-have-tag-based-reference-number",checked:se,onCheckedChange:St,disabled:wt})})]}),e.jsxs(p,{children:[e.jsx(n,{className:"font-medium",children:t("setting.canUserSkipLevel","User Can Skip Level")}),e.jsx(n,{children:s.canUserSkipLevel?"Yes":"No"}),e.jsx(n,{className:"text-right",children:e.jsx(g,{id:"can-user-skip-level",checked:M,onCheckedChange:yt,disabled:At})})]})]})]})})]}),e.jsx(Ae,{open:P,onOpenChange:v,children:e.jsxs(Be,{className:"dark:border-slate-700 dark:bg-slate-900",children:[e.jsxs(Pe,{children:[e.jsx(Fe,{className:"dark:text-slate-100",children:t("setting.editTitle")}),e.jsx(Nt,{className:"dark:text-slate-400",children:t("setting.editMsg")})]}),e.jsx("div",{className:"my-4",children:e.jsxs(Z,{value:k,onValueChange:a=>h(a),children:[e.jsx(ee,{className:"w-full dark:border-slate-700 dark:bg-slate-900",children:e.jsx(te,{placeholder:"Select scope"})}),e.jsx(ae,{className:"dark:border-slate-700 dark:bg-slate-900",children:kt.map(a=>e.jsx(f,{value:a,children:a.replace(/_/g," ").toUpperCase()},a))})]})}),e.jsxs(Ct,{className:"flex justify-end gap-2",children:[e.jsx(U,{variant:"secondary",onClick:()=>v(!1),className:"dark:bg-slate-800 dark:text-slate-100 dark:hover:bg-slate-700",children:t("common.Cancel")}),e.jsx(U,{onClick:zt,disabled:st,className:"bg-primary hover:bg-primary/90 text-primary-foreground",children:st?t("contentManagement.saving"):t("delegation.save")})]})]})})]})},Ms=()=>{var y,q,X,S,W;const{user:x}=Ue(),c=Ee(),Y=((q=(y=x==null?void 0:x.employee)==null?void 0:y[0])==null?void 0:q.organizationId)||"",B=He(),L=d.useId(),{getList:u}=Me(),{data:R,isLoading:r}=u(Y,{take:1e3}),[I,P]=d.useState(""),[v,k]=d.useState(null);d.useEffect(()=>{var o,j;!I&&((j=(o=R==null?void 0:R.data)==null?void 0:o.items)!=null&&j.length)&&P(R.data.items[0].id)},[I,R]);const h=((X=R==null?void 0:R.data)==null?void 0:X.items)??[],V=h.length>0,_=(S=h.find(o=>o.id===I))==null?void 0:S.name,{data:F,isLoading:G}=Qe(I),$=((W=F==null?void 0:F.data)==null?void 0:W.items)||[],m=$.find(o=>o.unitId===I)||$[0],se=!!(m!=null&&m.attachSignatureOnAttachment),D=!!(m!=null&&m.id),M=v===null?se:v;d.useEffect(()=>{k(null)},[I,se]);const{mutate:ne,isPending:J}=b({mutationFn:({id:o,value:j})=>N.updateInternalPrefixSuffix({attachSignatureOnAttachment:j,unitId:I},o),onSuccess:()=>{c.invalidateQueries({queryKey:["unitConfig",I]})},onError:()=>{k(null)}}),ie=o=>{!(m!=null&&m.id)||J||(k(o),ne({id:m.id,value:o}))};return e.jsx("section",{className:"w-full",children:e.jsx("div",{className:"relative overflow-hidden rounded-2xl border border-slate-200/80 bg-gradient-to-br from-white via-slate-50 to-slate-100/60 p-4 shadow-sm sm:p-6 dark:border-slate-700/80 dark:bg-gradient-to-br dark:from-slate-950 dark:via-slate-900 dark:to-slate-900",children:e.jsxs("div",{className:"relative space-y-5",children:[e.jsx("header",{className:"flex flex-col gap-2 border-b border-slate-200 pb-4 dark:border-slate-700 sm:flex-row sm:items-start sm:justify-between",children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{className:"inline-flex w-fit items-center gap-2 rounded-full bg-white/80 px-3 py-1 text-xs font-medium text-slate-700 ring-1 ring-slate-200 dark:bg-slate-800 dark:text-slate-300 dark:ring-slate-700",children:[e.jsx(ks,{className:"h-3.5 w-3.5"}),t("setting.attachmentSignature.badge")]}),e.jsxs("h2",{className:"text-xl font-semibold tracking-tight text-slate-900 dark:text-slate-100 sm:text-2xl flex gap-2",children:[e.jsx(Te,{className:"h-8 w-8 text-primary"}),t("setting.attachmentSignature.title")]}),e.jsx("p",{className:"max-w-2xl text-sm text-slate-600 dark:text-slate-400",children:t("setting.attachmentSignature.description")})]})}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2 rounded-xl border border-slate-200/80 bg-white/80 p-4 backdrop-blur-sm dark:border-slate-700 dark:bg-slate-900/70",children:[e.jsx(jt,{className:"text-sm font-medium text-slate-800 dark:text-slate-200",children:t("setting.attachmentSignature.unit")}),e.jsxs(Z,{value:I,onValueChange:o=>P(o),children:[e.jsx(ee,{className:"h-11 w-full bg-white/90 dark:border-slate-700 dark:bg-slate-900","aria-label":t("setting.attachmentSignature.unit"),children:e.jsx(te,{placeholder:t("setting.attachmentSignature.selectUnit")})}),e.jsx(ae,{children:r?e.jsx(f,{value:"loading",disabled:!0,children:t("setting.attachmentSignature.loadingUnits")}):V?h.map(o=>e.jsx(f,{value:o.id,children:B(o.name)},o.id)):e.jsx(f,{value:"no-units",disabled:!0,children:t("setting.attachmentSignature.noUnitsFound")})})]}),e.jsx("p",{className:"text-xs text-slate-500 dark:text-slate-400",children:t("setting.attachmentSignature.unitHint")})]}),e.jsxs("div",{className:"space-y-3 rounded-xl border border-slate-200/80 bg-white/80 p-4 backdrop-blur-sm dark:border-slate-700 dark:bg-slate-900/70",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(jt,{htmlFor:L,className:"text-sm font-medium text-slate-800 dark:text-slate-200",children:t("setting.attachmentSignature.toggleLabel")}),e.jsx("p",{id:`${L}-description`,className:"text-xs text-slate-500 dark:text-slate-400",children:t("setting.attachmentSignature.toggleDescription")})]}),e.jsx(g,{id:L,checked:M,onCheckedChange:ie,"aria-describedby":`${L}-description`,disabled:!D||G||J})]}),e.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-dashed border-slate-300/80 bg-slate-50/80 px-3 py-2 text-sm text-slate-600 dark:border-slate-700 dark:bg-slate-800/80 dark:text-slate-300",children:[e.jsx(ys,{className:"h-4 w-4 text-indigo-600 dark:text-indigo-400"}),e.jsxs("span",{children:[t("setting.attachmentSignature.status")," ",e.jsx("span",{className:"font-semibold",children:M?t("profile.enabled"):t("profile.disabled")})]})]}),!D&&!G&&e.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400",children:t("setting.noConfigFound")})]})]}),e.jsxs("footer",{className:"flex flex-wrap items-center gap-2 rounded-lg border border-slate-200/80 bg-white/70 px-3 py-2 text-xs text-slate-600 dark:border-slate-700 dark:bg-slate-900/70 dark:text-slate-300",children:[e.jsx(ts,{className:"h-3.5 w-3.5 text-slate-500 dark:text-slate-400"}),e.jsxs("span",{children:[t("setting.attachmentSignature.activeUnit")," ",e.jsx("strong",{className:"font-semibold",children:_?B(_):t("common.None")})]})]})]})})})},gn=()=>e.jsx("div",{className:"mx-auto w-full max-w-[1500px] space-y-6 p-4 sm:p-6",children:e.jsxs("div",{className:"grid grid-cols-1 gap-6 md:grid-cols-2",children:[e.jsx(Ts,{}),e.jsx(Ds,{}),e.jsx(As,{}),e.jsx(Ms,{})]})});export{gn as default};
|