robodev 0.22.0 → 0.24.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.
Files changed (178) hide show
  1. package/package.json +1 -1
  2. package/src/emit-starter.test.ts +36 -0
  3. package/templates/auth-chat/package.json +1 -1
  4. package/templates/backend/api/_lib.ts +9 -2
  5. package/templates/backend/package.json +1 -1
  6. package/templates/catalog.json +5 -0
  7. package/templates/empty/package.json +1 -1
  8. package/templates/marketplace/.config/local.spa.template.yml +27 -0
  9. package/templates/marketplace/.oxlint-base.json +29 -0
  10. package/templates/marketplace/.oxlintrc.json +78 -0
  11. package/templates/marketplace/.rulesync/rules/frontend-api-boundary.md +36 -0
  12. package/templates/marketplace/.rulesync/rules/frontend-component-structure.md +38 -0
  13. package/templates/marketplace/.rulesync/rules/frontend-forms.md +32 -0
  14. package/templates/marketplace/.rulesync/rules/frontend-notifications.md +24 -0
  15. package/templates/marketplace/.rulesync/rules/frontend-povio-components.md +42 -0
  16. package/templates/marketplace/.rulesync/rules/frontend-povio-ui.md +45 -0
  17. package/templates/marketplace/.rulesync/rules/frontend-query-autocomplete.md +29 -0
  18. package/templates/marketplace/.rulesync/rules/frontend-tables-and-lists.md +34 -0
  19. package/templates/marketplace/.rulesync/rules/frontend-translations.md +26 -0
  20. package/templates/marketplace/.rulesync/rules/project-overview.md +32 -0
  21. package/templates/marketplace/.rulesync/rules/robodev-api.md +30 -0
  22. package/templates/marketplace/.rulesync/rules/robodev-auth.md +40 -0
  23. package/templates/marketplace/.rulesync/rules/robodev-database.md +22 -0
  24. package/templates/marketplace/.rulesync/rules/role-based-app-structure.md +36 -0
  25. package/templates/marketplace/.rulesync/skills/media-feature/SKILL.md +21 -0
  26. package/templates/marketplace/.rulesync/skills/povio-ui-styling/SKILL.md +208 -0
  27. package/templates/marketplace/.rulesync/skills/povio-ui-styling/agents/openai.yaml +4 -0
  28. package/templates/marketplace/.rulesync/skills/robodev-api-route/SKILL.md +13 -0
  29. package/templates/marketplace/.rulesync/skills/robodev-table/SKILL.md +12 -0
  30. package/templates/marketplace/README.md +40 -0
  31. package/templates/marketplace/api/_lib.ts +677 -0
  32. package/templates/marketplace/api/cart/[id].ts +51 -0
  33. package/templates/marketplace/api/cart.ts +70 -0
  34. package/templates/marketplace/api/categories.ts +11 -0
  35. package/templates/marketplace/api/checkout.ts +157 -0
  36. package/templates/marketplace/api/health.ts +7 -0
  37. package/templates/marketplace/api/listings/[id].ts +101 -0
  38. package/templates/marketplace/api/listings/paginate.ts +29 -0
  39. package/templates/marketplace/api/listings.ts +90 -0
  40. package/templates/marketplace/api/me.ts +14 -0
  41. package/templates/marketplace/api/orders/[id]/complete.ts +27 -0
  42. package/templates/marketplace/api/orders/[id]/ship.ts +24 -0
  43. package/templates/marketplace/api/orders/[id].ts +15 -0
  44. package/templates/marketplace/api/purchases.ts +19 -0
  45. package/templates/marketplace/api/reviews.ts +58 -0
  46. package/templates/marketplace/api/sales.ts +19 -0
  47. package/templates/marketplace/api/watches/[listingId].ts +18 -0
  48. package/templates/marketplace/api/watches.ts +51 -0
  49. package/templates/marketplace/apps/fe/index.html +24 -0
  50. package/templates/marketplace/apps/fe/openapi-codegen.config.ts +72 -0
  51. package/templates/marketplace/apps/fe/package.json +84 -0
  52. package/templates/marketplace/apps/fe/public/apple-touch-icon.png +0 -0
  53. package/templates/marketplace/apps/fe/public/favicon-96x96.png +0 -0
  54. package/templates/marketplace/apps/fe/public/favicon.ico +0 -0
  55. package/templates/marketplace/apps/fe/public/favicon.svg +3 -0
  56. package/templates/marketplace/apps/fe/public/site.webmanifest +21 -0
  57. package/templates/marketplace/apps/fe/public/web-app-manifest-192x192.png +0 -0
  58. package/templates/marketplace/apps/fe/public/web-app-manifest-512x512.png +0 -0
  59. package/templates/marketplace/apps/fe/src/assets/fonts/GeneralSans-Bold.otf +0 -0
  60. package/templates/marketplace/apps/fe/src/assets/fonts/GeneralSans-Medium.otf +0 -0
  61. package/templates/marketplace/apps/fe/src/assets/fonts/GeneralSans-Regular.otf +0 -0
  62. package/templates/marketplace/apps/fe/src/assets/fonts/GeneralSans-Semibold.otf +0 -0
  63. package/templates/marketplace/apps/fe/src/assets/locales/en/translation.json +335 -0
  64. package/templates/marketplace/apps/fe/src/assets/locales/sl/translation.json +335 -0
  65. package/templates/marketplace/apps/fe/src/clients/app-rest-client.ts +15 -0
  66. package/templates/marketplace/apps/fe/src/clients/auth-token-store.ts +101 -0
  67. package/templates/marketplace/apps/fe/src/clients/rest/app-error-handler.ts +31 -0
  68. package/templates/marketplace/apps/fe/src/clients/rest/interceptors/authorization-header.interceptor.ts +15 -0
  69. package/templates/marketplace/apps/fe/src/clients/rest/interceptors/refresh-token.interceptor.ts +37 -0
  70. package/templates/marketplace/apps/fe/src/clients/rest/interceptors/response.interceptor.ts +17 -0
  71. package/templates/marketplace/apps/fe/src/components/404.tsx +18 -0
  72. package/templates/marketplace/apps/fe/src/components/features/auth/AuthBrandPanel.tsx +60 -0
  73. package/templates/marketplace/apps/fe/src/components/features/auth/AuthLayout.tsx +23 -0
  74. package/templates/marketplace/apps/fe/src/components/features/auth/LoginPage.tsx +111 -0
  75. package/templates/marketplace/apps/fe/src/components/features/auth/RegisterPage.tsx +143 -0
  76. package/templates/marketplace/apps/fe/src/components/features/marketplace/BrowsePage.tsx +76 -0
  77. package/templates/marketplace/apps/fe/src/components/features/marketplace/CartPage.tsx +88 -0
  78. package/templates/marketplace/apps/fe/src/components/features/marketplace/CheckoutPage.tsx +193 -0
  79. package/templates/marketplace/apps/fe/src/components/features/marketplace/ListingCard.tsx +50 -0
  80. package/templates/marketplace/apps/fe/src/components/features/marketplace/ListingDetailsPage.tsx +152 -0
  81. package/templates/marketplace/apps/fe/src/components/features/marketplace/ListingFormPage.tsx +243 -0
  82. package/templates/marketplace/apps/fe/src/components/features/marketplace/MyListingsPage.tsx +84 -0
  83. package/templates/marketplace/apps/fe/src/components/features/marketplace/OrdersPage.tsx +224 -0
  84. package/templates/marketplace/apps/fe/src/components/features/marketplace/WatchlistPage.tsx +56 -0
  85. package/templates/marketplace/apps/fe/src/components/features/profile/ProfilePage.tsx +96 -0
  86. package/templates/marketplace/apps/fe/src/components/googleAnalytics/GoogleAnalytics.tsx +35 -0
  87. package/templates/marketplace/apps/fe/src/components/layout/AppLayout.tsx +19 -0
  88. package/templates/marketplace/apps/fe/src/components/layout/app-header/AppHeader.tsx +95 -0
  89. package/templates/marketplace/apps/fe/src/components/layout/app-header/MobileNavigation.tsx +55 -0
  90. package/templates/marketplace/apps/fe/src/components/layout/app-header/NavLink.tsx +29 -0
  91. package/templates/marketplace/apps/fe/src/components/shared/branding/BrandLogo.tsx +13 -0
  92. package/templates/marketplace/apps/fe/src/components/shared/error/ErrorFallback.tsx +43 -0
  93. package/templates/marketplace/apps/fe/src/components/shared/error/ErrorText.tsx +20 -0
  94. package/templates/marketplace/apps/fe/src/components/shared/error/NotFound.tsx +36 -0
  95. package/templates/marketplace/apps/fe/src/components/shared/forms/RequiredLabel.tsx +21 -0
  96. package/templates/marketplace/apps/fe/src/components/shared/forms/RowInputWrapper.tsx +50 -0
  97. package/templates/marketplace/apps/fe/src/components/shared/head/AppHead.tsx +32 -0
  98. package/templates/marketplace/apps/fe/src/components/shared/head/DefaultAppHead.tsx +34 -0
  99. package/templates/marketplace/apps/fe/src/components/shared/layout/LoadingState.tsx +9 -0
  100. package/templates/marketplace/apps/fe/src/components/shared/layout/ThinPageWrapper.tsx +5 -0
  101. package/templates/marketplace/apps/fe/src/components/shared/page/PageHeader.tsx +69 -0
  102. package/templates/marketplace/apps/fe/src/components/shared/ui/Card.tsx +60 -0
  103. package/templates/marketplace/apps/fe/src/components/shared/ui/GoogleLoginButton.tsx +19 -0
  104. package/templates/marketplace/apps/fe/src/components/shared/ui/RequiredLabel.tsx +22 -0
  105. package/templates/marketplace/apps/fe/src/components/shared/ui/TableActions.tsx +22 -0
  106. package/templates/marketplace/apps/fe/src/config/app.config.ts +35 -0
  107. package/templates/marketplace/apps/fe/src/config/i18n.ts +43 -0
  108. package/templates/marketplace/apps/fe/src/config/inits/a11y.ts +14 -0
  109. package/templates/marketplace/apps/fe/src/config/inits/logger.ts +7 -0
  110. package/templates/marketplace/apps/fe/src/config/inits/sentry.ts +21 -0
  111. package/templates/marketplace/apps/fe/src/config/jwt.config.ts +2 -0
  112. package/templates/marketplace/apps/fe/src/config/query.config.ts +20 -0
  113. package/templates/marketplace/apps/fe/src/hooks/useAuth.ts +5 -0
  114. package/templates/marketplace/apps/fe/src/main.tsx +52 -0
  115. package/templates/marketplace/apps/fe/src/pages/(guest)/login.tsx +23 -0
  116. package/templates/marketplace/apps/fe/src/pages/(guest)/register.tsx +23 -0
  117. package/templates/marketplace/apps/fe/src/pages/(guest)/route.tsx +18 -0
  118. package/templates/marketplace/apps/fe/src/pages/(private)/cart.tsx +22 -0
  119. package/templates/marketplace/apps/fe/src/pages/(private)/checkout.tsx +22 -0
  120. package/templates/marketplace/apps/fe/src/pages/(private)/index.tsx +22 -0
  121. package/templates/marketplace/apps/fe/src/pages/(private)/listings/$id/index.tsx +37 -0
  122. package/templates/marketplace/apps/fe/src/pages/(private)/my-listings.tsx +22 -0
  123. package/templates/marketplace/apps/fe/src/pages/(private)/orders/$id.tsx +40 -0
  124. package/templates/marketplace/apps/fe/src/pages/(private)/orders/index.tsx +22 -0
  125. package/templates/marketplace/apps/fe/src/pages/(private)/profile.tsx +23 -0
  126. package/templates/marketplace/apps/fe/src/pages/(private)/route.tsx +18 -0
  127. package/templates/marketplace/apps/fe/src/pages/(private)/sales.tsx +22 -0
  128. package/templates/marketplace/apps/fe/src/pages/(private)/sell/$id.tsx +44 -0
  129. package/templates/marketplace/apps/fe/src/pages/(private)/sell/index.tsx +19 -0
  130. package/templates/marketplace/apps/fe/src/pages/(private)/watchlist.tsx +22 -0
  131. package/templates/marketplace/apps/fe/src/pages/(public)/auth.tsx +37 -0
  132. package/templates/marketplace/apps/fe/src/pages/(public)/route.tsx +9 -0
  133. package/templates/marketplace/apps/fe/src/pages/__root.tsx +164 -0
  134. package/templates/marketplace/apps/fe/src/providers/AppErrorBoundary.tsx +10 -0
  135. package/templates/marketplace/apps/fe/src/providers/OpenApiRuntimeProvider.tsx +31 -0
  136. package/templates/marketplace/apps/fe/src/providers/index.tsx +44 -0
  137. package/templates/marketplace/apps/fe/src/providers/jwt.provider.tsx +95 -0
  138. package/templates/marketplace/apps/fe/src/routeTree.gen.ts +435 -0
  139. package/templates/marketplace/apps/fe/src/styles/base.css +103 -0
  140. package/templates/marketplace/apps/fe/src/styles/fonts/fonts.tsx +10 -0
  141. package/templates/marketplace/apps/fe/src/styles/fonts/general-sans.css +31 -0
  142. package/templates/marketplace/apps/fe/src/styles/globals.css +28 -0
  143. package/templates/marketplace/apps/fe/src/styles/overrides/defaults/button.override.ts +536 -0
  144. package/templates/marketplace/apps/fe/src/styles/overrides/defaults/checkbox.override.ts +71 -0
  145. package/templates/marketplace/apps/fe/src/styles/overrides/defaults/input.override.ts +252 -0
  146. package/templates/marketplace/apps/fe/src/styles/overrides/defaults/label.override.ts +91 -0
  147. package/templates/marketplace/apps/fe/src/styles/overrides/defaults/modal.override.ts +57 -0
  148. package/templates/marketplace/apps/fe/src/styles/overrides/defaults/radio.override.ts +46 -0
  149. package/templates/marketplace/apps/fe/src/styles/overrides/defaults/table.override.ts +104 -0
  150. package/templates/marketplace/apps/fe/src/styles/overrides/defaults/tag.override.ts +66 -0
  151. package/templates/marketplace/apps/fe/src/styles/overrides/defaults/typography.override.ts +115 -0
  152. package/templates/marketplace/apps/fe/src/styles/overrides/outline.clsx.ts +10 -0
  153. package/templates/marketplace/apps/fe/src/styles/overrides/uiOverrides.override.ts +60 -0
  154. package/templates/marketplace/apps/fe/src/styles/theme.css +2177 -0
  155. package/templates/marketplace/apps/fe/src/types/i18next.d.ts +12 -0
  156. package/templates/marketplace/apps/fe/src/types/table.d.ts +17 -0
  157. package/templates/marketplace/apps/fe/src/types/ui.d.ts +26 -0
  158. package/templates/marketplace/apps/fe/src/types/vite-env.d.ts +20 -0
  159. package/templates/marketplace/apps/fe/src/utils/date.utils.ts +17 -0
  160. package/templates/marketplace/apps/fe/src/utils/image-fallback.ts +9 -0
  161. package/templates/marketplace/apps/fe/src/utils/listing-form.test.ts +69 -0
  162. package/templates/marketplace/apps/fe/src/utils/listing-form.ts +77 -0
  163. package/templates/marketplace/apps/fe/src/utils/listing-submit.ts +29 -0
  164. package/templates/marketplace/apps/fe/src/utils/number.utils.ts +12 -0
  165. package/templates/marketplace/apps/fe/src/utils/string.utils.ts +5 -0
  166. package/templates/marketplace/apps/fe/src/vite-env.d.ts +1 -0
  167. package/templates/marketplace/apps/fe/tsconfig.app.json +32 -0
  168. package/templates/marketplace/apps/fe/tsconfig.json +9 -0
  169. package/templates/marketplace/apps/fe/tsconfig.node.json +31 -0
  170. package/templates/marketplace/apps/fe/vite.config.ts +125 -0
  171. package/templates/marketplace/database.ts +154 -0
  172. package/templates/marketplace/openapi.json +2303 -0
  173. package/templates/marketplace/oxfmt.config.js +23 -0
  174. package/templates/marketplace/package.json +18 -0
  175. package/templates/marketplace/rulesync.jsonc +18 -0
  176. package/templates/marketplace/tsconfig.json +11 -0
  177. package/templates/space/api/_lib.ts +9 -2
  178. package/templates/space/package.json +1 -1
