diff --git a/apps/console/src/pages/organizations/cookie-banners/configuration/cookies/_components/AddCookieRow.tsx b/apps/console/src/pages/organizations/cookie-banners/configuration/cookies/_components/AddCookieRow.tsx index e92974210..8343009b6 100644 --- a/apps/console/src/pages/organizations/cookie-banners/configuration/cookies/_components/AddCookieRow.tsx +++ b/apps/console/src/pages/organizations/cookie-banners/configuration/cookies/_components/AddCookieRow.tsx @@ -51,6 +51,7 @@ export function AddCookieRow({ name: data.name, maxAgeSeconds: toMaxAgeSeconds(data.duration.value, data.duration.unit), description: data.description, + excluded: false, }); }; @@ -62,6 +63,7 @@ export function AddCookieRow({ placeholder={__("Cookie name")} /> + { + updatePattern({ + variables: { + input: { + cookiePatternId: patternId, + excluded, + }, + }, + onCompleted(_response, errors) { + if (errors?.length) { + toast({ + title: __("Error"), + description: errors[0].message, + variant: "error", + }); + return; + } + }, + onError(error) { + toast({ + title: __("Error"), + description: formatError( + __("Failed to update cookie"), + error as GraphQLError, + ), + variant: "error", + }); + }, + }); + }; + const handleDeleteCookie = (patternId: string) => { deletePattern({ variables: { @@ -568,7 +607,8 @@ export function CategorySection({ categoryKey, onDelete }: CategorySectionProps) - + + + + +
{__("Name")}{__("Name")}{__("Source")} {__("Duration")} {__("Description")} @@ -587,9 +627,30 @@ export function CategorySection({ categoryKey, onDelete }: CategorySectionProps) /> ) : ( -
- {pattern.displayName} +
+ handleToggleExcluded(pattern.id, !pattern.excluded)} + disabled={isUpdatingPattern} + title={__("Include this cookie in the banner")} + /> + {pattern.displayName} +
+
+ + {pattern.source === "SCRIPT" ? __("Script") : __("Pre-existing")} + {humanizeSeconds(pattern.maxAgeSeconds ?? null)} diff --git a/apps/console/src/pages/organizations/cookie-banners/configuration/cookies/_components/EditCookieRow.tsx b/apps/console/src/pages/organizations/cookie-banners/configuration/cookies/_components/EditCookieRow.tsx index 64672b4b6..26ba99b16 100644 --- a/apps/console/src/pages/organizations/cookie-banners/configuration/cookies/_components/EditCookieRow.tsx +++ b/apps/console/src/pages/organizations/cookie-banners/configuration/cookies/_components/EditCookieRow.tsx @@ -14,7 +14,7 @@ import { fromMaxAgeSeconds, toMaxAgeSeconds } from "@probo/helpers"; import { useTranslate } from "@probo/i18n"; -import { Button, DurationInput, Input, Td, Tr } from "@probo/ui"; +import { Button, DurationInput, Input, Td, Toggle, Tr } from "@probo/ui"; import { Controller, useForm } from "react-hook-form"; import { useFragment } from "react-relay"; import { graphql } from "relay-runtime"; @@ -28,6 +28,7 @@ export const editCookieRowFragment = graphql` displayName maxAgeSeconds description + excluded } `; @@ -35,6 +36,7 @@ interface CookieFormValues { name: string; duration: { value: string; unit: string }; description: string; + excluded: boolean; } interface EditCookieRowProps { @@ -59,6 +61,7 @@ export function EditCookieRow({ name: cookie.displayName, duration: initial, description: cookie.description, + excluded: cookie.excluded, }, }); @@ -67,17 +70,33 @@ export function EditCookieRow({ name: data.name, maxAgeSeconds: toMaxAgeSeconds(data.duration.value, data.duration.unit), description: data.description, + excluded: data.excluded, }); }; return (
- +
+ ( + field.onChange(!checked)} + title={__("Include this cookie in the banner")} + /> + )} + /> + +
-
+