57 lines
2.9 KiB
JavaScript
57 lines
2.9 KiB
JavaScript
import { m as require_jsx_runtime } from "../_libs/react+tanstack__react-query.mjs";
|
|
import { p as Package, x as ChevronRight } from "../_libs/lucide-react.mjs";
|
|
import { a as p, s as MyTouchableOpacity, t as AppContainer } from "./src-u_N1opJl.mjs";
|
|
import { n as trpc } from "./trpc-client-CQOIB5UU.mjs";
|
|
import { l as useNavigate } from "../_libs/@tanstack/react-router+[...].mjs";
|
|
//#region node_modules/.nitro/vite/services/ssr/assets/me.orders-CSqnUtwy.js
|
|
var import_jsx_runtime = require_jsx_runtime();
|
|
function OrdersPage() {
|
|
const navigate = useNavigate();
|
|
const { data } = trpc.user.order.getOrders.useQuery({
|
|
page: 0,
|
|
limit: 20
|
|
});
|
|
const orders = data?.data || [];
|
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(AppContainer, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(p, {
|
|
weight: "bold",
|
|
className: "mb-4 text-xl",
|
|
children: "My Orders"
|
|
}), orders.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
className: "flex flex-col items-center gap-4 py-20",
|
|
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Package, { className: "h-12 w-12 text-gray-300" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(p, {
|
|
className: "text-gray-500",
|
|
children: "No orders yet"
|
|
})]
|
|
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
className: "flex flex-col gap-3",
|
|
children: orders.map((order) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(MyTouchableOpacity, {
|
|
onClick: () => navigate({
|
|
to: "/me/orders/$id",
|
|
params: { id: String(order.id) }
|
|
}),
|
|
className: "rounded-xl border border-gray-100 bg-white p-4 shadow-sm",
|
|
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
className: "flex items-center justify-between",
|
|
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(p, {
|
|
weight: "semibold",
|
|
className: "text-sm",
|
|
children: ["Order #", order.id]
|
|
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(p, {
|
|
className: "text-xs text-gray-500",
|
|
children: order.createdAt ? new Date(order.createdAt).toLocaleDateString() : ""
|
|
})] }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
className: "flex items-center gap-2",
|
|
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
className: `rounded-full px-2 py-0.5 text-xs font-medium ${order.status === "delivered" ? "bg-green-100 text-green-700" : order.status === "cancelled" ? "bg-red-100 text-red-700" : "bg-yellow-100 text-yellow-700"}`,
|
|
children: order.status
|
|
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ChevronRight, { className: "h-4 w-4 text-gray-400" })]
|
|
})]
|
|
}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(p, {
|
|
className: "mt-1 text-xs text-gray-400",
|
|
children: ["Total: ₹", order.totalAmount || 0]
|
|
})]
|
|
}, order.id))
|
|
})] });
|
|
}
|
|
//#endregion
|
|
export { OrdersPage as component };
|