Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
KAZUNI_API_KEY=
CONTACT_FROM_EMAIL=
CONTACT_TO_EMAIL=
30 changes: 11 additions & 19 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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/
32 changes: 26 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@
# Joen Trust
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`.
9 changes: 9 additions & 0 deletions app/agriculture/page.tsx
Original file line number Diff line number Diff line change
@@ -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 <SectorPageView page={AGRICULTURE} />;
}
66 changes: 66 additions & 0 deletions app/contact/actions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
"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("&", "&amp;")
.replaceAll("<", "&lt;")
.replaceAll(">", "&gt;")
.replaceAll('"', "&quot;");
}

export async function sendContactMessage(
_previous: ContactState,
formData: FormData,
): Promise<ContactState> {
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<Record<ContactField, string>> = {};
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 = `<p><strong>From:</strong> ${escapeHtml(name)} &lt;${escapeHtml(email)}&gt;<br><strong>Topic:</strong> ${escapeHtml(topic)}</p><p style="white-space:pre-wrap">${escapeHtml(message)}</p>`;

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,
replyTo: 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" };
}
70 changes: 70 additions & 0 deletions app/contact/contact-form.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<p className="form-note ok" role="status">
Thank you. Your message is with the trustees and one of us will reply.
</p>
);
}

return (
<form action={action} noValidate>
<div className="two">
<label>
Your name
<input name="name" autoComplete="name" required aria-invalid={Boolean(errors.name)} />
{errors.name && <span className="field-error">{errors.name}</span>}
</label>
<label>
Email
<input
name="email"
type="email"
autoComplete="email"
required
aria-invalid={Boolean(errors.email)}
/>
{errors.email && <span className="field-error">{errors.email}</span>}
</label>
</div>
<label>
What is it about?
<select name="topic" defaultValue={CONTACT_TOPICS[0]}>
{CONTACT_TOPICS.map((topic) => (
<option key={topic}>{topic}</option>
))}
</select>
{errors.topic && <span className="field-error">{errors.topic}</span>}
</label>
<label>
Message
<textarea name="message" required aria-invalid={Boolean(errors.message)} />
{errors.message && <span className="field-error">{errors.message}</span>}
</label>
<label className="trap" aria-hidden="true">
Website
<input name="website" tabIndex={-1} autoComplete="off" />
</label>
{state.kind === "failed" && (
<p className="form-note fail" role="alert">
Your message did not send. Please try again, or write to info@joentrust.com.
</p>
)}
<button className="btn" type="submit" disabled={pending}>
{pending ? "Sending..." : "Send message"}
</button>
</form>
);
}
59 changes: 59 additions & 0 deletions app/contact/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import type { Metadata } from "next";
import Link from "next/link";
import { Crumbs } from "@/components/crumbs";
import { ExternalLink } from "@/components/external-link";
import { COMPANIES, SITE } from "@/lib/content";
import { ContactForm } from "./contact-form";

export const metadata: Metadata = {
title: "Contact",
description: "Write to the trustees of Joen Trust.",
};

export default function ContactPage() {
const liveCompanies = COMPANIES.filter((company) => company.domain !== null);
return (
<div className="wrap">
<section className="page-hero" style={{ paddingBottom: 0 }}>
<Crumbs trail={[{ label: "Contact" }]} />
<div className="grid" style={{ gridTemplateColumns: "1fr", paddingBottom: 24 }}>
<h1 style={{ maxWidth: "14ch" }}>Talk to the trustees.</h1>
<p className="lede">
Tell us what you have in mind. One of us reads every message and replies.
</p>
</div>
</section>
<section className="section split" style={{ paddingTop: 48 }}>
<ContactForm />
<div className="direct">
<div>
<h3>Write to us directly</h3>
<p>For anything about the trust.</p>
<a href={`mailto:${SITE.email}`}>{SITE.email}</a>
</div>
<div>
<h3>Already a customer?</h3>
<p>Product support is handled by each company.</p>
{liveCompanies.map(
(company) =>
company.domain && (
<div key={company.name}>
<ExternalLink domain={company.domain} className="" />
</div>
),
)}
</div>
<div>
<h3>Investing with us</h3>
<p>Partners invest in our companies directly.</p>
<Link href="/investment">How it works</Link>
</div>
<div>
<h3>Where we are</h3>
<p>Malawi</p>
</div>
</div>
</section>
</div>
);
}
61 changes: 61 additions & 0 deletions app/family/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import type { Metadata } from "next";
import { ContactBand } from "@/components/contact-band";
import { Crumbs } from "@/components/crumbs";
import { Principles } from "@/components/principles";
import { TRUSTEES } from "@/lib/content";

export const metadata: Metadata = {
title: "The family",
description: "Why Joel and Eunice Ngozo started Joen Trust, and how it decides what to hold.",
};

export default function FamilyPage() {
return (
<>
<div className="wrap">
<section className="page-hero" style={{ paddingBottom: 0 }}>
<Crumbs trail={[{ label: "The family" }]} />
<div className="grid" style={{ gridTemplateColumns: "1fr", paddingBottom: 24 }}>
<h1 style={{ maxWidth: "14ch" }}>A family trust, built to be handed on.</h1>
</div>
</section>
<section className="letter" style={{ paddingTop: 48 }}>
<h2>Why we started it</h2>
<div className="body">
<p>
We started Joen Trust so that what we build together outlasts any one project, and any
one of us.
</p>
<p className="soft">
Land, buildings and software look like three different businesses. To us they are the
same promise: make something useful in Malawi, look after it properly, and hand it on
in better shape than we found it.
</p>
<p className="soft">
The trust holds each business for the long run. It does not sell to make a quick
return, and it does not borrow against one lane to rescue another. Every decision is
judged on whether we would still be glad of it in thirty years.
</p>
</div>
</section>
<section className="section split" style={{ paddingTop: 0 }}>
<h2>Trustees</h2>
<div className="people">
{TRUSTEES.map((trustee) => (
<div key={trustee.name}>
<h3>{trustee.name}</h3>
<div className="role">Trustee</div>
{trustee.focus && <p>{trustee.focus}</p>}
</div>
))}
</div>
</section>
<Principles style={{ paddingTop: 0 }} />
</div>
<ContactBand
title="Want to talk to the trustees?"
detail="Partnerships, investment or a project in Malawi. One of us will reply."
/>
</>
);
}
Loading