69 lines
2.9 KiB
JavaScript
69 lines
2.9 KiB
JavaScript
import "../_runtime.mjs";
|
|
import { h as require_react, m as require_jsx_runtime } from "../_libs/react+tanstack__react-query.mjs";
|
|
import { g as MapPin } from "../_libs/lucide-react.mjs";
|
|
import { a as p, t as AppContainer } from "./src-u_N1opJl.mjs";
|
|
import { n as trpc } from "./trpc-client-CQOIB5UU.mjs";
|
|
require_react();
|
|
var import_jsx_runtime = require_jsx_runtime();
|
|
function AddressesPage() {
|
|
const utils = trpc.useUtils();
|
|
const { data } = trpc.user.address.getUserAddresses.useQuery();
|
|
const deleteMutation = trpc.user.address.deleteAddress.useMutation({ onSuccess: () => utils.user.address.getUserAddresses.invalidate() });
|
|
const addresses = 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 Addresses"
|
|
}), addresses.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)(MapPin, { className: "h-12 w-12 text-gray-300" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(p, {
|
|
className: "text-gray-500",
|
|
children: "No addresses saved"
|
|
})]
|
|
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
className: "flex flex-col gap-3",
|
|
children: addresses.map((addr) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
className: "rounded-xl border border-gray-100 bg-white p-4 shadow-sm",
|
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
className: "flex items-start justify-between",
|
|
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
className: "flex-1",
|
|
children: [
|
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(p, {
|
|
weight: "semibold",
|
|
children: addr.name
|
|
}),
|
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(p, {
|
|
className: "text-sm text-gray-600",
|
|
children: [addr.addressLine1, addr.addressLine2 ? `, ${addr.addressLine2}` : ""]
|
|
}),
|
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(p, {
|
|
className: "text-sm text-gray-600",
|
|
children: [
|
|
addr.city,
|
|
", ",
|
|
addr.state,
|
|
" - ",
|
|
addr.pincode
|
|
]
|
|
}),
|
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(p, {
|
|
className: "text-sm text-gray-500",
|
|
children: addr.phone
|
|
}),
|
|
addr.isDefault && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
className: "mt-1 inline-block rounded-full bg-brand-100 px-2 py-0.5 text-xs text-brand-700",
|
|
children: "Default"
|
|
})
|
|
]
|
|
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
|
|
onClick: () => deleteMutation.mutate({ id: addr.id }),
|
|
className: "text-sm text-red-500 hover:text-red-700",
|
|
children: "Delete"
|
|
})]
|
|
})
|
|
}, addr.id))
|
|
})] });
|
|
}
|
|
//#endregion
|
|
export { AddressesPage as component };
|