Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | 157x 157x 255x 2x 255x 1x | import { CollapsibleCard } from "../../ui/collapsible";
import { MultiSelect } from "../../ui/multi-select";
import type { ProFormSectionProps } from "./types";
import { Award } from "lucide-react";
/**
* BrandsSection component displays brand relationships.
* Includes brands the pro works with and official brand partnerships.
*/
export function BrandsSection({
pro,
onUpdateField,
brands = {},
isLoadingTaxonomy = false,
}: ProFormSectionProps) {
// Ensure brands is always an object (handle null/undefined)
const brandsData = brands || {};
return (
<CollapsibleCard
title="Brands"
description="Which brands does this pro work with?"
icon={<Award className="h-5 w-5" />}
defaultOpen={(pro.brandsWorkWith?.length || 0) > 0}
>
<div className="space-y-4 pt-4">
{isLoadingTaxonomy ? (
<div className="animate-pulse space-y-4">
<div className="h-10 bg-background-muted rounded" />
<div className="h-10 bg-background-muted rounded" />
</div>
) : (
<>
<div className="space-y-2">
<label
htmlFor="admin-brands-work-with"
id="admin-brands-work-with-label"
className="text-sm font-medium text-foreground-default"
>
Brands We Work With
</label>
<MultiSelect
id="admin-brands-work-with"
aria-labelledby="admin-brands-work-with-label"
options={Object.entries(brandsData).flatMap(
([category, brandList]) =>
brandList.map((brand) => ({
value: brand.id,
label: `${brand.name} (${category})`,
})),
)}
selected={pro.brandsWorkWith || []}
onChange={(values) =>
onUpdateField(
"brandsWorkWith",
values.length > 0 ? values : null,
)
}
placeholder="Select brands"
/>
</div>
<div className="space-y-2">
<label
htmlFor="admin-brands-official-partner"
id="admin-brands-official-partner-label"
className="text-sm font-medium text-foreground-default"
>
Official Brand Partners
</label>
<MultiSelect
id="admin-brands-official-partner"
aria-labelledby="admin-brands-official-partner-label"
options={Object.entries(brandsData).flatMap(
([category, brandList]) =>
brandList.map((brand) => ({
value: brand.id,
label: `${brand.name} (${category})`,
})),
)}
selected={pro.brandsOfficialPartner || []}
onChange={(values) =>
onUpdateField(
"brandsOfficialPartner",
values.length > 0 ? values : null,
)
}
placeholder="Select official partnerships"
/>
</div>
</>
)}
</div>
</CollapsibleCard>
);
}
|