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} +
+ +