@@ -0,0 +1,224 @@
1
+ import {
2
+ Button,
3
+ TextArea,
4
+ TextInput,
5
+ Typography,
6
+ useForm,
7
+ useFormValue,
8
+ useToast,
9
+ } from "@povio/ui/tanstack";
10
+ import { useQueryClient } from "@tanstack/react-query";
11
+ import { useTranslation } from "react-i18next";
12
+ import { z } from "zod";
13
+
14
+ import { LoadingState } from "@/components/shared/layout/LoadingState";
15
+ import { PageHeader } from "@/components/shared/page/PageHeader";
16
+ import { Card } from "@/components/shared/ui/Card";
17
+ import { OrderQueries } from "@/openapi/order/order.queries";
18
+ import type { OrderModels } from "@/openapi/order/order.models";
19
+ import { PurchaseQueries } from "@/openapi/purchase/purchase.queries";
20
+ import { ReviewQueries } from "@/openapi/review/review.queries";
21
+ import { SaleQueries } from "@/openapi/sale/sale.queries";
22
+ import { formatCents } from "@/utils/listing-form";
23
+
24
+ export function OrdersPage() {
25
+ const { t } = useTranslation();
26
+ const { data: purchases, isLoading: loadingPurchases } = PurchaseQueries.useGetAll();
27
+ const { data: sales, isLoading: loadingSales } = SaleQueries.useGetAll();
28
+
29
+ return (
30
+ <div className="flex flex-col gap-8">
31
+ <PageHeader title={t(($) => $.orders.title)} />
32
+ <section className="flex flex-col gap-3">
33
+ <Typography size="title-5" variant="prominent-1">
34
+ {t(($) => $.orders.purchases)}
35
+ </Typography>
36
+ {loadingPurchases ? (
37
+ <LoadingState />
38
+ ) : !purchases || purchases.length === 0 ? (
39
+ <Typography size="body-3" className="text-text-default-2">
40
+ {t(($) => $.orders.emptyPurchases)}
41
+ </Typography>
42
+ ) : (
43
+ purchases.map((order) => <OrderSummary key={order.id} order={order} />)
44
+ )}
45
+ </section>
46
+ <section className="flex flex-col gap-3">
47
+ <Typography size="title-5" variant="prominent-1">
48
+ {t(($) => $.orders.sales)}
49
+ </Typography>
50
+ {loadingSales ? (
51
+ <LoadingState />
52
+ ) : !sales || sales.length === 0 ? (
53
+ <Typography size="body-3" className="text-text-default-2">
54
+ {t(($) => $.orders.emptySales)}
55
+ </Typography>
56
+ ) : (
57
+ sales.map((order) => <OrderSummary key={order.id} order={order} />)
58
+ )}
59
+ </section>
60
+ </div>
61
+ );
62
+ }
63
+
64
+ function OrderSummary({ order }: { order: OrderModels.OrderDto }) {
65
+ const { t } = useTranslation();
66
+ return (
67
+ <Card>
68
+ <Typography size="title-5">{order.items.map((item) => item.title).join(", ")}</Typography>
69
+ <Typography size="label-3" className="text-text-default-2">
70
+ {t(($) => $.orders.status[order.status as "paid" | "shipped" | "completed"])} ·{" "}
71
+ {formatCents(order.totalCents)}
72
+ </Typography>
73
+ <Button
74
+ size="xs"
75
+ variant="outlined"
76
+ color="secondary"
77
+ link={{ to: "/orders/$id", params: { id: order.id } }}
78
+ >
79
+ {order.id.slice(0, 8)}
80
+ </Button>
81
+ </Card>
82
+ );
83
+ }
84
+
85
+ interface OrderDetailPageProps {
86
+ order: OrderModels.OrderDto;
87
+ role: "buyer" | "seller";
88
+ }
89
+
90
+ export function OrderDetailPage({ order, role }: OrderDetailPageProps) {
91
+ const { t } = useTranslation();
92
+ const queryClient = useQueryClient();
93
+ const { successToast, errorToast } = useToast();
94
+ const ship = OrderQueries.useShip();
95
+ const complete = OrderQueries.useComplete();
96
+ const createReview = ReviewQueries.useCreate();
97
+ const reviewForm = useForm({
98
+ zodSchema: z.object({
99
+ listingId: z.string().min(1),
100
+ rating: z.string().min(1),
101
+ body: z.string().optional(),
102
+ }),
103
+ defaultValues: {
104
+ listingId: order.items[0]?.listingId ?? "",
105
+ rating: "5",
106
+ body: "",
107
+ },
108
+ });
109
+ const reviewListingId = useFormValue(reviewForm, (values) => values.listingId);
110
+
111
+ const invalidate = async () => {
112
+ await queryClient.invalidateQueries({ queryKey: PurchaseQueries.keys.all });
113
+ await queryClient.invalidateQueries({ queryKey: SaleQueries.keys.all });
114
+ await queryClient.invalidateQueries({ queryKey: OrderQueries.keys.all });
115
+ };
116
+
117
+ const onShip = async () => {
118
+ try {
119
+ await ship.mutateAsync({ id: order.id });
120
+ await invalidate();
121
+ successToast({ text: t(($) => $.orders.shipSuccess) });
122
+ } catch {
123
+ errorToast({ text: t(($) => $.orders.shipError) });
124
+ }
125
+ };
126
+
127
+ const onComplete = async () => {
128
+ try {
129
+ await complete.mutateAsync({ id: order.id });
130
+ await invalidate();
131
+ successToast({ text: t(($) => $.orders.completeSuccess) });
132
+ } catch {
133
+ errorToast({ text: t(($) => $.orders.completeError) });
134
+ }
135
+ };
136
+
137
+ const onReview = async (data: { listingId: string; rating: string; body?: string }) => {
138
+ try {
139
+ await createReview.mutateAsync({
140
+ data: {
141
+ listingId: data.listingId,
142
+ orderId: order.id,
143
+ rating: Number(data.rating),
144
+ body: data.body,
145
+ },
146
+ });
147
+ await queryClient.invalidateQueries({ queryKey: ReviewQueries.keys.all });
148
+ successToast({ text: t(($) => $.orders.reviewSuccess) });
149
+ } catch {
150
+ errorToast({ text: t(($) => $.orders.reviewError) });
151
+ }
152
+ };
153
+
154
+ return (
155
+ <div className="flex flex-col gap-6">
156
+ <PageHeader
157
+ enableBack
158
+ backProps={{ backLink: { to: "/orders" } }}
159
+ title={t(($) => $.orders.title)}
160
+ />
161
+ <Card>
162
+ <Typography size="label-3" className="text-text-default-2">
163
+ {t(($) => $.orders.status[order.status as "paid" | "shipped" | "completed"])}
164
+ </Typography>
165
+ {order.items.map((item) => (
166
+ <Typography key={item.id} size="body-3">
167
+ {item.qty} × {item.title} · {formatCents(item.unitPriceCents)}
168
+ </Typography>
169
+ ))}
170
+ <Typography size="body-3">
171
+ {t(($) => $.orders.total)}: {formatCents(order.totalCents)}
172
+ </Typography>
173
+ <Typography size="label-3" className="text-text-default-2">
174
+ {order.shippingName}, {order.shippingLine1}, {order.shippingCity}
175
+ </Typography>
176
+ {role === "seller" && order.status === "paid" ? (
177
+ <Button size="xs" onPress={() => void onShip()}>
178
+ {t(($) => $.orders.ship)}
179
+ </Button>
180
+ ) : null}
181
+ {role === "buyer" && order.status === "shipped" ? (
182
+ <Button size="xs" onPress={() => void onComplete()}>
183
+ {t(($) => $.orders.complete)}
184
+ </Button>
185
+ ) : null}
186
+ </Card>
187
+
188
+ {role === "buyer" && order.status === "completed" ? (
189
+ <form onSubmit={reviewForm.handleSubmit(onReview)} className="flex max-w-xl flex-col gap-3">
190
+ <Typography size="title-5">{t(($) => $.orders.review)}</Typography>
191
+ <div className="flex flex-wrap gap-1">
192
+ {order.items.map((item) => (
193
+ <Button
194
+ key={item.listingId}
195
+ type="button"
196
+ size="xs"
197
+ variant={reviewListingId === item.listingId ? "contained" : "outlined"}
198
+ color={reviewListingId === item.listingId ? "primary" : "secondary"}
199
+ onPress={() => reviewForm.setFieldValue("listingId", item.listingId)}
200
+ >
201
+ {item.title}
202
+ </Button>
203
+ ))}
204
+ </div>
205
+ <TextInput
206
+ variant="filled"
207
+ size="extra-small"
208
+ field={{ form: reviewForm, name: "rating" }}
209
+ label={t(($) => $.orders.reviewRating)}
210
+ />
211
+ <TextArea
212
+ variant="filled"
213
+ size="extra-small"
214
+ field={{ form: reviewForm, name: "body" }}
215
+ label={t(($) => $.orders.reviewBody)}
216
+ />
217
+ <Button type="submit" size="xs">
218
+ {t(($) => $.orders.reviewSubmit)}
219
+ </Button>
220
+ </form>
221
+ ) : null}
222
+ </div>
223
+ );
224
+ }
@@ -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
+ }
@@ -0,0 +1,13 @@
1
+ import clsx from "clsx";
2
+ import type { HTMLAttributes } from "react";
3
+
4
+ export function BrandLogo({ className, ...props }: HTMLAttributes<HTMLSpanElement>) {
5
+ return (
6
+ <span
7
+ className={clsx("inline-flex h-[34px] items-center font-semibold text-xl tracking-tight", className)}
8
+ {...props}
9
+ >
10
+ Tiny
11
+ </span>
12
+ );
13
+ }
@@ -0,0 +1,43 @@
1
+ import { ErrorHandler } from "@povio/openapi-codegen-cli";
2
+ import { Button, Typography } from "@povio/ui";
3
+ import { useTranslation } from "react-i18next";
4
+
5
+ import { ThinPageWrapper } from "@/components/shared/layout/ThinPageWrapper";
6
+
7
+ export interface ErrorFallbackProps {
8
+ error: unknown;
9
+ resetError: () => void;
10
+ }
11
+
12
+ export const ErrorFallback = ({ error, resetError }: ErrorFallbackProps) => {
13
+ const { t } = useTranslation();
14
+
15
+ return (
16
+ <ThinPageWrapper>
17
+ <main className="flex flex-col items-center justify-center gap-2 p-8">
18
+ <Typography
19
+ size="headline-1"
20
+ variant="prominent-1"
21
+ as="h2"
22
+ >
23
+ {t(($) => $.shared.errorFallback.heading)}
24
+ </Typography>
25
+ <Typography
26
+ size="title-2"
27
+ className="text-center text-text-error-1"
28
+ >
29
+ {t(($) => $.shared.errorFallback.subheading, {
30
+ error: ErrorHandler.getErrorMessage(error),
31
+ })}
32
+ </Typography>
33
+ <Button
34
+ size="s"
35
+ type="button"
36
+ onPress={resetError}
37
+ >
38
+ {t(($) => $.shared.errorFallback.retryBtn)}
39
+ </Button>
40
+ </main>
41
+ </ThinPageWrapper>
42
+ );
43
+ };