PageSourceSearch

https://bizvanguard.ai/assets/ClockAlerts-BM_ml7pS.js

js bizvanguard.ai collected 2026-10-05 13:47:35 UTC 29,524 bytes, 1 lines download raw bytes

1import{u as W,r as A,j as e}from"./vendor-react-zwv87yMD.js";import{u as Ne,a as H,b as K}from"./vendor-query-DYq8g7OI.js";import{T as Re,a as Pe,b as te,c as le}from"./tabs-Dd8Qm6LV.js";import{B as k}from"./button-DlBDuKbo.js";import{I as p}from"./input-C9cRIRX4.js";import{L as x}from"./label-CSUA9GMO.js";import{S as V}from"./switch-DcU2Tpfn.js";import{B as T}from"./badge-QivbhJml.js";import{T as He}from"./textarea-CfTUtQow.js";import{C as P,a as qe,b as Ge,d as J,c as Ke}from"./card-CzWdebcx.js";import{T as be,a as fe,b as Y,c as g,d as ye,e as N}from"./table-BLRYsg93.js";import{D as Ae,a as ve,b as ke,c as Se,d as Ce}from"./dialog-CCoQRIQ_.js";import{A as Ve,a as Ue,b as $e,c as Qe,d as Be,e as ze,f as Je,g as Ye}from"./alert-dialog-P2RRIvov.js";import{S as re,a as ce,c as ne,d as D,b as Te}from"./select-D2pLZtG9.js";import{a as I,c as We}from"./api-client-wl3SCNAO.js";import{e as we}from"./employees-BPFguWOi.js";import{u as he,f as Ze}from"./authStore-Bv6p2Ne2.js";import{aM as Ee,B as Oe,w as R,av as ie,j as oe,n as de,a0 as Ie,ap as Fe,aq as ae,_ as me,ao as Xe,v as es,c as ue,T as ss,X as ts}from"./vendor-icons-bLSWzydc.js";import"./vendor-charts-CtrTLS4K.js";import"./vendor-i18n-BdYkS11p.js";import"./vendor-ui-CfDMlrKu.js";import"./vendor-pdf-DQuePnfN.js";import"./vendor-state-ByI9XJey.js";import"./vendor-editor-C_dhmuey.js";import"./utils-BXSzAfFa.js";import"./i18n-CwjSIy0a.js";async function ls(){return(await I.get("/clock-alerts/job-sites")).data}async function as(s){return(await I.post("/clock-alerts/job-sites",s)).data}async function rs(s,o){return(await I.patch(`/clock-alerts/job-sites/${s}`,o)).data}async function cs(s){await I.delete(`/clock-alerts/job-sites/${s}`)}async function ns(s,o){return(await I.patch(`/clock-alerts/job-sites/${s}/employees`,{employeeIds:o})).data}async function is(){return(await I.get("/clock-alerts/configs")).data}async function os(s,o){return(await I.patch(`/clock-alerts/configs/${s}`,o)).data}async function ds(s){return(await I.get("/clock-alerts/logs",{params:s})).data}const ms={LATE_CLOCK_IN:"Late Clock-In",MISSING_CLOCK_OUT:"Missing Clock-Out",NO_SHOW:"No-Show",GEOFENCE_VIOLATION:"Geofence Violation",EARLY_CLOCK_OUT:"Early Clock-Out",OVERTIME_APPROACHING:"Overtime Approaching"},us={LATE_CLOCK_IN:{minutes:15},MISSING_CLOCK_OUT:{minutes:30},NO_SHOW:{},GEOFENCE_VIOLATION:{miles:.5},EARLY_CLOCK_OUT:{minutes:60},OVERTIME_APPROACHING:{hours:7.5}},ge={LATE_CLOCK_IN:e.jsx(R,{className:"h-5 w-5"}),MISSING_CLOCK_OUT:e.jsx(R,{className:"h-5 w-5"}),NO_SHOW:e.jsx(ss,{className:"h-5 w-5"}),GEOFENCE_VIOLATION:e.jsx(me,{className:"h-5 w-5"}),EARLY_CLOCK_OUT:e.jsx(R,{className:"h-5 w-5"}),OVERTIME_APPROACHING:e.jsx(R,{className:"h-5 w-5"})};function hs(){var y,v,B;const{t:s}=W("reports"),o=Ne(),{permissions:h,currentOrganizationId:m}=he(),S=h.includes("MANAGE_ORGANIZATION_SETTINGS"),[d,F]=A.useState(null),[b,u]=A.useState({}),{data:r=[],isLoading:j}=H({queryKey:["alert-configs",m],queryFn:is,enabled:!!m,staleTime:300*1e3,gcTime:1200*1e3}),{data:L=[]}=H({queryKey:["members",m],queryFn:Ze,enabled:!!m,staleTime:300*1e3,gcTime:1200*1e3}),w=K({mutationFn:({alertType:l,dto:c})=>os(l,c),onSuccess:()=>{o.invalidateQueries({queryKey:["alert-configs"]}),F(null)}}),U=l=>{S&&w.mutate({alertType:l.alertType,dto:{enabled:!l.enabled}})},$=l=>{F(l),u({enabled:l.enabled,thresholdMinutes:l.thresholdMinutes??void 0,thresholdMiles:l.thresholdMiles??void 0,thresholdHours:l.thresholdHours??void 0,enableSms:l.enableSms,enableEmail:l.enableEmail,recipients:l.recipients||[]})},E=()=>{F(null),u({})},_=()=>{d&&w.mutate({alertType:d.alertType,dto:b})},Q=l=>{const c={type:l};u(n=>({...n,recipients:[...n.recipients||[],c]}))},M=(l,c)=>{u(n=>({...n,recipients:(n.recipients||[]).map((O,q)=>q===l?{...O,...c}:O)}))},i=l=>{u(c=>({...c,recipients:(c.recipients||[]).filter((n,O)=>O!==l)}))},f=l=>l.alertType==="GEOFENCE_VIOLATION"?s("clockAlerts.threshold.miles",{value:l.thresholdMiles??.5}):l.alertType==="OVERTIME_APPROACHING"?s("clockAlerts.threshold.hours",{value:l.thresholdHours??7.5}):l.alertType==="NO_SHOW"?s("clockAlerts.threshold.na"):s("clockAlerts.threshold.minutes",{value:l.thresholdMinutes??0});return j?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground",children:s("clockAlerts.config.intro")}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:r.map(l=>{var c;
1return e.jsxs(P,{className:`cursor-pointer transition-all ${l.enabled?"ring-2 ring-primary/50":"opacity-75"}`,onClick:()=>S&&$(l),children:[e.jsx(qe,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`p-2 rounded-lg ${l.enabled?"bg-primary/10 text-primary":"bg-muted text-muted-foreground"}`,children:ge[l.alertType]}),e.jsx(Ge,{className:"text-base",children:s(`clockAlerts.alertTypes.${l.alertType}.label`)})]}),e.jsx(V,{checked:l.enabled,onCheckedChange:()=>U(l),onClick:n=>n.stopPropagation(),disabled:!S})]})}),e.jsxs(J,{children:[e.jsx(Ke,{className:"text-sm mb-3",children:s(`clockAlerts.alertTypes.${l.alertType}.description`)}),e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:s("clockAlerts.card.threshold")}),e.jsx("span",{className:"font-medium",children:f(l)})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:s("clockAlerts.card.channels")}),e.jsxs("div",{className:"flex items-center gap-2",children:[l.enableSms&&e.jsxs(T,{variant:"outline",className:"text-xs",children:[e.jsx(ie,{className:"h-3 w-3 mr-1"}),"SMS"]}),l.enableEmail&&e.jsxs(T,{variant:"outline",className:"text-xs",children:[e.jsx(oe,{className:"h-3 w-3 mr-1"}),"Email"]}),!l.enableSms&&!l.enableEmail&&e.jsx("span",{className:"text-muted-foreground",children:s("clockAlerts.card.none")})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:s("clockAlerts.card.recipients")}),e.jsx("span",{className:"font-medium",children:s("clockAlerts.card.recipientsCount",{count:((c=l.recipients)==null?void 0:c.length)||0})})]})]})]})]},l.id)})}),e.jsx(Ae,{open:!!d,onOpenChange:()=>E(),children:e.jsxs(ve,{className:"sm:max-w-[550px] max-h-[90vh] overflow-y-auto",children:[e.jsx(ke,{children:e.jsxs(Se,{className:"flex items-center gap-2",children:[d&&ge[d.alertType],d&&s(`clockAlerts.alertTypes.${d.alertType}.label`)]})}),d&&e.jsxs("div",{className:"space-y-6 py-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(x,{children:s("clockAlerts.edit.enableAlert")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s("clockAlerts.edit.enableAlertHint")})]}),e.jsx(V,{checked:b.enabled,onCheckedChange:l=>u(c=>({...c,enabled:l}))})]}),d.alertType!=="NO_SHOW"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{children:s(`clockAlerts.alertTypes.${d.alertType}.threshold`)}),d.alertType==="GEOFENCE_VIOLATION"?e.jsx(p,{type:"number",step:"0.1",min:"0.1",value:b.thresholdMiles??"",onChange:l=>u(c=>({...c,thresholdMiles:parseFloat(l.target.value)||void 0})),placeholder:"0.5"}):d.alertType==="OVERTIME_APPROACHING"?e.jsx(p,{type:"number",step:"0.5",min:"1",value:b.thresholdHours??"",onChange:l=>u(c=>({...c,thresholdHours:parseFloat(l.target.value)||void 0})),placeholder:"7.5"}):e.jsx(p,{type:"number",min:"1",value:b.thresholdMinutes??"",onChange:l=>u(c=>({...c,thresholdMinutes:parseInt(l.target.value)||void 0})),placeholder:String(((y=us[d.alertType])==null?void 0:y.minutes)??15)})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(x,{children:s("clockAlerts.edit.channels")}),e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(V,{id:"enableSms",checked:b.enableSms,onCheckedChange:l=>u(c=>({...c,enableSms:l}))}),e.jsxs(x,{htmlFor:"enableSms",className:"flex items-center gap-1",children:[e.jsx(ie,{className:"h-4 w-4"}),"SMS"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(V,{id:"enableEmail",checked:b.enableEmail,onCheckedChange:l=>u(c=>({...c,enableEmail:l}))}),e.jsxs(x,{htmlFor:"enableEmail",className:"flex items-center gap-1",children:[e.jsx(oe,{className:"h-4 w-4"}),"Email"]})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(x,{children:s("clockAlerts.edit.recipients")}),e.jsxs(re,{onValueChange:l=>Q(l),children:[e.jsxs(ce,{className:"w-[180px]",children:[e.jsx(de,{className:"h-4 w-4 mr-2"}),s("clockAlerts.edit.addRecipient")]}),e.jsxs(ne,{children:[e.jsx(D,{value:"ADMIN",children:s("clockAlerts.recipient.allAdmins")}),e.jsx(D,{value:"SPECIFIC_USER",children:s("clockAlerts.recipient.specificUser")}),e.jsx(D,{value:"SPECIFIC_EMAIL",children:s("clockAlerts.recipient.emailAddress")}),e.jsx(D,{value:"SPECIFIC_PHONE",children:s("clockAlerts.recipient.phoneNumber")})]})]})]}),(((v=b.recipients)==null?void 0:v.length)??0)===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4 border rounded-lg",children:s("clockAlerts.edit.noRecipients")}):e.jsx("div",{className:"space-y-2",children:(B=b.recipients)==null?void 0:B.map((l,c)=>e.jsxs("div",{className:"flex items-center gap-2 p-2 border rounded-lg",children:[l.type==="ADMIN"&&e.jsxs("div",{className:"flex-1 flex items-center gap-2",children:[e.jsx(Ie,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{children:s("clockAlerts.recipient.allOrgAdmins")})]}),l.type==="SPECIFIC_USER"&&e.jsx("div",{className:"flex-1",children:e.jsxs(re,{value:l.userId||"",onValueChange:n=>M(c,{userId:n}),children:[e.jsx(ce,{children:e.jsx(Te,{placeholder:s("clockAlerts.recipient.selectUser")})}),e.jsx(ne,{children:L.map(n=>e.jsxs(D,{value:n.id,children:[n.firstName," ",n.lastName]},n.id))})]})}),l.type==="SPECIFIC_EMAIL"&&e.jsx("div",{className:"flex-1",children:e.jsx(p,{type:"email",placeholder:"[email protected]",value:l.email||"",onChange:n=>M(c,{email:n.target.value})})}),l.type==="SPECIFIC_PHONE"&&e.jsx("div",{className:"flex-1",children:e.jsx(p,{type:"tel",placeholder:"+1234567890",value:l.phoneNumber||"",onChange:n=>M(c,{phoneNumber:n.target.value})})}),e.jsx(k,{type:"button",variant:"ghost",size:"icon",onClick:()=>i(c),children:e.jsx(Fe,{className:"h-4 w-4 text-destructive"})})]},c))})]})]}),e.jsxs(Ce,{children:[e.jsx(k,{variant:"outline",onClick:E,children:s("clockAlerts.common.cancel")}),e.jsx(k,{onClick:_,disabled:w.isPending,children:w.isPending?s("clockAlerts.common.saving"):s("clockAlerts.common.saveChanges")}
1)]})]})})]})}function xs(){const{t:s}=W("reports"),{currentOrganizationId:o}=he(),[h,m]=A.useState({}),{data:S=[],isLoading:d}=H({queryKey:["alert-logs",o,h],queryFn:()=>ds(h),staleTime:120*1e3,gcTime:600*1e3}),{data:F=[]}=H({queryKey:["employees",o],queryFn:we.getAll,staleTime:300*1e3,gcTime:1200*1e3}),b=r=>{const j=F.find(L=>L.id===r);return j?`${j.firstName} ${j.lastName}`:s("clockAlerts.logs.unknown")},u=r=>{switch(r){case"SENT":return e.jsxs(T,{variant:"outline",className:"bg-green-50 text-green-700 border-green-200",children:[e.jsx(ue,{className:"h-3 w-3 mr-1"}),s("clockAlerts.logs.status.sent")]});case"DELIVERED":return e.jsxs(T,{variant:"outline",className:"bg-blue-50 text-blue-700 border-blue-200",children:[e.jsx(ue,{className:"h-3 w-3 mr-1"}),s("clockAlerts.logs.status.delivered")]});case"FAILED":return e.jsxs(T,{variant:"outline",className:"bg-red-50 text-red-700 border-red-200",children:[e.jsx(ts,{className:"h-3 w-3 mr-1"}),s("clockAlerts.logs.status.failed")]});default:return e.jsxs(T,{variant:"outline",className:"bg-yellow-50 text-yellow-700 border-yellow-200",children:[e.jsx(R,{className:"h-3 w-3 mr-1"}),s("clockAlerts.logs.status.pending")]})}};return e.jsxs("div",{className:"space-y-4",children:[e.jsx(P,{children:e.jsx(J,{className:"py-4",children:e.jsxs("div",{className:"flex flex-wrap items-end gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(x,{className:"text-xs text-muted-foreground",children:s("clockAlerts.logs.alertType")}),e.jsxs(re,{value:h.alertType||"all",onValueChange:r=>m(j=>({...j,alertType:r==="all"?void 0:r})),children:[e.jsx(ce,{className:"w-[200px]",children:e.jsx(Te,{placeholder:s("clockAlerts.logs.allTypes")})}),e.jsxs(ne,{children:[e.jsx(D,{value:"all",children:s("clockAlerts.logs.allTypes")}),Object.keys(ms).map(r=>e.jsx(D,{value:r,children:s(`clockAlerts.alertTypes.${r}.label`)},r))]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(x,{className:"text-xs text-muted-foreground",children:s("clockAlerts.logs.startDate")}),e.jsx(p,{type:"date",value:h.startDate||"",onChange:r=>m(j=>({...j,startDate:r.target.value||void 0})),className:"w-[160px]"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(x,{className:"text-xs text-muted-foreground",children:s("clockAlerts.logs.endDate")}),e.jsx(p,{type:"date",value:h.endDate||"",onChange:r=>m(j=>({...j,endDate:r.target.value||void 0})),className:"w-[160px]"})]}),e.jsx(k,{variant:"outline",onClick:()=>m({}),disabled:Object.keys(h).length===0,children:s("clockAlerts.logs.clearFilters")})]})})}),d?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):S.length===0?e.jsx(P,{children:e.jsxs(J,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(Ee,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("p",{className:"text-lg font-medium",children:s("clockAlerts.logs.empty")}),e.jsx("p",{className:"text-muted-foreground text-center max-w-md mt-1",children:Object.keys(h).length>0?s("clockAlerts.logs.emptyFiltered"):s("clockAlerts.logs.emptyDefault")})]})}):e.jsx(P,{children:e.jsxs(be,{children:[e.jsx(fe,{children:e.jsxs(Y,{children:[e.jsx(g,{children:s("clockAlerts.logs.th.dateTime")}),e.jsx(g,{children:s("clockAlerts.logs.th.alertType")}),e.jsx(g,{children:s("clockAlerts.logs.th.employee")}),e.jsx(g,{children:s("clockAlerts.logs.th.channel")}),e.jsx(g,{children:s("clockAlerts.logs.th.recipient")}),e.jsx(g,{children:s("clockAlerts.logs.th.status")}),e.jsx(g,{children:s("clockAlerts.logs.th.message")})]})}),e.jsx(ye,{children:S.map(r=>e.jsxs(Y,{children:[e.jsx(N,{className:"whitespace-nowrap",children:We(r.createdAt)}),e.jsx(N,{children:e.jsx(T,{variant:"secondary",children:s(`clockAlerts.alertTypes.${r.alertType}.label`)})}),e.jsx(N,{children:b(r.employeeId)}),e.jsx(N,{children:e.jsxs(T,{variant:"outline",className:"capitalize",children:[r.channel==="sms"?e.jsx(ie,{className:"h-3 w-3 mr-1"}):e.jsx(oe,{className:"h-3 w-3 mr-1"}),r.channel]})}),e.jsx(N,{className:"max-w-[150px] truncate",title:r.recipientValue,children:r.recipientValue}),e.jsx(N,{children:u(r.status)}),e.jsx(N,{className:"max-w-[200px]",children:e.jsx("p",{className:"truncate text-sm text-muted-foreground",title:r.message,children:r.message})})]},r.id))})]})})]})}function js(){var pe;const{t:s}=W("reports"),o=Ne(),{permissions:h,currentOrganizationId:m}=he(),S=h.includes("MANAGE_ORGANIZATION_SETTINGS"),[d,F]=A.useState(""),[b,u]=A.useState(!1),[r,j]=A.useState(null),[L,w]=A.useState(null),[U,$]=A.useState(!1),[E,_]=A.useState([]),[Q,M]=A.useState(""),[i,f]=A.useState({name:"",address:"",latitude:0,longitude:0,geofenceRadiusMiles:.5,isActive:!0,notes:""}),[y,v]=A.useState({}),B=async()=>{var t;if(!((t=i.address)!=null&&t.trim())){v(a=>({...a,address:s("clockAlerts.jobSites.errors.enterAddress")}));return}$(!0),v(a=>({...a,coordinates:"",address:""}));try{const a=await fetch(`https://nominatim.openstreetmap.org/search?format=json&q=${encodeURIComponent(i.address)}&limit=1`,{headers:{"User-Agent":"SchedulerApp/1.0"}});if(!a.ok)throw new Error("Geocoding request failed");const C=await a.json();if(C.length===0){v(se=>({...se,address:s("clockAlerts.jobSites.errors.notFound")}));return}const{lat:G,lon:ee}=C[0];f(se=>({...se,latitude:parseFloat(parseFloat(G).toFixed(7)),longitude:parseFloat(parseFloat(ee).toFixed(7))}))}catch(a){console.error("Geocoding error:",a),v(C=>({...C,address:s("clockAlerts.jobSites.errors.lookupFailed")}))}finally{$(!1)}},{data:l=[],isLoading:c}=H({queryKey:["jobSites",m],queryFn:ls,staleTime:300*1e3,gcTime:1200*1e3,enabled:!!m}),{data:n=[]}=H({queryKey:["employees",m],queryFn:we.getAll,staleTime:300*1e3,gcTime:1200*1e3,enabled:!!m}),O=K({mutationFn:as,onSuccess:()=>{o.invalidateQueries({queryKey:["jobSites",m]}),X()}}),q=K({mutationFn:({id:t,data:a})=>rs(t,a),onSuccess:()=>{o.invalidateQueries({queryKey:["jobSites",m]}),X()}}),xe=K({mutationFn:cs,onSuccess:()=>{o.invalidateQueries({queryKey:["jobSites",m]}),w(null)}}),z=K({mutationFn:({id:t,employeeIds:a})=>ns(t,a),onSuccess:()=>{o.invalidateQueries({queryKey:["jobSites",m]}),o.invalidateQueries({queryKey:["employees",m]})}}),Z=t=>{var a;v({}),M(""),t?(j(t),f({name:t.name,address:t.address||"",latitude:t.latitude,longitude:t.longitude,geofenceRadiusMiles:t.geofenceRadiusMiles,isActive:t.isActive,notes:t.notes||""}),_(((a=t.employees)==null?void 0:a.map(C=>C.id))||[])):(j(null),f({name:"",address:"",latitude:0,longitude:0,geofenceRadiusMiles:.5,isActive:!0,notes:""}),_([])),u(!0)},X=()=>{u(!1),j(null),v({}),_([]),M("")},Le=()=>{const t={};return i.name.trim()||(t.name=s("clockAlerts.jobSites.errors.nameRequired")),i.latitude===0&&i.longitude===0&&(t.coordinates=s("clockAlerts.jobSites.errors.coordsRequired")),(i.latitude<-90||i.latitude>90)&&(t.latitude=s("clockAlerts.jobSites.errors.latRange")),(i.longitude<-180||i.longitude>180)&&(t.longitude=s("clockAlerts.jobSites.errors.lngRange")),v(t),Object.keys(t).length===0},_e=async t=>{t.preventDefault(),Le()&&(r?q.mutate({id:r.id,data:i},{onSuccess:()=>{z.mutate({id:r.id,employeeIds:E})}}):O.mutate(i,{onSuccess:a=>{E.length>0&&z.mutate({id:a.id,employeeIds:E})}}))},Me=()=>{L&&xe.mutate(L)},je=l.filter(t=>{var C;const a=d.toLowerCase();return t.name.toLowerCase().includes(a)||((C=t.address)==null?void 0:C.toLowerCase().includes(a))}),De=()=>{navigator.geolocation?navigator.geolocation.getCurrentPosition(t=>{f(a=>({...a,latitude:parseFloat(t.coords.latitude.toFixed(7)),longitude:parseFloat(t.coords.longitude.toFixed(7))}))},t=>{console.error("Error getting location:",t),v(a=>({...a,coordinates:s("clockAlerts.jobSites.errors.locationUnavailable")}))}):v(t=>
1({...t,coordinates:s("clockAlerts.jobSites.errors.geoUnsupported")}))};return e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground",children:s("clockAlerts.jobSites.intro")}),e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"relative max-w-sm flex-1",children:[e.jsx(ae,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(p,{placeholder:s("clockAlerts.jobSites.searchPlaceholder"),value:d,onChange:t=>F(t.target.value),className:"pl-9"})]}),S&&e.jsxs(k,{onClick:()=>Z(),children:[e.jsx(de,{className:"mr-2 h-4 w-4"}),s("clockAlerts.jobSites.add")]})]}),c?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):je.length===0?e.jsx(P,{children:e.jsxs(J,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(Oe,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("p",{className:"text-lg font-medium",children:s("clockAlerts.jobSites.empty")}),e.jsx("p",{className:"text-muted-foreground text-center max-w-md mt-1",children:s(d?"clockAlerts.jobSites.emptySearch":"clockAlerts.jobSites.emptyDefault")}),S&&!d&&e.jsxs(k,{className:"mt-4",onClick:()=>Z(),children:[e.jsx(de,{className:"mr-2 h-4 w-4"}),s("clockAlerts.jobSites.addFirst")]})]})}):e.jsx(P,{children:e.jsxs(be,{children:[e.jsx(fe,{children:e.jsxs(Y,{children:[e.jsx(g,{children:s("clockAlerts.jobSites.th.name")}),e.jsx(g,{children:s("clockAlerts.jobSites.th.address")}),e.jsx(g,{children:s("clockAlerts.jobSites.th.coordinates")}),e.jsx(g,{className:"text-center",children:s("clockAlerts.jobSites.th.radius")}),e.jsx(g,{className:"text-center",children:s("clockAlerts.jobSites.th.employees")}),e.jsx(g,{className:"text-center",children:s("clockAlerts.jobSites.th.status")}),S&&e.jsx(g,{className:"w-[100px]",children:s("clockAlerts.jobSites.th.actions")})]})}),e.jsx(ye,{children:je.map(t=>{var a;return e.jsxs(Y,{children:[e.jsx(N,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(me,{className:"h-4 w-4 text-muted-foreground"}),t.name]})}),e.jsx(N,{className:"text-muted-foreground",children:t.address||"-"}),e.jsxs(N,{className:"font-mono text-sm text-muted-foreground",children:[Number(t.latitude).toFixed(4),", ",Number(t.longitude).toFixed(4)]}),e.jsx(N,{className:"text-center",children:s("clockAlerts.jobSites.radiusMi",{value:Number(t.geofenceRadiusMiles)})}),e.jsx(N,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(Ie,{className:"h-4 w-4 text-muted-foreground"}),((a=t._count)==null?void 0:a.employees)??0]})}),e.jsx(N,{className:"text-center",children:e.jsx("span",{className:`inline-flex items-center px-2 py-1 rounded-full text-xs font-medium ${t.isActive?"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200":"bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-200"}`,children:t.isActive?s("clockAlerts.jobSites.active"):s("clockAlerts.jobSites.inactive")})}),S&&e.jsx(N,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(k,{variant:"ghost",size:"icon",onClick:()=>Z(t),children:e.jsx(Xe,{className:"h-4 w-4"})}),e.jsx(k,{variant:"ghost",size:"icon",onClick:()=>w(t.id),children:e.jsx(Fe,{className:"h-4 w-4 text-destructive"})})]})})]},t.id)})})]})}),e.jsx(Ae,{open:b,onOpenChange:u,children:e.jsxs(ve,{className:"sm:max-w-[500px]",children:[e.jsx(ke,{children:e.jsx(Se,{children:s(r?"clockAlerts.jobSites.form.editTitle":"clockAlerts.jobSites.form.addTitle")})}),e.jsxs("form",{onSubmit:_e,children:[e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{htmlFor:"name",children:s("clockAlerts.jobSites.form.name")}),e.jsx(p,{id:"name",value:i.name,onChange:t=>f(a=>({...a,name:t.target.value})),placeholder:s("clockAlerts.jobSites.form.namePlaceholder")}),y.name&&e.jsx("p",{className:"text-sm text-destructive",children:y.name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(x,{htmlFor:"address",children:s("clockAlerts.jobSites.form.address")}),e.jsx(k,{type:"button",variant:"outline",size:"sm",onClick:B,disabled:U||!((pe=i.address)!=null&&pe.trim()),children:U?e.jsxs(e.Fragment,{children:[e.jsx(es,{className:"mr-2 h-3 w-3 animate-spin"}),s("clockAlerts.jobSites.form.lookingUp")]}):e.jsxs(e.Fragment,{children:[e.jsx(ae,{className:"mr-2 h-3 w-3"}),s("clockAlerts.jobSites.form.lookup")]})})]}),e.jsx(p,{id:"address",value:i.address,onChange:t=>f(a=>({...a,address:t.target.value})),placeholder:s("clockAlerts.jobSites.form.addressPlaceholder")}),y.address&&e.jsx("p",{className:"text-sm text-destructive",children:y.address})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(x,{children:s("clockAlerts.jobSites.form.coordinates")}),e.jsxs(k,{type:"button",variant:"outline",size:"sm",onClick:De,children:[e.jsx(me,{className:"mr-2 h-3 w-3"}),s("clockAlerts.jobSites.form.useCurrentLocation")]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(p,{type:"number",step:"any",value:i.latitude||"",onChange:t=>f(a=>({...a,latitude:parseFloat(t.target.value)||0})),placeholder:s("clockAlerts.jobSites.form.latitude")}),y.latitude&&e.jsx("p",{className:"text-sm text-destructive mt-1",children:y.latitude})]}),e.jsxs("div",{children:[e.jsx(p,{type:"number",step:"any",value:i.longitude||"",onChange:t=>f(a=>({...a,longitude:parseFloat(t.target.value)||0})),placeholder:s("clockAlerts.jobSites.form.longitude")}),y.longitude&&e.jsx("p",{className:"text-sm text-destructive mt-1",children:y.longitude})]})]}
1),y.coordinates&&e.jsx("p",{className:"text-sm text-destructive",children:y.coordinates}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("clockAlerts.jobSites.form.coordsHint")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{htmlFor:"radius",children:s("clockAlerts.jobSites.form.radius")}),e.jsx(p,{id:"radius",type:"number",step:"0.1",min:"0.1",max:"10",value:i.geofenceRadiusMiles??"",onChange:t=>f(a=>({...a,geofenceRadiusMiles:parseFloat(t.target.value)||.5})),placeholder:"0.5"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("clockAlerts.jobSites.form.radiusHint")})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(x,{htmlFor:"isActive",children:s("clockAlerts.jobSites.active")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("clockAlerts.jobSites.form.activeHint")})]}),e.jsx(V,{id:"isActive",checked:i.isActive,onCheckedChange:t=>f(a=>({...a,isActive:t}))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{htmlFor:"notes",children:s("clockAlerts.jobSites.form.notes")}),e.jsx(He,{id:"notes",value:i.notes,onChange:t=>f(a=>({...a,notes:t.target.value})),placeholder:s("clockAlerts.jobSites.form.notesPlaceholder"),rows:3})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(x,{children:s("clockAlerts.jobSites.form.assignedEmployees")}),e.jsx(T,{variant:"secondary",children:s("clockAlerts.jobSites.form.selectedCount",{count:E.length})})]}),e.jsxs("div",{className:"relative",children:[e.jsx(ae,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(p,{placeholder:s("clockAlerts.jobSites.form.searchEmployees"),value:Q,onChange:t=>M(t.target.value),className:"pl-9"})]}),e.jsx("div",{className:"border rounded-md max-h-[200px] overflow-y-auto",children:n.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:s("clockAlerts.jobSites.form.noEmployees")}):e.jsx("div",{className:"divide-y",children:n.filter(t=>{const a=Q.toLowerCase();return t.firstName.toLowerCase().includes(a)||t.lastName.toLowerCase().includes(a)}).map(t=>{const a=E.includes(t.id);return e.jsxs("label",{className:`flex items-center gap-3 px-3 py-2 cursor-pointer hover:bg-muted/50 ${a?"bg-primary/5":""}`,children:[e.jsx("input",{type:"checkbox",checked:a,onChange:C=>{C.target.checked?_(G=>[...G,t.id]):_(G=>G.filter(ee=>ee!==t.id))},className:"h-4 w-4 rounded border-gray-300 text-primary focus:ring-primary"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-sm font-medium truncate",children:[t.firstName," ",t.lastName]}),t.position&&e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:t.position})]}),a&&e.jsx(ue,{className:"h-4 w-4 text-primary flex-shrink-0"})]},t.id)})})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("clockAlerts.jobSites.form.assignHint")})]})]}),e.jsxs(Ce,{children:[e.jsx(k,{type:"button",variant:"outline",onClick:X,children:s("clockAlerts.common.cancel")}),e.jsx(k,{type:"submit",disabled:O.isPending||q.isPending||z.isPending,children:O.isPending||q.isPending||z.isPending?s("clockAlerts.common.saving"):s(r?"clockAlerts.common.saveChanges":"clockAlerts.jobSites.form.create")})]})]})]})}),e.jsx(Ve,{open:!!L,onOpenChange:()=>w(null),children:e.jsxs(Ue,{children:[e.jsxs($e,{children:[e.jsx(Qe,{children:s("clockAlerts.jobSites.deleteDialog.title")}),e.jsx(Be,{children:s("clockAlerts.jobSites.deleteDialog.description")})]}),e.jsxs(ze,{children:[e.jsx(Je,{children:s("clockAlerts.common.cancel")}),e.jsx(Ye,{onClick:Me,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:xe.isPending?s("clockAlerts.jobSites.deleteDialog.deleting"):s("clockAlerts.jobSites.deleteDialog.delete")})]})]})})]})}function Ks(){const{t:s}=W("reports"),[o,h]=A.useState("configuration");return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:s("clockAlerts.title")}),e.jsx("p",{className:"text-muted-foreground",children:s("clockAlerts.subtitle")})]}),e.jsxs(Re,{value:o,onValueChange:h,children:[e.jsxs(Pe,{children:[e.jsxs(te,{value:"configuration",className:"flex items-center gap-2",children:[e.jsx(Ee,{className:"h-4 w-4"}),s("clockAlerts.tabs.configuration")]}),e.jsxs(te,{value:"job-sites",className:"flex items-center gap-2",children:[e.jsx(Oe,{className:"h-4 w-4"}),s("clockAlerts.tabs.jobSites")]}),e.jsxs(te,{value:"logs",className:"flex items-center gap-2",children:[e.jsx(R,{className:"h-4 w-4"}),s("clockAlerts.tabs.logs")]})]}),e.jsx(le,{value:"configuration",className:"mt-6",children:e.jsx(hs,{})}),e.jsx(le,{value:"job-sites",className:"mt-6",children:e.jsx(js,{})}),e.jsx(le,{value:"logs",className:"mt-6",children:e.jsx(xs,{})})]})]})}export{Ks as default};

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.