import{r as e}from"./rolldown-runtime-hePW80VL.js";import{o as t}from"./vendor-forms-yQg41KHz.js";import{d as n,t as r}from"./vendor-react-CAGJwf-T.js";import{t as i}from"./circle-x-BmjkkTIE.js";import{t as a}from"./info-By5SCiDM.js";import{Dt as o,Ot as s,vt as c}from"./index-Z_bdWDpJ.js";var l=e(t(),1),u=r(),d=`https://api.wheelsmart-lms.staging.absol.in/api/v1`;function f(){let[e]=n(),t=e.get(`token`),[r,f]=(0,l.useState)(()=>t?{status:`loading`}:{status:`error`,message:`No token provided in the link.`,errorCode:`INVALID`}),p=(0,l.useRef)(!1);return(0,l.useEffect)(()=>{p.current||!t||(p.current=!0,fetch(`${d}/workflow/email-action/`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({token:t})}).then(async e=>{let t=await e.json().catch(()=>({}));t.success?f({status:`success`,action:t.action,message:t.message||`Action processed successfully.`,workflowName:t.workflow_name,documentName:t.document_name}):f({status:`error`,action:t.action,message:t.message||`Unable to process this action.`,errorCode:t.error_code||`ERROR`,approvalStatus:t.approval_status})}).catch(()=>{f({status:`error`,message:`Something went wrong. Please log in to take action.`,errorCode:`ERROR`})}))},[t]),(0,u.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-[var(--color-background)] p-4`,children:(0,u.jsxs)(`div`,{className:`w-full max-w-md space-y-4 rounded-xl border border-[var(--color-border)] bg-[var(--color-surface)] p-10 text-center shadow-[var(--shadow-lg)]`,children:[r.status===`loading`&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(c,{className:`mx-auto h-12 w-12 animate-spin text-[var(--color-text-muted)]`}),(0,u.jsx)(`p`,{className:`text-lg text-[var(--color-text-secondary)]`,children:`Processing your action…`})]}),r.status===`success`&&(0,u.jsxs)(u.Fragment,{children:[r.action===`approve`?(0,u.jsx)(o,{className:`mx-auto h-14 w-14 text-emerald-500`}):(0,u.jsx)(i,{className:`mx-auto h-14 w-14 text-red-500`}),(0,u.jsx)(`h1`,{className:`text-2xl font-bold text-[var(--color-text-primary)]`,children:r.action===`approve`?`Approved`:`Rejected`}),(0,u.jsx)(`p`,{className:`text-[var(--color-text-secondary)]`,children:r.message}),r.documentName&&(0,u.jsxs)(`p`,{className:`text-sm text-[var(--color-text-muted)]`,children:[`Document: `,(0,u.jsx)(`span`,{className:`font-medium`,children:r.documentName})]}),r.workflowName&&(0,u.jsxs)(`p`,{className:`text-sm text-[var(--color-text-muted)]`,children:[`Workflow: `,(0,u.jsx)(`span`,{className:`font-medium`,children:r.workflowName})]}),(0,u.jsx)(`a`,{href:`/admin/workflow/approvals`,className:`mt-4 inline-block text-sm text-[var(--color-primary)] hover:underline`,children:`Go to Approvals`})]}),r.status===`error`&&(()=>{let e=r.errorCode===`NOT_PENDING`&&r.approvalStatus===`approved`,t=r.errorCode===`NOT_PENDING`&&r.approvalStatus===`rejected`,n=r.errorCode===`NOT_PENDING`;return(0,u.jsxs)(u.Fragment,{children:[e?(0,u.jsx)(o,{className:`mx-auto h-14 w-14 text-emerald-400`}):t?(0,u.jsx)(i,{className:`mx-auto h-14 w-14 text-red-400`}):n?(0,u.jsx)(a,{className:`mx-auto h-14 w-14 text-blue-400`}):(0,u.jsx)(s,{className:`mx-auto h-14 w-14 text-amber-500`}),(0,u.jsx)(`h1`,{className:`text-2xl font-bold text-[var(--color-text-primary)]`,children:r.errorCode===`USED`?`Already Actioned`:r.errorCode===`EXPIRED`?`Link Expired`:e?`Already Approved`:t?`Already Rejected`:n?`Already Processed`:`Unable to Process`}),(0,u.jsx)(`p`,{className:`text-[var(--color-text-secondary)]`,children:r.message}),(0,u.jsx)(`a`,{href:`/admin/workflow/approvals`,className:`mt-4 inline-block text-sm text-[var(--color-primary)] hover:underline`,children:`Log in to view approvals`})]})})()]})})}export{f as default};