1import{j as e,a as r}from"./query-YQf5_TCb.js";import{h as y,i as h,L as g,u as N,F as k,c as m}from"./index-oGxM1WZq.js";import{B as a}from"./button-BoJFaSM5.js";import{S as C}from"./skeleton-ujht-kmt.js";import{k as w}from"./appointments-client-Bm2hBTiA.js";import{C as S}from"./circle-alert-BcYOr9z5.js";import{L as T}from"./log-out-Q9kTaW4b.js";import{C as B}from"./chevron-right-CGrO6W4L.js";import"./radix-ui-jHlGqCL3.js";import"./index-BBBx8TSb.js";const L={paid:"bg-primary/10 text-primary",unpaid:"bg-secondary text-secondary-foreground border border-border",cancelled:"bg-destructive/10 text-destructive"};function z(){return e.jsx("div",{className:"flex min-h-[80vh] items-center justify-center p-4",children:e.jsxs("div",{className:"w-full max-w-sm space-y-6 text-center",children:[e.jsxs("div",{children:[e.jsx("div",{className:"mb-4 inline-flex h-12 w-12 items-center justify-center rounded-xl bg-primary",children:e.jsx(h,{className:"h-6 w-6 text-primary-foreground"})}),e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"My Bookings"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Sign in to view and manage your appointments"})]}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(a,{asChild:!0,children:e.jsx(g,{to:"/login?redirect=/my-bookings",children:"Sign in"})}),e.jsx(a,{asChild:!0,variant:"outline",children:e.jsx(g,{to:"/signup",children:"Create account"})})]})]})})}function A({clientId:s,displayName:i,email:d,onLogout:c}){const l=N(),[n,p]=r.useState("upcoming"),[u,f]=r.useState([]),[j,x]=r.useState(!0),[b,v]=r.useState("UTC");return r.useEffect(()=>{w().then(t=>v(t.config.timezone??"UTC")).catch(()=>{})},[]),r.useEffect(()=>{x(!0),fetch(`/api/appointments/customer/my-bookings?client_id=${s}&tab=${n}&per_page=20`).then(t=>t.json()).then(t=>f(t.results??[])).finally(()=>x(!1))},[s,n]),e.jsx("div",{className:"min-h-screen bg-background",children:e.jsxs("div",{className:"mx-auto max-w-2xl space-y-6 p-4 sm:p-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:"My Bookings"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:e.jsx(k,{devId:"736a2b",guard:{file:"src/pages/my-bookings/index.tsx",tagName:"p",sourceKind:"bound-expression",contentKey:null,contentKeyTemplate:null,expressionHash:"sha256:d65486dc75b645c2a9ff8a862406bbbe153aa91c3dce65c6b262df1b20e96403"},children:i?`Welcome back, ${i}!`:d})})]}),e.jsxs(a,{variant:"ghost",size:"sm",onClick:c,children:[e.jsx(T,{className:"mr-1.5 h-4 w-4"}),"Sign out"]})]}),e.jsx("div",{className:"flex gap-2",children:["upcoming","past"].map(t=>e.jsx("button",{onClick:()=>p(t),className:m("rounded-full px-4 py-1.5 text-sm font-medium capitalize transition-colors",n===t?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground hover:bg-accent hover:text-accent-foreground"),children:t},t))}),e.jsx("div",{className:"space-y-3",children:j?Array.from({length:3}).map((t,o)=>e.jsx(C,{className:"h-20 rounded-xl"},o)):u.length===0?e.jsxs("div",{className:"rounded-xl border border-border bg-card p-8 text-center",children:[e.jsx(h,{className:"mx-auto mb-3 h-8 w-8 text-muted-foreground"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["No ",n," bookings"]}),n==="upcoming"&&e.jsx(a,{className:"mt-4",size:"sm",onClick:()=>void l("/"),children:"Book an appointment"})]}):u.map(t=>{var o;return e.jsxs("div",{className:m("flex items-center justify-between rounded-xl border border-border bg-card p-4","cursor-pointer transition-colors hover:border-border/80"),onClick:()=>void l(`/my-bookings/${t.id}?client_id=${s}`),children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-foreground",children:((o=t.service)==null?void 0:o.name)??`Booking #${t.uniqueId.slice(0,8)}`}),e.jsx("p",{className:"mt-0.5 text-sm text-muted-foreground",children:t.startTime?new Date(t.startTime).toLocaleString([],{weekday:"short",month:"short",day:"numeric",hour:"numeric",minute:"2-digit",timeZone:b}):"â"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:m("rounded-full px-2.5 py-1 text-xs font-medium",L[t.status]??"bg-muted text-muted-foreground"),children:t.status}),e.jsx(B,{className:"h-4 w-4 text-muted-foreground"})]})]},t.id)})})]})})}function P(){const{user:s,isAuthenticated:i,isLoading:d,logout:c}=y();return d?null:!i||!s?e.jsx(z,{}):s.identityType!=="Client"?e.jsx("div",{className:"flex min-h-[80vh] items-center justify-center p-4",children:e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(S,{className:"h-5 w-5"}),e.jsx("p",{className:"text-sm",children:"This page is for customers only."})]})}):e.jsx(A,{clientId:s.identityId,displayName:s.displayName,email:s.email,onLogout:()=>void c()})}
vendor: 22 bytes, line 1
1export{P 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.