fix(orders): review modal mount review fixes (customer fallback, dead ai wiring)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
parent
de87eb312e
commit
a80721c6e0
2 changed files with 13 additions and 21 deletions
|
|
@ -92,7 +92,7 @@ function OrdersReviewModalMount({
|
|||
order: import("@/lib/types").Order;
|
||||
items: OrderItem[];
|
||||
customer: import("@/lib/types").Customer;
|
||||
company: import("@/lib/types").Company;
|
||||
company: import("@/lib/types").Company | null;
|
||||
customers: import("@/lib/types").Customer[];
|
||||
quoteEmail: { subject: string; body: string };
|
||||
attachments: import("@/lib/types").QuoteAttachment[];
|
||||
|
|
@ -134,22 +134,20 @@ function OrdersReviewModalMount({
|
|||
|
||||
if (cancelled) return;
|
||||
|
||||
// Customer fallback chain: expand → match by ID in the loaded list →
|
||||
// first customer as a last resort. The "first customer" fallback
|
||||
// is misleading (it's just the newest customer in PB, not anything
|
||||
// related to the order), but it preserves the previous UX if the
|
||||
// list happens to be empty after filtering.
|
||||
const customer =
|
||||
(order.expand?.customer as import("@/lib/types").Customer) ||
|
||||
customersResult.find((c) => c.id === order.customer) ||
|
||||
customersResult[0];
|
||||
// Company can be null if the order's company record isn't loaded.
|
||||
// The modal renders "(unknown)" in that case rather than fabricating
|
||||
// a stub with the wrong ID.
|
||||
const company =
|
||||
(order.expand?.company as import("@/lib/types").Company) || {
|
||||
id: order.company,
|
||||
created: "",
|
||||
updated: "",
|
||||
collectionId: "",
|
||||
collectionName: "",
|
||||
company: "(unknown)",
|
||||
address: "",
|
||||
vendor: "",
|
||||
company_email: "",
|
||||
company_tel: "",
|
||||
};
|
||||
(order.expand?.company as import("@/lib/types").Company) || null;
|
||||
|
||||
setData({
|
||||
order,
|
||||
|
|
@ -465,10 +463,8 @@ export default function OrdersPage() {
|
|||
isExpanded={expanded.has(order.id)}
|
||||
showAll={showAllByOrder.has(order.id)}
|
||||
activeTab={activeTab}
|
||||
aiExpanded={false}
|
||||
onToggleExpand={() => toggleExpand(order.id)}
|
||||
onToggleShowAll={() => toggleShowAll(order.id)}
|
||||
onToggleAi={() => {}}
|
||||
onOpen={() => router.push(`/orders/${order.id}`)}
|
||||
onOpenReview={() => openReview(order.id)}
|
||||
/>
|
||||
|
|
@ -525,10 +521,8 @@ function OrderCard({
|
|||
isExpanded,
|
||||
showAll,
|
||||
activeTab,
|
||||
aiExpanded,
|
||||
onToggleExpand,
|
||||
onToggleShowAll,
|
||||
onToggleAi,
|
||||
onOpen,
|
||||
onOpenReview,
|
||||
}: {
|
||||
|
|
@ -537,10 +531,8 @@ function OrderCard({
|
|||
isExpanded: boolean;
|
||||
showAll: boolean;
|
||||
activeTab: TabGroup;
|
||||
aiExpanded: boolean;
|
||||
onToggleExpand: () => void;
|
||||
onToggleShowAll: () => void;
|
||||
onToggleAi: () => void;
|
||||
onOpen: () => void;
|
||||
onOpenReview: () => void;
|
||||
}) {
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ export interface OrdersReviewModalProps {
|
|||
items: OrderItem[];
|
||||
customers: Customer[];
|
||||
customer: Customer;
|
||||
company: Company;
|
||||
company: Company | null;
|
||||
quoteEmail: { subject: string; body: string };
|
||||
attachments: QuoteAttachment[];
|
||||
}
|
||||
|
|
@ -375,7 +375,7 @@ export function OrdersReviewModal({
|
|||
<div className="space-y-1.5">
|
||||
<Label className="text-xs">Company</Label>
|
||||
<p className="h-9 inline-flex items-center px-3 rounded-md border bg-muted/30 text-sm">
|
||||
{company.company}
|
||||
{company?.company || "(unknown)"}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue