Firmenkunden-CRM mit B2B-Patenschaften und Firmenportal
Admin: Firmen mit Vertriebsstufe und Wiedervorlage, Ansprechpartner mit Einladung ins Portal, B2B-Patenschaften mit Lieferungen und Neuigkeiten, private Dokumente, Notizen und Anfragen. Portal unter /konto/firma: Patenschaften, Lieferungen, Neuigkeiten, Dokument-Download und Anfrageformular. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,111 @@
|
||||
import { medusaConfig, medusaFetch } from "./medusa";
|
||||
|
||||
/** Firmenportal: Daten des angemeldeten Firmenkunden. */
|
||||
|
||||
export interface B2bDelivery {
|
||||
title: string;
|
||||
quantity: string | null;
|
||||
planned_at: string | null;
|
||||
shipped_at: string | null;
|
||||
tracking_number: string | null;
|
||||
status: "planned" | "shipped" | "delivered";
|
||||
}
|
||||
|
||||
export interface B2bReport {
|
||||
id: string;
|
||||
title: string;
|
||||
body: string | null;
|
||||
images: string[];
|
||||
published_at: string;
|
||||
}
|
||||
|
||||
export interface B2bSponsorship {
|
||||
id: string;
|
||||
title: string;
|
||||
colonies: number;
|
||||
location: string | null;
|
||||
start_date: string | null;
|
||||
end_date: string | null;
|
||||
price: number | null;
|
||||
status: "offer" | "active" | "renewal" | "ended";
|
||||
deliveries: B2bDelivery[];
|
||||
reports: B2bReport[];
|
||||
}
|
||||
|
||||
export interface B2bDocument {
|
||||
id: string;
|
||||
title: string;
|
||||
kind: "contract" | "certificate" | "invoice" | "offer" | "other";
|
||||
file_name: string;
|
||||
sponsorship_id: string | null;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export interface B2bPortal {
|
||||
company: { name: string; street: string | null; postal_code: string | null; city: string | null; vat_id: string | null };
|
||||
contacts: { name: string; email: string; role: string | null; has_login: boolean }[];
|
||||
sponsorships: B2bSponsorship[];
|
||||
documents: B2bDocument[];
|
||||
inquiries: { kind: string; colonies: number | null; message: string | null; status: "open" | "done"; created_at: string }[];
|
||||
}
|
||||
|
||||
export const PATEN_STATUS: Record<string, string> = {
|
||||
offer: "Angebot",
|
||||
active: "Aktiv",
|
||||
renewal: "Verlängerung steht an",
|
||||
ended: "Beendet",
|
||||
};
|
||||
|
||||
export const LIEFER_STATUS: Record<string, string> = {
|
||||
planned: "Geplant",
|
||||
shipped: "Versendet",
|
||||
delivered: "Zugestellt",
|
||||
};
|
||||
|
||||
export const DOKUMENT_ARTEN: Record<string, string> = {
|
||||
contract: "Vertrag",
|
||||
certificate: "Urkunde",
|
||||
invoice: "Rechnung",
|
||||
offer: "Angebot",
|
||||
other: "Dokument",
|
||||
};
|
||||
|
||||
export const ANFRAGE_ARTEN: Record<string, string> = {
|
||||
new: "Neue Patenschaft",
|
||||
more: "Mehr Völker",
|
||||
other: "Sonstiges",
|
||||
};
|
||||
|
||||
/** Portal-Daten, oder `null`, wenn das Konto zu keiner Firma gehört. */
|
||||
export async function getMyCompany(token: string): Promise<B2bPortal | null> {
|
||||
const { url, key } = medusaConfig();
|
||||
const res = await fetch(`${url}/store/customers/me/b2b`, {
|
||||
headers: { Authorization: `Bearer ${token}`, "x-publishable-api-key": key },
|
||||
});
|
||||
if (res.status === 404) return null;
|
||||
if (!res.ok) throw new Error(`Firmenportal nicht ladbar (${res.status})`);
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export async function getInvite(token: string): Promise<{ email: string; first_name: string | null; company: string } | null> {
|
||||
try {
|
||||
return await medusaFetch(`/store/b2b/invite?token=${encodeURIComponent(token)}`);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export async function acceptInvite(token: string, password: string): Promise<{ email: string }> {
|
||||
return medusaFetch("/store/b2b/invite", { method: "POST", body: JSON.stringify({ token, password }) });
|
||||
}
|
||||
|
||||
export async function createInquiry(
|
||||
token: string,
|
||||
payload: { kind: string; colonies?: number | null; message?: string }
|
||||
): Promise<void> {
|
||||
await medusaFetch("/store/customers/me/b2b/inquiries", {
|
||||
method: "POST",
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
---
|
||||
import Layout from "../../layouts/Layout.astro";
|
||||
import { getInvite } from "../../lib/b2b";
|
||||
|
||||
export const prerender = false;
|
||||
|
||||
const token = Astro.url.searchParams.get("token") ?? "";
|
||||
const einladung = token ? await getInvite(token) : null;
|
||||
---
|
||||
|
||||
<Layout title="Firmenportal – Zugang einrichten" description="Legen Sie Ihr Passwort für das place4bees-Firmenportal fest.">
|
||||
<section class="honeycomb-bg pt-24 pb-[var(--section-y)] sm:pt-28">
|
||||
<div class="mx-auto max-w-[30rem] px-[var(--gutter)]">
|
||||
<span class="section-label">Firmenportal</span>
|
||||
<h1 class="mt-5">Zugang einrichten</h1>
|
||||
|
||||
{einladung ? (
|
||||
<form id="invite-form" class="surface mt-10 grid gap-5 p-7 shadow-xs sm:p-8" data-token={token} data-email={einladung.email}>
|
||||
<p class="text-brand-text">
|
||||
{einladung.first_name ? `Hallo ${einladung.first_name}, l` : "L"}egen Sie Ihr Passwort für den Zugang von
|
||||
<strong class="text-brand-ink">{einladung.company}</strong> fest.
|
||||
</p>
|
||||
<div>
|
||||
<label class="field-label" for="invite-email">E-Mail</label>
|
||||
<input id="invite-email" class="field" type="email" value={einladung.email} disabled autocomplete="username" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="field-label" for="invite-password">Passwort (mindestens 8 Zeichen)</label>
|
||||
<input id="invite-password" class="field" type="password" name="password" required minlength="8" autocomplete="new-password" />
|
||||
</div>
|
||||
<p id="invite-status" role="alert" class="hidden text-sm text-[#b4453a]"></p>
|
||||
<button type="submit" class="btn btn-primary mt-1 w-full disabled:pointer-events-none disabled:opacity-55">
|
||||
Zugang einrichten
|
||||
</button>
|
||||
</form>
|
||||
) : (
|
||||
<div class="surface mt-10 p-7 shadow-xs sm:p-8">
|
||||
<p class="text-brand-text">
|
||||
Dieser Link ist abgelaufen oder wurde schon benutzt. Haben Sie Ihr Passwort bereits festgelegt, melden Sie sich
|
||||
einfach an. Sonst schicken wir Ihnen gern eine neue Einladung: kontakt@place4bees.com.
|
||||
</p>
|
||||
<a href="/konto/anmelden?redirect=/konto/firma" class="btn btn-primary mt-6 w-full">Zur Anmeldung</a>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</section>
|
||||
</Layout>
|
||||
|
||||
<script>
|
||||
import { acceptInvite } from "../../lib/b2b";
|
||||
import { loginCustomer } from "../../lib/auth";
|
||||
import { setCustomerTokenClient } from "../../lib/customerCookie";
|
||||
|
||||
document.addEventListener("astro:page-load", () => {
|
||||
const form = document.getElementById("invite-form") as HTMLFormElement | null;
|
||||
const status = document.getElementById("invite-status");
|
||||
if (!form) return;
|
||||
const token = form.dataset.token ?? "";
|
||||
// Das Token nicht im Verlauf stehen lassen.
|
||||
history.replaceState(history.state, "", window.location.pathname);
|
||||
|
||||
form.addEventListener("submit", async (event) => {
|
||||
event.preventDefault();
|
||||
const button = form.querySelector("button[type=submit]") as HTMLButtonElement;
|
||||
button.disabled = true;
|
||||
status?.classList.add("hidden");
|
||||
const passwort = String(new FormData(form).get("password"));
|
||||
try {
|
||||
const { email } = await acceptInvite(token, passwort);
|
||||
setCustomerTokenClient(await loginCustomer(email, passwort));
|
||||
window.location.href = "/konto/firma";
|
||||
} catch (err) {
|
||||
if (status) {
|
||||
status.textContent = err instanceof Error ? err.message : "Das hat nicht geklappt.";
|
||||
status.classList.remove("hidden");
|
||||
}
|
||||
button.disabled = false;
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,28 @@
|
||||
import type { APIRoute } from "astro";
|
||||
import { medusaConfig } from "../../../../lib/medusa";
|
||||
|
||||
export const prerender = false;
|
||||
|
||||
/**
|
||||
* Dokument-Download fürs Firmenportal. Ein Link im Browser kann kein
|
||||
* Bearer-Token mitschicken; deshalb holt diese Route die Datei mit dem
|
||||
* Token aus dem Cookie und reicht sie durch.
|
||||
*/
|
||||
export const GET: APIRoute = async ({ params, cookies, redirect }) => {
|
||||
const token = cookies.get("customer_jwt")?.value;
|
||||
if (!token) return redirect(`/konto/anmelden?redirect=/konto/firma`);
|
||||
|
||||
const { url, key } = medusaConfig();
|
||||
const res = await fetch(`${url}/store/customers/me/b2b/documents/${encodeURIComponent(params.id ?? "")}`, {
|
||||
headers: { Authorization: `Bearer ${token}`, "x-publishable-api-key": key },
|
||||
});
|
||||
if (!res.ok) return new Response("Dokument nicht gefunden.", { status: res.status === 401 ? 401 : 404 });
|
||||
|
||||
return new Response(res.body, {
|
||||
headers: {
|
||||
"Content-Type": res.headers.get("Content-Type") ?? "application/octet-stream",
|
||||
"Content-Disposition": res.headers.get("Content-Disposition") ?? "attachment",
|
||||
"Cache-Control": "private, no-store",
|
||||
},
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,273 @@
|
||||
---
|
||||
import Layout from "../../../layouts/Layout.astro";
|
||||
import {
|
||||
ANFRAGE_ARTEN,
|
||||
DOKUMENT_ARTEN,
|
||||
getMyCompany,
|
||||
LIEFER_STATUS,
|
||||
PATEN_STATUS,
|
||||
type B2bPortal,
|
||||
} from "../../../lib/b2b";
|
||||
|
||||
export const prerender = false;
|
||||
|
||||
const token = Astro.cookies.get("customer_jwt")?.value;
|
||||
if (!token) {
|
||||
return Astro.redirect("/konto/anmelden?redirect=/konto/firma");
|
||||
}
|
||||
|
||||
let portal: B2bPortal | null;
|
||||
try {
|
||||
portal = await getMyCompany(token);
|
||||
} catch {
|
||||
Astro.cookies.delete("customer_jwt", { path: "/" });
|
||||
return Astro.redirect("/konto/anmelden?redirect=/konto/firma");
|
||||
}
|
||||
// Kein Firmenkunde: Das normale Konto ist der richtige Ort.
|
||||
if (!portal) return Astro.redirect("/konto");
|
||||
|
||||
const datum = (wert: string | null | undefined) =>
|
||||
wert ? new Intl.DateTimeFormat("de-DE", { dateStyle: "medium" }).format(new Date(wert)) : null;
|
||||
const euro = (wert: number | null) =>
|
||||
wert === null || wert === undefined
|
||||
? null
|
||||
: new Intl.NumberFormat("de-DE", { style: "currency", currency: "EUR" }).format(Number(wert));
|
||||
|
||||
const laufend = portal.sponsorships.filter((p) => p.status === "active" || p.status === "renewal");
|
||||
const voelker = laufend.reduce((summe, p) => summe + p.colonies, 0);
|
||||
const titelZu = new Map(portal.sponsorships.map((p) => [p.id, p.title]));
|
||||
---
|
||||
|
||||
<Layout title="Firmenportal" description="Ihre Bienenpatenschaften bei place4bees im Überblick.">
|
||||
<section class="honeycomb-bg pt-24 pb-[var(--section-y)] sm:pt-28">
|
||||
<div class="mx-auto max-w-[60rem] px-[var(--gutter)]">
|
||||
<a href="/konto" class="text-sm text-brand-text hover:text-brand-ink">← Mein Konto</a>
|
||||
<span class="section-label mt-6 block">Firmenportal</span>
|
||||
<h1 class="mt-5">{portal.company.name}</h1>
|
||||
<p class="mt-2.5 text-brand-text">
|
||||
{laufend.length > 0
|
||||
? `${laufend.length} laufende Patenschaft${laufend.length > 1 ? "en" : ""} mit ${voelker} ${voelker === 1 ? "Bienenvolk" : "Bienenvölkern"}`
|
||||
: "Zurzeit keine laufende Patenschaft"}
|
||||
</p>
|
||||
|
||||
<h2 class="mt-16 text-h3">Ihre Bienenpatenschaften</h2>
|
||||
|
||||
{portal.sponsorships.length === 0 && (
|
||||
<div class="surface mt-6 px-8 py-12 text-center shadow-xs">
|
||||
<p class="text-brand-text">Sobald Ihre Patenschaft eingerichtet ist, finden Sie sie hier.</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div class="mt-6 grid gap-6">
|
||||
{portal.sponsorships.map((p) => (
|
||||
<article class="surface p-6 shadow-xs sm:p-8">
|
||||
<div class="flex flex-wrap items-start justify-between gap-4">
|
||||
<div>
|
||||
<h3 class="text-xl font-medium text-brand-ink">{p.title}</h3>
|
||||
<p class="mt-1 text-sm text-brand-text-muted">
|
||||
{[
|
||||
`${p.colonies} ${p.colonies === 1 ? "Bienenvolk" : "Bienenvölker"}`,
|
||||
p.location,
|
||||
datum(p.start_date) && `${datum(p.start_date)} – ${datum(p.end_date) ?? "offen"}`,
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(" · ")}
|
||||
</p>
|
||||
</div>
|
||||
<span
|
||||
class:list={[
|
||||
"rounded-[6px] px-3 py-1.5 text-xs font-medium",
|
||||
p.status === "renewal" ? "bg-brand-primary text-brand-ink" : "bg-brand-surface-sunk text-brand-text",
|
||||
]}
|
||||
>
|
||||
{PATEN_STATUS[p.status] ?? p.status}
|
||||
</span>
|
||||
</div>
|
||||
{euro(p.price) && <p class="mt-3 text-sm text-brand-text">Preis: {euro(p.price)} netto für die Laufzeit</p>}
|
||||
|
||||
<div class="mt-8 grid gap-8 md:grid-cols-[1fr_1.4fr]">
|
||||
<div>
|
||||
<h4 class="text-sm font-medium uppercase tracking-wide text-brand-text-muted">Lieferungen</h4>
|
||||
{p.deliveries.length === 0 ? (
|
||||
<p class="mt-3 text-sm text-brand-text">Noch keine Lieferungen geplant.</p>
|
||||
) : (
|
||||
<ul class="mt-3 grid gap-3">
|
||||
{p.deliveries.map((l) => (
|
||||
<li class="border-l-2 border-brand-primary pl-4">
|
||||
<p class="font-medium text-brand-ink">{l.title}</p>
|
||||
<p class="text-sm text-brand-text">
|
||||
{[
|
||||
l.quantity,
|
||||
l.status === "planned"
|
||||
? datum(l.planned_at) && `geplant ${datum(l.planned_at)}`
|
||||
: `${LIEFER_STATUS[l.status]}${datum(l.shipped_at) ? ` am ${datum(l.shipped_at)}` : ""}`,
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(" · ") || LIEFER_STATUS[l.status]}
|
||||
</p>
|
||||
{l.tracking_number && <p class="text-sm text-brand-text-muted">Sendungsnummer {l.tracking_number}</p>}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h4 class="text-sm font-medium uppercase tracking-wide text-brand-text-muted">Neuigkeiten von Ihren Völkern</h4>
|
||||
{p.reports.length === 0 ? (
|
||||
<p class="mt-3 text-sm text-brand-text">Bald berichten wir hier, wie es Ihren Bienen geht.</p>
|
||||
) : (
|
||||
<div class="mt-3 grid gap-6">
|
||||
{p.reports.map((r) => (
|
||||
<div>
|
||||
<p class="text-sm text-brand-text-muted">{datum(r.published_at)}</p>
|
||||
<p class="font-medium text-brand-ink">{r.title}</p>
|
||||
{r.body && <p class="mt-1.5 whitespace-pre-line text-sm leading-relaxed text-brand-text">{r.body}</p>}
|
||||
{r.images.length > 0 && (
|
||||
<div class="mt-3 grid grid-cols-2 gap-2 sm:grid-cols-3">
|
||||
{r.images.map((bild) => (
|
||||
<a href={bild} target="_blank" rel="noopener">
|
||||
<img src={bild} alt="" loading="lazy" class="aspect-square w-full rounded-[8px] object-cover" />
|
||||
</a>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<h2 class="mt-16 text-h3">Dokumente</h2>
|
||||
{portal.documents.length === 0 ? (
|
||||
<p class="mt-4 text-brand-text">Noch keine Dokumente hinterlegt.</p>
|
||||
) : (
|
||||
<ul class="mt-6 grid gap-3">
|
||||
{portal.documents.map((d) => (
|
||||
<li>
|
||||
<a
|
||||
href={`/konto/firma/dokument/${d.id}`}
|
||||
class="group card-interactive flex flex-wrap items-center justify-between gap-x-6 gap-y-2 p-5"
|
||||
>
|
||||
<div>
|
||||
<p class="font-medium text-brand-ink">{d.title}</p>
|
||||
<p class="mt-1 text-sm text-brand-text-muted">
|
||||
{[DOKUMENT_ARTEN[d.kind], d.sponsorship_id && titelZu.get(d.sponsorship_id), datum(d.created_at)]
|
||||
.filter(Boolean)
|
||||
.join(" · ")}
|
||||
</p>
|
||||
</div>
|
||||
<span class="text-sm font-medium text-brand-primary">Herunterladen</span>
|
||||
</a>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
|
||||
<h2 class="mt-16 text-h3">Anfrage an uns</h2>
|
||||
<p class="mt-2 text-brand-text">Mehr Völker, eine weitere Patenschaft oder eine Frage? Wir melden uns schnellstmöglich.</p>
|
||||
<form id="anfrage-form" class="surface mt-6 grid gap-5 p-7 shadow-xs sm:p-8">
|
||||
<div class="grid gap-5 sm:grid-cols-2">
|
||||
<div>
|
||||
<label class="field-label" for="anfrage-art">Worum geht es?</label>
|
||||
<select id="anfrage-art" name="kind" class="field" required>
|
||||
<option value="more">Mehr Völker für eine bestehende Patenschaft</option>
|
||||
<option value="new">Neue Patenschaft</option>
|
||||
<option value="other">Sonstiges</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="field-label" for="anfrage-voelker">Anzahl Völker (optional)</label>
|
||||
<input id="anfrage-voelker" name="colonies" class="field" type="number" min="1" max="1000" />
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="field-label" for="anfrage-text">Nachricht</label>
|
||||
<textarea id="anfrage-text" name="message" class="field min-h-28" maxlength="5000"></textarea>
|
||||
</div>
|
||||
<p id="anfrage-status" role="status" class="hidden text-sm"></p>
|
||||
<div>
|
||||
<button type="submit" class="btn btn-primary disabled:pointer-events-none disabled:opacity-55">Anfrage senden</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
{portal.inquiries.length > 0 && (
|
||||
<ul class="mt-6 grid gap-2 text-sm text-brand-text">
|
||||
{portal.inquiries.map((a) => (
|
||||
<li>
|
||||
{datum(a.created_at)} · {ANFRAGE_ARTEN[a.kind] ?? a.kind}
|
||||
{a.colonies ? ` (${a.colonies} Völker)` : ""} ·{" "}
|
||||
<span class="font-medium">{a.status === "open" ? "in Bearbeitung" : "erledigt"}</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
|
||||
<h2 class="mt-16 text-h3">Ihre Firma bei uns</h2>
|
||||
<div class="mt-6 grid gap-6 sm:grid-cols-2">
|
||||
<div class="surface p-6 shadow-xs">
|
||||
<p class="font-medium text-brand-ink">{portal.company.name}</p>
|
||||
<p class="mt-1 text-sm leading-relaxed text-brand-text">
|
||||
{portal.company.street}
|
||||
{portal.company.street && <br />}
|
||||
{[portal.company.postal_code, portal.company.city].filter(Boolean).join(" ")}
|
||||
</p>
|
||||
{portal.company.vat_id && <p class="mt-2 text-sm text-brand-text-muted">USt-IdNr. {portal.company.vat_id}</p>}
|
||||
</div>
|
||||
<div class="surface p-6 shadow-xs">
|
||||
<p class="font-medium text-brand-ink">Ansprechpartner</p>
|
||||
<ul class="mt-2 grid gap-1.5 text-sm text-brand-text">
|
||||
{portal.contacts.map((k) => (
|
||||
<li>
|
||||
{k.name || k.email}
|
||||
{k.role && <span class="text-brand-text-muted"> · {k.role}</span>}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<p class="mt-3 text-sm text-brand-text-muted">
|
||||
Änderungen oder weitere Zugänge? Schreiben Sie uns an{" "}
|
||||
<a href="mailto:kontakt@place4bees.com" class="underline">kontakt@place4bees.com</a>.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</Layout>
|
||||
|
||||
<script>
|
||||
import { createInquiry } from "../../../lib/b2b";
|
||||
import { getCustomerTokenClient } from "../../../lib/customerCookie";
|
||||
|
||||
document.addEventListener("astro:page-load", () => {
|
||||
const form = document.getElementById("anfrage-form") as HTMLFormElement | null;
|
||||
const status = document.getElementById("anfrage-status");
|
||||
|
||||
form?.addEventListener("submit", async (event) => {
|
||||
event.preventDefault();
|
||||
const token = getCustomerTokenClient();
|
||||
if (!token || !status) return;
|
||||
const button = form.querySelector("button[type=submit]") as HTMLButtonElement;
|
||||
button.disabled = true;
|
||||
const daten = new FormData(form);
|
||||
const voelker = String(daten.get("colonies") ?? "").trim();
|
||||
try {
|
||||
await createInquiry(token, {
|
||||
kind: String(daten.get("kind")),
|
||||
colonies: voelker ? Number(voelker) : null,
|
||||
message: String(daten.get("message") ?? ""),
|
||||
});
|
||||
form.reset();
|
||||
status.textContent = "Danke! Ihre Anfrage ist bei uns angekommen.";
|
||||
status.className = "text-sm text-brand-ink";
|
||||
} catch (err) {
|
||||
status.textContent = err instanceof Error ? err.message : "Das hat nicht geklappt.";
|
||||
status.className = "text-sm text-[#b4453a]";
|
||||
}
|
||||
button.disabled = false;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -1,6 +1,7 @@
|
||||
---
|
||||
import Layout from "../../layouts/Layout.astro";
|
||||
import { getCustomerMe, getEmailVerification, listMyOrders } from "../../lib/auth";
|
||||
import { getMyCompany } from "../../lib/b2b";
|
||||
|
||||
export const prerender = false;
|
||||
|
||||
@@ -24,6 +25,10 @@ try {
|
||||
return Astro.redirect("/konto/anmelden?redirect=/konto");
|
||||
}
|
||||
|
||||
// Firmenkunden bekommen einen Weg ins Firmenportal. Fehler hier sollen das
|
||||
// normale Konto nicht blockieren.
|
||||
const firma = await getMyCompany(token).catch(() => null);
|
||||
|
||||
const STATUS_LABELS: Record<string, string> = {
|
||||
pending: "In Bearbeitung",
|
||||
completed: "Abgeschlossen",
|
||||
@@ -79,6 +84,16 @@ function statusLabel(order: { status: string; fulfillment_status?: string }): st
|
||||
</div>
|
||||
)}
|
||||
|
||||
{firma && (
|
||||
<a href="/konto/firma" class="group card-interactive mt-10 flex flex-wrap items-center justify-between gap-4 p-6 sm:p-7">
|
||||
<div>
|
||||
<p class="font-medium text-brand-ink">Firmenportal {firma.company.name}</p>
|
||||
<p class="mt-1 text-sm text-brand-text">Bienenpatenschaften, Lieferungen, Neuigkeiten und Dokumente</p>
|
||||
</div>
|
||||
<span class="text-sm font-medium text-brand-primary">Öffnen →</span>
|
||||
</a>
|
||||
)}
|
||||
|
||||
<h2 class="mt-16 text-h3">Meine Bestellungen</h2>
|
||||
|
||||
{orders.length === 0 && (
|
||||
|
||||
Reference in New Issue
Block a user