Skip to content

Open-source agentic AI Search Execution Platform. Track AI visibility, find opportunities, and let agents turn signals into prioritized actions and drafted fixes across ChatGPT, Claude, Gemini, Google AI Overviews, Google AI Mode, Perplexity, Grok, and Microsoft Copilot.

fix(web): show brand location labels (#904)

ZaSourceCodedf5a507a2653
diff --git a/web/messages/en.json b/web/messages/en.json
index d83a62785..eaa2285bc 100644
--- a/web/messages/en.json
+++ b/web/messages/en.json
@@ -2223,6 +2223,10 @@
"dangerTab": "Danger Zone",
"saveChanges": "Save Changes",
"saved": "Brand updated!",
+ "region": "Region",
+ "stateOptional": "State (optional)",
+ "nationwide": "Nationwide (no state)",
+ "stateHint": "Localizes AI answers to this state from the next tracking run onward.",
"deleteWarning": "This action cannot be undone. All data for this brand (insights, content, competitors) will be permanently deleted.",
"confirmDelete": "Type the brand name to confirm:",
"deleteConfirmPlaceholder": "Brand name",
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/brands/[id]/settings/page.test.tsx b/web/src/app/[locale]/(dashboard)/dashboard/brands/[id]/settings/page.test.tsx
new file mode 100644
index 000000000..829c60008
--- /dev/null
+++ b/web/src/app/[locale]/(dashboard)/dashboard/brands/[id]/settings/page.test.tsx
@@ -0,0 +1,142 @@
+import { Suspense } from 'react';
+import { act } from 'react';
+import { createRoot } from 'react-dom/client';
+import { afterEach, describe, expect, it, vi } from 'vitest';
+import type { Brand } from '@/types';
+
+(
+ globalThis as typeof globalThis & {
+ IS_REACT_ACT_ENVIRONMENT: boolean;
+ }
+).IS_REACT_ACT_ENVIRONMENT = true;
+
+const brand: Brand = {
+ id: 'brand-id',
+ organizationId: 'organization-id',
+ name: 'Acme',
+ slug: 'acme',
+ industry: 'Technology',
+ region: 'US',
+ state: 'CA',
+ shoppingModeEnabled: false,
+ isActive: true,
+ domains: [],
+ createdAt: '2026-01-01T00:00:00.000Z',
+ updatedAt: '2026-01-01T00:00:00.000Z',
+};
+
+const translations: Record<string, string> = {
+ 'settings.region': 'Translated Region',
+ 'settings.stateOptional': 'Translated State',
+ 'settings.nationwide': 'Translated Nationwide',
+ 'settings.stateHint': 'Translated state hint',
+};
+
+vi.mock('next-intl', () => ({
+ useTranslations: () => (key: string) => translations[key] ?? key,
+}));
+
+vi.mock('@/i18n/navigation', () => ({
+ Link: ({ children, ...props }: React.ComponentProps<'a'>) => <a {...props}>{children}</a>,
+ useRouter: () => ({ push: vi.fn() }),
+}));
+
+vi.mock('@/stores/use-brand-store', () => ({
+ useBrandStore: () => ({
+ brands: [brand],
+ updateBrand: vi.fn(),
+ removeBrand: vi.fn(),
+ }),
+}));
+
+vi.mock('@/hooks/use-user-role', () => ({
+ useUserRole: () => ({ canAdmin: true }),
+}));
+
+vi.mock('@/lib/actions/brand', () => ({
+ deleteBrand: vi.fn(),
+ setBrandActive: vi.fn(),
+ setBrandShoppingMode: vi.fn(),
+ updateBrand: vi.fn(),
+}));
+
+vi.mock('@/lib/actions/brand-domain', () => ({
+ syncDomains: vi.fn(),
+}));
+
+vi.mock('@/lib/actions/competitor', () => ({
+ addCompetitor: vi.fn(),
+ deleteCompetitor: vi.fn(),
+ getCompetitors: vi.fn().mockResolvedValue([]),
+}));
+
+vi.mock('@/config/api', () => ({
+ getPublicApiBaseUrl: () => null,
+}));
+
+vi.mock('sonner', () => ({
+ toast: {
+ error: vi.fn(),
+ success: vi.fn(),
+ },
+}));
+
+import BrandSettingsPage from './page';
+
+afterEach(() => {
+ brand.state = 'CA';
+ document.body.replaceChildren();
+ vi.restoreAllMocks();
+});
+
+describe('brand settings location selects', () => {
+ it('shows translated labels instead of stored codes', async () => {
+ const consoleWarning = vi.spyOn(console, 'warn').mockImplementation(() => {});
+ const container = document.createElement('div');
+ document.body.append(container);
+ const root = createRoot(container);
+
+ await act(async () => {
+ root.render(
+ <Suspense>
+ <BrandSettingsPage params={Promise.resolve({ id: brand.id })} />
+ </Suspense>,
+ );
+ });
+
+ const values = Array.from(container.querySelectorAll('[data-slot="select-value"]'));
+
+ expect(values.map((value) => value.textContent)).toEqual([
+ 'Technology',
+ 'United States',
+ 'California',
+ ]);
+ expect(container.textContent).toContain('Translated Region');
+ expect(container.textContent).toContain('Translated State');
+ expect(container.textContent).toContain('Translated state hint');
+ expect(consoleWarning).not.toHaveBeenCalledWith(expect.stringContaining('[ui/select]'));
+
+ await act(async () => root.unmount());
+ });
+
+ it('shows the translated nationwide label when no state is selected', async () => {
+ brand.state = undefined;
+ const container = document.createElement('div');
+ document.body.append(container);
+ const root = createRoot(container);
+
+ await act(async () => {
+ root.render(
+ <Suspense>
+ <BrandSettingsPage params={Promise.resolve({ id: brand.id })} />
+ </Suspense>,
+ );
+ });
+
+ const values = Array.from(container.querySelectorAll('[data-slot="select-value"]'));
+
+ expect(values[2]?.textContent).toBe('Translated Nationwide');
+
+ await act(async () => root.unmount());
+ });
+});
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/brands/[id]/settings/page.tsx b/web/src/app/[locale]/(dashboard)/dashboard/brands/[id]/settings/page.tsx
index 910e703f3..7bda18ea3 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/brands/[id]/settings/page.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/brands/[id]/settings/page.tsx
@@ -15,7 +15,7 @@ import { getCompetitors, addCompetitor, deleteCompetitor } from '@/lib/actions/c
import { getFaviconUrl } from '@/lib/favicon';
import type { Competitor } from '@/types';
import { INDUSTRIES, type Brand, type BrandDomain } from '@/types';
-import { REGIONS, US_STATES } from '@/config/prompt-options';
+import { REGIONS, REGION_ITEMS, US_STATES, US_STATE_ITEMS } from '@/config/prompt-options';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
@@ -61,6 +61,8 @@ interface PageProps {
params: Promise<{ id: string }>;
}
+const INDUSTRY_ITEMS = INDUSTRIES.map((industry) => ({ value: industry, label: industry }));
+
export default function BrandSettingsPage({ params }: PageProps) {
const { id } = use(params);
const t = useTranslations('brands');
@@ -153,6 +155,7 @@ function GeneralTab({
const [region, setRegion] = useState(brand.region ?? 'US');
const [usState, setUsState] = useState(brand.state ?? '');
const [isSaving, setIsSaving] = useState(false);
+ const stateItems = [{ value: 'nationwide', label: t('settings.nationwide') }, ...US_STATE_ITEMS];
const handleSave = async () => {
if (!name.trim()) return;
@@ -220,7 +223,11 @@ function GeneralTab({
<div className="space-y-2">
<Label htmlFor="industry">{t('industry')}</Label>
- <Select value={industry} onValueChange={(v) => setIndustry(v ?? '')}>
+ <Select
+ items={INDUSTRY_ITEMS}
+ value={industry}
+ onValueChange={(v) => setIndustry(v ?? '')}
+ >
<SelectTrigger id="industry">
<SelectValue placeholder={t('industryPlaceholder')} />
</SelectTrigger>
@@ -246,8 +253,9 @@ function GeneralTab({
</div>
<div className="space-y-2">
- <Label>Region</Label>
+ <Label>{t('settings.region')}</Label>
<Select
+ items={REGION_ITEMS}
value={region}
onValueChange={(v) => {
if (!v) return;
@@ -270,8 +278,9 @@ function GeneralTab({
{region === 'US' && (
<div className="space-y-2">
- <Label>State (optional)</Label>
+ <Label>{t('settings.stateOptional')}</Label>
<Select
+ items={stateItems}
value={usState || 'nationwide'}
onValueChange={(v) => setUsState(!v || v === 'nationwide' ? '' : v)}
>
@@ -279,7 +288,7 @@ function GeneralTab({
<SelectValue />
</SelectTrigger>
<SelectContent>
- <SelectItem value="nationwide">Nationwide (no state)</SelectItem>
+ <SelectItem value="nationwide">{t('settings.nationwide')}</SelectItem>
{US_STATES.map((s) => (
<SelectItem key={s.code} value={s.code}>
{s.label}
@@ -287,9 +296,7 @@ function GeneralTab({
))}
</SelectContent>
</Select>
- <p className="text-xs text-muted-foreground">
- Localizes AI answers to this state from the next tracking run onward.
- </p>
+ <p className="text-xs text-muted-foreground">{t('settings.stateHint')}</p>
</div>
)}