916ad39176
Deploy to route.crispygoat.com / deploy (push) Failing after 3m1s
- Add MinIO/S3-compatible storage client (src/lib/storage.ts) with uploadObject, deleteObject, presigned URL helpers, and BUCKETS constant - Wire product images, brand logos, and water log photos to MinIO via the new storage client - Migrate forgot-password to Neon Auth (remove Supabase /auth/v1/recover call) - Migrate send-scheduled cron to direct Postgres + Resend (remove Supabase Edge Function proxy) - Add logoUrl to email types (OrderReceipt, Welcome, PasswordReset) and pass brand_settings.logo_url from all call sites - Update email templates to use dynamic logoUrl instead of hardcoded Supabase bucket URLs - Remove hardcoded Supabase URLs from TuxedoVideoHero, TuxedoAboutPage, TimeTrackingFieldClient; use brand_settings props + local public/ fallback - Download brand logos (3) and tuxedo-hero.mp4 (36MB) from Supabase bucket to public/ for local development - Add MinIO env vars to .env.example (endpoint, access key, secret, buckets) - Fix TimeTrackingFieldClient to destructure logoUrl and brandAccent props - Fix admin/users.ts logoUrl type (null → undefined for optional string) - Remove stale sb- cookie from wholesale-auth - Migrate tuxedo/about page to remove supabase import and use pool query for wholesale_settings lookup
85 lines
3.0 KiB
TypeScript
85 lines
3.0 KiB
TypeScript
"use server";
|
|
|
|
import { getAdminUser } from "@/lib/admin-permissions";
|
|
import { getActiveBrandId } from "@/lib/brand-scope";
|
|
import { supabase } from "@/lib/supabase";
|
|
import AdminAccessDenied from "@/components/admin/AdminAccessDenied";
|
|
import TaxDashboard from "@/components/admin/TaxDashboard";
|
|
import { PageHeader } from "@/components/admin/design-system";
|
|
|
|
type Props = {
|
|
params: Promise<{ brandId?: string }>;
|
|
};
|
|
|
|
export default async function TaxesPage({ params }: Props) {
|
|
const { brandId: brandIdParam } = await params;
|
|
const adminUser = await getAdminUser();
|
|
if (!adminUser) return <AdminAccessDenied />;
|
|
|
|
const activeBrandId = await getActiveBrandId(adminUser, brandIdParam);
|
|
if (!activeBrandId && adminUser.role !== "platform_admin") {
|
|
return <AdminAccessDenied message="You don't have access to that brand." />;
|
|
}
|
|
const effectiveBrandId = activeBrandId ?? "";
|
|
const isPlatformAdmin = adminUser.role === "platform_admin";
|
|
|
|
let resolvedBrandId = effectiveBrandId;
|
|
if (isPlatformAdmin && !resolvedBrandId) {
|
|
const { data: firstBrand } = await supabase
|
|
.from("brands")
|
|
.select("id")
|
|
.limit(1)
|
|
.single() as unknown as { data: { id: string } | null };
|
|
if (firstBrand?.id) {
|
|
resolvedBrandId = String(firstBrand.id);
|
|
} else {
|
|
return (
|
|
<main className="min-h-screen px-6 py-12" style={{ backgroundColor: "var(--admin-bg)" }}>
|
|
<div className="mx-auto max-w-6xl">
|
|
<div className="rounded-2xl p-8 text-center border" style={{
|
|
backgroundColor: "white",
|
|
borderColor: "var(--admin-border)"
|
|
}}>
|
|
<h1 className="text-2xl font-bold" style={{ color: "var(--admin-text-primary)" }}>No Brands Found</h1>
|
|
<p className="mt-2" style={{ color: "var(--admin-text-muted)" }}>Create a brand in the database first.</p>
|
|
<a href="/admin" className="mt-4 inline-block rounded-xl px-6 py-3 text-sm font-medium border transition-colors"
|
|
style={{
|
|
backgroundColor: "var(--admin-bg-subtle)",
|
|
borderColor: "var(--admin-border)",
|
|
color: "var(--admin-text-primary)"
|
|
}}>
|
|
Back to Admin
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
);
|
|
}
|
|
}
|
|
|
|
if (!resolvedBrandId) return <AdminAccessDenied />;
|
|
|
|
const { data: brands } = await supabase
|
|
.from("brands")
|
|
.select("id, name")
|
|
.order("name");
|
|
|
|
const allBrands = (brands ?? []) as Array<{ id: string; name: string }>;
|
|
|
|
return (
|
|
<main className="min-h-screen" style={{ backgroundColor: "var(--admin-bg)" }}>
|
|
<div className="mx-auto max-w-6xl px-6 py-10">
|
|
<PageHeader
|
|
title="Tax Dashboard"
|
|
subtitle="Sales tax collected on orders shipped to nexus states."
|
|
/>
|
|
|
|
<TaxDashboard
|
|
brands={allBrands}
|
|
initialBrandId={resolvedBrandId}
|
|
isPlatformAdmin={isPlatformAdmin}
|
|
/>
|
|
</div>
|
|
</main>
|
|
);
|
|
} |