PageSourceSearch

https://dealer-setup-wizard.emergent.host/static/js/6882.7f2264c5.chunk.js

js dealer-setup-wizard.emergent.host collected 2026-10-03 03:21:16 UTC 12,360 bytes, 2 lines download raw bytes

1"use strict";(self.webpackChunkfrontend=self.webpackChunkfrontend||[]).push([[6882],{6882(e,t,a){a.r(t),a.d(t,{default:()=>S});var s=a(5544),r=a(5043),n=a(8975),d=a(6833),i=a(5469),c=a(247),l=a(5088),o=a(9698),m=a(9493),u=a(8006),h=a(8384),x=a(614),g=a(6328),f=a(4980),p=a(5187),j=a(3390),b=a(1140),N=a(1981),v=a(8713),y=a(5598),k=a(1457),w=a(6930),_=a(579);function S(){const e=(0,w.Bd)().t,t=(0,p.A)().user,a=(0,n.Zp)(),d=(0,r.useState)([]),c=(0,s.A)(d,2),l=c[0],o=c[1],m=(0,r.useState)(""),u=(0,s.A)(m,2),x=u[0],j=u[1],b=(0,r.useState)(null),N=(0,s.A)(b,2),v=N[0],y=N[1],S=(0,r.useState)("STRICT"),R=(0,s.A)(S,2),T=R[0],I=R[1],E=(0,r.useState)(null),B=(0,s.A)(E,2),L=B[0],P=B[1],Z=(0,r.useState)([]),D=(0,s.A)(Z,2),O=D[0],F=D[1],$=(0,r.useState)(!0),W=(0,s.A)($,2),q=W[0],z=W[1],G=(0,r.useCallback)(async()=>{z(!0);try{var e;const t=await Promise.all([f.api.get("/shifts").catch(()=>({data:{}})),f.api.get("/attendance/active").catch(()=>({data:{}})),f.api.get("/attendance/mine?limit=30").catch(()=>({data:{items:[]}}))]),a=(0,s.A)(t,3),r=a[0],n=a[1],d=a[2];o(r.data.shifts||[]),y(r.data.pump||null),I(((null===(e=r.data.pump)||void 0===e?void 0:e.attendance_mode)||"STRICT").toUpperCase()),(r.data.shifts||[]).length&&j(r.data.shifts[0].id),P(n.data.attendance||null),F(d.data.items||[])}catch(t){g.oR.error((0,f.KI)(t))}finally{z(!1)}},[]);return(0,r.useEffect)(()=>{G()},[G]),(0,_.jsxs)("div",{className:"min-h-screen bg-background text-foreground","data-testid":"manager-attendance-page",children:[(0,_.jsx)("header",{className:"sticky top-0 z-40 border-b border-border bg-card/95 backdrop-blur",children:(0,_.jsxs)("div",{className:"mx-auto flex max-w-3xl items-center justify-between gap-2 px-4 py-3",children:[(0,_.jsxs)("button",{className:"flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground",onClick:()=>a("/"),"data-testid":"mgr-att-back",children:[(0,_.jsx)(i.A,{className:"h-4 w-4"})," Back"]}),(0,_.jsxs)("div",{className:"flex items-center gap-2 text-sm font-semibold",children:[(0,_.jsx)(h.A,{className:"h-4 w-4 text-primary"})," My Attendance"]}),(0,_.jsx)(k.A,{where:"manager-attendance"})]})}),(0,_.jsxs)("main",{className:"mx-auto max-w-3xl space-y-5 px-4 py-6 md:px-6",children:[q?(0,_.jsx)("div",{className:"rounded-2xl border border-border bg-card p-8 text-center text-sm text-muted-foreground",children:e("common.loading")}):L?(0,_.jsx)(A,{attendance:L,onCheckedOut:G}):(0,_.jsx)(C,{shifts:l,shiftId:x,setShiftId:j,pump:v,attendanceMode:T,onCheckedIn:G}),(0,_.jsx)(M,{history:O,you:t})]})]})}function A(e){let t=e.attendance,a=e.onCheckedOut;const n=(0,w.Bd)().t,i=(0,r.useState)(!1),c=(0,s.A)(i,2),l=c[0],o=c[1],h=new Date(t.checked_in_at),x=Math.max(0,Math.floor((Date.now()-h.getTime())/6e4));return(0,_.jsxs)(b.Zp,{className:"border-2 border-emerald-400/60 bg-emerald-50/40 dark:bg-emerald-950/20","data-testid":"mgr-att-active-card",children:[(0,_.jsx)(b.aR,{className:"pb-2",children:(0,_.jsxs)(b.ZB,{className:"flex items-center gap-2 text-lg",children:[(0,_.jsx)(d.A,{className:"h-5 w-5 text-emerald-600"}),"You're on-site"]})}),(0,_.jsxs)(b.Wu,{className:"space-y-3",children:[(0,_.jsxs)("div",{className:"grid gap-2 text-sm md:grid-cols-3",children:[(0,_.jsxs)("div",{children:[(0,_.jsx)("span",{className:"text-muted-foreground",children:"Shift \xb7 "}),(0,_.jsx)("b",{children:t.shift_name})]}),(0,_.jsxs)("div",{children:[(0,_.jsx)("span",{className:"text-muted-foreground",children:"Since \xb7 "}),(0,_.jsx)("b",{children:h.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]}),(0,_.jsxs)("div",{children:[(0,_.jsx)("span",{className:"text-muted-foreground",children:"Elapsed \xb7 "}),(0,_.jsxs)("b",{children:[Math.floor(x/60),"h ",x%60,"m"]})]})]}),null!=t.distance_m&&(0,_.jsxs)("div",{className:"text-xs text-muted-foreground",children:[(0,_.jsx)(u.A,{className:"mr-1 inline h-3.5 w-3.5"})," ~",Math.round(t.distance_m),"m from pump when you checked in"]}),(0,_.jsxs)(j.$,{variant:"destructive",onClick:async()=>{if(window.confirm("End your on-site shift now?")){o(!0);try{await f.api.post("/attendance/check-out"),g.oR.success(n("manager.myattendance.checked_out_see_you_tomorrow")),a()}catch(e){g.oR.error((0,f.KI)(e))}finally{o(!1)}}},disabled:l,"data-testid":"mgr-att-checkout",className:"w-full",children:[(0,_.jsx)(m.A,{className:"h-4 w-4"})," ",l?"Ending\u2026":"End on-site shift"]})]})]})}function C(e){let t=e.shifts,a=e.shiftId,n=e.setShiftId,d=e.pump,i=e.attendanceMode,l=e.onCheckedIn;const m=(0,w.Bd)().t,h=(0,r.useState)(null),x=(0,s.A)(h,2),p=x[0],y=x[1],k=(0,r.useState)(!1),S=(0,s.A)(k,2),A=S[0],C=S[1],M=(0,r.useState)(null),T=(0,s.A)(M,2),I=T[0],E=T[1],B=(0,r.useState)(!1),L=(0,s.A)(B,2),P=L[0],Z=L[1],D=(0,r.useState)(!1),O
1=(0,s.A)(D,2),F=O[0],$=O[1],W="OFF"===i,q=p&&null!==d&&void 0!==d&&d.latitude?Math.round(function(e,t,a,s){const r=e=>e*Math.PI/180,n=6371e3,d=r(a-e),i=r(s-t),c=Math.sin(d/2)**2+Math.cos(r(e))*Math.cos(r(a))*Math.sin(i/2)**2;return 2*n*Math.atan2(Math.sqrt(c),Math.sqrt(1-c))}(p.lat,p.lng,d.latitude,d.longitude)):null;return(0,_.jsxs)(b.Zp,{className:"border-border","data-testid":"mgr-att-checkin-card",children:[(0,_.jsxs)(b.aR,{className:"pb-3",children:[(0,_.jsxs)(b.ZB,{className:"flex items-center gap-2 text-lg",children:[(0,_.jsx)(o.A,{className:"h-5 w-5 text-amber-500"})," Start your on-site shift"]}),(0,_.jsx)("p",{className:"text-xs text-muted-foreground",children:"Same STRICT selfie + GPS as salesmen. This proves you were on-site during the shift."})]}),(0,_.jsxs)(b.Wu,{className:"space-y-4",children:[(0,_.jsxs)("div",{children:[(0,_.jsx)(N.J,{className:"text-[11px] font-semibold uppercase tracking-wider text-muted-foreground",children:m("csa.shift")}),0===t.length?(0,_.jsx)("div",{className:"mt-1 rounded-lg border border-red-200 bg-red-50 p-3 text-xs text-red-800 dark:border-red-900/60 dark:bg-red-950/40 dark:text-red-200",children:"No shifts configured. Set up shifts in Pump Setup first."}):(0,_.jsxs)(v.l6,{value:a,onValueChange:n,children:[(0,_.jsx)(v.bq,{"data-testid":"mgr-att-shift",className:"mt-1 h-11",children:(0,_.jsx)(v.yv,{})}),(0,_.jsx)(v.gC,{children:t.map(e=>(0,_.jsxs)(v.eb,{value:e.id,children:[e.name," \xb7 ",e.start_time||"","\u2013",e.end_time||""]},e.id))})]})]}),W?(0,_.jsx)("div",{className:"rounded-lg border border-emerald-300 bg-emerald-50/70 p-3 text-xs text-emerald-900 dark:border-emerald-900/60 dark:bg-emerald-950/40 dark:text-emerald-200",children:"Your dealer has disabled the STRICT selfie + GPS. Tap Start to log attendance."}):(0,_.jsx)(_.Fragment,{children:(0,_.jsxs)("div",{className:"grid gap-3 md:grid-cols-2",children:[(0,_.jsxs)("div",{className:"rounded-xl border border-border bg-card p-3",children:[(0,_.jsxs)("div",{className:"flex items-center justify-between text-xs",children:[(0,_.jsx)("span",{className:"font-semibold text-muted-foreground",children:m("setup.location")}),(0,_.jsxs)(j.$,{size:"sm",variant:"outline",onClick:()=>{if(C(!0),!navigator.geolocation)return g.oR.error(m("manager.myattendance.geolocation_not_supported")),void C(!1);navigator.geolocation.getCurrentPosition(e=>{y({lat:e.coords.latitude,lng:e.coords.longitude}),C(!1)},e=>{g.oR.error("Location error: ".concat(e.message)),C(!1)},{enableHighAccuracy:!0,timeout:1e4,maximumAge:0})},disabled:A,"data-testid":"mgr-att-loc",children:[(0,_.jsx)(u.A,{className:"h-3.5 w-3.5"})," ",A?"\u2026":p?"Refresh":"Capture"]})]}),p?(0,_.jsxs)("div",{className:"mt-2 space-y-0.5 text-[11px] font-mono",children:[(0,_.jsxs)("div",{children:[m("csa.csaportal.lat")," ",(0,_.jsx)("b",{children:p.lat.toFixed(6)})]}),(0,_.jsxs)("div",{children:[m("csa.csaportal.lng")," ",(0,_.jsx)("b",{children:p.lng.toFixed(6)})]}),null!=q&&(0,_.jsxs)("div",{className:"text-muted-foreground",children:["~",q,"m from pump"]})]}):(0,_.jsx)("div",{className:"mt-2 text-[11px] text-muted-foreground",children:m("manager.myattendance.tap_capture_to_get_your_gps")})]}),(0,_.jsxs)("div",{className:"rounded-xl border border-border bg-card p-3",children:[(0,_.jsxs)("div",{className:"flex items-center justify-between text-xs",children:[(0,_.jsx)("span",{className:"font-semibold text-muted-foreground",children:m("manager.myattendance.selfie")}),(0,_.jsxs)(j.$,{size:"sm",variant:"outline",onClick:()=>Z(!0),"data-testid":"mgr-att-cam",children:[(0,_.jsx)(c.A,{className:"h-3.5 w-3.5"})," ",I?"Retake":"Take"]})]}),I?(0,_.jsx)("img",{src:I,alt:"selfie",className:"mx-auto mt-2 h-24 w-24 rounded-lg object-cover shadow-sm"}):(0,_.jsx)("div",{className:"mt-2 text-[11px] text-muted-foreground",children:m("manager.myattendance.tap_take_to_verify_your_face")})]})]})}),(0,_.jsxs)(j.$,{className:"h-12 w-full",onClick:async()=>{if(!a)return g.oR.error(m("csa.csaportal.pick_a_shift"));if(!W&&!p)return g.oR.error(m("csa.csaportal.capture_your_location_first"));if(!W&&!I)return g.oR.error(m("csa.csaportal.take_a_selfie_first"));$(!0);try{const e={shift_id:a};W||(e.latitude=p.lat,e.longitude=p.lng,e.selfie_base64=I),await f.api.post("/attendance/check-in",e),g.oR.success(m("manager.myattendance.checked_in")),l()}catch(e){g.oR.error((0,f.KI)(e))}finally{$(!1)}},disabled:F||!a||!W&&(!p||!I),"data-testid":"mgr-att-submit",children:[(0,_.jsx)(o.A,{className:"h-4 w-4"})," ",F?"Starting\u2026":"Start on-site shift"]}),P&&(0,_.jsx)(R,{onClose:()=>Z(!1),onCapture:e=>{E(e),Z(!1)}})]})]})}function R(e){let t=e.onClose,a=e.onCapture;const s=(0,w.Bd)().t,n=(0,r.useRef)(null),d=(0,r.useRef)(null);(0,r.useEffect)(()=>{let e=!1;return(async()=>{try{const t=await navigator.mediaDevices.getUserMedia({video:{facingMode:"user",width:{ideal:640}},audio:!1});
1if(e)return void t.getTracks().forEach(e=>e.stop());d.current=t,n.current&&(n.current.srcObject=t)}catch(t){g.oR.error(s("manager.myattendance.camera_permission_denied"))}})(),()=>{var t;e=!0,null===(t=d.current)||void 0===t||t.getTracks().forEach(e=>e.stop())}},[]);return(0,_.jsx)(y.lG,{open:!0,onOpenChange:t,children:(0,_.jsxs)(y.Cf,{className:"max-w-md","data-testid":"mgr-att-selfie-dialog",children:[(0,_.jsx)(y.c7,{children:(0,_.jsxs)(y.L3,{className:"flex items-center justify-between",children:["Take selfie",(0,_.jsx)("button",{onClick:t,className:"text-muted-foreground hover:text-foreground",children:(0,_.jsx)(x.A,{className:"h-4 w-4"})})]})}),(0,_.jsx)("video",{ref:n,autoPlay:!0,playsInline:!0,muted:!0,className:"h-64 w-full rounded-lg bg-black object-cover"}),(0,_.jsxs)(j.$,{onClick:()=>{const e=n.current;if(!e)return;const t=document.createElement("canvas");t.width=e.videoWidth||480,t.height=e.videoHeight||640,t.getContext("2d").drawImage(e,0,0,t.width,t.height),a(t.toDataURL("image/jpeg",.75))},className:"mt-2 w-full","data-testid":"mgr-att-selfie-capture",children:[(0,_.jsx)(c.A,{className:"h-4 w-4"})," Capture"]})]})})}function M(e){let t=e.history,a=e.you;return t.length?(0,_.jsxs)(b.Zp,{className:"border-border","data-testid":"mgr-att-history",children:[(0,_.jsxs)(b.aR,{className:"pb-2",children:[(0,_.jsxs)(b.ZB,{className:"flex items-center gap-2 text-base",children:[(0,_.jsx)(l.A,{className:"h-4 w-4 text-muted-foreground"})," Recent attendance"]}),(0,_.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Last ",t.length," check-in",1===t.length?"":"s"," for ",null===a||void 0===a?void 0:a.name,". Read-only audit trail."]})]}),(0,_.jsx)(b.Wu,{children:(0,_.jsx)("div",{className:"divide-y divide-border text-sm",children:t.map(e=>{const t=e.checked_in_at?new Date(e.checked_in_at):null,a=e.checked_out_at?new Date(e.checked_out_at):null,s=t&&a?Math.floor((a-t)/6e4):null;return(0,_.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2 py-2 text-xs","data-testid":"mgr-att-row-".concat(e.id),children:[(0,_.jsxs)("div",{className:"min-w-0",children:[(0,_.jsxs)("div",{className:"font-semibold",children:[e.date," \xb7 ",e.shift_name]}),(0,_.jsxs)("div",{className:"mt-0.5 text-[11px] text-muted-foreground",children:["In ",t?t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"\u2014",a?" \xb7 Out ".concat(a.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})):" \xb7 still on-site",null!=s&&" \xb7 ".concat(Math.floor(s/60),"h ").concat(s%60,"m")]})]}),null!=e.distance_m&&(0,_.jsxs)("span",{className:"rounded-full bg-secondary px-2 py-0.5 font-mono text-[10px]",children:["~",Math.round(e.distance_m),"m"]})]},e.id)})})})]}):null}}}]);
2//# sourceMappingURL=6882.7f2264c5.chunk.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.