From 54c7a393c4c0ce6b58ca487e9fcbff2ff0cd5960 Mon Sep 17 00:00:00 2001 From: joseyvanaarsen Date: Sun, 8 Mar 2026 17:49:16 +0100 Subject: [PATCH] Add Next.js frontend with TypeScript and React. Login and listings are added. Yet to add more auth, dashboard, etc. --- frontend/valora-web/.gitignore | 41 + frontend/valora-web/README.md | 36 + frontend/valora-web/app/browse/[id]/page.tsx | 201 + frontend/valora-web/app/browse/page.tsx | 212 + frontend/valora-web/app/dashboard/page.tsx | 10 + frontend/valora-web/app/favicon.ico | Bin 0 -> 25931 bytes frontend/valora-web/app/globals.css | 75 + frontend/valora-web/app/layout.tsx | 30 + frontend/valora-web/app/login/page.tsx | 9 + frontend/valora-web/app/page.tsx | 217 + frontend/valora-web/app/providers.tsx | 37 + frontend/valora-web/app/register/page.tsx | 9 + frontend/valora-web/components.json | 25 + .../valora-web/components/auth/auth-guard.tsx | 48 + .../valora-web/components/auth/login-form.tsx | 151 + .../components/auth/register-form.tsx | 224 + .../components/dashboard/dashboard-home.tsx | 49 + .../valora-web/components/layout/footer.tsx | 29 + .../valora-web/components/layout/navbar.tsx | 100 + .../components/listings/feature-badges.tsx | 31 + .../components/listings/listing-card.tsx | 102 + .../components/listings/listing-filters.tsx | 72 + .../listings/listing-grid-skeleton.tsx | 25 + .../components/listings/listing-grid.tsx | 18 + .../listings/listing-results-header.tsx | 54 + .../components/listings/listing-search.tsx | 38 + frontend/valora-web/components/ui/button.tsx | 60 + frontend/valora-web/eslint.config.mjs | 18 + frontend/valora-web/hooks/use-current-user.ts | 36 + frontend/valora-web/lib/api/api-client.ts | 74 + frontend/valora-web/lib/api/auth-api.ts | 33 + frontend/valora-web/lib/api/listings-api.ts | 97 + frontend/valora-web/lib/auth/token-storage.ts | 25 + frontend/valora-web/lib/config.ts | 9 + .../lib/listings/feature-parser.tsx | 60 + frontend/valora-web/lib/site-config.ts | 10 + frontend/valora-web/lib/utils.ts | 6 + frontend/valora-web/next.config.ts | 7 + frontend/valora-web/package-lock.json | 9975 +++++++++++++++++ frontend/valora-web/package.json | 40 + frontend/valora-web/postcss.config.mjs | 7 + frontend/valora-web/public/file.svg | 1 + frontend/valora-web/public/globe.svg | 1 + frontend/valora-web/public/next.svg | 1 + frontend/valora-web/public/vercel.svg | 1 + frontend/valora-web/public/window.svg | 1 + frontend/valora-web/tsconfig.json | 34 + frontend/valora-web/types/auth.ts | 29 + frontend/valora-web/types/listings.ts | 30 + src/Valora.Api/Program.cs | 27 +- 50 files changed, 12420 insertions(+), 5 deletions(-) create mode 100644 frontend/valora-web/.gitignore create mode 100644 frontend/valora-web/README.md create mode 100644 frontend/valora-web/app/browse/[id]/page.tsx create mode 100644 frontend/valora-web/app/browse/page.tsx create mode 100644 frontend/valora-web/app/dashboard/page.tsx create mode 100644 frontend/valora-web/app/favicon.ico create mode 100644 frontend/valora-web/app/globals.css create mode 100644 frontend/valora-web/app/layout.tsx create mode 100644 frontend/valora-web/app/login/page.tsx create mode 100644 frontend/valora-web/app/page.tsx create mode 100644 frontend/valora-web/app/providers.tsx create mode 100644 frontend/valora-web/app/register/page.tsx create mode 100644 frontend/valora-web/components.json create mode 100644 frontend/valora-web/components/auth/auth-guard.tsx create mode 100644 frontend/valora-web/components/auth/login-form.tsx create mode 100644 frontend/valora-web/components/auth/register-form.tsx create mode 100644 frontend/valora-web/components/dashboard/dashboard-home.tsx create mode 100644 frontend/valora-web/components/layout/footer.tsx create mode 100644 frontend/valora-web/components/layout/navbar.tsx create mode 100644 frontend/valora-web/components/listings/feature-badges.tsx create mode 100644 frontend/valora-web/components/listings/listing-card.tsx create mode 100644 frontend/valora-web/components/listings/listing-filters.tsx create mode 100644 frontend/valora-web/components/listings/listing-grid-skeleton.tsx create mode 100644 frontend/valora-web/components/listings/listing-grid.tsx create mode 100644 frontend/valora-web/components/listings/listing-results-header.tsx create mode 100644 frontend/valora-web/components/listings/listing-search.tsx create mode 100644 frontend/valora-web/components/ui/button.tsx create mode 100644 frontend/valora-web/eslint.config.mjs create mode 100644 frontend/valora-web/hooks/use-current-user.ts create mode 100644 frontend/valora-web/lib/api/api-client.ts create mode 100644 frontend/valora-web/lib/api/auth-api.ts create mode 100644 frontend/valora-web/lib/api/listings-api.ts create mode 100644 frontend/valora-web/lib/auth/token-storage.ts create mode 100644 frontend/valora-web/lib/config.ts create mode 100644 frontend/valora-web/lib/listings/feature-parser.tsx create mode 100644 frontend/valora-web/lib/site-config.ts create mode 100644 frontend/valora-web/lib/utils.ts create mode 100644 frontend/valora-web/next.config.ts create mode 100644 frontend/valora-web/package-lock.json create mode 100644 frontend/valora-web/package.json create mode 100644 frontend/valora-web/postcss.config.mjs create mode 100644 frontend/valora-web/public/file.svg create mode 100644 frontend/valora-web/public/globe.svg create mode 100644 frontend/valora-web/public/next.svg create mode 100644 frontend/valora-web/public/vercel.svg create mode 100644 frontend/valora-web/public/window.svg create mode 100644 frontend/valora-web/tsconfig.json create mode 100644 frontend/valora-web/types/auth.ts create mode 100644 frontend/valora-web/types/listings.ts diff --git a/frontend/valora-web/.gitignore b/frontend/valora-web/.gitignore new file mode 100644 index 0000000..5ef6a52 --- /dev/null +++ b/frontend/valora-web/.gitignore @@ -0,0 +1,41 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +/node_modules +/.pnp +.pnp.* +.yarn/* +!.yarn/patches +!.yarn/plugins +!.yarn/releases +!.yarn/versions + +# testing +/coverage + +# next.js +/.next/ +/out/ + +# production +/build + +# misc +.DS_Store +*.pem + +# debug +npm-debug.log* +yarn-debug.log* +yarn-error.log* +.pnpm-debug.log* + +# env files (can opt-in for committing if needed) +.env* + +# vercel +.vercel + +# typescript +*.tsbuildinfo +next-env.d.ts diff --git a/frontend/valora-web/README.md b/frontend/valora-web/README.md new file mode 100644 index 0000000..e215bc4 --- /dev/null +++ b/frontend/valora-web/README.md @@ -0,0 +1,36 @@ +This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app). + +## Getting Started + +First, run the development server: + +```bash +npm run dev +# or +yarn dev +# or +pnpm dev +# or +bun dev +``` + +Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. + +You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file. + +This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel. + +## Learn More + +To learn more about Next.js, take a look at the following resources: + +- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. +- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. + +You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome! + +## Deploy on Vercel + +The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. + +Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details. diff --git a/frontend/valora-web/app/browse/[id]/page.tsx b/frontend/valora-web/app/browse/[id]/page.tsx new file mode 100644 index 0000000..3d1f64f --- /dev/null +++ b/frontend/valora-web/app/browse/[id]/page.tsx @@ -0,0 +1,201 @@ +"use client"; + +import Link from "next/link"; +import { use } from "react"; +import { useQuery } from "@tanstack/react-query"; +import { ArrowLeft, CalendarDays, Sparkles, Tag } from "lucide-react"; +import { FeatureBadges } from "@/components/listings/feature-badges"; +import { Footer } from "@/components/layout/footer"; +import { Navbar } from "@/components/layout/navbar"; +import { parseFeaturesJson } from "@/lib/listings/feature-parser"; +import { listingsApi } from "@/lib/api/listings-api"; + +interface ListingDetailPageProps { + params: Promise<{ + id: string; + }>; +} + +function formatCurrency(value: number | null): string { + if (value === null) { + return "Niet beschikbaar"; + } + + return new Intl.NumberFormat("nl-NL", { + style: "currency", + currency: "EUR", + maximumFractionDigits: 0, + }).format(value); +} + +function formatCategory(categoryKey: string): string { + return categoryKey + .replaceAll("-", " ") + .replaceAll("_", " ") + .replace(/\b\w/g, (char) => char.toUpperCase()); +} + +export default function ListingDetailPage({ + params, +}: ListingDetailPageProps): React.JSX.Element { + const resolvedParams = use(params); + + const query = useQuery({ + queryKey: ["listing-detail", resolvedParams.id], + queryFn: ({ signal }) => listingsApi.getById(resolvedParams.id, signal), + }); + + const features = query.data ? parseFeaturesJson(query.data.featuresJson) : []; + + return ( + <> + + +
+ + + Terug naar browse + + + {query.isLoading ? ( +
+
+
+
+
+ ) : null} + + {query.isError ? ( +
+

+ Listing kon niet worden geladen +

+

+ De listing bestaat mogelijk niet, of je backend is niet bereikbaar. +

+
+ ) : null} + + {query.data ? ( +
+
+
+ +
+
+
+

+ {formatCategory(query.data.categoryKey)} +

+

+ {query.data.title} +

+
+ + + {query.data.status} + +
+ +

+ {query.data.description} +

+ +
+ +
+ +
+
+
+ +

+ Vraagprijs +

+
+

+ {formatCurrency(query.data.askingPrice)} +

+
+ +
+
+ +

+ Voorspelde prijs +

+
+

+ {formatCurrency(query.data.predictedPrice)} +

+
+
+ +
+
+ +

+ Geplaatst op{" "} + {new Intl.DateTimeFormat("nl-NL", { + dateStyle: "full", + }).format(new Date(query.data.createdAtUtc))} +

+
+
+
+
+ + +
+ ) : null} +
+ +