Skip to content

Commit

Permalink
feat: add footer buttons to manage modal
Browse files Browse the repository at this point in the history
  • Loading branch information
rikhall1515 committed May 3, 2024
1 parent a320f95 commit d1788da
Showing 1 changed file with 81 additions and 0 deletions.
81 changes: 81 additions & 0 deletions components/cookies/manage/buttons.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
"use client";
import type { UseFormSetValue } from "react-hook-form";

import { Button } from "@/components/ui/button";
import { useCookieContext } from "@/context/cookie";

type CookieInputs = {
necessary: boolean;
preferences: boolean;
analytics: boolean;
advertising: boolean;
};

type ButtonProps = {
setValue: UseFormSetValue<CookieInputs>;
};

export function DenyAll({ setValue }: ButtonProps) {
const cookieStore = useCookieContext();
return (
<>
<Button
type="submit"
tabIndex={cookieStore.isManageConsentMenuOpen ? 0 : -1}
onClick={() => {
setValue("necessary", true);
setValue("preferences", false);
setValue("analytics", false);
setValue("advertising", false);
cookieStore.toggleManageConsentMenu();
}}
variant="outline"
className="flex h-[3rem] w-full grow items-center justify-center rounded-lg px-6 font-bold transition-all md:w-fit"
>
<span className="z-[2]">Deny all</span>
</Button>
</>
);
}

export function AcceptAll({ setValue }: ButtonProps) {
const cookieStore = useCookieContext();
return (
<>
<Button
type="submit"
tabIndex={cookieStore.isManageConsentMenuOpen ? 0 : -1}
onClick={() => {
setValue("necessary", true);
setValue("preferences", true);
setValue("analytics", true);
setValue("advertising", true);
cookieStore.toggleManageConsentMenu();
}}
variant="default"
className="flex h-[3rem] w-full grow items-center justify-center rounded-lg px-6 font-bold transition-all md:w-fit"
>
<span className="z-[2]">Accept All</span>
</Button>
</>
);
}

export function AcceptSelection() {
const cookieStore = useCookieContext();
return (
<>
<Button
type="submit"
tabIndex={cookieStore.isManageConsentMenuOpen ? 0 : -1}
onClick={() => {
cookieStore.toggleManageConsentMenu();
}}
variant="outline"
className="flex h-[3rem] w-full grow items-center justify-center rounded-lg px-6 font-bold transition-all md:w-fit"
>
<span className="z-[2]">Accept Selection</span>
</Button>
</>
);
}

0 comments on commit d1788da

Please sign in to comment.