PageSourceSearch

https://harbor-os.com/assets/AdminConsignmentDetail-Aaz19wwh.js

js harbor-os.com collected 2026-10-02 01:31:57 UTC 7,621 bytes, 1 lines download raw bytes

1import{u as L,br as $,r as f,g as E,i as w,j as e,aD as S,f as O,M as A,a$ as q,a_ as I,bs as y,G as B}from"./vendor-B3bqREfz.js";import{u as H,B as t,C as c,d,g as T,a as u,b as h,D as K,h as R,j as Q,k as Y,l as G,I as C,m as V,f as P,q as k}from"./index-BHZdkTHk.js";import{L as D}from"./label-USjEtjxC.js";const _=n=>{switch(n){case"pending":return"bg-yellow-100 text-yellow-800";case"active":return"bg-green-100 text-green-800";case"sold":return"bg-blue-100 text-blue-800";case"cancelled":return"bg-red-100 text-red-800";default:return"bg-gray-100 text-gray-800"}};function Z(){const{toast:n}=H(),[,N]=L(),[,o]=$("/admin/consignments/:id"),i=o!=null&&o.id?parseInt(o.id):NaN,[z,m]=f.useState(!1),[p,l]=f.useState(""),[g,r]=f.useState(""),{data:s,isLoading:F,isError:M}=E({queryKey:["/api/consignment",i],queryFn:async()=>{const a=await fetch(`/api/consignment/${i}`,{credentials:"include"});if(!a.ok)throw new Error(await a.text());return a.json()},enabled:!isNaN(i)}),v=()=>{k.invalidateQueries({queryKey:["/api/consignment",i]}),k.invalidateQueries({queryKey:["/api/consignment/list"]})},x=w({mutationFn:async a=>(await P("PATCH",`/api/consignment/${i}`,{status:a})).json(),onSuccess:()=>{v(),n({title:"Status updated"})},onError:a=>{n({title:"Could not update status",description:a.message,variant:"destructive"})}}),j=w({mutationFn:async({dateSold:a,finalSalePrice:b})=>(await P("PATCH",`/api/consignment/${i}/finalize-sold`,{dateSold:a,finalSalePrice:b})).json(),onSuccess:()=>{v(),n({title:"Consignment finalized as SOLD",description:"Sale record saved to sold history."}),m(!1),l(""),r("")},onError:a=>{n({title:"Failed to finalize sale",description:a.message,variant:"destructive"})}});return F?e.jsx("div",{className:"p-8",children:"Loading…"}):M||!s?e.jsxs("div",{className:"p-4 sm:p-8 max-w-3xl mx-auto space-y-4",children:[e.jsxs(t,{variant:"ghost",className:"gap-2 pl-1",onClick:()=>N("/admin/consignments"),children:[e.jsx(S,{className:"w-4 h-4"})," Back to consignments"]}),e.jsx(c,{children:e.jsx(d,{className:"py-12 text-center text-muted-foreground",children:"Consignment not found."})})]}):e.jsxs("div",{className:"p-4 sm:p-8 max-w-4xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-3",children:[e.jsxs(t,{variant:"ghost",className:"gap-2 pl-1 self-start",onClick:()=>N("/admin/consignments"),"data-testid":"button-back",children:[e.jsx(S,{className:"w-4 h-4"})," Back to consignments"]}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold",children:s.vesselName}),e.jsx(T,{className:_(s.status||"pending"),children:s.status})]}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["Submitted ",s.createdAt?O(new Date(s.createdAt),"MMM d, yyyy"):"-"]})]})]}),e.jsxs("div",{className:"grid md:grid-cols-2 gap-6",children:[e.jsxs(c,{children:[e.jsx(u,{children:e.jsx(h,{className:"text-base",children:"Vessel Information"})}),e.jsxs(d,{className:"space-y-1.5 text-sm",children:[e.jsxs("p",{className:"font-medium text-base",children:[s.vesselYear," ",s.vesselMake," ",s.vesselModel]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Name:"})," ",s.vesselName]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Length:"})," ",s.vesselLength?`${s.vesselLength} ft`:"—"]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Hull:"})," ",s.hullMaterial||"—"]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Asking Price:"})," ",e.jsxs("span",{className:"font-semibold",children:["$",s.askingPrice]})]}),s.finalSalePrice&&e.jsxs("p",{className:"text-green-700 font-semibold",children:["Final Sale: $",s.finalSalePrice]}),s.dateSold&&e.jsxs("p",{className:"text-slate-500",children:["Sold: ",s.dateSold]})]})]}),e.jsxs(c,{children:[e.jsx(u,{children:e.jsx(h,{className:"text-base",children:"Owner Contact"})}),e.jsxs(d,{className:"space-y-1.5 text-sm",children:[e.jsx("p",{className:"font-medium text-base",children:s.ownerName}),s.ownerEmail&&e.jsxs("p",{className:"flex items-center gap-2",children:[e.jsx(A,{className:"w-3.5 h-3.5 text-muted-foreground"})," ",e.jsx("a",{className:"text-blue-600 hover:underline",href:`mailto:${s.ownerEmail}`,children:s.ownerEmail})]}),s.ownerPhone&&e.jsxs("p",{className:"flex items-center gap-2",children:[e.jsx(q,{className:"w-3.5 h-3.5 text-muted-foreground"})," ",e.jsx("a",{className:"text-blue-600 hover:underline",href:`tel:${s.ownerPhone}`,children:s.ownerPhone})]}),s.location&&e.jsxs("p",{className:"flex items-center gap-2",children:[e.jsx(I,{className:"w-3.5 h-3.5 text-muted-foreground"})," ",s.location]})]})]})]}),e.jsxs(c,{children:[e.jsx(u,{children:e.jsx(h,{className:"text-base",children:"Description"})}),e.jsx(d,{children:e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:s.description||"No description provided."})})]}),s.notes&&e.jsxs(c,{children:[e.jsx(u,{children:e.jsx(h,{className:"text-base",children:"Internal Notes"})}),e.jsx(d,{children:e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:s.notes})})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 justify-end border-t pt-4",children:[s.status==="pending"&&e.jsx(t,{disabled:x.isPending,onClick:()=>x.mutate("active"),"data-testid":"button-approve",children:"Approve & Mark Active"}),s.status==="active"&&e.jsxs(t,{variant:"outline",className:"text-green-700 border-green-300 hover:bg-green-50 gap-1",onClick:()=>{var a;m(!0),l(new Date().toISOString().slice(0,10)),r(((a=s.askingPrice)==null?void 0:a.toString())||"")},"data-testid":"button-finalize-sold",children:[e.jsx(y,{className:"w-4 h-4"}),"Finalize as SOLD"]}
1),s.status!=="cancelled"&&s.status!=="sold"&&e.jsx(t,{variant:"destructive",disabled:x.isPending,onClick:()=>x.mutate("cancelled"),"data-testid":"button-cancel",children:"Cancel / Reject"})]}),e.jsx(K,{open:z,onOpenChange:a=>{a||(m(!1),l(""),r(""))},children:e.jsxs(R,{className:"sm:max-w-md",children:[e.jsxs(Q,{className:"bg-blue-600 -mx-6 -mt-6 px-6 pt-6 pb-4 rounded-t-lg",children:[e.jsxs(Y,{className:"text-white text-xl flex items-center gap-2",children:[e.jsx(y,{className:"w-5 h-5"}),"Finalize as SOLD"]}),e.jsx(G,{className:"text-blue-100",children:"Congratulations on the sale! Enter the details below to record this transaction."})]}),e.jsxs("div",{className:"space-y-4 pt-4",children:[e.jsxs("div",{className:"bg-slate-50 rounded-lg p-3 text-sm",children:[e.jsxs("p",{className:"font-medium text-slate-800",children:[s.vesselYear," ",s.vesselMake," ",s.vesselModel]}),e.jsxs("p",{className:"text-slate-500",children:["Listed at $",s.askingPrice]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{htmlFor:"finalize-date-sold",children:"Date Sold"}),e.jsx(C,{id:"finalize-date-sold",type:"date",value:p,onChange:a=>l(a.target.value),max:new Date().toISOString().slice(0,10)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(D,{htmlFor:"finalize-sale-price",children:"Final Sale Price ($)"}),e.jsx(C,{id:"finalize-sale-price",type:"number",min:"0",step:"0.01",value:g,onChange:a=>r(a.target.value),placeholder:"0.00"})]})]}),e.jsxs(V,{className:"gap-2",children:[e.jsx(t,{variant:"outline",onClick:()=>{m(!1),l(""),r("")},children:"Cancel"}),e.jsx(t,{className:"bg-blue-600 hover:bg-blue-700 text-white",disabled:!p||!g||j.isPending,onClick:()=>j.mutate({dateSold:p,finalSalePrice:parseFloat(g)}),children:j.isPending?e.jsx(B,{className:"w-4 h-4 animate-spin"}):"OK"})]})]})})]})}export{Z 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.