feat: Add CookiesContext to +Page component
This commit is contained in:
parent
78e9df72f7
commit
3d5cc75984
@ -1,25 +0,0 @@
|
|||||||
import type { PageContext } from "vike/types";
|
|
||||||
|
|
||||||
import { getTelefuncContext } from "@/lib/getTelefuncContext";
|
|
||||||
import { CookieParser } from "@/services/CookieParser";
|
|
||||||
|
|
||||||
type ConsentCookies = keyof PageContext["cookies"]["consent"];
|
|
||||||
|
|
||||||
export async function onUpdateConsentCookie(cookieName: ConsentCookies, cookieValue: boolean) {
|
|
||||||
const context = getTelefuncContext();
|
|
||||||
const { reply } = context;
|
|
||||||
|
|
||||||
CookieParser.set(reply, cookieName, cookieValue.toString(), 365);
|
|
||||||
|
|
||||||
return { ok: true, message: "Updated consent cookie", cookieName, cookieValue };
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function onAcceptAllConsentCookie() {
|
|
||||||
const context = getTelefuncContext();
|
|
||||||
const { reply } = context;
|
|
||||||
|
|
||||||
CookieParser.set(reply, "analytics", "true", 365);
|
|
||||||
CookieParser.set(reply, "customization", "true", 365);
|
|
||||||
|
|
||||||
return { ok: true, message: "Updated consents cookies" };
|
|
||||||
}
|
|
||||||
@ -1,8 +1,11 @@
|
|||||||
import { Link } from "@/components/common/Link";
|
import { CookiesContext } from "@/components/common/Cookies";
|
||||||
import { Button } from "@/components/syntax/Button";
|
import { Button } from "@/components/syntax/Button";
|
||||||
import React from "react";
|
import { Link } from "@/components/common/Link";
|
||||||
|
import React, { useContext } from "react";
|
||||||
|
|
||||||
export function Page() {
|
export function Page() {
|
||||||
|
const { setIsOpen } = useContext(CookiesContext);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-4 p-4">
|
<div className="flex flex-col gap-4 p-4">
|
||||||
<h1 className="font-display text-3xl tracking-tight text-slate-900 dark:text-white">
|
<h1 className="font-display text-3xl tracking-tight text-slate-900 dark:text-white">
|
||||||
@ -79,13 +82,7 @@ export function Page() {
|
|||||||
paragraphe.
|
paragraphe.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<Button
|
<Button variant="secondary" className="w-max max-w-full" onClick={() => setIsOpen(true)}>
|
||||||
variant="secondary"
|
|
||||||
className="w-max max-w-full"
|
|
||||||
onClick={() => {
|
|
||||||
// TODO
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Paramétrer les cookies
|
Paramétrer les cookies
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
|
|||||||
0
app/providers/ThemeProvider.telefunc.ts
Normal file
0
app/providers/ThemeProvider.telefunc.ts
Normal file
Loading…
Reference in New Issue
Block a user