From 562bc9fb704e99161949aabbe145338116629d4c Mon Sep 17 00:00:00 2001 From: Joel Fickson Date: Fri, 27 Nov 2026 21:24:25 +0100 Subject: [PATCH 1/3] feat: rebuild joentrust.com in Next.js Replace the Astro starter with a Next.js App Router site: home, agriculture, real estate, technology, family, contact, investment, privacy and terms. Contact form sends through Kazuni via a server action. --- .env.example | 3 + .gitignore | 30 +- README.md | 32 +- app/agriculture/page.tsx | 9 + app/contact/actions.ts | 65 + app/contact/contact-form.tsx | 70 + app/contact/page.tsx | 59 + app/family/page.tsx | 61 + app/globals.css | 744 ++++++ app/icon.svg | 1 + app/investment/page.tsx | 39 + app/layout.tsx | 42 + app/not-found.tsx | 19 + app/page.tsx | 166 ++ app/privacy/page.tsx | 52 + app/real-estate/page.tsx | 9 + app/robots.ts | 6 + app/sitemap.ts | 18 + app/technology/page.tsx | 73 + app/terms/page.tsx | 50 + astro.config.mjs | 8 - biome.json | 41 + components/audience-grid.tsx | 26 + components/company-graph.tsx | 101 + components/contact-band.tsx | 19 + components/crumbs.tsx | 20 + components/external-link.tsx | 9 + components/holding-row.tsx | 14 + components/mark.tsx | 9 + components/next-page.tsx | 19 + components/page-hero.tsx | 24 + components/principles.tsx | 17 + components/scenes.tsx | 83 + components/sector-page.tsx | 32 + components/site-footer.tsx | 15 + components/site-nav.tsx | 34 + lib/contact.schema.ts | 19 + lib/content.ts | 266 ++ lib/env.server.ts | 19 + next.config.ts | 8 + package.json | 42 +- pnpm-lock.yaml | 4590 +++++----------------------------- src/env.d.ts | 1 - src/layouts/Layout.astro | 34 - src/pages/index.astro | 33 - tailwind.config.mjs | 23 - tsconfig.json | 35 +- vercel.json | 4 + 48 files changed, 3057 insertions(+), 4036 deletions(-) create mode 100644 .env.example create mode 100644 app/agriculture/page.tsx create mode 100644 app/contact/actions.ts create mode 100644 app/contact/contact-form.tsx create mode 100644 app/contact/page.tsx create mode 100644 app/family/page.tsx create mode 100644 app/globals.css create mode 100644 app/icon.svg create mode 100644 app/investment/page.tsx create mode 100644 app/layout.tsx create mode 100644 app/not-found.tsx create mode 100644 app/page.tsx create mode 100644 app/privacy/page.tsx create mode 100644 app/real-estate/page.tsx create mode 100644 app/robots.ts create mode 100644 app/sitemap.ts create mode 100644 app/technology/page.tsx create mode 100644 app/terms/page.tsx delete mode 100644 astro.config.mjs create mode 100644 biome.json create mode 100644 components/audience-grid.tsx create mode 100644 components/company-graph.tsx create mode 100644 components/contact-band.tsx create mode 100644 components/crumbs.tsx create mode 100644 components/external-link.tsx create mode 100644 components/holding-row.tsx create mode 100644 components/mark.tsx create mode 100644 components/next-page.tsx create mode 100644 components/page-hero.tsx create mode 100644 components/principles.tsx create mode 100644 components/scenes.tsx create mode 100644 components/sector-page.tsx create mode 100644 components/site-footer.tsx create mode 100644 components/site-nav.tsx create mode 100644 lib/contact.schema.ts create mode 100644 lib/content.ts create mode 100644 lib/env.server.ts create mode 100644 next.config.ts delete mode 100644 src/env.d.ts delete mode 100644 src/layouts/Layout.astro delete mode 100644 src/pages/index.astro delete mode 100644 tailwind.config.mjs create mode 100644 vercel.json diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..63337ca --- /dev/null +++ b/.env.example @@ -0,0 +1,3 @@ +KAZUNI_API_KEY= +CONTACT_FROM_EMAIL= +CONTACT_TO_EMAIL= diff --git a/.gitignore b/.gitignore index 5e57968..bd42f9f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,21 +1,13 @@ -# build output -dist/ - -# generated types -.astro/ - -# dependencies -civil-crater/node_modules/ - -# logs -npm-debug.log* -yarn-debug.log* -yarn-error.log* -pnpm-debug.log* - -# environment variables +node_modules/ +.next/ +out/ +next-env.d.ts +*.tsbuildinfo +.vercel/ .env -.env.production - -# macOS-specific files +.env.local +.env.*.local .DS_Store +.idea/ +.vscode/ +.claude/worktrees/ diff --git a/README.md b/README.md index 54eb23c..e9e6dbc 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,27 @@ -# Fickson Limited -It all starts with a dream +# joentrust.com -## Services -- Real Estate -- Agriculture -- Technology +The website of Joen Trust. Next.js App Router, deployed on Vercel (project `fickson`) on merge to `master`. + +## Develop + +```bash +pnpm install +pnpm dev # http://localhost:3005 +pnpm typecheck && pnpm lint && pnpm build +``` + +## Contact form + +The form posts to a server action that sends the message through Kazuni. Set these on the Vercel project: + +| Variable | What it is | +| -------------------- | ------------------------------------------------------- | +| `KAZUNI_API_KEY` | Kazuni API key for a sender verified on the from domain | +| `CONTACT_FROM_EMAIL` | Sender address, on a domain verified in Kazuni | +| `CONTACT_TO_EMAIL` | Inbox the trustees read | + +Without them the form shows a "did not send" message and logs which variables are missing. + +## Content + +Page copy lives in `lib/content.ts`. The approved design mocks are in `Documents/Joen Trust/site/mocks/c2`. diff --git a/app/agriculture/page.tsx b/app/agriculture/page.tsx new file mode 100644 index 0000000..ddf0788 --- /dev/null +++ b/app/agriculture/page.tsx @@ -0,0 +1,9 @@ +import type { Metadata } from "next"; +import { SectorPageView } from "@/components/sector-page"; +import { AGRICULTURE } from "@/lib/content"; + +export const metadata: Metadata = { title: "Agriculture", description: AGRICULTURE.lede }; + +export default function AgriculturePage() { + return ; +} diff --git a/app/contact/actions.ts b/app/contact/actions.ts new file mode 100644 index 0000000..77a30e2 --- /dev/null +++ b/app/contact/actions.ts @@ -0,0 +1,65 @@ +"use server"; + +import { Kazuni } from "@kazuni/sdk"; +import { type ContactField, type ContactState, contactSchema } from "@/lib/contact.schema"; +import { readContactEnv } from "@/lib/env.server"; + +const FIELDS: ContactField[] = ["name", "email", "topic", "message"]; + +function isField(value: unknown): value is ContactField { + return typeof value === "string" && (FIELDS as string[]).includes(value); +} + +function escapeHtml(value: string): string { + return value + .replaceAll("&", "&") + .replaceAll("<", "<") + .replaceAll(">", ">") + .replaceAll('"', """); +} + +export async function sendContactMessage( + _previous: ContactState, + formData: FormData, +): Promise { + const parsed = contactSchema.safeParse({ + name: formData.get("name"), + email: formData.get("email"), + topic: formData.get("topic"), + message: formData.get("message"), + website: formData.get("website") ?? "", + }); + + if (!parsed.success) { + if (parsed.error.issues.some((issue) => issue.path[0] === "website")) { + return { kind: "sent" }; + } + const errors: Partial> = {}; + for (const issue of parsed.error.issues) { + const field = issue.path[0]; + if (isField(field) && !errors[field]) errors[field] = issue.message; + } + return { kind: "invalid", errors }; + } + + const { name, email, topic, message } = parsed.data; + const text = `From: ${name} <${email}>\nTopic: ${topic}\n\n${message}`; + const html = `

