Organize Brand tab by brand selection for platform admins

- Added BrandSelector component showing all brands as cards
- Platform admins see brand selector at top of Brand tab
- Non-platform admins see only their brand's settings
- Brand selection via ?brand= query param updates the page
- Cards show which brand is currently selected
This commit is contained in:
2026-06-02 04:17:50 +00:00
parent 7783604141
commit f72cfad5f3
2 changed files with 90 additions and 5 deletions
+17 -4
View File
@@ -9,18 +9,31 @@ export const metadata = {
description: "Manage your brand settings, workers, tasks, and user permissions",
};
export default async function AdminSettingsPage() {
export default async function AdminSettingsPage({
searchParams,
}: {
searchParams: Promise<{ brand?: string }>;
}) {
const adminUser = await getAdminUser();
if (!adminUser) redirect("/login");
const brandId = adminUser.brand_id ?? "64294306-5f42-463d-a5e8-2ad6c81a96de";
const params = await searchParams;
const isPlatformAdmin = adminUser.role === "platform_admin";
// Platform admin can select a brand via query param, otherwise use their assigned brand
let brandId = adminUser.brand_id ?? "";
if (isPlatformAdmin && params.brand) {
brandId = params.brand;
} else if (!brandId) {
brandId = "64294306-5f42-463d-a5e8-2ad6c81a96de";
}
const [{ users, error }, { brands }] = await Promise.all([
getAdminUsers(adminUser.role === "platform_admin" ? undefined : (adminUser.brand_id ?? undefined)),
getAdminUsers(isPlatformAdmin ? undefined : (adminUser.brand_id ?? undefined)),
getBrands(),
]);
// Fetch payment settings for the brand tab
// Fetch payment settings for the current brand
const paymentResult = await getPaymentSettings(brandId);
const paymentSettings = paymentResult.success ? paymentResult.settings : null;