Skip to content

Commit d5a6692

Browse files
Fix pre-existing TypeScript errors in orders.ts and checkout page
- Add missing `meta` field to orders fallback to match PaginatedResponse type - Fix type narrowing for updateAddress result by checking `!result.success` first Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent d2c3980 commit d5a6692

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/app/[country]/[locale]/(checkout)/checkout/[id]/page.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,14 +369,16 @@ export default function CheckoutPage({ params }: CheckoutPageProps) {
369369
// Update a saved address
370370
const handleUpdateSavedAddress = async (id: string, data: AddressParams) => {
371371
const result = await updateAddress(id, data);
372-
if (result.success && result.address) {
373-
// Update local state
372+
if (!result.success) {
373+
throw new Error(result.error || "Failed to update address");
374+
}
375+
if (result.address) {
374376
setSavedAddresses((prev) =>
375377
prev.map((addr) => (addr.id === id ? result.address! : addr)),
376378
);
377379
return result.address;
378380
}
379-
throw new Error(result.error || "Failed to update address");
381+
throw new Error("Failed to update address");
380382
};
381383

382384
// Navigate back to a previous step

src/lib/data/orders.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ import { getOrder as _getOrder, listOrders } from "@spree/next";
44
import { withFallback } from "./utils";
55

66
export async function getOrders(params?: Record<string, unknown>) {
7-
return withFallback(() => listOrders(params), { data: [] });
7+
return withFallback(() => listOrders(params), {
8+
data: [],
9+
meta: { page: 1, limit: 25, count: 0, pages: 0 },
10+
});
811
}
912

1013
export async function getOrder(id: string, params?: Record<string, unknown>) {

0 commit comments

Comments
 (0)