From: ${escapeHtml(name)} <${escapeHtml(email)}>
Topic: ${escapeHtml(topic)}

${escapeHtml(message)}

`; + + try { + const env = readContactEnv(); + const kazuni = new Kazuni({ apiKey: env.KAZUNI_API_KEY }); + await kazuni.send.email({ + from: env.CONTACT_FROM_EMAIL, + to: env.CONTACT_TO_EMAIL, + subject: `Website: ${topic} from ${name}`, + text, + html, + }); + } catch (error) { + console.error("contact form send failed", error); + return { kind: "failed" }; + } + + return { kind: "sent" }; +} diff --git a/app/contact/contact-form.tsx b/app/contact/contact-form.tsx new file mode 100644 index 0000000..1dd04e3 --- /dev/null +++ b/app/contact/contact-form.tsx @@ -0,0 +1,70 @@ +"use client"; + +import { useActionState } from "react"; +import type { ContactState } from "@/lib/contact.schema"; +import { CONTACT_TOPICS } from "@/lib/content"; +import { sendContactMessage } from "./actions"; + +const INITIAL: ContactState = { kind: "idle" }; + +export function ContactForm() { + const [state, action, pending] = useActionState(sendContactMessage, INITIAL); + const errors = state.kind === "invalid" ? state.errors : {}; + + if (state.kind === "sent") { + return ( +

+ Thank you. Your message is with the trustees and one of us will reply. +

+ ); + } + + return ( +
+
+ + +
+ +