robodev 0.23.0 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/emit-starter.test.ts +36 -0
- package/templates/auth-chat/package.json +1 -1
- package/templates/backend/package.json +1 -1
- package/templates/catalog.json +5 -0
- package/templates/empty/package.json +1 -1
- package/templates/marketplace/.config/local.spa.template.yml +27 -0
- package/templates/marketplace/.oxlint-base.json +29 -0
- package/templates/marketplace/.oxlintrc.json +78 -0
- package/templates/marketplace/.rulesync/rules/frontend-api-boundary.md +36 -0
- package/templates/marketplace/.rulesync/rules/frontend-component-structure.md +38 -0
- package/templates/marketplace/.rulesync/rules/frontend-forms.md +32 -0
- package/templates/marketplace/.rulesync/rules/frontend-notifications.md +24 -0
- package/templates/marketplace/.rulesync/rules/frontend-povio-components.md +42 -0
- package/templates/marketplace/.rulesync/rules/frontend-povio-ui.md +45 -0
- package/templates/marketplace/.rulesync/rules/frontend-query-autocomplete.md +29 -0
- package/templates/marketplace/.rulesync/rules/frontend-tables-and-lists.md +34 -0
- package/templates/marketplace/.rulesync/rules/frontend-translations.md +26 -0
- package/templates/marketplace/.rulesync/rules/project-overview.md +32 -0
- package/templates/marketplace/.rulesync/rules/robodev-api.md +30 -0
- package/templates/marketplace/.rulesync/rules/robodev-auth.md +40 -0
- package/templates/marketplace/.rulesync/rules/robodev-database.md +22 -0
- package/templates/marketplace/.rulesync/rules/role-based-app-structure.md +36 -0
- package/templates/marketplace/.rulesync/skills/media-feature/SKILL.md +21 -0
- package/templates/marketplace/.rulesync/skills/povio-ui-styling/SKILL.md +208 -0
- package/templates/marketplace/.rulesync/skills/povio-ui-styling/agents/openai.yaml +4 -0
- package/templates/marketplace/.rulesync/skills/robodev-api-route/SKILL.md +13 -0
- package/templates/marketplace/.rulesync/skills/robodev-table/SKILL.md +12 -0
- package/templates/marketplace/README.md +40 -0
- package/templates/marketplace/api/_lib.seed.test.ts +10 -0
- package/templates/marketplace/api/_lib.ts +734 -0
- package/templates/marketplace/api/cart/[id].ts +51 -0
- package/templates/marketplace/api/cart.ts +70 -0
- package/templates/marketplace/api/categories.ts +11 -0
- package/templates/marketplace/api/checkout.ts +157 -0
- package/templates/marketplace/api/health.ts +7 -0
- package/templates/marketplace/api/listings/[id].ts +101 -0
- package/templates/marketplace/api/listings/paginate.ts +29 -0
- package/templates/marketplace/api/listings.ts +90 -0
- package/templates/marketplace/api/me.ts +14 -0
- package/templates/marketplace/api/orders/[id]/complete.ts +27 -0
- package/templates/marketplace/api/orders/[id]/ship.ts +24 -0
- package/templates/marketplace/api/orders/[id].ts +15 -0
- package/templates/marketplace/api/purchases.ts +19 -0
- package/templates/marketplace/api/reviews.ts +58 -0
- package/templates/marketplace/api/sales.ts +19 -0
- package/templates/marketplace/api/watches/[listingId].ts +18 -0
- package/templates/marketplace/api/watches.ts +51 -0
- package/templates/marketplace/apps/fe/index.html +24 -0
- package/templates/marketplace/apps/fe/openapi-codegen.config.ts +72 -0
- package/templates/marketplace/apps/fe/package.json +84 -0
- package/templates/marketplace/apps/fe/public/apple-touch-icon.png +0 -0
- package/templates/marketplace/apps/fe/public/favicon-96x96.png +0 -0
- package/templates/marketplace/apps/fe/public/favicon.ico +0 -0
- package/templates/marketplace/apps/fe/public/favicon.svg +3 -0
- package/templates/marketplace/apps/fe/public/site.webmanifest +21 -0
- package/templates/marketplace/apps/fe/public/web-app-manifest-192x192.png +0 -0
- package/templates/marketplace/apps/fe/public/web-app-manifest-512x512.png +0 -0
- package/templates/marketplace/apps/fe/src/assets/fonts/GeneralSans-Bold.otf +0 -0
- package/templates/marketplace/apps/fe/src/assets/fonts/GeneralSans-Medium.otf +0 -0
- package/templates/marketplace/apps/fe/src/assets/fonts/GeneralSans-Regular.otf +0 -0
- package/templates/marketplace/apps/fe/src/assets/fonts/GeneralSans-Semibold.otf +0 -0
- package/templates/marketplace/apps/fe/src/assets/locales/en/translation.json +336 -0
- package/templates/marketplace/apps/fe/src/assets/locales/sl/translation.json +336 -0
- package/templates/marketplace/apps/fe/src/clients/app-rest-client.ts +15 -0
- package/templates/marketplace/apps/fe/src/clients/auth-token-store.ts +101 -0
- package/templates/marketplace/apps/fe/src/clients/rest/app-error-handler.ts +31 -0
- package/templates/marketplace/apps/fe/src/clients/rest/interceptors/authorization-header.interceptor.ts +15 -0
- package/templates/marketplace/apps/fe/src/clients/rest/interceptors/refresh-token.interceptor.ts +37 -0
- package/templates/marketplace/apps/fe/src/clients/rest/interceptors/response.interceptor.ts +17 -0
- package/templates/marketplace/apps/fe/src/components/404.tsx +18 -0
- package/templates/marketplace/apps/fe/src/components/features/auth/AuthBrandPanel.tsx +60 -0
- package/templates/marketplace/apps/fe/src/components/features/auth/AuthLayout.tsx +23 -0
- package/templates/marketplace/apps/fe/src/components/features/auth/LoginPage.tsx +111 -0
- package/templates/marketplace/apps/fe/src/components/features/auth/RegisterPage.tsx +143 -0
- package/templates/marketplace/apps/fe/src/components/features/marketplace/BrowsePage.tsx +76 -0
- package/templates/marketplace/apps/fe/src/components/features/marketplace/CartPage.tsx +88 -0
- package/templates/marketplace/apps/fe/src/components/features/marketplace/CheckoutPage.tsx +193 -0
- package/templates/marketplace/apps/fe/src/components/features/marketplace/ListingCard.tsx +50 -0
- package/templates/marketplace/apps/fe/src/components/features/marketplace/ListingDetailsPage.tsx +194 -0
- package/templates/marketplace/apps/fe/src/components/features/marketplace/ListingForm.tsx +278 -0
- package/templates/marketplace/apps/fe/src/components/features/marketplace/ListingFormPage.tsx +27 -0
- package/templates/marketplace/apps/fe/src/components/features/marketplace/ListingGallery.tsx +54 -0
- package/templates/marketplace/apps/fe/src/components/features/marketplace/MyListingsPage.tsx +137 -0
- package/templates/marketplace/apps/fe/src/components/features/marketplace/OrderStatusTag.tsx +24 -0
- package/templates/marketplace/apps/fe/src/components/features/marketplace/OrderSummaryCard.tsx +39 -0
- package/templates/marketplace/apps/fe/src/components/features/marketplace/OrdersPage.tsx +236 -0
- package/templates/marketplace/apps/fe/src/components/features/marketplace/WatchlistPage.tsx +56 -0
- package/templates/marketplace/apps/fe/src/components/features/profile/ProfilePage.tsx +96 -0
- package/templates/marketplace/apps/fe/src/components/googleAnalytics/GoogleAnalytics.tsx +35 -0
- package/templates/marketplace/apps/fe/src/components/layout/AppLayout.tsx +19 -0
- package/templates/marketplace/apps/fe/src/components/layout/app-header/AppHeader.tsx +95 -0
- package/templates/marketplace/apps/fe/src/components/layout/app-header/MobileNavigation.tsx +55 -0
- package/templates/marketplace/apps/fe/src/components/layout/app-header/NavLink.tsx +29 -0
- package/templates/marketplace/apps/fe/src/components/shared/branding/BrandLogo.tsx +13 -0
- package/templates/marketplace/apps/fe/src/components/shared/error/ErrorFallback.tsx +43 -0
- package/templates/marketplace/apps/fe/src/components/shared/error/ErrorText.tsx +20 -0
- package/templates/marketplace/apps/fe/src/components/shared/error/NotFound.tsx +36 -0
- package/templates/marketplace/apps/fe/src/components/shared/forms/RequiredLabel.tsx +21 -0
- package/templates/marketplace/apps/fe/src/components/shared/forms/RowInputWrapper.tsx +50 -0
- package/templates/marketplace/apps/fe/src/components/shared/head/AppHead.tsx +32 -0
- package/templates/marketplace/apps/fe/src/components/shared/head/DefaultAppHead.tsx +34 -0
- package/templates/marketplace/apps/fe/src/components/shared/layout/LoadingState.tsx +9 -0
- package/templates/marketplace/apps/fe/src/components/shared/layout/ThinPageWrapper.tsx +5 -0
- package/templates/marketplace/apps/fe/src/components/shared/page/PageHeader.tsx +69 -0
- package/templates/marketplace/apps/fe/src/components/shared/ui/Card.tsx +60 -0
- package/templates/marketplace/apps/fe/src/components/shared/ui/GoogleLoginButton.tsx +19 -0
- package/templates/marketplace/apps/fe/src/components/shared/ui/RequiredLabel.tsx +22 -0
- package/templates/marketplace/apps/fe/src/components/shared/ui/TableActions.tsx +22 -0
- package/templates/marketplace/apps/fe/src/config/app.config.ts +35 -0
- package/templates/marketplace/apps/fe/src/config/i18n.ts +43 -0
- package/templates/marketplace/apps/fe/src/config/inits/a11y.ts +14 -0
- package/templates/marketplace/apps/fe/src/config/inits/logger.ts +7 -0
- package/templates/marketplace/apps/fe/src/config/inits/sentry.ts +21 -0
- package/templates/marketplace/apps/fe/src/config/jwt.config.ts +2 -0
- package/templates/marketplace/apps/fe/src/config/query.config.ts +20 -0
- package/templates/marketplace/apps/fe/src/hooks/useAuth.ts +5 -0
- package/templates/marketplace/apps/fe/src/main.tsx +52 -0
- package/templates/marketplace/apps/fe/src/pages/(guest)/login.tsx +23 -0
- package/templates/marketplace/apps/fe/src/pages/(guest)/register.tsx +23 -0
- package/templates/marketplace/apps/fe/src/pages/(guest)/route.tsx +18 -0
- package/templates/marketplace/apps/fe/src/pages/(private)/cart.tsx +22 -0
- package/templates/marketplace/apps/fe/src/pages/(private)/checkout.tsx +22 -0
- package/templates/marketplace/apps/fe/src/pages/(private)/index.tsx +22 -0
- package/templates/marketplace/apps/fe/src/pages/(private)/listings/$id/index.tsx +37 -0
- package/templates/marketplace/apps/fe/src/pages/(private)/my-listings.tsx +32 -0
- package/templates/marketplace/apps/fe/src/pages/(private)/orders/$id.tsx +40 -0
- package/templates/marketplace/apps/fe/src/pages/(private)/orders/index.tsx +22 -0
- package/templates/marketplace/apps/fe/src/pages/(private)/profile.tsx +23 -0
- package/templates/marketplace/apps/fe/src/pages/(private)/route.tsx +18 -0
- package/templates/marketplace/apps/fe/src/pages/(private)/sales.tsx +22 -0
- package/templates/marketplace/apps/fe/src/pages/(private)/sell/$id.tsx +44 -0
- package/templates/marketplace/apps/fe/src/pages/(private)/sell/index.tsx +15 -0
- package/templates/marketplace/apps/fe/src/pages/(private)/watchlist.tsx +22 -0
- package/templates/marketplace/apps/fe/src/pages/(public)/auth.tsx +37 -0
- package/templates/marketplace/apps/fe/src/pages/(public)/route.tsx +9 -0
- package/templates/marketplace/apps/fe/src/pages/__root.tsx +164 -0
- package/templates/marketplace/apps/fe/src/providers/AppErrorBoundary.tsx +10 -0
- package/templates/marketplace/apps/fe/src/providers/OpenApiRuntimeProvider.tsx +31 -0
- package/templates/marketplace/apps/fe/src/providers/index.tsx +44 -0
- package/templates/marketplace/apps/fe/src/providers/jwt.provider.tsx +95 -0
- package/templates/marketplace/apps/fe/src/routeTree.gen.ts +435 -0
- package/templates/marketplace/apps/fe/src/styles/base.css +103 -0
- package/templates/marketplace/apps/fe/src/styles/fonts/fonts.tsx +10 -0
- package/templates/marketplace/apps/fe/src/styles/fonts/general-sans.css +31 -0
- package/templates/marketplace/apps/fe/src/styles/globals.css +28 -0
- package/templates/marketplace/apps/fe/src/styles/overrides/defaults/button.override.ts +536 -0
- package/templates/marketplace/apps/fe/src/styles/overrides/defaults/checkbox.override.ts +71 -0
- package/templates/marketplace/apps/fe/src/styles/overrides/defaults/input.override.ts +252 -0
- package/templates/marketplace/apps/fe/src/styles/overrides/defaults/label.override.ts +91 -0
- package/templates/marketplace/apps/fe/src/styles/overrides/defaults/modal.override.ts +57 -0
- package/templates/marketplace/apps/fe/src/styles/overrides/defaults/radio.override.ts +46 -0
- package/templates/marketplace/apps/fe/src/styles/overrides/defaults/table.override.ts +104 -0
- package/templates/marketplace/apps/fe/src/styles/overrides/defaults/tag.override.ts +66 -0
- package/templates/marketplace/apps/fe/src/styles/overrides/defaults/typography.override.ts +115 -0
- package/templates/marketplace/apps/fe/src/styles/overrides/outline.clsx.ts +10 -0
- package/templates/marketplace/apps/fe/src/styles/overrides/uiOverrides.override.ts +60 -0
- package/templates/marketplace/apps/fe/src/styles/theme.css +2177 -0
- package/templates/marketplace/apps/fe/src/types/i18next.d.ts +12 -0
- package/templates/marketplace/apps/fe/src/types/table.d.ts +17 -0
- package/templates/marketplace/apps/fe/src/types/ui.d.ts +26 -0
- package/templates/marketplace/apps/fe/src/types/vite-env.d.ts +20 -0
- package/templates/marketplace/apps/fe/src/utils/date.utils.ts +17 -0
- package/templates/marketplace/apps/fe/src/utils/image-fallback.ts +9 -0
- package/templates/marketplace/apps/fe/src/utils/listing-form.test.ts +69 -0
- package/templates/marketplace/apps/fe/src/utils/listing-form.ts +77 -0
- package/templates/marketplace/apps/fe/src/utils/listing-submit.ts +29 -0
- package/templates/marketplace/apps/fe/src/utils/number.utils.ts +12 -0
- package/templates/marketplace/apps/fe/src/utils/string.utils.ts +5 -0
- package/templates/marketplace/apps/fe/src/vite-env.d.ts +1 -0
- package/templates/marketplace/apps/fe/tsconfig.app.json +32 -0
- package/templates/marketplace/apps/fe/tsconfig.json +9 -0
- package/templates/marketplace/apps/fe/tsconfig.node.json +31 -0
- package/templates/marketplace/apps/fe/vite.config.ts +125 -0
- package/templates/marketplace/database.ts +154 -0
- package/templates/marketplace/openapi.json +2303 -0
- package/templates/marketplace/oxfmt.config.js +23 -0
- package/templates/marketplace/package.json +18 -0
- package/templates/marketplace/rulesync.jsonc +18 -0
- package/templates/marketplace/tsconfig.json +11 -0
- package/templates/space/package.json +1 -1
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Tag } from "@povio/ui";
|
|
2
|
+
import { useTranslation } from "react-i18next";
|
|
3
|
+
|
|
4
|
+
type OrderStatus = "paid" | "shipped" | "completed";
|
|
5
|
+
|
|
6
|
+
const STATUS_COLOR: Record<OrderStatus, "warning" | "primary" | "success"> = {
|
|
7
|
+
paid: "warning",
|
|
8
|
+
shipped: "primary",
|
|
9
|
+
completed: "success",
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
interface OrderStatusTagProps {
|
|
13
|
+
status: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function OrderStatusTag({ status }: OrderStatusTagProps) {
|
|
17
|
+
const { t } = useTranslation();
|
|
18
|
+
const known = status === "paid" || status === "shipped" || status === "completed" ? status : null;
|
|
19
|
+
if (!known) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return <Tag color={STATUS_COLOR[known]}>{t(($) => $.orders.status[known])}</Tag>;
|
|
24
|
+
}
|
package/templates/marketplace/apps/fe/src/components/features/marketplace/OrderSummaryCard.tsx
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Button, Typography } from "@povio/ui/tanstack";
|
|
2
|
+
import { useTranslation } from "react-i18next";
|
|
3
|
+
|
|
4
|
+
import { Card } from "@/components/shared/ui/Card";
|
|
5
|
+
import type { OrderModels } from "@/openapi/order/order.models";
|
|
6
|
+
import { formatCents } from "@/utils/listing-form";
|
|
7
|
+
|
|
8
|
+
import { OrderStatusTag } from "./OrderStatusTag";
|
|
9
|
+
|
|
10
|
+
interface OrderSummaryCardProps {
|
|
11
|
+
order: OrderModels.OrderDto;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function OrderSummaryCard({ order }: OrderSummaryCardProps) {
|
|
15
|
+
const { t } = useTranslation();
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<Card>
|
|
19
|
+
<Typography size="title-5">{order.items.map((item) => item.title).join(", ")}</Typography>
|
|
20
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
21
|
+
<OrderStatusTag status={order.status} />
|
|
22
|
+
<Typography
|
|
23
|
+
size="label-3"
|
|
24
|
+
className="text-text-default-2"
|
|
25
|
+
>
|
|
26
|
+
{formatCents(order.totalCents)}
|
|
27
|
+
</Typography>
|
|
28
|
+
</div>
|
|
29
|
+
<Button
|
|
30
|
+
size="xs"
|
|
31
|
+
variant="outlined"
|
|
32
|
+
color="secondary"
|
|
33
|
+
link={{ to: "/orders/$id", params: { id: order.id } }}
|
|
34
|
+
>
|
|
35
|
+
{t(($) => $.orders.view)}
|
|
36
|
+
</Button>
|
|
37
|
+
</Card>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { Button, TextArea, TextInput, Typography, useForm, useFormValue, useToast } from "@povio/ui/tanstack";
|
|
2
|
+
import { useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { useTranslation } from "react-i18next";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
|
|
6
|
+
import { LoadingState } from "@/components/shared/layout/LoadingState";
|
|
7
|
+
import { PageHeader } from "@/components/shared/page/PageHeader";
|
|
8
|
+
import { Card } from "@/components/shared/ui/Card";
|
|
9
|
+
import { OrderQueries } from "@/openapi/order/order.queries";
|
|
10
|
+
import type { OrderModels } from "@/openapi/order/order.models";
|
|
11
|
+
import { PurchaseQueries } from "@/openapi/purchase/purchase.queries";
|
|
12
|
+
import { ReviewQueries } from "@/openapi/review/review.queries";
|
|
13
|
+
import { SaleQueries } from "@/openapi/sale/sale.queries";
|
|
14
|
+
import { formatCents } from "@/utils/listing-form";
|
|
15
|
+
|
|
16
|
+
import { OrderStatusTag } from "./OrderStatusTag";
|
|
17
|
+
import { OrderSummaryCard } from "./OrderSummaryCard";
|
|
18
|
+
|
|
19
|
+
export function OrdersPage() {
|
|
20
|
+
const { t } = useTranslation();
|
|
21
|
+
const { data: purchases, isLoading: loadingPurchases } = PurchaseQueries.useGetAll();
|
|
22
|
+
const { data: sales, isLoading: loadingSales } = SaleQueries.useGetAll();
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<div className="flex flex-col gap-8">
|
|
26
|
+
<PageHeader title={t(($) => $.orders.title)} />
|
|
27
|
+
<section className="flex flex-col gap-3">
|
|
28
|
+
<Typography
|
|
29
|
+
size="title-5"
|
|
30
|
+
variant="prominent-1"
|
|
31
|
+
>
|
|
32
|
+
{t(($) => $.orders.purchases)}
|
|
33
|
+
</Typography>
|
|
34
|
+
{loadingPurchases ? (
|
|
35
|
+
<LoadingState />
|
|
36
|
+
) : !purchases || purchases.length === 0 ? (
|
|
37
|
+
<Typography
|
|
38
|
+
size="body-3"
|
|
39
|
+
className="text-text-default-2"
|
|
40
|
+
>
|
|
41
|
+
{t(($) => $.orders.emptyPurchases)}
|
|
42
|
+
</Typography>
|
|
43
|
+
) : (
|
|
44
|
+
purchases.map((order) => (
|
|
45
|
+
<OrderSummaryCard
|
|
46
|
+
key={order.id}
|
|
47
|
+
order={order}
|
|
48
|
+
/>
|
|
49
|
+
))
|
|
50
|
+
)}
|
|
51
|
+
</section>
|
|
52
|
+
<section className="flex flex-col gap-3">
|
|
53
|
+
<Typography
|
|
54
|
+
size="title-5"
|
|
55
|
+
variant="prominent-1"
|
|
56
|
+
>
|
|
57
|
+
{t(($) => $.orders.sales)}
|
|
58
|
+
</Typography>
|
|
59
|
+
{loadingSales ? (
|
|
60
|
+
<LoadingState />
|
|
61
|
+
) : !sales || sales.length === 0 ? (
|
|
62
|
+
<Typography
|
|
63
|
+
size="body-3"
|
|
64
|
+
className="text-text-default-2"
|
|
65
|
+
>
|
|
66
|
+
{t(($) => $.orders.emptySales)}
|
|
67
|
+
</Typography>
|
|
68
|
+
) : (
|
|
69
|
+
sales.map((order) => (
|
|
70
|
+
<OrderSummaryCard
|
|
71
|
+
key={order.id}
|
|
72
|
+
order={order}
|
|
73
|
+
/>
|
|
74
|
+
))
|
|
75
|
+
)}
|
|
76
|
+
</section>
|
|
77
|
+
</div>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
interface OrderDetailPageProps {
|
|
82
|
+
order: OrderModels.OrderDto;
|
|
83
|
+
role: "buyer" | "seller";
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function OrderDetailPage({ order, role }: OrderDetailPageProps) {
|
|
87
|
+
const { t } = useTranslation();
|
|
88
|
+
const queryClient = useQueryClient();
|
|
89
|
+
const { successToast, errorToast } = useToast();
|
|
90
|
+
const ship = OrderQueries.useShip();
|
|
91
|
+
const complete = OrderQueries.useComplete();
|
|
92
|
+
const createReview = ReviewQueries.useCreate();
|
|
93
|
+
const reviewForm = useForm({
|
|
94
|
+
zodSchema: z.object({
|
|
95
|
+
listingId: z.string().min(1),
|
|
96
|
+
rating: z.string().min(1),
|
|
97
|
+
body: z.string().optional(),
|
|
98
|
+
}),
|
|
99
|
+
defaultValues: {
|
|
100
|
+
listingId: order.items[0]?.listingId ?? "",
|
|
101
|
+
rating: "5",
|
|
102
|
+
body: "",
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
const reviewListingId = useFormValue(reviewForm, (values) => values.listingId);
|
|
106
|
+
|
|
107
|
+
const invalidate = async () => {
|
|
108
|
+
await queryClient.invalidateQueries({ queryKey: PurchaseQueries.keys.all });
|
|
109
|
+
await queryClient.invalidateQueries({ queryKey: SaleQueries.keys.all });
|
|
110
|
+
await queryClient.invalidateQueries({ queryKey: OrderQueries.keys.all });
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const onShip = async () => {
|
|
114
|
+
try {
|
|
115
|
+
await ship.mutateAsync({ id: order.id });
|
|
116
|
+
await invalidate();
|
|
117
|
+
successToast({ text: t(($) => $.orders.shipSuccess) });
|
|
118
|
+
} catch {
|
|
119
|
+
errorToast({ text: t(($) => $.orders.shipError) });
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const onComplete = async () => {
|
|
124
|
+
try {
|
|
125
|
+
await complete.mutateAsync({ id: order.id });
|
|
126
|
+
await invalidate();
|
|
127
|
+
successToast({ text: t(($) => $.orders.completeSuccess) });
|
|
128
|
+
} catch {
|
|
129
|
+
errorToast({ text: t(($) => $.orders.completeError) });
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const onReview = async (data: { listingId: string; rating: string; body?: string }) => {
|
|
134
|
+
try {
|
|
135
|
+
await createReview.mutateAsync({
|
|
136
|
+
data: {
|
|
137
|
+
listingId: data.listingId,
|
|
138
|
+
orderId: order.id,
|
|
139
|
+
rating: Number(data.rating),
|
|
140
|
+
body: data.body,
|
|
141
|
+
},
|
|
142
|
+
});
|
|
143
|
+
await queryClient.invalidateQueries({ queryKey: ReviewQueries.keys.all });
|
|
144
|
+
successToast({ text: t(($) => $.orders.reviewSuccess) });
|
|
145
|
+
} catch {
|
|
146
|
+
errorToast({ text: t(($) => $.orders.reviewError) });
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
return (
|
|
151
|
+
<div className="flex flex-col gap-6">
|
|
152
|
+
<PageHeader
|
|
153
|
+
enableBack
|
|
154
|
+
backProps={{ backLink: { to: "/orders" } }}
|
|
155
|
+
title={t(($) => $.orders.title)}
|
|
156
|
+
/>
|
|
157
|
+
<Card>
|
|
158
|
+
<OrderStatusTag status={order.status} />
|
|
159
|
+
{order.items.map((item) => (
|
|
160
|
+
<Typography
|
|
161
|
+
key={item.id}
|
|
162
|
+
size="body-3"
|
|
163
|
+
>
|
|
164
|
+
{item.qty} × {item.title} · {formatCents(item.unitPriceCents)}
|
|
165
|
+
</Typography>
|
|
166
|
+
))}
|
|
167
|
+
<Typography size="body-3">
|
|
168
|
+
{t(($) => $.orders.total)}: {formatCents(order.totalCents)}
|
|
169
|
+
</Typography>
|
|
170
|
+
<Typography
|
|
171
|
+
size="label-3"
|
|
172
|
+
className="text-text-default-2"
|
|
173
|
+
>
|
|
174
|
+
{order.shippingName}, {order.shippingLine1}, {order.shippingCity}
|
|
175
|
+
</Typography>
|
|
176
|
+
{role === "seller" && order.status === "paid" ? (
|
|
177
|
+
<Button
|
|
178
|
+
size="xs"
|
|
179
|
+
onPress={() => void onShip()}
|
|
180
|
+
>
|
|
181
|
+
{t(($) => $.orders.ship)}
|
|
182
|
+
</Button>
|
|
183
|
+
) : null}
|
|
184
|
+
{role === "buyer" && order.status === "shipped" ? (
|
|
185
|
+
<Button
|
|
186
|
+
size="xs"
|
|
187
|
+
onPress={() => void onComplete()}
|
|
188
|
+
>
|
|
189
|
+
{t(($) => $.orders.complete)}
|
|
190
|
+
</Button>
|
|
191
|
+
) : null}
|
|
192
|
+
</Card>
|
|
193
|
+
|
|
194
|
+
{role === "buyer" && order.status === "completed" ? (
|
|
195
|
+
<form
|
|
196
|
+
onSubmit={reviewForm.handleSubmit(onReview)}
|
|
197
|
+
className="flex max-w-xl flex-col gap-3"
|
|
198
|
+
>
|
|
199
|
+
<Typography size="title-5">{t(($) => $.orders.review)}</Typography>
|
|
200
|
+
<div className="flex flex-wrap gap-1">
|
|
201
|
+
{order.items.map((item) => (
|
|
202
|
+
<Button
|
|
203
|
+
key={item.listingId}
|
|
204
|
+
type="button"
|
|
205
|
+
size="xs"
|
|
206
|
+
variant={reviewListingId === item.listingId ? "contained" : "outlined"}
|
|
207
|
+
color={reviewListingId === item.listingId ? "primary" : "secondary"}
|
|
208
|
+
onPress={() => reviewForm.setFieldValue("listingId", item.listingId)}
|
|
209
|
+
>
|
|
210
|
+
{item.title}
|
|
211
|
+
</Button>
|
|
212
|
+
))}
|
|
213
|
+
</div>
|
|
214
|
+
<TextInput
|
|
215
|
+
variant="filled"
|
|
216
|
+
size="extra-small"
|
|
217
|
+
field={{ form: reviewForm, name: "rating" }}
|
|
218
|
+
label={t(($) => $.orders.reviewRating)}
|
|
219
|
+
/>
|
|
220
|
+
<TextArea
|
|
221
|
+
variant="filled"
|
|
222
|
+
size="extra-small"
|
|
223
|
+
field={{ form: reviewForm, name: "body" }}
|
|
224
|
+
label={t(($) => $.orders.reviewBody)}
|
|
225
|
+
/>
|
|
226
|
+
<Button
|
|
227
|
+
type="submit"
|
|
228
|
+
size="xs"
|
|
229
|
+
>
|
|
230
|
+
{t(($) => $.orders.reviewSubmit)}
|
|
231
|
+
</Button>
|
|
232
|
+
</form>
|
|
233
|
+
) : null}
|
|
234
|
+
</div>
|
|
235
|
+
);
|
|
236
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Button, Typography, useToast } from "@povio/ui/tanstack";
|
|
2
|
+
import { useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { useTranslation } from "react-i18next";
|
|
4
|
+
|
|
5
|
+
import { LoadingState } from "@/components/shared/layout/LoadingState";
|
|
6
|
+
import { PageHeader } from "@/components/shared/page/PageHeader";
|
|
7
|
+
import { WatchQueries } from "@/openapi/watch/watch.queries";
|
|
8
|
+
|
|
9
|
+
import { ListingCard } from "./ListingCard";
|
|
10
|
+
|
|
11
|
+
export function WatchlistPage() {
|
|
12
|
+
const { t } = useTranslation();
|
|
13
|
+
const queryClient = useQueryClient();
|
|
14
|
+
const { errorToast } = useToast();
|
|
15
|
+
const { data, isLoading } = WatchQueries.useGetAll();
|
|
16
|
+
const remove = WatchQueries.useDeleteApiWatchesByListingId();
|
|
17
|
+
const items = data ?? [];
|
|
18
|
+
|
|
19
|
+
const onRemove = async (listingId: string) => {
|
|
20
|
+
try {
|
|
21
|
+
await remove.mutateAsync({ listingId });
|
|
22
|
+
await queryClient.invalidateQueries({ queryKey: WatchQueries.keys.all });
|
|
23
|
+
} catch {
|
|
24
|
+
errorToast({ text: t(($) => $.watchlist.removeError) });
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<div className="flex flex-col gap-6">
|
|
30
|
+
<PageHeader title={t(($) => $.watchlist.title)} />
|
|
31
|
+
{isLoading ? (
|
|
32
|
+
<LoadingState />
|
|
33
|
+
) : items.length === 0 ? (
|
|
34
|
+
<Typography size="body-3" className="text-text-default-2">
|
|
35
|
+
{t(($) => $.watchlist.empty)}
|
|
36
|
+
</Typography>
|
|
37
|
+
) : (
|
|
38
|
+
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2 md:grid-cols-3">
|
|
39
|
+
{items.map((item) => (
|
|
40
|
+
<div key={item.id} className="flex flex-col gap-2">
|
|
41
|
+
<ListingCard listing={item.listing} />
|
|
42
|
+
<Button
|
|
43
|
+
size="xs"
|
|
44
|
+
variant="outlined"
|
|
45
|
+
color="secondary"
|
|
46
|
+
onPress={() => void onRemove(item.listingId)}
|
|
47
|
+
>
|
|
48
|
+
{t(($) => $.watchlist.remove)}
|
|
49
|
+
</Button>
|
|
50
|
+
</div>
|
|
51
|
+
))}
|
|
52
|
+
</div>
|
|
53
|
+
)}
|
|
54
|
+
</div>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { Button, TextInput, Typography, useForm, useToast } from "@povio/ui/tanstack";
|
|
2
|
+
import { Check } from "lucide-react";
|
|
3
|
+
import { useEffect } from "react";
|
|
4
|
+
import { useTranslation } from "react-i18next";
|
|
5
|
+
|
|
6
|
+
import { LoadingState } from "@/components/shared/layout/LoadingState";
|
|
7
|
+
import { PageHeader } from "@/components/shared/page/PageHeader";
|
|
8
|
+
import { Card } from "@/components/shared/ui/Card";
|
|
9
|
+
import { useAuth } from "@/hooks/useAuth";
|
|
10
|
+
import { UserModels } from "@/openapi/user/user.models";
|
|
11
|
+
import { UserQueries } from "@/openapi/user/user.queries";
|
|
12
|
+
|
|
13
|
+
export function ProfilePage() {
|
|
14
|
+
const { t } = useTranslation();
|
|
15
|
+
const { isAuthenticated, user } = useAuth();
|
|
16
|
+
const { successToast, errorToast } = useToast();
|
|
17
|
+
|
|
18
|
+
const { data: fetchedUser, isLoading } = UserQueries.useGet({ enabled: isAuthenticated });
|
|
19
|
+
const fullUser = fetchedUser ?? user;
|
|
20
|
+
const updateProfile = UserQueries.useUpdate();
|
|
21
|
+
|
|
22
|
+
const form = useForm({
|
|
23
|
+
zodSchema: UserModels.UserMeUpdateRequestSchema,
|
|
24
|
+
defaultValues: {
|
|
25
|
+
name: "",
|
|
26
|
+
email: "",
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
if (fullUser) {
|
|
32
|
+
form.reset({
|
|
33
|
+
name: fullUser.name ?? "",
|
|
34
|
+
email: fullUser.email ?? "",
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}, [form, fullUser]);
|
|
38
|
+
|
|
39
|
+
const onSubmit = async (data: UserModels.UserMeUpdateRequest) => {
|
|
40
|
+
try {
|
|
41
|
+
await updateProfile.mutateAsync({ data });
|
|
42
|
+
successToast({ text: t(($) => $.profile.form.notifications.success) });
|
|
43
|
+
} catch {
|
|
44
|
+
errorToast({ text: t(($) => $.profile.form.notifications.error) });
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
if (isLoading && !fullUser) {
|
|
49
|
+
return <LoadingState />;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<div className="flex flex-col gap-6">
|
|
54
|
+
<PageHeader title={t(($) => $.profile.form.title)} />
|
|
55
|
+
|
|
56
|
+
<Card>
|
|
57
|
+
<div className="flex flex-col gap-4">
|
|
58
|
+
<Typography
|
|
59
|
+
size="body-3"
|
|
60
|
+
className="text-text-default-2"
|
|
61
|
+
>
|
|
62
|
+
{t(($) => $.profile.form.description)}
|
|
63
|
+
</Typography>
|
|
64
|
+
|
|
65
|
+
<form
|
|
66
|
+
onSubmit={form.handleSubmit(onSubmit)}
|
|
67
|
+
className="flex flex-col gap-6"
|
|
68
|
+
>
|
|
69
|
+
<TextInput
|
|
70
|
+
field={{ form, name: "email" }}
|
|
71
|
+
label={t(($) => $.profile.form.email)}
|
|
72
|
+
placeholder={t(($) => $.profile.form.emailPlaceholder)}
|
|
73
|
+
/>
|
|
74
|
+
<TextInput
|
|
75
|
+
field={{ form, name: "name" }}
|
|
76
|
+
label={t(($) => $.profile.form.name)}
|
|
77
|
+
placeholder={t(($) => $.profile.form.namePlaceholder)}
|
|
78
|
+
/>
|
|
79
|
+
|
|
80
|
+
<div className="flex justify-end">
|
|
81
|
+
<Button
|
|
82
|
+
type="submit"
|
|
83
|
+
size="s"
|
|
84
|
+
icon={Check}
|
|
85
|
+
isDisabled={updateProfile.isPending}
|
|
86
|
+
isLoading={updateProfile.isPending}
|
|
87
|
+
>
|
|
88
|
+
{updateProfile.isPending ? t(($) => $.profile.form.submitLoading) : t(($) => $.profile.form.submit)}
|
|
89
|
+
</Button>
|
|
90
|
+
</div>
|
|
91
|
+
</form>
|
|
92
|
+
</div>
|
|
93
|
+
</Card>
|
|
94
|
+
</div>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { useEffect, useRef } from "react";
|
|
2
|
+
|
|
3
|
+
import { AppConfig } from "@/config/app.config";
|
|
4
|
+
|
|
5
|
+
const { measurementId } = AppConfig.googleAnalytics;
|
|
6
|
+
|
|
7
|
+
const GoogleAnalytics = () => {
|
|
8
|
+
const isInitializedRef = useRef(false);
|
|
9
|
+
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
if (isInitializedRef.current || !measurementId || (window as any).gtag) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
isInitializedRef.current = true;
|
|
15
|
+
|
|
16
|
+
const script1 = document.createElement("script");
|
|
17
|
+
script1.async = true;
|
|
18
|
+
script1.src = `https://www.googletagmanager.com/gtag/js?id=${measurementId}`;
|
|
19
|
+
|
|
20
|
+
const script2 = document.createElement("script");
|
|
21
|
+
script2.innerHTML = `
|
|
22
|
+
window.dataLayer = window.dataLayer || [];
|
|
23
|
+
function gtag(){dataLayer.push(arguments);}
|
|
24
|
+
gtag('js', new Date());
|
|
25
|
+
gtag('config', '${measurementId}');
|
|
26
|
+
`;
|
|
27
|
+
|
|
28
|
+
document.head.appendChild(script1);
|
|
29
|
+
document.head.appendChild(script2);
|
|
30
|
+
}, []);
|
|
31
|
+
|
|
32
|
+
return null;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export default GoogleAnalytics;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
import { AppHeader } from "./app-header/AppHeader";
|
|
4
|
+
|
|
5
|
+
interface AppLayoutProps {
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function AppLayout({ children }: AppLayoutProps) {
|
|
10
|
+
return (
|
|
11
|
+
<div className="flex min-h-dvh w-full flex-col">
|
|
12
|
+
<AppHeader />
|
|
13
|
+
|
|
14
|
+
<main className="flex w-full flex-1 flex-col">
|
|
15
|
+
<div className="w-full flex-1 px-4 py-4">{children}</div>
|
|
16
|
+
</main>
|
|
17
|
+
</div>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { Button, IconButton, Link, Menu } from "@povio/ui";
|
|
2
|
+
import { useNavigate } from "@tanstack/react-router";
|
|
3
|
+
import clsx from "clsx";
|
|
4
|
+
import { ChevronDown, MenuIcon, X } from "lucide-react";
|
|
5
|
+
import { type Key, useState } from "react";
|
|
6
|
+
import { useTranslation } from "react-i18next";
|
|
7
|
+
|
|
8
|
+
import { BrandLogo } from "@/components/shared/branding/BrandLogo";
|
|
9
|
+
import { useAuth } from "@/hooks/useAuth";
|
|
10
|
+
|
|
11
|
+
import { MobileNavigation } from "./MobileNavigation";
|
|
12
|
+
import { NavLink } from "./NavLink";
|
|
13
|
+
|
|
14
|
+
export function AppHeader() {
|
|
15
|
+
const { t } = useTranslation();
|
|
16
|
+
const navigate = useNavigate();
|
|
17
|
+
const { isAuthenticated, user, logout } = useAuth();
|
|
18
|
+
const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false);
|
|
19
|
+
|
|
20
|
+
const menuItems = [
|
|
21
|
+
{ label: t(($) => $.layout.header.profile), id: "profile" },
|
|
22
|
+
{ label: t(($) => $.layout.header.logout), id: "logout" },
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
const accountLabel = user?.name || user?.email || t(($) => $.layout.header.profile);
|
|
26
|
+
|
|
27
|
+
const handleMenuAction = (key: Key) => {
|
|
28
|
+
if (key === "profile") {
|
|
29
|
+
navigate({ to: "/profile" });
|
|
30
|
+
} else if (key === "logout") {
|
|
31
|
+
logout();
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<header
|
|
37
|
+
className={clsx(
|
|
38
|
+
"relative z-11 flex shrink-0 items-center gap-4 border-elevation-outline-default-1 border-b bg-elevation-fill-default-1 px-4",
|
|
39
|
+
isMobileMenuOpen && "flex-wrap",
|
|
40
|
+
)}
|
|
41
|
+
>
|
|
42
|
+
<Link
|
|
43
|
+
to="/"
|
|
44
|
+
aria-label={t(($) => $.layout.header.logo)}
|
|
45
|
+
className="flex shrink-0 items-center no-underline!"
|
|
46
|
+
>
|
|
47
|
+
<BrandLogo className="text-interactive-contained-primary-idle" />
|
|
48
|
+
</Link>
|
|
49
|
+
|
|
50
|
+
<div className="hidden min-w-0 lg:block">
|
|
51
|
+
<nav className="flex flex-row items-center gap-1 overflow-visible border-elevation-outline-default-1 px-0">
|
|
52
|
+
<NavLink to="/">{t(($) => $.layout.header.nav.browse)}</NavLink>
|
|
53
|
+
<NavLink to="/my-listings">{t(($) => $.layout.header.nav.sell)}</NavLink>
|
|
54
|
+
<NavLink to="/watchlist">{t(($) => $.layout.header.nav.watchlist)}</NavLink>
|
|
55
|
+
<NavLink to="/orders">{t(($) => $.layout.header.nav.orders)}</NavLink>
|
|
56
|
+
<NavLink to="/cart">{t(($) => $.layout.header.nav.cart)}</NavLink>
|
|
57
|
+
</nav>
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
{isAuthenticated && (
|
|
61
|
+
<div className="ml-auto hidden shrink-0 items-center gap-2 lg:flex">
|
|
62
|
+
<Menu
|
|
63
|
+
trigger={
|
|
64
|
+
<div className="flex cursor-pointer items-center gap-1">
|
|
65
|
+
<Button
|
|
66
|
+
type="button"
|
|
67
|
+
color="secondary"
|
|
68
|
+
variant="text"
|
|
69
|
+
size="xs"
|
|
70
|
+
className="items-center gap-1 overflow-hidden whitespace-nowrap text-text-default-1 [&>span]:font-labels-default!"
|
|
71
|
+
>
|
|
72
|
+
{accountLabel}
|
|
73
|
+
</Button>
|
|
74
|
+
<ChevronDown className="size-5 shrink-0" />
|
|
75
|
+
</div>
|
|
76
|
+
}
|
|
77
|
+
items={menuItems}
|
|
78
|
+
onAction={handleMenuAction}
|
|
79
|
+
/>
|
|
80
|
+
</div>
|
|
81
|
+
)}
|
|
82
|
+
|
|
83
|
+
<IconButton
|
|
84
|
+
className="ml-auto lg:hidden"
|
|
85
|
+
color="primary"
|
|
86
|
+
icon={isMobileMenuOpen ? X : MenuIcon}
|
|
87
|
+
label={t(($) => (isMobileMenuOpen ? $.layout.header.closeMenu : $.layout.header.openMenu))}
|
|
88
|
+
size="xs"
|
|
89
|
+
variant="ghost"
|
|
90
|
+
onPress={() => setIsMobileMenuOpen((isOpen) => !isOpen)}
|
|
91
|
+
/>
|
|
92
|
+
{isMobileMenuOpen ? <MobileNavigation /> : null}
|
|
93
|
+
</header>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Menu, TextButton } from "@povio/ui";
|
|
2
|
+
import { useNavigate } from "@tanstack/react-router";
|
|
3
|
+
import { User } from "lucide-react";
|
|
4
|
+
import type { Key } from "react";
|
|
5
|
+
import { useTranslation } from "react-i18next";
|
|
6
|
+
|
|
7
|
+
import { useAuth } from "@/hooks/useAuth";
|
|
8
|
+
|
|
9
|
+
import { NavLink } from "./NavLink";
|
|
10
|
+
|
|
11
|
+
export function MobileNavigation() {
|
|
12
|
+
const { t } = useTranslation();
|
|
13
|
+
const navigate = useNavigate();
|
|
14
|
+
const { isAuthenticated, user, logout } = useAuth();
|
|
15
|
+
const accountLabel = user?.name || user?.email || t(($) => $.layout.header.profile);
|
|
16
|
+
|
|
17
|
+
const handleMenuAction = (key: Key) => {
|
|
18
|
+
if (key === "profile") {
|
|
19
|
+
navigate({ to: "/profile" });
|
|
20
|
+
} else if (key === "logout") {
|
|
21
|
+
logout();
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<div className="-mx-4 flex w-[calc(100%+2rem)] basis-full flex-col gap-2 border-elevation-outline-default-1 border-t px-4 py-3 lg:hidden">
|
|
27
|
+
<nav className="flex flex-col gap-1">
|
|
28
|
+
<NavLink to="/">{t(($) => $.layout.header.nav.browse)}</NavLink>
|
|
29
|
+
<NavLink to="/my-listings">{t(($) => $.layout.header.nav.sell)}</NavLink>
|
|
30
|
+
<NavLink to="/watchlist">{t(($) => $.layout.header.nav.watchlist)}</NavLink>
|
|
31
|
+
<NavLink to="/orders">{t(($) => $.layout.header.nav.orders)}</NavLink>
|
|
32
|
+
<NavLink to="/cart">{t(($) => $.layout.header.nav.cart)}</NavLink>
|
|
33
|
+
</nav>
|
|
34
|
+
|
|
35
|
+
{isAuthenticated ? (
|
|
36
|
+
<Menu
|
|
37
|
+
items={[
|
|
38
|
+
{ id: "profile", label: t(($) => $.layout.header.profile) },
|
|
39
|
+
{ id: "logout", label: t(($) => $.layout.header.logout) },
|
|
40
|
+
]}
|
|
41
|
+
trigger={
|
|
42
|
+
<TextButton
|
|
43
|
+
className="mr-auto"
|
|
44
|
+
color="secondary"
|
|
45
|
+
icon={User}
|
|
46
|
+
>
|
|
47
|
+
{accountLabel}
|
|
48
|
+
</TextButton>
|
|
49
|
+
}
|
|
50
|
+
onAction={handleMenuAction}
|
|
51
|
+
/>
|
|
52
|
+
) : null}
|
|
53
|
+
</div>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Link, type LinkProps, Typography } from "@povio/ui";
|
|
2
|
+
import { useMatchRoute } from "@tanstack/react-router";
|
|
3
|
+
import clsx from "clsx";
|
|
4
|
+
|
|
5
|
+
export function NavLink({ to, children, ...props }: LinkProps) {
|
|
6
|
+
const matchRoute = useMatchRoute();
|
|
7
|
+
const isActive = Boolean(matchRoute({ to, fuzzy: true }));
|
|
8
|
+
|
|
9
|
+
return (
|
|
10
|
+
<Link
|
|
11
|
+
to={to}
|
|
12
|
+
className={clsx(
|
|
13
|
+
"no-underline! flex min-h-auto items-center rounded-xs px-button-side-xs py-button-height-xs font-medium transition-colors",
|
|
14
|
+
isActive
|
|
15
|
+
? "bg-elevation-fill-default-4 font-semibold text-interactive-text-primary-idle"
|
|
16
|
+
: "text-text-default-2 hover:bg-elevation-fill-default-2 hover:text-text-default-1",
|
|
17
|
+
)}
|
|
18
|
+
{...props}
|
|
19
|
+
>
|
|
20
|
+
<Typography
|
|
21
|
+
className="relative whitespace-nowrap no-underline! after:invisible after:block after:h-0 after:overflow-hidden after:font-semibold after:content-[attr(data-text)]"
|
|
22
|
+
size="label-2"
|
|
23
|
+
data-text={children}
|
|
24
|
+
>
|
|
25
|
+
{children}
|
|
26
|
+
</Typography>
|
|
27
|
+
</Link>
|
|
28
|
+
);
|
|
29
|
+
}
|