-
-
{order.time}
+
+
+ {/* پایین کارت */}
+
+
+ {images.length > 0 ? (
+ images.map((img) => (
+
+ {img.src ? (
+

+ ) : (
+
+ {img.alt.charAt(0)}
+
+ )}
+
+ ))
+ ) : (
+
بدون تصویر
+ )}
-
-
- {order.itemsCount} کالا • {order.totalPrice.toLocaleString('fa-IR')} تومان
-
+
+
+
{timeText}
+
+ {totalItems} کالا • {orderGroup.total_amount.toLocaleString("fa-IR")} تومان
+
+
+
-
-
-
);
};
diff --git a/src/lib/api/gooyal-accounts.ts b/src/lib/api/gooyal-accounts.ts
index 92a0e16..041b5ad 100644
--- a/src/lib/api/gooyal-accounts.ts
+++ b/src/lib/api/gooyal-accounts.ts
@@ -1,7 +1,7 @@
import "server-only";
import { getValidSession } from "@/lib/auth/session";
import { ApiError, type WinofyErrorDetails } from "./errors";
-import { logWinofyRequest, logWinofyResponse } from "./dev-logger";
+// import { logWinofyRequest, logWinofyResponse } from "./dev-logger";
const BASE_URL = process.env.GOOYAL_ACCOUNTS_BASE_URL!;
@@ -35,7 +35,7 @@ export async function gooyalFetch
(path: string, options: GooyalFetchOptions =
}
}
- logWinofyRequest?.(method, url.toString(), body);
+ // logWinofyRequest?.(method, url.toString(), body);
const res = await fetch(url.toString(), {
...rest,
@@ -45,12 +45,12 @@ export async function gooyalFetch(path: string, options: GooyalFetchOptions =
});
if (res.status === 204) {
- logWinofyResponse?.(method, url.toString(), res.status, null);
+ // logWinofyResponse?.(method, url.toString(), res.status, null);
return undefined as T;
}
const data = await res.json().catch(() => null);
- logWinofyResponse?.(method, url.toString(), res.status, data);
+ // logWinofyResponse?.(method, url.toString(), res.status, data);
if (!res.ok) {
const envelope = data as { status_message?: string; details?: WinofyErrorDetails } | null;
diff --git a/src/lib/providers/orders-provider.tsx b/src/lib/providers/orders-provider.tsx
new file mode 100644
index 0000000..12b3900
--- /dev/null
+++ b/src/lib/providers/orders-provider.tsx
@@ -0,0 +1,42 @@
+"use client";
+
+import { createContext, useContext, type ReactNode } from "react";
+import type { OrderGroup } from "@/types/api";
+
+type OrdersContextValue = {
+ data: OrderGroup[] | null;
+ error: string | null;
+ isLoading: boolean;
+};
+
+const OrdersContext = createContext(undefined);
+
+export function OrdersProvider({
+ children,
+ orderGroups,
+ error = null,
+ }: {
+ children: ReactNode;
+ orderGroups: OrderGroup[] | null;
+ error?: string | null;
+}) {
+ return (
+
+ {children}
+
+ );
+}
+
+export function useOrders() {
+ const ctx = useContext(OrdersContext);
+ if (ctx === undefined) {
+ throw new Error("useOrders must be used within OrdersProvider");
+ }
+ return ctx;
+}
\ No newline at end of file