Rename categories to consentCategories

Exclude the UNCATEGORISED category at the SQL level so
the admin cookie/display/translations pages only see
consent-relevant categories. Removes dead client-side
UNCATEGORISED filters that are no longer needed.

Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
Émile Ré
2026-05-04 19:51:22 +04:00
parent 3254c6ddec
commit c26b9c0abe
10 changed files with 113 additions and 27 deletions

View File

@@ -31,8 +31,8 @@ export const cookieBannerCookiesPageQuery = graphql`
__typename
... on CookieBanner {
id
categories(first: 50, orderBy: { field: RANK, direction: ASC })
@connection(key: "CookieBannerCookiesPage_categories")
consentCategories(first: 50, orderBy: { field: RANK, direction: ASC })
@connection(key: "CookieBannerCookiesPage_consentCategories")
@required(action: THROW) {
__id
edges {
@@ -86,8 +86,8 @@ export default function CookieBannerCookiesPage({
}
const banner = data.node;
const connectionId = banner.categories.__id;
const categories = banner.categories.edges.map(e => e.node);
const connectionId = banner.consentCategories.__id;
const categories = banner.consentCategories.edges.map(e => e.node);
const sorted = [...categories].sort((a, b) => a.rank - b.rank);
const [deleteCategory]

View File

@@ -80,7 +80,7 @@ export const categorySectionFragment = graphql`
}
}
cookieBanner @required(action: THROW) {
categories(first: 50, orderBy: { field: RANK, direction: ASC }) @required(action: THROW) {
consentCategories(first: 50, orderBy: { field: RANK, direction: ASC }) @required(action: THROW) {
edges {
node {
id
@@ -451,7 +451,7 @@ export function CategorySection({ categoryKey, onDelete }: CategorySectionProps)
});
};
const allCategories = category.cookieBanner.categories.edges.map(e => e.node) ?? [];
const allCategories = category.cookieBanner.consentCategories.edges.map(e => e.node) ?? [];
const siblingCategories = allCategories.filter(c => c.id !== category.id);
const handleMoveCookie = (patternId: string, targetCategoryId: string) => {

View File

@@ -25,8 +25,8 @@ import type { CategoryListReorderMutation } from "#/__generated__/core/CategoryL
const categoryListFragment = graphql`
fragment CategoryList_cookieBanner on CookieBanner {
id
categories(first: 50, orderBy: { field: RANK, direction: ASC })
@connection(key: "CategoryList_categories")
consentCategories(first: 50, orderBy: { field: RANK, direction: ASC })
@connection(key: "CategoryList_consentCategories")
@required(action: THROW) {
__id
edges {
@@ -87,8 +87,8 @@ export function CategoryList({ cookieBannerKey }: CategoryListProps) {
const confirm = useConfirm();
const banner = useFragment(categoryListFragment, cookieBannerKey);
const connectionId = banner.categories.__id;
const categories = banner.categories.edges.map(e => e.node);
const connectionId = banner.consentCategories.__id;
const categories = banner.consentCategories.edges.map(e => e.node);
const [deleteCategory] = useMutation<CategoryListDeleteMutation>(deleteCategoryMutation);
const [reorderCategory] = useMutation<CategoryListReorderMutation>(reorderCategoryMutation);

View File

@@ -36,7 +36,7 @@ export const cookieBannerTranslationsPageQuery = graphql`
language
translations
}
categories(first: 50, orderBy: { field: RANK, direction: ASC }) @required(action: THROW) {
consentCategories(first: 50, orderBy: { field: RANK, direction: ASC }) @required(action: THROW) {
edges {
node {
id
@@ -101,14 +101,14 @@ export default function CookieBannerTranslationsPage({
const categories = useMemo(
() =>
banner.categories.edges.map(e => ({
banner.consentCategories.edges.map(e => ({
id: e.node.id,
name: e.node.name,
slug: e.node.slug,
description: e.node.description,
kind: e.node.kind,
})),
[banner.categories],
[banner.consentCategories],
);
const necessaryCategoryName = useMemo(

View File

@@ -42,8 +42,6 @@ export function PanelTranslationSection({
const buttonSave = useWatch({ control, name: "button_save" });
const categoryTranslations = useWatch({ control, name: "categories" });
const visibleCategories = categories.filter(c => c.kind !== "UNCATEGORISED");
const translatedNecessaryName = (() => {
const necessaryCat = categories.find(c => c.kind === "NECESSARY");
if (!necessaryCat) return necessaryCategoryName;
@@ -157,13 +155,13 @@ export function PanelTranslationSection({
</div>
</div>
{visibleCategories.length > 0 && (
{categories.length > 0 && (
<div className="space-y-4">
<h4 className="text-sm font-medium text-txt-secondary">
{__("Category names")}
</h4>
<div className="grid grid-cols-2 gap-4">
{visibleCategories.map(cat => (
{categories.map(cat => (
<Card key={cat.id} className="border p-4 space-y-3">
<div className="text-sm text-txt-secondary">
{cat.name}

View File

@@ -99,7 +99,6 @@ export function TranslationEditor({
const catDefaults: CategoryTranslations = {};
for (const cat of categories) {
if (cat.kind === "UNCATEGORISED") continue;
const existing = existingCategoryTranslations?.[cat.id];
catDefaults[cat.id] = {
name: existing?.name ?? "",