PageSourceSearch

https://www.performancecarexclusive.com/assets/js/EventConsentPage-DTySzAzU.js

js performancecarexclusive.com collected 2026-10-04 03:03:39 UTC 16,177 bytes, 2 lines download raw bytes

1import{j as t}from"./query-U2Cx38is.js";import{r as l,L as A,c as I}from"./vendor-GwJQMIA-.js";import{T as R,u as $}from"./ToastContainer-BIcs0n28.js";import{u as T}from"./useDataTable-BQl6oM-q.js";import{e as B}from"./events-D-OicCk4.js";import{a as O}from"./index-Z4pnWrZL.js";import{u as q,U as M,g as p}from"./api-Cm6TCQLV.js";import{t as U}from"./common-DZd4LPBH.js";import{G as v,C as w,f as E}from"./bookingFormatting-LWK3pROt.js";import{u as G,a as V}from"./useConsent-E2Rkrg4a.js";import{f as _}from"./consent-B1AoXbDd.js";import{g as z,a as H}from"./bookingPassenger-IktPqtMa.js";import{L as F}from"./LoadingState-CpigRoua.js";import{m as W}from"./passenger-Gf4gCpHs.js";import{E as Y}from"./EmptyState-V83ZL0Aq.js";import{D as Q}from"./DataTable-eUgIAGQH.js";import{P}from"./PageHeader-KxaVswDz.js";import{C as J}from"./ConfirmDialog-D04mt4PR.js";import"./ui-B-dksMZM.js";import"./utils-y1iingcd.js";import"./Pagination-BCz4SiTx.js";const K={totalEligible:0,consented:0,inProgress:0,requested:0,notRequested:0},j={async getForBooking(e,s){return q.get(`/events/${e}/bookings/${s}/consent`)},async getForEvent(e,s={}){const n=U(s),r=await O.get(`${M}/events/${e}/consents${n}`);return{data:r.data.data,counts:r.data.meta??K}},async requestConsent(e,s){return q.post(`/events/${e}/consent-requests`,s)}},X={totalEligible:0,consented:0,inProgress:0,requested:0,notRequested:0};function Z(e,s){const[n,r]=l.useState(null),[a,d]=l.useState([]),[i,c]=l.useState(X),[o,m]=l.useState(!0),[u,g]=l.useState(void 0),{sortBy:x,sortDirection:k,handleSort:L,currentSort:D}=T({defaultSortBy:"daysOutstanding",defaultSortDirection:"desc"}),y=!!(n?.requiresIndemnitySigning||n?.requiresEmergencyContactDetails);l.useEffect(()=>{if(!e)return;async function f(){try{const b=await B.getById(e);r(b)}catch(b){s.error("Failed to load event",p(b))}}f()},[e,s]);const h=l.useCallback(async()=>{if(!e||!y){m(!1);return}m(!0);try{const f=x?k==="desc"?`-${x}`:x:void 0,b=await j.getForEvent(e,{status:u,sort:f});d(b.data),c(b.counts)}catch(f){s.error("Failed to load consent positions",p(f))}finally{m(!1)}},[e,y,u,x,k,s]);return l.useEffect(()=>{h()},[h]),{event:n,hasConsentFlag:y,rows:a,counts:i,isLoading:o,statusFilter:u,setStatusFilter:g,currentSort:D,handleSort:L,reload:h}}function ee({eventId:e,toast:s,onDispatched:n}){const[r,a]=l.useState(!1);return{dispatch:l.useCallback(async(i,c)=>{a(!0);try{const o=await j.requestConsent(e,i);s.success(`${c} - sent to ${o.sentCount} of ${o.totalEligible}`,o.failedCount>0||o.skippedCount>0?`${o.failedCount} failed, ${o.skippedCount} skipped`:void 0),n()}catch(o){s.error(`Could not send ${c.toLowerCase()}`,p(o))}finally{a(!1)}},[e,s,n]),isDispatching:r}}function te({rows:e,selectedIds:s,dispatch:n}){const[r,a]=l.useState(null);return{pendingRequest:r,requestForRow:u=>{if(u.status!=="Consented"){n({scope:"Selected",bookingIds:[u.bookingId]},"Consent request");return}a({scope:"Selected",bookingIds:[u.bookingId],title:"Resend consent request",message:`${u.member?.name??"This member"} has already consented. Send the request again anyway?`,variant:"warning"})},requestForSelected:()=>{const u=Array.from(s),g=e.filter(x=>s.has(x.bookingId)&&x.status==="Consented").length;if(g===0){n({scope:"Selected",bookingIds:u},"Consent requests");return}a({scope:"Selected",bookingIds:u,title:"Resend consent requests",message:`${g} of the ${u.length} selected bookings have already consented and will be sent again. Continue?`,variant:"warning"})},requestForAll:()=>{a({scope:"All",title:"Request from everyone outstanding",message:"Send a consent request email to every eligible booking that has not yet consented?",variant:"info"})},confirmPendingRequest:()=>{r&&(n({scope:r.scope,bookingIds:r.bookingIds},r.title),a(null))},cancelPendingRequest:()=>{a(null)}}}function se(e){if(!(e.status!=="Consented"||!e.consentedAt))return e.event?.id}function ne(e){return`Download consent document for ${e.member?.name??"this booking"}`}function re({consent:e}){const{status:s,errorMessage:n,download:r}=G(),a=se(e);if(!a)return t.jsx("span",{className:"text-gray-300",children:"-"});const d=s==="pending";return t.jsx("button",{type:"button",onClick:()=>{r(a,e.bookingId)},disabled:d,"aria-label":ne(e),"aria-busy":d,title:n??void 0,className:"text-green-600 hover:text-green-900 disabled:opacity-50 disabled:cursor-not-allowed",children:d?"Preparing...":"Download"})}
1function ae({consent:e,onChase:s,isDispatching:n}){const{status:r,errorMessage:a,resend:d}=V(),i=e.event?.id;return!(!!e.consentedAt&&!!i)||!i?t.jsx("button",{type:"button",onClick:()=>{s(e)},disabled:n,className:"text-purple-600 hover:text-purple-900 disabled:opacity-50",children:"Resend"}):t.jsx("button",{type:"button",onClick:()=>{d(i,e.bookingId)},disabled:r==="pending","aria-busy":r==="pending",title:a??"Re-send the confirmation email with the link to their copy",className:"text-purple-600 hover:text-purple-900 disabled:opacity-50 disabled:cursor-not-allowed",children:oe(r)})}function oe(e){return e==="pending"?"Sending...":e==="sent"?"Sent":e==="error"?"Retry":"Resend copy"}function ie({consent:e}){const s={numberOfGuests:e.readiness.passengerRequired?1:0,guestName:e.guestName,passenger:e.passenger?{id:e.passenger.id,name:e.passenger.name}:null},n=z(s);if(n==="none")return t.jsx("span",{className:"text-gray-400",children:"-"});const r=H(s);if(n==="legacy")return t.jsxs(v,{state:"legacy",children:[r," (no record)"]});if(n==="missing")return t.jsx(v,{state:"missing",children:"No passenger record"});const a=!e.readiness.passengerEmergencyContactComplete;return t.jsxs("div",{className:"space-y-1",children:[t.jsx(v,{state:"passenger",children:r}),a&&t.jsx("p",{className:"text-xs text-amber-700",children:"No emergency contact on file"})]})}function le(e){return[{key:"member",header:"Member",render:s=>t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-gray-900",children:s.member?.name??"Unknown"}),t.jsx("div",{className:"text-xs text-gray-500",children:s.bookingReference})]})},{key:"status",header:"State",render:s=>t.jsx(w,{status:s.status})},{key:"requestedAt",header:"Requested",render:s=>s.requestedAt?E(s.requestedAt):"-"},{key:"daysOutstanding",header:"Outstanding",sortable:!0,render:s=>_(s.daysOutstanding)},{key:"passenger",header:"Passenger",render:s=>t.jsx(ie,{consent:s})},{key:"actions",header:"",className:"text-right",render:s=>t.jsxs("div",{className:"flex items-center gap-3 justify-end",children:[t.jsx(re,{consent:s}),t.jsx(ae,{consent:s,onChase:e.requestForRow,isDispatching:e.isDispatching}),t.jsx("button",{type:"button",onClick:()=>{e.viewRow(s.bookingId)},className:"text-amber-600 hover:text-amber-900",children:"View"})]})}]}function de({snapshot:e}){return t.jsxs("div",{className:"rounded-lg border border-gray-200 p-4",children:[t.jsx("p",{className:"text-xs font-medium text-gray-500 uppercase mb-1",children:"Member"}),t.jsxs("p",{className:"text-sm font-medium text-gray-900",children:[e.memberFirstName," ",e.memberLastName]}),e.memberEmail&&t.jsx("p",{className:"text-xs text-gray-500",children:e.memberEmail}),e.memberEmergencyContactName&&t.jsxs("p",{className:"text-xs text-gray-600 mt-1",children:["Emergency contact: ",e.memberEmergencyContactName,e.memberEmergencyContactRelationship?` (${e.memberEmergencyContactRelationship})`:"",e.memberEmergencyContactPhoneNumber?` - ${e.memberEmergencyContactPhoneNumber}`:""]})]})}function ce({snapshot:e}){return!e.passengerFirstName&&!e.passengerLastName?null:t.jsxs("div",{className:"rounded-lg border border-gray-200 p-4",children:[t.jsx("p",{className:"text-xs font-medium text-gray-500 uppercase mb-1",children:"Passenger"}),t.jsxs("p",{className:"text-sm font-medium text-gray-900",children:[e.passengerFirstName," ",e.passengerLastName]}),e.passengerEmail&&t.jsx("p",{className:"text-xs text-gray-500",children:e.passengerEmail}),e.passengerDrivingLicenceNumber&&t.jsxs("p",{className:"text-xs text-gray-600 mt-1",children:["Driving licence: ",W(e.passengerDrivingLicenceNumber)]}),e.passengerEmergencyContactName&&t.jsxs("p",{className:"text-xs text-gray-600 mt-1",children:["Emergency contact: ",e.passengerEmergencyContactName,e.passengerEmergencyContactRelationship?` (${e.passengerEmergencyContactRelationship})`:"",e.passengerEmergencyContactPhoneNumber?` - ${e.passengerEmergencyContactPhoneNumber}`:""]})]})}function ue({label:e,value:s}){return t.jsxs("div",{children:[t.jsx("dt",{className:"text-gray-500",children:e}),t.jsx("dd",{className:"text-gray-900",children:s})]})}const N="-";function S(e){return e?E(e):N}function C(e){return e??N}function me(e){return[{label:"Requested",value:S(e.requestedAt)},{label:"Requested by",value:C(e.requestedBy?.name)},{label:"Consented",value:S(e.consentedAt)},{label:"Passenger authority",value:e.confirmedPassengerAuthority?"Confirmed":N},{label:"Terms version",value:C(e.termsVersion)},{label:"Etiquette version",value:C(e.etiquetteVersion)}]}function ge({consent:e}){return t.jsx("dl",{className:"grid grid-cols-2 gap-3 text-sm",children:me(e).map(s=>t.jsx(ue,{label:s.label,value:s.value},s.label))})}function xe({consent:e}){return t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium text-gray-900",children:e.member?.name??"Unknown member"}),t.jsx("p",{className:"text-xs text-gray-500",children:e.bookingReference})]}),t.jsx(w,{status:e.status})]}),t.jsx(ge,{consent:e}),e.snapshot&&t.jsxs("div",{className:"space-y-3 pt-2 border-t border-gray-100",children:[t.jsx("p",{className:"text-xs font-medium text-gray-500 uppercase",children:"What was signed"}),t.jsx(de,{snapshot:e.snapshot}),t.jsx(ce,{snapshot:e.snapshot})]})]})}function be({eventId:e,bookingId:s,onClose:n}){const[r,a]=l.useState(null),[d,i]=l.useState(!0),[c,o]=l.useState(null);return l.useEffect(()=>{let m=!1;async function u(){i(!0),o(null);try{const g=await j.getForBooking(e,s);m||a(g)}catch(g){m||o(p(g))}finally{m||i(!1)}}return u(),()=>{m=!0}},[e,s]),t.jsxs("div",{className:"fixed inset-0 z-50 overflow-y-auto",role:"dialog","aria-modal":"true","aria-labelledby":"
1consent-record-title",children:[t.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 transition-opacity",onClick:n}),t.jsx("div",{className:"flex min-h-full items-center justify-center p-4",children:t.jsxs("div",{className:"relative bg-white rounded-lg shadow-xl max-w-lg w-full p-6 transform transition-all max-h-[85vh] overflow-y-auto",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsx("h3",{id:"consent-record-title",className:"text-lg font-semibold text-gray-900",children:"Consent Record"}),t.jsx("button",{type:"button",onClick:n,className:"text-gray-400 hover:text-gray-600","aria-label":"Close",children:t.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),d&&t.jsx(F,{message:"Loading consent record..."}),!d&&c&&t.jsxs("p",{className:"text-sm text-red-600",children:["Unable to load this record: ",c]}),!d&&!c&&r&&t.jsx(xe,{consent:r})]})})]})}const fe=[{value:"",label:"All statuses"},{value:"outstanding",label:"Outstanding only"},{value:"NotRequested",label:"Not requested"},{value:"Requested",label:"Requested"},{value:"InProgress",label:"In progress"},{value:"Consented",label:"Consented"}];function pe({status:e,onStatusChange:s}){const n=e==="outstanding";return t.jsxs("div",{className:"bg-white rounded-lg shadow p-4 mb-6 flex flex-wrap items-end gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Status"}),t.jsx("select",{value:e??"",onChange:r=>{s(r.target.value||void 0)},className:"block w-full px-3 py-2 border border-gray-300 rounded-md text-sm focus:ring-amber-500 focus:border-amber-500",children:fe.map(r=>t.jsx("option",{value:r.value,children:r.label},r.value))})]}),t.jsx("button",{type:"button",onClick:()=>{s(n?void 0:"outstanding")},className:`px-3 py-2 text-sm font-medium rounded-md border ${n?"bg-amber-500 text-black border-amber-500":"bg-white text-gray-700 border-gray-300 hover:bg-gray-50"}`,children:"Outstanding only"})]})}function ye(){return t.jsxs("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4",fill:"none"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})}function he({count:e,isDispatching:s,onRequest:n}){return e===0?null:t.jsxs("div",{className:"px-6 py-3 bg-blue-50 border-b border-blue-100 flex items-center justify-between",children:[t.jsxs("p",{className:"text-sm text-blue-700",children:[e," booking",e===1?"":"s"," selected."]}),t.jsx("button",{type:"button",onClick:n,disabled:s,className:"inline-flex items-center gap-2 px-4 py-2 text-sm font-medium text-black bg-amber-500 rounded-md hover:bg-amber-600 disabled:opacity-50",children:s?t.jsxs(t.Fragment,{children:[t.jsx(ye,{}),"Sending..."]}):"Request Consent"})]})}function ve({list:e,columns:s,selection:n,isDispatching:r,onRequestSelected:a}){return e.hasConsentFlag?t.jsxs(t.Fragment,{children:[t.jsxs("p",{className:"text-sm text-gray-600 mb-4",children:[e.counts.consented," of ",e.counts.totalEligible," consented"]}),t.jsx(pe,{status:e.statusFilter,onStatusChange:e.setStatusFilter}),t.jsx(he,{count:n.ids.size,isDispatching:r,onRequest:a}),t.jsx(Q,{data:e.rows,columns:s,keyField:"bookingId",isLoading:e.isLoading,onSort:e.handleSort,currentSort:e.currentSort,emptyMessage:"No eligible bookings found",emptyIcon:"document",selectable:!0,selectedIds:n.ids,onSelectionChange:n.onChange})]}):t.jsx(Y,{icon:"document",message:"This event does not require consent tracking",description:"Neither indemnity signing nor emergency contact details are required for this event."})}function Ce({eventId:e,eventName:s,hasConsentFlag:n,onRequestAll:r}){return t.jsx(P,{title:`Consent for ${s}`,breadcrumbs:[{label:"Admin",href:"/admin"},{label:"Events",href:"/admin/events"},{label:s,href:`/admin/events/${e}`},{label:"Consent"}],actions:t.jsxs("div",{className:"flex items-center gap-3",children:[n&&t.jsx("button",{type:"button",onClick:r,className:"px-4 py-2 text-sm font-medium text-black bg-amber-500 rounded-md hover:bg-amber-600",children:"Request From Everyone Outstanding"}),t.jsx(A,{to:`/admin/events/${e}`,className:"px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50",children:"Back to Event"})]})})}function je({prompts:e,isLoading:s}){const n=e.pendingRequest;return n?t.jsx(J,{isOpen:!0,onClose:e.cancelPendingRequest,onConfirm:e.confirmPendingRequest,title:n.title,message:n.message,confirmLabel:"Send",variant:n.variant,isLoading:s}):null}function Ne({toast:e}){return t.jsxs(t.Fragment,{children:[t.jsx(P,{title:"Event Consent",breadcrumbs:[{label:"Admin",href:"/admin"},{label:"Events",href:"/admin/events"},{label:"Consent"}]}),t.jsx(F,{message:"Loading event..."}),t.jsx(R,{toasts:e.toasts,onRemove:e.removeToast})]})}function ze(){const{id:e}=I(),s=$(),[n,r]=l.useState(new Set),[a,d]=l.useState(null),i=Z(e,s),c=ee({eventId:e??"",toast:s,onDispatched:()=>{r(new Set),i.reload()}}),o=te({rows:i.rows,selectedIds:n,dispatch:c.dispatch});if(!e)return t.jsx("div",{children:"Event ID is required"});if(!i.event)return t.jsx(Ne,{toast:s});const m=le({requestForRow:o.requestForRow,viewRow:d,isDispatching:c.isDispatching});return t.jsxs(t.Fragment,{children:[t.jsx(Ce,{eventId:e,eventName:i.event.name,hasConsentFlag:i.hasConsentFlag,onRequestAll:o.requestForAll}),t.jsx(ve,{list:i,columns:m,selection:{ids:n,onChange:r},isDispatching:c.isDispatching,onRequestSelected:o.requestForSelected}),a&&t.jsx(be,{eventId:e,bookingId:a,onClose:()=>{d(null)}}),t.jsx(je,{prompts:o,isLoading:c.isDispatching}),t.jsx(R,{toasts:s.toasts,onRemove:s.removeToast})]})}
1export{ze as default};
2//# sourceMappingURL=EventConsentPage-DTySzAzU.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.