1import{u as q,r as d,bi as O,j as e,aL as y,bj as Q,ao as U,bh as z,aq as G,X}from"./index-GIzFOf59.js";import{P as H,a as J,b as x,c as K,e as W,f as Y,d as Z}from"./pagination-CDGk0Mcl.js";import{P as I}from"./plus-XNRT2MJ8.js";import{C as ee}from"./credit-card-S9IxrPYo.js";import{B as se}from"./building-2-zJ8WzAjk.js";import{M as te}from"./map-pin-D7JAAhmv.js";import"./chevron-left-fajey10C.js";const xe=()=>{const m=q(),[g,w]=d.useState("all"),[k,S]=d.useState("all"),[p,C]=d.useState("all"),[h,P]=d.useState(""),[j,D]=d.useState(""),[F,n]=d.useState(1),[f,_]=d.useState(!0),M={status:g!=="all"?g:void 0,paymentStatus:p!=="all"?p:void 0,startDate:h||void 0,endDate:j||void 0,page:F,limit:10,sortBy:"createdAt",sortOrder:"desc"},{data:B,isLoading:b,error:N}=O(M),u=B?.data||[],t=B?.pagination||{total:0,page:1,pages:0},c=[g!=="all",k!=="all",p!=="all",h,j].filter(Boolean).length,E=()=>{w("all"),S("all"),C("all"),P(""),D(""),n(1)},L=s=>{switch(s?.toLowerCase()){case"pending":return"bg-amber-100 text-amber-700 border-amber-200";case"confirmed":return"bg-blue-100 text-blue-700 border-blue-200";case"completed":return"bg-green-100 text-green-700 border-green-200";case"cancelled":case"declined":return"bg-red-100 text-red-700 border-red-200";default:return"bg-gray-100 text-gray-700 border-gray-200"}},$=s=>{switch(s?.toLowerCase()){case"paid":return"bg-green-100 text-green-700 border-green-200";
1case"pending":return"bg-amber-100 text-amber-700 border-amber-200";case"failed":return"bg-red-100 text-red-700 border-red-200";default:return"bg-gray-100 text-gray-700 border-gray-200"}},v=s=>{s<1||s>t.pages||n(s)},R=()=>{if(!t.pages)return null;const s=t.page,l=t.pages,A=1,i=[];if(l<=7)for(let a=1;a<=l;a++)i.push(a);else{const a=Math.max(s-A,1),o=Math.min(s+A,l),T=a>2,V=o<l-1;if(i.push(1),T)i.push("dots");else for(let r=2;r<a;r++)i.push(r);for(let r=Math.max(a,2);r<=Math.min(o,l-1);r++)i.push(r);if(V)i.push("dots");else for(let r=o+1;r<l;r++)i.push(r);l>1&&i.push(l)}return i.map((a,o)=>a==="dots"?e.jsx(x,{children:e.jsx(Y,{})},`dots-${o}`):e.jsx(x,{children:e.jsx(Z,{onClick:()=>v(a),isActive:s===a,className:"cursor-pointer",children:a})},a))};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"mb-8 p-6 rounded-2xl text-white overflow-hidden relative bg-gradient-to-br from-blue-900 to-blue-600",children:[e.jsx("div",{className:"absolute top-0 right-0 w-48 h-48 rounded-full bg-white opacity-10 -mr-20 -mt-20"}),e.jsx("div",{className:"absolute bottom-0 left-0 w-36 h-36 rounded-full bg-white opacity-5 -ml-20 -mb-20"}),e.jsx("div",{className:"relative z-10",children:e.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold mb-1",children:"My Bookings"}),e.jsx("p",{className:"text-blue-100",children:"View and manage your service bookings"})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2 bg-[#3c84ce] bg-opacity-15 px-3 py-2 rounded-full",children:[e.jsx(y,{className:"w-5 h-5 text-white"}),e.jsxs("span",{className:"font-medium text-white",children:[t.total||0," Bookings"]})]}),e.jsxs("button",{onClick:()=>m("/crew/booking/new-create-booking"),className:`flex items-center gap-2 px-4 py-2 bg-white text-blue-900 rounded-lg 2 hover:bg-blue-50 transition-colors font-medium shadow-sm cursor-pointer`,children:[e.jsx(I,{className:"w-5 h-5"}),e.jsx("span",{children:"Create Booking"})]})]})]})})]}),e.jsxs("div",{className:"bg-white rounded-xl shadow-sm border border-gray-200 mb-6 overflow-hidden transition-all",children:[e.jsxs("button",{onClick:()=>_(!f),className:"w-full px-6 py-4 flex items-center justify-between bg-gradient-to-r from-gray-50 to-gray-100 hover:from-gray-100 hover:to-gray-200 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-sky-600 flex items-center justify-center text-white",children:e.jsx(Q,{className:"w-5 h-5"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("h3",{className:"font-semibold text-gray-900",children:"Filter Bookings"}),e.jsx("p",{className:"text-xs text-gray-500",children:c>0?`${c} active filter${c>1?"s":""}`:"No filters applied"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[c>0&&e.jsx("span",{className:"px-2.5 py-0.5 bg-sky-600 text-white text-xs font-semibold rounded-full",children:c}),e.jsx(U,{className:`w-5 h-5 text-gray-500 transition-transform ${f?"rotate-180":""}`})]})]}),f&&e.jsxs("div",{className:"p-6 border-t border-gray-200",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-6 gap-4",children:[e.jsxs("div",{className:"xl:col-span-1",children:[e.jsxs("label",{className:"flex items-center gap-2 text-xs font-semibold text-gray-700 mb-2 uppercase tracking-wide",children:[e.jsx(z,{className:"w-4 h-4 text-sky-600"}),"Booking Status"]}),e.jsxs("select",{value:g,onChange:s=>{w(s.target.value),n(1)},className:"w-full px-3 py-2 rounded-lg border border-gray-300 bg-white focus:border-sky-500 focus:ring-2 focus:ring-sky-500/20 transition-all",children:[e.jsx("option",{value:"all",children:"All Statuses"}),e.jsx("option",{value:"pending",children:"Pending"}),e.jsx("option",{value:"confirmed",children:"Confirmed"}),e.jsx("option",{value:"declined",children:"Declined"}),e.jsx("option",{value:"cancelled",children:"Cancelled"}),e.jsx("option",{value:"completed",children:"Completed"})]})]}),e.jsxs("div",{className:"xl:col-span-1",children:[e.jsxs("label",{className:"flex items-center gap-2 text-xs font-semibold text-gray-700 mb-2 uppercase tracking-wide",children:[e.jsx(G,{className:"w-4 h-4 text-sky-600"}),"Quote Status"]}),e.jsxs("select",{value:k,onChange:s=>{S(s.target.value),n(1)},className:"w-full px-3 py-2 rounded-lg border border-gray-300 bg-white focus:border-sky-500 focus:ring-2 focus:ring-sky-500/20 transition-all",children:[e.jsx("option",{value:"all",children:"All Statuses"}),e.jsx("option",{value:"not_required",children:"Not Required"}),e.jsx("option",{value:"pending",children:"Pending"}),e.jsx("option",{value:"provided",children:"Provided"}),e.jsx("option",{value:"accepted",children:"Accepted"}),e.jsx("option",{value:"rejected",children:"Rejected"})]})]}),e.jsxs("div",{className:"xl:col-span-1",children:[e.jsxs("label",{className:"flex items-center gap-2 text-xs font-semibold text-gray-700 mb-2 uppercase tracking-wide",children:[e.jsx(ee,{className:"w-4 h-4 text-sky-600"}),"Payment Status"]}),e.jsxs("select",{value:p,onChange:s=>{C(s.target.value),n(1)},className:"w-full px-3 py-2 rounded-lg border border-gray-300 bg-white focus:border-sky-500 focus:ring-2 focus:ring-sky-500/20 transition-all",children:[e.jsx("option",{value:"all",children:"All Statuses"}),e.jsx("option",{value:"pending",children:"Pending"}),e.jsx("option",{value:"paid",children:"Paid"}),e.jsx("option",{value:"failed",children:"Failed"})]})]}),e.jsxs("div",{className:"sm:col-span-2 lg:col-span-3 xl:col-span-3",children:[e.jsxs("label",{className:"flex items-center gap-2 text-xs font-semibold text-gray-700 mb-2 uppercase tracking-wide",children:[e.jsx(y,{className:"w-4 h-4 text-sky-600"}),"Date Range"]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:[e.jsx("input",{type:"date",value:h,onChange:s=>{P(s.target.value),n(1)},className:"flex-1 px-3 py-2 rounded-lg border border-gray-300 bg-white focus:border-sky-500 focus:ring-2 focus:ring-sky-500/20 transition-all text-sm"}),e.jsx("input",{type:"date",value:j,min:h,onChange:s=>{D(s.target.value),n(1)},className:"flex-1 px-3 py-2 rounded-lg border border-gray-300 bg-white focus:border-sky-500 focus:ring-2 focus:ring-sky-500/20 transition-all text-sm"})]})]})]}),c>0&&e.jsx("div",{className:"mt-4 flex justify-end",children:e.jsxs("button",{onClick:E,className:"flex items-center gap-2 px-4 py-2 text-gray-700 hover:text-gray-900 border border-gray-300 rounded-lg hover:bg-gray-50 transition-colors font-medium text-sm",children:[e.jsx(X,{className:"w-4 h-4"}),"Clear All Filters"]})})]})]}),b&&e.jsx("div",{className:"space-y-4",children:[...Array(5)].map((s,l)=>e.jsxs("div",{className:"animate-pulse bg-white rounded-xl p-6 border border-gray-200",children:[e.jsxs("div",{className:"flex justify-between items-start mb-4",children:[e.jsx("div",{className:"h-6 bg-gray-200 rounded w-32"}),e.jsx("div",{className:"h-6 bg-gray-200 rounded w-24"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-4 bg-gray-200 rounded w-full"}),e.jsx("div",{className:"h-4 bg-gray-200 rounded w-3/4"})]})]},l))}),N&&e.jsx("div",{className:"bg-red-50 border border-red-200 rounded-xl p-4 text-red-700",children:e.jsx("p",{children:"Error loading bookings. Please try again."})}),!b&&!N&&u.length===0&&e.jsxs("div",{className:"text-center py-12 bg-white rounded-xl border border-gray-200",children:[e.jsx(y,{className:"w-16 h-16 text-gray-300 mx-auto mb-4"}),e.jsx("h3",{className:"text-xl font-semibold text-gray-900 mb-2",children:"No bookings found"}),e.jsx("p",{className:"text-gray-600 mb-6",children:"Get started by creating your first booking"}),e.jsxs("button",{onClick:()=>m("/crew/booking/new-create-booking"),className:"inline-flex items-center gap-2 px-6 py-3 bg-sky-600 text-white rounded-lg hover:bg-sky-700 transition-colors font-medium",children:[e.jsx(I,{className:"w-5 h-5"}),"Create Booking"]})]}),!b&&!N&&u.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"hidden md:block bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{className:"bg-gray-50 border-b border-gray-200",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-6 py-4 text-left text-xs font-semibold text-gray-700 uppercase tracking-wider",children:"Booking ID"}),e.jsx("th",{className:"px-6 py-4 text-left text-xs font-semibold text-gray-700 uppercase tracking-wider",children:"Service"}),e.jsx("th",{className:"px-6 py-4 text-left text-xs font-semibold text-gray-700 uppercase tracking-wider",children:"Vendor"}),e.jsx("th",{className:"px-6 py-4 text-left text-xs font-semibold text-gray-700 uppercase tracking-wider",children:"Location"}),e.jsx("th",{className:"px-6 py-4 text-left text-xs font-semibold text-gray-700 uppercase tracking-wider",children:"Booking Date"}),e.jsx("th",{className:"px-6 py-4 text-left text-xs font-semibold text-gray-700 uppercase tracking-wider",children:"Status"}),e.jsx("th",{className:"px-6 py-4 text-center text-xs font-semibold text-gray-700 uppercase tracking-wider",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-200",children:u.map(s=>e.jsxs("tr",{className:"hover:bg-gray-50 transition-colors duration-150",children:[e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsx("span",{className:"text-sm font-medium text-sky-600",children:s.bookingId||s._id?.slice(-8)})}),e.jsx("td",{className:"px-6 py-4",children:e.jsx("div",{className:"text-sm text-gray-900 font-medium max-w-xs truncate",children:s.serviceId?.name||"Service"})}),e.jsx("td",{className:"px-6 py-4",children:e.jsx("div",{className:"text-sm text-gray-900 max-w-xs truncate",children:s.businessId?.businessName||s.vendorName||"N/A"})}),e.jsx("td",{className:"px-6 py-4",children:e.jsx("div",{className:"text-sm text-gray-600 max-w-xs truncate",children:s.serviceLocation?.city&&s.serviceLocation?.state?`${s.serviceLocation.city}, ${s.serviceLocation.state}`:"N/A"})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap",children:e.jsx("span",{className:"text-sm text-gray-900",children:s.bookingDate||s.dateTime?new Date(s.bookingDate||s.dateTime).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}):"Not set"})}),e.jsx("td",{className:"px-6 py-4",children:e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-gray-500 font-medium",children:"Booking:"}),e.jsx("span",{className:`px-2.5 py-1 rounded-full text-xs font-medium border ${L(s.status)}`,children:s.status||"Pending"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-gray-500 font-medium",children:"Payment:"}),e.jsx("span",{className:`px-2.5 py-1 rounded-full text-xs font-medium border ${$(s.paymentStatus)}`,children:s.paymentStatus||"Pending"})]})]})}),e.jsx("td",{className:"px-6 py-4 whitespace-nowrap text-center",children:e.jsx("button",{onClick:()=>m(`/crew/booking/details/${s._id}`),className:`inline-flex items-center px-3 py-1.5 bg-sky-600 text-white text-sm 3 font-medium rounded-lg hover:bg-sky-700 transition-colors cursor-pointer`,children:"View"})})]},s._id))})]})})}),e.jsx("div",{className:"md:hidden space-y-4",children:u.map(s=>e.jsx("div",{className:"bg-white rounded-xl shadow-sm border border-gray-200 p-5 hover:shadow-md transition-all duration-200",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900",children:s.bookingId||s._id?.slice(-8)}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-gray-500 font-medium min-w-[70px]",children:"Booking:"}),e.jsx("span",{className:`px-3 py-1 rounded-full text-xs font-medium border ${L(s.status)}`,children:s.status||"Pending"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-gray-500 font-medium min-w-[70px]",children:"Payment:"}),e.jsx("span",{className:`px-3 py-1 rounded-full text-xs font-medium border ${$(s.paymentStatus)}`,children:s.paymentStatus||"Pending"})]})]})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[e.jsx(se,{className:"w-4 h-4 mt-0.5 flex-shrink-0 text-gray-400"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-gray-900 truncate",children:s.serviceId?.name||"Service"}),e.jsx("p",{className:"text-xs text-gray-600 truncate",children:s.businessId?.businessName||s.vendorName||"Vendor"})]})]}),s.serviceLocation&&e.jsxs("div",{className:"flex items-start gap-2 text-sm text-gray-600",children:[e.jsx(te,{className:"w-4 h-4 mt-0.5 flex-shrink-0 text-gray-400"}),e.jsxs("p",{className:"truncate",children:[s.serviceLocation.city,", ",s.serviceLocation.state]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-600",children:[e.jsx(y,{className:"w-4 h-4 flex-shrink-0 text-gray-400"}),e.jsx("p",{children:s.bookingDate||s.dateTime?new Date(s.bookingDate||s.dateTime).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}):"Date not set"})]})]}),e.jsx("div",{className:"pt-3 border-t border-gray-100",children:e.jsx("button",{onClick:()=>m(`/crew/booking/details/${s._id}`),className:"w-full px-4 py-2.5 bg-sky-600 text-white rounded-lg hover:bg-sky-700 transition-colors font-medium text-sm",children:"View Details"})})]})},s._id))}),t.pages>1&&e.jsx(H,{className:"mt-8",children:e.jsxs(J,{className:"flex items-center gap-1 sm:gap-2",children:[e.jsx(x,{children:e.jsx(K,{onClick:()=>v(t.page-1),className:t.page===1?"pointer-events-none opacity-50":"cursor-pointer"})}),e.jsx(x,{className:"sm:hidden",children:e.jsxs("span",{className:"px-3 py-1 text-sm font-medium",children:[t.page," / ",t.pages]})}),e.jsx("div",{className:"hidden sm:flex gap-1",children:R()}),e.jsx(x,{children:e.jsx(W,{onClick:()=>v(t.page+1),className:t.page===t.pages?"pointer-events-none opacity-50":"cursor-pointer"})})]})})]})]})};export{xe 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.