PageSourceSearch

https://homoeopia.com/assets/OrderDetail-eR0wiBIK.js

js homoeopia.com collected 2026-10-09 22:02:27 UTC 10,779 bytes, 1 lines download raw bytes

1import{p as W,n as X,r as t,j as e,z as A,B as d,h as N,E as c,F as m,G as o,R as U,J as x,bl as E,A as K,a6 as F,ak as Q,ai as Y,a8 as Z,aa as ee,ab as se,ac as ae,ad as re,I as p,ae as te}from"./index-CqTG0Hmb.js";import{A as y}from"./AdminLayout-C7SxZOOR.js";import{L as i}from"./label-DJQ-upKz.js";import{S as L}from"./separator-vhGz1ds9.js";import{S as R,a as B,b as z,c as $,d as l}from"./select-BJ_92Dep.js";import{b as le,c as ne}from"./useAdminOrders-BTU_5mAz.js";import{A as ie}from"./arrow-left-BEJS9Oh9.js";import{C as de}from"./circle-x-IXHKZhI5.js";import{f as u}from"./format-s8OofwFx.js";import"./menu-BSxi1WeZ.js";import"./index-_dDgDZm6.js";import"./chevron-down-DhCxXW_K.js";import"./differenceInCalendarDays-DaxxJQY5.js";function be(){var T;const{id:g}=W(),b=X(),{data:s,isLoading:V}=le(g||""),f=ne(),[H,h]=t.useState(!1),[j,_]=t.useState("pending"),[w,S]=t.useState(""),[v,C]=t.useState(""),[D,k]=t.useState(""),[O,M]=t.useState(""),[I,P]=t.useState(""),q=[{value:"delhivery",label:"Delhivery"},{value:"bluedart",label:"BlueDart"},{value:"dtdc",label:"DTDC"},{value:"ecom-express",label:"Ecom Express"},{value:"india-post",label:"India Post"},{value:"shiprocket",label:"Shiprocket"},{value:"manual",label:"Manual / Self Delivery"},{value:"other",label:"Other"}],n=a=>new Intl.NumberFormat("en-IN",{style:"currency",currency:"INR",maximumFractionDigits:0}).format(a),G=a=>{switch(a){case"pending":return"bg-yellow-100 text-yellow-800";case"confirmed":case"processing":return"bg-blue-100 text-blue-800";case"shipped":return"bg-purple-100 text-purple-800";case"delivered":return"bg-green-100 text-green-800";case"cancelled":case"refunded":return"bg-red-100 text-red-800";default:return"bg-gray-100 text-gray-800"}},J=async()=>{g&&(j==="shipped"&&!v||(await f.mutateAsync({id:g,status:j,tracking_number:w||void 0,courier_name:v||void 0,tracking_url:D||void 0,estimated_delivery:O||void 0,notes:I||void 0}),h(!1),S(""),C(""),k(""),M(""),P("")))};if(V)return e.jsx(y,{title:"Loading...",children:e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(A,{className:"h-8 w-8 animate-spin text-muted-foreground"})})});if(!s)return e.jsx(y,{title:"Order Not Found",children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-muted-foreground",children:"Order not found"}),e.jsx(d,{onClick:()=>b("/admin/orders"),className:"mt-4",children:"Back to Orders"})]})});const r=s.shipping_address;return e.jsxs(y,{title:`Order ${s.order_number}`,description:`Placed on ${u(new Date(s.created_at),"dd MMMM yyyy, h:mm a")}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs(d,{variant:"ghost",onClick:()=>b("/admin/orders"),children:[e.jsx(ie,{className:"h-4 w-4 mr-2"}),"Back to Orders"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(N,{className:`${G(s.status)} text-sm`,children:s.status.charAt(0).toUpperCase()+s.status.slice(1)}),e.jsx(d,{onClick:()=>{_(s.status),h(!0)},children:"Update Status"})]})]}),e.jsxs("div",{className:"grid lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs(c,{children:[e.jsx(m,{children:e.jsxs(o,{className:"flex items-center gap-2",children:[e.jsx(U,{className:"h-5 w-5"}),"Order Items"]})}),e.jsxs(x,{children:[e.jsx("div",{className:"space-y-4",children:(T=s.items)==null?void 0:T.map(a=>e.jsxs("div",{className:"flex items-center justify-between py-3 border-b last:border-0",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"h-12 w-12 bg-muted rounded-lg flex items-center justify-center",children:e.jsx(U,{className:"h-6 w-6 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:a.product_name}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[n(a.unit_price)," × ",a.quantity]})]})]}),e.jsx("p",{className:"font-medium",children:n(a.total_price)})]},a.id))}),e.jsx(L,{className:"my-4"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Subtotal"}),e.jsx("span",{children:n(s.subtotal)})]}),s.shipping_amount&&e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Shipping"}),e.jsx("span",{children:n(s.shipping_amount)})]}),s.discount_amount&&s.discount_amount>0&&e.jsxs("div",{className:"flex justify-between text-sm text-green-600",children:[e.jsx("span",{children:"Discount"}),e.jsxs("span",{children:["-",n(s.discount_amount)]})]}),e.jsx(L,{}),e.jsxs("div",{className:"flex justify-between font-medium text-lg",children:[e.jsx("span",{children:"Total"}),e.jsx("span",{children:n(s.total_amount)})]})]})]})]}),e.jsxs(c,{children:[e.jsx(m,{children:e.jsx(o,{children:"Order Timeline"})}),e.jsx(x,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"h-8 w-8 rounded-full bg-green-100 flex items-center justify-center",children:e.jsx(E,{className:"h-4 w-4 text-green-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Order Placed"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:u(new Date(s.created_at),"dd MMM yyyy, h:mm a")})]})]}),s.shipped_at&&e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"h-8 w-8 rounded-full bg-purple-100 flex items-center justify-center",children:e.jsx(K,{className:"h-4 w-4 text-purple-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Shipped"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:u(new Date(s.shipped_at),"dd MMM yyyy, h:mm a")}),s.tracking_number&&e.jsxs("p",{className:"text-sm",children:["Tracking: ",s.tracking_number,s.courier_name&&` (${s.courier_name})`]})]})]}),s.delivered_at&&e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"h-8 w-8 rounded-full bg-green-100 flex items-center justify-center",children:e.jsx(E,{className:"h-4 w-4 text-green-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Delivered"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:u(new Date(s.delivered_at),"dd MMM yyyy, h:mm a")})]})]}),s.cancelled_at&&e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"h-8 w-8 rounded-full bg-red-100 flex items-center justify-center",children:e.jsx(de,{className:"h-4 w-4 text-red-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Cancelled"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:u(new Date(s.cancelled_at),"dd MMM yyyy, h:mm a")}),s.cancellation_reason&&e.jsxs("p",{className:"text-sm",children:["Reason: ",s.cancellation_reason]})]})]})]})})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(c,{children:[e.jsx(m,{children:e.jsxs(o,{className:"flex items-center gap-2",children:[e.jsx(F,{className:"h-5 w-5"}),"Shipping Address"]})}),e.jsx(x,{children:r&&e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Q,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:r.full_name})]}),e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(F,{className:"h-4 w-4 text-muted-foreground mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{children:r.address_line1}),r.address_line2&&e.jsx("p",{children:r.address_line2}),e.jsxs("p",{children:[r.city,", ",r.state," - ",r.pincode]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Y,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{children:r.phone})]})]})})]}),e.jsxs(c,{children:[e.jsx(m,{children:e.jsx(o,{children:"Payment"})}),e.jsx(x,{className:"space-y-2",children:s.razorpay_payment_id?e.jsxs(e.Fragment,{children:[e.jsx(N,{variant:"outline",className:"bg-blue-50 text-blue-700 border-blue-200",children:"Prepaid (Razorpay)"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:["Payment ID: ",s.razorpay_payment_id]}),s.razorpay_order_id&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Order ID: ",s.razorpay_order_id]})]}):e.jsx(N,{variant:"outline",className:"bg-yellow-50 text-yellow-700 border-yellow-200",children:"Cash on Delivery"})})]}),s.notes&&e.jsxs(c,{children:[e.jsx(m,{children:e.jsx(o,{children:"Notes"})}),e.jsx(x,{children:e.jsx("p",{className:"text-sm text-muted-foreground",children:s.notes})})]})]})]}),e.jsx(Z,{open:H,onOpenChange:h,children:e.jsxs(ee,{children:[e.jsxs(se,{children:[e.jsx(ae,{children:"Update Order Status"}),e.jsxs(re,{children:["Change the status of order ",s.order_number]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{children:"New Status"}),e.jsxs(R,{value:j,onValueChange:a=>_(a),children:[e.jsx(B,{children:e.jsx(z,{})}),e.jsxs($,{children:[e.jsx(l,{value:"pending",children:"Pending"}),e.jsx(l,{value:"confirmed",children:"Confirmed"}),e.jsx(l,{value:"processing",children:"Processing"}),e.jsx(l,{value:"shipped",children:"Shipped"}),e.jsx(l,{value:"delivered",children:"Delivered"}),e.jsx(l,{value:"cancelled",children:"Cancelled"})]})]})]}),j==="shipped"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{children:"Courier Service *"}),e.jsxs(R,{value:v,onValueChange:C,children:[e.jsx(B,{children:e.jsx(z,{placeholder:"Select courier"})}),e.jsx($,{children:q.map(a=>e.jsx(l,{value:a.value,children:a.label},a.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{children:"Tracking Number"}),e.jsx(p,{value:w,onChange:a=>S(a.target.value),placeholder:"Enter tracking number (AWB)"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{children:"Tracking URL (Optional)"}),e.jsx(p,{value:D,onChange:a=>k(a.target.value),placeholder:"https://..."}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"For manual couriers, add a custom tracking link if available"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{children:"Estimated Delivery Date"}),e.jsx(p,{type:"date",value:O,onChange:a=>M(a.target.value),min:new Date().toISOString().split("T")[0]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{children:"Internal Notes (Admin Only)"}
1),e.jsx(p,{value:I,onChange:a=>P(a.target.value),placeholder:"Add notes about this order update..."})]})]}),e.jsxs(te,{children:[e.jsx(d,{variant:"outline",onClick:()=>h(!1),children:"Cancel"}),e.jsxs(d,{onClick:J,disabled:f.isPending,children:[f.isPending&&e.jsx(A,{className:"h-4 w-4 mr-2 animate-spin"}),"Update Status"]})]})]})})]})}export{be 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.