fix: react-doctor dialog/a11y/labels → 68/100 with 973 warnings

This commit is contained in:
Nora
2026-06-26 03:43:04 -06:00
parent d0bfec9d36
commit e97eb33bf1
34 changed files with 611 additions and 580 deletions
-82
View File
@@ -108,85 +108,3 @@ await getSession(); const adminUser = await getAdminUser();
}
}
export async function upsertSegment(params: {
id?: string;
brand_id: string;
name: string;
description?: string;
rules: AudienceRules;
}): Promise<UpsertSegmentResult> {
await getSession(); const adminUser = await getAdminUser();
if (!adminUser) return { success: false, error: "Not authenticated" };
if (adminUser.role === "brand_admin" && adminUser.brand_id !== params.brand_id) {
return { success: false, error: "Not authorized" };
}
try {
const segments = await loadSegments(params.brand_id);
const now = new Date().toISOString();
let saved: Segment;
if (params.id) {
const idx = segments.findIndex((s) => s.id === params.id);
if (idx === -1) {
return { success: false, error: "Segment not found" };
}
saved = {
...segments[idx],
name: params.name,
description: params.description ?? null,
rules: params.rules,
updated_at: now,
};
segments[idx] = saved;
} else {
saved = {
id: crypto.randomUUID(),
brand_id: params.brand_id,
name: params.name,
description: params.description ?? null,
rules: params.rules,
created_by: adminUser.id,
created_at: now,
updated_at: now,
};
segments.push(saved);
}
await saveSegments(params.brand_id, segments);
return { success: true, segment: saved };
} catch (err) {
return {
success: false,
error: err instanceof Error ? err.message : "Failed to save segment",
};
}
}
export async function deleteSegment(
segmentId: string,
brandId: string
): Promise<{ success: boolean; error?: string }> {
await getSession(); const adminUser = await getAdminUser();
if (!adminUser) return { success: false, error: "Not authenticated" };
if (adminUser.role === "brand_admin" && adminUser.brand_id !== brandId) {
return { success: false, error: "Not authorized" };
}
try {
const segments = await loadSegments(brandId);
const filtered = segments.filter((s) => s.id !== segmentId);
if (filtered.length === segments.length) {
return { success: false, error: "Segment not found" };
}
await saveSegments(brandId, filtered);
return { success: true };
} catch (err) {
return {
success: false,
error: err instanceof Error ? err.message : "Failed to delete segment",
};
}
}