From 736d198d7d0d2034c64cd0d90feb6079a7a6c653 Mon Sep 17 00:00:00 2001
From: Dominik Koch
Date: Tue, 7 Jan 2025 19:11:28 +0100
Subject: [PATCH 1/3] sync(staff): prod -> main
---
data/staffs.json | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/data/staffs.json b/data/staffs.json
index 8221fdae..a991dea5 100644
--- a/data/staffs.json
+++ b/data/staffs.json
@@ -4,7 +4,7 @@
"categories": ["Developers", "Translators"],
"description": "Founder, Lead Developer, German Translator",
"imageUrl": "https://cdn.wouldyoubot.gg/staff/developer/Dominik.webp",
- "websiteUrl": "https://dominikko.ch/"
+ "websiteUrl": "https://brickver.com/@dominik"
},
{
"name": "ForGetFulSkyBro",
@@ -20,6 +20,20 @@
"imageUrl": "https://cdn.wouldyoubot.gg/staff/developer/Skeleton.webp",
"websiteUrl": "https://github.com/nidrux"
},
+ {
+ "name": "Taqib",
+ "categories": ["Developers"],
+ "description": "Developer",
+ "imageUrl": "https://cdn.wouldyoubot.gg/staff/developer/Taqib.webp",
+ "websiteUrl": "https://taqib.dev/"
+ },
+ {
+ "name": "Woofer21",
+ "categories": ["Developers"],
+ "description": "Developer",
+ "imageUrl": "https://cdn.wouldyoubot.gg/staff/developer/Woofer.webp",
+ "websiteUrl": "https://woofer21.com/"
+ },
{
"name": "Noam",
"categories": ["Translators", "Beta Testers"],
@@ -55,13 +69,6 @@
"imageUrl": "https://cdn.wouldyoubot.gg/staff/special/Finn.webp",
"websiteUrl": "https://github.com/finnkoetting"
},
- {
- "name": "Sean",
- "categories": ["Contributors"],
- "description": "EX-Developer",
- "imageUrl": "https://cdn.wouldyoubot.gg/staff/special/Sean.webp",
- "websiteUrl": "https://sattler.dev/"
- },
{
"name": "NightKiller",
"categories": ["Contributors", "Beta Testers"],
@@ -129,16 +136,9 @@
"name": "Paulos",
"categories": ["Developers"],
"description": "Frontend Guy",
- "imageUrl": "https://cdn.wouldyoubot.gg/staff/special/Paulos.webp",
+ "imageUrl": "https://cdn.wouldyoubot.gg/staff/developer/Paulos.webp",
"websiteUrl": "https://dpaulos6.com?utm_source=wouldyoubot.gg"
},
- {
- "name": "Paul",
- "categories": ["Developers"],
- "description": "Full-stack Developer",
- "imageUrl": "https://cdn.wouldyoubot.gg/staff/developer/Paul.webp",
- "websiteUrl": "https://github.com/Jester0027"
- },
{
"name": "Dan",
"categories": ["Contributors"],
From 4a5d8affc83fec1027c3381329dff1f2e35f8922 Mon Sep 17 00:00:00 2001
From: Dominik Koch
Date: Tue, 7 Jan 2025 19:36:10 +0100
Subject: [PATCH 2/3] sync: full prod to staging sync
---
.vscode/settings.json | 5 +-
app/layout.tsx | 52 ++--
app/page.tsx | 3 +-
app/premium/page.tsx | 353 ++-----------------------
components/Embeds/MainDiscordEmbed.tsx | 283 ++++++++++----------
components/FeatureItem.tsx | 16 +-
components/Footer.tsx | 18 +-
components/Homepage/Content.tsx | 216 +++++++--------
components/Premium/Content.tsx | 305 +++++++++++++++++++++
components/cookies/cookie-banner.tsx | 78 ++++++
components/cookies/cookie-dialog.tsx | 118 +++++++++
components/cookies/cookie-provider.tsx | 131 +++++++++
components/cookies/index.ts | 5 +
components/plausible-script.tsx | 19 ++
helpers/hooks/useCookies.ts | 64 ++++-
package.json | 2 +-
pnpm-lock.yaml | 68 +++--
17 files changed, 1083 insertions(+), 653 deletions(-)
create mode 100644 components/Premium/Content.tsx
create mode 100644 components/cookies/cookie-banner.tsx
create mode 100644 components/cookies/cookie-dialog.tsx
create mode 100644 components/cookies/cookie-provider.tsx
create mode 100644 components/cookies/index.ts
create mode 100644 components/plausible-script.tsx
diff --git a/.vscode/settings.json b/.vscode/settings.json
index b0c11a73..b654e82e 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -2,5 +2,8 @@
"css.customData": [
".vscode/tailwind.json"
],
- "editor.defaultFormatter": "esbenp.prettier-vscode"
+ "editor.defaultFormatter": "esbenp.prettier-vscode",
+ "[typescriptreact]": {
+ "editor.defaultFormatter": "vscode.typescript-language-features"
+ }
}
diff --git a/app/layout.tsx b/app/layout.tsx
index f0aca701..6fb89762 100644
--- a/app/layout.tsx
+++ b/app/layout.tsx
@@ -1,11 +1,15 @@
+import { PlausibleScript } from '@/components/plausible-script'
+import { CookieProvider } from '@/components/cookies'
+import { IdTokenJWT } from '@/helpers/oauth/types'
import { getIdToken } from '@/helpers/oauth'
+import { ThemeProvider } from 'next-themes'
import Footer from '@/components/Footer'
import Navbar from '@/components/Navbar'
import { Inter } from 'next/font/google'
import Alert from '@/components/Alert'
-import Providers from './providers'
import React from 'react'
import './globals.css'
+
const inter = Inter({ subsets: ['latin'] })
export default function RootLayout({
@@ -16,30 +20,30 @@ export default function RootLayout({
const idToken = getIdToken()
return (
-
+
-
-
-
- Would You Bot • Upgrade your server with Premium
-
-
-
- {children}
-
-
-
+
+
+
+
+ Would You Bot • Upgrade your server with Premium
+
+
+
+ {children}
+
+
+
+
)
diff --git a/app/page.tsx b/app/page.tsx
index f2b19e90..d770d623 100644
--- a/app/page.tsx
+++ b/app/page.tsx
@@ -61,7 +61,6 @@ const Home = async () => {
const serverData = await serverResponse.json()
const servers = JSON.parse(serverData.result ?? null) ?? []
- const filteredServers = servers.filter((g: any) => g.name !== 'Pornhub')
return (
<>
@@ -70,7 +69,7 @@ const Home = async () => {
initialRatherQuestion={getRandomQuestion('rather')}
initialNhieQuestion={getRandomQuestion('nhie')}
serverCount={serverCount}
- servers={filteredServers}
+ servers={servers}
/>
diff --git a/app/premium/page.tsx b/app/premium/page.tsx
index 7761c8fd..9f922975 100644
--- a/app/premium/page.tsx
+++ b/app/premium/page.tsx
@@ -1,330 +1,35 @@
-// TODO remove the use client directive in favor of a server component
-'use client'
+import Content from '@/components/Premium/Content'
+import type { Metadata, Viewport } from 'next'
-import {
- ApplePay,
- CheckIcon,
- CloseIcon,
- GooglePay,
- Link,
- MasterCard,
- PayPal,
- Stripe,
- StripeSquare,
- Visa
-} from './_components/icons'
-import {
- Dialog,
- DialogContent,
- DialogDescription,
- DialogHeader,
- DialogTitle,
- DialogTrigger
-} from '@/components/ui/dialog'
-import {
- Select,
- SelectContent,
- SelectItem,
- SelectTrigger,
- SelectValue
-} from '@/components/ui/select'
-import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'
-import DiscordLoginButton from '@/components/DiscordLoginButton'
-import PlansComparison from './_components/PlansComparison'
-import { LazyMotion, domAnimation, m } from 'framer-motion'
-import CheckoutButton from './_components/checkoutButton'
-import { DiscordGuild, PricingData } from './_types'
-import { ServersListSkeleton } from './_components'
-import { useIdToken } from '@/helpers/hooks'
-import { Suspense, useState } from 'react'
-import { getServer } from '@/lib/redis'
-import Image from 'next/image'
-import Head from 'next/head'
-
-const pricingData: PricingData = {
- price: { monthly: 2.99, yearly: 29.99 },
- premium: {
- 'All Freemium Features': true,
- 'Unlimited Custom Questions': true,
- 'Customized Webhook Branding': true,
- 'Prevent Questions from Repeating': true,
- 'Get Rid of Button Ads': true,
- 'Auto Pin Daily Messages': true,
- 'Support the Development': true
- }
+export const metadata: Metadata = {
+ metadataBase: new URL('https://wouldyoubot.gg'),
+ title: 'Premium - Would You Bot',
+ description: 'Get premium for Would You Bot and unlock all features!',
+ twitter: {
+ title: 'Premium - Would You Bot',
+ description: 'Get premium for Would You Bot and unlock all features!'
+ },
+ openGraph: {
+ title: 'Premium - Would You Bot',
+ description: 'Get premium for Would You Bot and unlock all features!'
+ },
+ robots: {
+ index: true,
+ follow: true
+ }
}
-const data = [
- {
- criteria: '5 Gamemodes',
- free: true,
- premium: true
- },
- {
- criteria: 'Question of the Day',
- free: true,
- premium: true
- },
- {
- criteria: 'Question Repeat Prevention',
- free: false,
- premium: true
- },
- {
- criteria: 'Thousands of Questions',
- free: true,
- premium: true
- },
- {
- criteria: 'Custom Questions',
- free: 'Limited (100 per category)',
- premium: 'Unlimited'
- },
- {
- criteria: 'Custom Webhook Branding',
- free: false,
- premium: true
- },
- {
- criteria: 'Auto Pin Daily Messages',
- free: false,
- premium: true
- }
-]
+export const viewport: Viewport = {
+ themeColor: '#facc15',
+ maximumScale: 5
+}
export default function Premium() {
- const [isMonthly, setIsMonthly] = useState(true)
- const [serversData, setServersData] = useState([])
- const [serverId, setServerId] = useState()
- const idToken = useIdToken(null)
-
- const handleChange = () => {
- setIsMonthly(!isMonthly)
- }
-
- const fetchData = async () => {
- const servers = (await getServer()) as DiscordGuild[]
- setServersData(servers)
- }
-
- return (
- <>
-
- Would You - Premium
-
-
-
-
-
-
-
- Premium
-
-
- Select the plan that suits your needs and benefit from our
- discord bot.
-
-
-
-
-
-
-
- Monthly
-
-
- Yearly
-
-
-
-
-
-
-
-
- 2 months free
-
-
- Premium
-
-
- 2 months free
-
-
-
- {isMonthly ?
- pricingData.price.monthly
- : pricingData.price.yearly}
-
-
- {isMonthly ? '/ month' : '/ year'}
-
-
-
- Experience the full power of our Would You bot.
-
-
- {Object.keys(pricingData['premium']).map(
- (text, index) => (
-
- {(
- pricingData['premium'][
- text as keyof (typeof pricingData)['premium']
- ]
- ) ?
-
- :
- }
- {text}
-
- )
- )}
-
-
- {idToken ?
- {
- fetchData()
- }}
- className="flex w-full items-center justify-center gap-2 rounded-xl bg-green-500 py-2 font-bold leading-loose text-foreground transition hover:bg-green-600 focus:ring-0"
- >
- Continue with Stripe
-
-
- :
- }
-
-
-
-
- Buy{' '}
-
- Would
- {' '}
- You
- {isMonthly ? ' Monthly' : ' Yearly'}
-
-
-
-
-
-
-
-
-
- }>
- {serversData.map((server: DiscordGuild) => (
-
-
-
-
-
-
-
-
-
- {server.name}
-
-
-
- ))}
-
-
-
-
-
-
- {idToken ?
-
- Or click{' '}
-
- here
- {' '}
- to manage your subscriptions
-
- : null}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- >
- )
+ return (
+ <>
+
+
+
+ >
+ )
}
diff --git a/components/Embeds/MainDiscordEmbed.tsx b/components/Embeds/MainDiscordEmbed.tsx
index 2756a282..a5b540f1 100644
--- a/components/Embeds/MainDiscordEmbed.tsx
+++ b/components/Embeds/MainDiscordEmbed.tsx
@@ -1,158 +1,157 @@
'use client'
+
import {
- DiscordActionRow,
- DiscordAttachments,
- DiscordButton,
- DiscordCommand,
- DiscordEmbed,
- DiscordEmbedDescription,
- DiscordEmbedFooter,
- DiscordMessage,
- DiscordMessages
+ DiscordActionRow,
+ DiscordAttachments,
+ DiscordButton,
+ DiscordCommand,
+ DiscordEmbed,
+ DiscordEmbedDescription,
+ DiscordEmbedFooter,
+ DiscordMessage,
+ DiscordMessages
} from '@skyra/discord-components-react'
import { getRandomQuestion } from '@/helpers/getRandomQuestion'
-import { LazyMotion, domAnimation, m } from 'framer-motion'
import profiles from '@/data/profiles.json'
import { useTheme } from 'next-themes'
+import { motion } from 'motion/react'
import { FC, useState } from 'react'
interface MainProps {
- initialQuestion: string
+ initialQuestion: string
}
const MainDiscordEmbed: FC = ({ initialQuestion }) => {
- const { theme } = useTheme()
- const [replayedRounds, setReplayedRounds] = useState(0)
- const [currentQuestion, setCurrentQuestion] = useState(initialQuestion)
+ const { theme } = useTheme()
+ const [replayedRounds, setReplayedRounds] = useState(0)
+ const [currentQuestion, setCurrentQuestion] = useState(initialQuestion)
- const replay = () => {
- if (replayedRounds < 3) {
- setCurrentQuestion(getRandomQuestion('rather'))
- setReplayedRounds(replayedRounds + 1)
- }
- }
+ const replay = () => {
+ if (replayedRounds < 3) {
+ setCurrentQuestion(getRandomQuestion('rather'))
+ setReplayedRounds(replayedRounds + 1)
+ }
+ }
- return (
-
-
-
- 0}
- >
-
-
-
- {currentQuestion}
-
-
- Requested by dominikdev | Type: General | ID: 64
-
-
-
-
- Results
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {replayedRounds < 3 ?
- replay()}
- emoji="/emojis/refresh.svg"
- emojiName="refresh"
- >
- New Question
-
- :
- window.open('https://wouldyoubot.gg/invite', '_blank')
- }
- emoji="/emojis/external.svg"
- emojiName="external"
- >
- Invite Would You
-
- }
-
-
-
-
-
-
- )
+ return (
+
+
+ 0}
+ >
+
+
+
+ {currentQuestion}
+
+
+ Requested by dominikdev | Type: General | ID: 64
+
+
+
+
+ Results
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {replayedRounds < 3 ?
+ replay()}
+ emoji="/emojis/refresh.svg"
+ emojiName="refresh"
+ >
+ New Question
+
+ :
+ window.open('https://wouldyoubot.gg/invite', '_blank')
+ }
+ emoji="/emojis/external.svg"
+ emojiName="external"
+ >
+ Invite Would You
+
+ }
+
+
+
+
+
+ )
}
export default MainDiscordEmbed
diff --git a/components/FeatureItem.tsx b/components/FeatureItem.tsx
index 3ae36ad9..c50539ae 100644
--- a/components/FeatureItem.tsx
+++ b/components/FeatureItem.tsx
@@ -1,12 +1,14 @@
-import { m } from 'framer-motion'
+'use client'
+
+import { motion } from 'motion/react'
const FeatureItem: React.FC<{
left: React.ReactNode
right: React.ReactNode
reverse?: true
}> = ({ left, right, reverse }) => (
-
-
+
{left}
-
-
+
{right}
-
+
)
diff --git a/components/Footer.tsx b/components/Footer.tsx
index 6c44cf30..3fd0c5f1 100644
--- a/components/Footer.tsx
+++ b/components/Footer.tsx
@@ -1,9 +1,14 @@
-'use server'
+'use client'
+import { useCookieContext } from './cookies'
+import { Settings } from 'lucide-react'
+import { Button } from './ui/button'
import Image from 'next/image'
import Link from 'next/link'
-const Footer = async () => {
+const Footer = () => {
+ const { showCookieDialog } = useCookieContext()
+
const recommendedLinks = [
{
name: 'Home',
@@ -94,6 +99,15 @@ const Footer = async () => {
. All rights reserved.
+ {/* */}
+
+
+ Manage Cookies
+
diff --git a/components/Homepage/Content.tsx b/components/Homepage/Content.tsx
index 774fd732..effd17dd 100644
--- a/components/Homepage/Content.tsx
+++ b/components/Homepage/Content.tsx
@@ -4,7 +4,7 @@ import NeverHaveIEverEmbed from '@/components/Embeds/NeverHaveIEverEmbed'
import DailyMessageEmbed from '@/components/Embeds/DailyMessageEmbed'
import HigherLowerEmbed from '@/components/Embeds/HigherLowerEmbed'
import MainDiscordEmbed from '@/components/Embeds/MainDiscordEmbed'
-import { domAnimation, LazyMotion, m } from 'framer-motion'
+import { motion } from 'motion/react'
import ServerMarquee from '@/components/ServerMarquee'
import { Button, buttonVariants } from '../ui/button'
import FeatureItem from '@/components/FeatureItem'
@@ -36,67 +36,63 @@ export function HomeContent({
].join('/')} - Daily Message`
return (
-
-
-
+
+
+ Entertain Your
+
+
+ Discord
+ {' '}
+
+ Server
+
+
+
+ Play fun and entertaining games with Would You, featuring user polls
+ and customization. Play Would You Rather, Truth or Dare, Never Have
+ I Ever, Higher or Lower, and What Would You Do!
+
+
+
+
+ Trusted by your favorite servers!
+
+
+
-
- Entertain Your
-
-
- Discord
- {' '}
-
- Server
-
-
-
- Play fun and entertaining games with Would You, featuring user polls
- and customization. Play Would You Rather, Truth or Dare, Never Have
- I Ever, Higher or Lower, and What Would You Do!
-
-
-
-
- Trusted by your favorite servers!
-
-
-
- Unleash the Fun
-
-
-
-
-
-
-
-
-
@@ -118,19 +114,15 @@ export function HomeContent({
+ speed={40} />
+ direction="right" />
-
-
-
-
+
What Does Would You Offer To Your Server?
-
+
}
- left={
- <>
-
- Increase user engagement
-
-
- Keep your community engaged and active with daily "Would
- You Rather" messages!
-
- >
- }
- />
+ left={<>
+
+ Increase user engagement
+
+
+ Keep your community engaged and active with daily "Would
+ You Rather" messages!
+
+ >} />
-
- Entertain your server
-
-
- Entertain your discord server with fun and interactive games
- like Would You Rather, Truth or Dare, Never Have I Ever, Higher
- or Lower, and What Would You Do!
-
- >
- }
- right={ }
- />
+ left={<>
+
+ Entertain your server
+
+
+ Entertain your discord server with fun and interactive games
+ like Would You Rather, Truth or Dare, Never Have I Ever, Higher
+ or Lower, and What Would You Do!
+
+ >}
+ right={ } />
}
- left={
- <>
-
- Upgrade your server
-
-
- Upgrade your server with Would You, featuring a wide variety of
- games and customized questions.
-
- >
- }
- />
-
-
-
-
+
+ Upgrade your server
+
+
+ Upgrade your server with Would You, featuring a wide variety of
+ games and customized questions.
+
+ >} />
+
+
Would You
-
-
+
Invite To Your Server Now!
-
-
+
Invite
-
-
-
+
+ >
)
}
diff --git a/components/Premium/Content.tsx b/components/Premium/Content.tsx
new file mode 100644
index 00000000..aa2a35d9
--- /dev/null
+++ b/components/Premium/Content.tsx
@@ -0,0 +1,305 @@
+// TODO remove the use client directive in favor of a server component
+'use client'
+
+import {
+ Dialog,
+ DialogContent,
+ DialogDescription,
+ DialogHeader,
+ DialogTitle,
+ DialogTrigger
+} from '@/components/ui/dialog'
+import {
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue
+} from '@/components/ui/select'
+import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'
+import DiscordLoginButton from '@/components/DiscordLoginButton'
+import { useIdToken } from '@/helpers/hooks'
+import { Suspense, useState } from 'react'
+import { getServer } from '@/lib/redis'
+import Image from 'next/image'
+import Head from 'next/head'
+import { ServersListSkeleton } from '@/app/premium/_components'
+import CheckoutButton from '@/app/premium/_components/checkoutButton'
+import { CloseIcon, StripeSquare, ApplePay, GooglePay, MasterCard, Visa, PayPal, Stripe } from '@/app/premium/_components/icons'
+import PlansComparison from '@/app/premium/_components/PlansComparison'
+import { PricingData, DiscordGuild } from '@/app/premium/_types'
+import { CheckIcon, Link } from 'lucide-react'
+
+const pricingData: PricingData = {
+ price: { monthly: 2.99, yearly: 29.99 },
+ premium: {
+ 'All Freemium Features': true,
+ 'Unlimited Custom Questions': true,
+ 'Customized Webhook Branding': true,
+ 'Prevent Questions from Repeating': true,
+ 'Get Rid of Button Ads': true,
+ 'Auto Pin Daily Messages': true,
+ 'Support the Development': true
+ }
+}
+
+const data = [
+ {
+ criteria: '5 Gamemodes',
+ free: true,
+ premium: true
+ },
+ {
+ criteria: 'Question of the Day',
+ free: true,
+ premium: true
+ },
+ {
+ criteria: 'Question Repeat Prevention',
+ free: false,
+ premium: true
+ },
+ {
+ criteria: 'Thousands of Questions',
+ free: true,
+ premium: true
+ },
+ {
+ criteria: 'Custom Questions',
+ free: 'Limited (100 per category)',
+ premium: 'Unlimited'
+ },
+ {
+ criteria: 'Custom Webhook Branding',
+ free: false,
+ premium: true
+ },
+ {
+ criteria: 'Auto Pin Daily Messages',
+ free: false,
+ premium: true
+ }
+]
+
+export default function Premium() {
+ const [isMonthly, setIsMonthly] = useState(true)
+ const [serversData, setServersData] = useState
([])
+ const [serverId, setServerId] = useState()
+ const idToken = useIdToken(null)
+
+ const handleChange = () => {
+ setIsMonthly(!isMonthly)
+ }
+
+ const fetchData = async () => {
+ const servers = (await getServer()) as DiscordGuild[]
+ setServersData(servers)
+ }
+
+ return (
+ <>
+
+ Would You - Premium
+
+
+
+
+
+
+ Premium
+
+
+ Select the plan that suits your needs and benefit from our
+ discord bot.
+
+
+
+
+
+
+
+ Monthly
+
+
+ Yearly
+
+
+
+
+
+
+
+
+ 2 months free
+
+
+ Premium
+
+
+ 2 months free
+
+
+
+ {isMonthly ?
+ pricingData.price.monthly
+ : pricingData.price.yearly}
+
+
+ {isMonthly ? '/ month' : '/ year'}
+
+
+
+ Experience the full power of our Would You bot.
+
+
+ {Object.keys(pricingData['premium']).map(
+ (text, index) => (
+
+ {(
+ pricingData['premium'][
+ text as keyof (typeof pricingData)['premium']
+ ]
+ ) ?
+
+ :
+ }
+ {text}
+
+ )
+ )}
+
+
+ {idToken ?
+ {
+ fetchData()
+ }}
+ className="flex w-full items-center justify-center gap-2 rounded-xl bg-green-500 py-2 font-bold leading-loose text-foreground transition hover:bg-green-600 focus:ring-0"
+ >
+ Continue with Stripe
+
+
+ :
+ }
+
+
+
+
+ Buy{' '}
+
+ Would
+ {' '}
+ You
+ {isMonthly ? ' Monthly' : ' Yearly'}
+
+
+
+
+
+
+
+
+
+ }>
+ {serversData.map((server: DiscordGuild) => (
+
+
+
+
+
+
+
+
+
+ {server.name}
+
+
+
+ ))}
+
+
+
+
+
+
+ {idToken ?
+
+ Or click{' '}
+
+ here
+ {' '}
+ to manage your subscriptions
+
+ : null}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ >
+ )
+}
diff --git a/components/cookies/cookie-banner.tsx b/components/cookies/cookie-banner.tsx
new file mode 100644
index 00000000..49b356eb
--- /dev/null
+++ b/components/cookies/cookie-banner.tsx
@@ -0,0 +1,78 @@
+'use client'
+
+import { useCookieContext, CookieDialog } from '@/components/cookies'
+import { Button } from '@/components/ui/button'
+import { useState, useEffect } from 'react'
+
+export function CookieBanner() {
+ const { setShowBanner, state, setPreferences } = useCookieContext()
+ const [showModal, setShowModal] = useState(false)
+
+ useEffect(() => {
+ const cookieString = document.cookie
+ const isCookiesSet = cookieString.includes('cookiePreferences=')
+ setShowBanner(!isCookiesSet)
+ }, [setShowBanner])
+
+ const handleAcceptAll = () => {
+ const allPreferences = {
+ necessary: true,
+ analytics: true
+ }
+ setPreferences(allPreferences)
+ setShowBanner(false)
+ }
+
+ const handleRequiredOnly = () => {
+ const requiredPreferences = {
+ necessary: true,
+ analytics: false
+ }
+ setPreferences(requiredPreferences)
+ setShowBanner(false)
+ }
+
+ if (!state.preferences.necessary) return null
+
+ return (
+ <>
+
+
+
+ We use cookies to enhance your browsing experience and analyze our
+ traffic.
+
+
+ setShowModal(true)}
+ >
+ Customize
+
+
+ Required Only
+
+
+ Accept All
+
+
+
+
+
+ setShowModal(false)}
+ />
+ >
+ )
+}
diff --git a/components/cookies/cookie-dialog.tsx b/components/cookies/cookie-dialog.tsx
new file mode 100644
index 00000000..9dfa27f1
--- /dev/null
+++ b/components/cookies/cookie-dialog.tsx
@@ -0,0 +1,118 @@
+'use client'
+
+import {
+ Dialog,
+ DialogContent,
+ DialogHeader,
+ DialogTitle,
+ DialogDescription,
+ DialogFooter
+} from '@/components/ui/dialog'
+import { CookiePreferences } from '@/helpers/hooks/useCookies'
+import { Button } from '@/components/ui/button'
+import { Switch } from '@/components/ui/switch'
+import { Label } from '@/components/ui/label'
+import { useRouter } from 'next/navigation'
+import { useState } from 'react'
+
+interface CookieDialogProps {
+ preferences: CookiePreferences
+ onSave: (preferences: CookiePreferences) => void
+ onClose: () => void
+ open: boolean
+}
+
+export function CookieDialog({
+ preferences,
+ onSave,
+ onClose,
+ open
+}: CookieDialogProps) {
+ const [localPreferences, setLocalPreferences] = useState(preferences)
+ const router = useRouter()
+
+ const handleSavePreferences = () => {
+ onSave(localPreferences)
+ onClose()
+ router.refresh()
+ }
+
+ const handleReset = () => {
+ setLocalPreferences({
+ necessary: true,
+ analytics: true
+ })
+ }
+
+ const preferenceDescriptions: Record = {
+ necessary: 'All the necessary cookies needed to run the website.',
+ analytics: 'Optional analytics used to enhance your analytics.'
+ }
+
+ return (
+
+
+
+ Cookie Preferences
+
+ Customize your cookie preferences here. You can enable or disable
+ different categories of cookies.
+
+
+
+ {Object.entries(localPreferences).map(
+ ([key, value]: [string, boolean]) => (
+
+
+
+ {key}
+
+
+ {preferenceDescriptions[key as keyof CookiePreferences]}
+
+
+
+ setLocalPreferences((prev) => ({
+ ...prev,
+ [key]: checked
+ }))
+ }
+ disabled={key === 'necessary'}
+ className="data-[state=checked]:bg-brand-primary"
+ />
+
+ )
+ )}
+
+
+
+ Reset
+
+
+ Save Preferences
+
+
+
+
+ )
+}
diff --git a/components/cookies/cookie-provider.tsx b/components/cookies/cookie-provider.tsx
new file mode 100644
index 00000000..bac423ac
--- /dev/null
+++ b/components/cookies/cookie-provider.tsx
@@ -0,0 +1,131 @@
+'use client'
+
+import React, {
+ createContext,
+ useContext,
+ useReducer,
+ useCallback,
+ useEffect
+} from 'react'
+import { CookieDialog, CookieBanner } from '@/components/cookies'
+import { CookiePreferences } from '@/helpers/hooks/useCookies'
+
+const actionTypes = {
+ SHOW_DIALOG: 'SHOW_DIALOG',
+ HIDE_DIALOG: 'HIDE_DIALOG',
+ SET_PREFERENCES: 'SET_PREFERENCES',
+ REVOKE_PERMISSIONS: 'REVOKE_PERMISSIONS',
+ SET_SHOW_BANNER: 'SET_SHOW_BANNER'
+} as const
+
+interface CookieState {
+ showDialog: boolean
+ showBanner: boolean
+ preferences: CookiePreferences
+}
+
+const initialState: CookieState = {
+ showDialog: false,
+ showBanner: false,
+ preferences: {
+ necessary: true,
+ analytics: true
+ }
+}
+
+function cookieReducer(state: CookieState, action: any): CookieState {
+ switch (action.type) {
+ case actionTypes.SHOW_DIALOG:
+ return { ...state, showDialog: true }
+ case actionTypes.HIDE_DIALOG:
+ return { ...state, showDialog: false }
+ case actionTypes.SET_PREFERENCES:
+ return { ...state, preferences: action.payload, showBanner: false }
+ case actionTypes.REVOKE_PERMISSIONS:
+ return { ...state, preferences: initialState.preferences }
+ case actionTypes.SET_SHOW_BANNER:
+ return { ...state, showBanner: action.payload }
+ default:
+ return state
+ }
+}
+
+const CookieContext = createContext<{
+ state: CookieState
+ showCookieDialog: () => void
+ hideCookieDialog: () => void
+ setPreferences: (preferences: CookiePreferences) => void
+ setShowBanner: (show: boolean) => void
+}>({
+ state: initialState,
+ showCookieDialog: () => {},
+ hideCookieDialog: () => {},
+ setPreferences: () => {},
+ setShowBanner: () => {}
+})
+
+export const CookieProvider: React.FC<{ children: React.ReactNode }> = ({
+ children
+}) => {
+ const [state, dispatch] = useReducer(cookieReducer, initialState)
+
+ const showCookieDialog = useCallback(
+ () => dispatch({ type: actionTypes.SHOW_DIALOG }),
+ []
+ )
+ const hideCookieDialog = useCallback(
+ () => dispatch({ type: actionTypes.HIDE_DIALOG }),
+ []
+ )
+
+ const setPreferences = useCallback((preferences: CookiePreferences) => {
+ dispatch({ type: actionTypes.SET_PREFERENCES, payload: preferences })
+ document.cookie = `cookiePreferences=${JSON.stringify(preferences)}; path=/`
+ }, [])
+
+ const setShowBanner = useCallback((show: boolean) => {
+ dispatch({ type: actionTypes.SET_SHOW_BANNER, payload: show })
+ }, [])
+
+ useEffect(() => {
+ const cookieString = document.cookie
+ const cookiePreferencesMatch = cookieString.match(
+ /cookiePreferences=([^;]+)/
+ )
+
+ if (cookiePreferencesMatch) {
+ const cookiePreferences = JSON.parse(cookiePreferencesMatch[1])
+ dispatch({
+ type: actionTypes.SET_PREFERENCES,
+ payload: cookiePreferences
+ })
+ } else {
+ setShowBanner(true)
+ }
+ }, [setShowBanner])
+
+ return (
+
+ {children}
+ {state.showBanner && }
+ {state.showDialog && (
+
+ )}
+
+ )
+}
+
+export const useCookieContext = () => useContext(CookieContext)
diff --git a/components/cookies/index.ts b/components/cookies/index.ts
new file mode 100644
index 00000000..09ebb5a6
--- /dev/null
+++ b/components/cookies/index.ts
@@ -0,0 +1,5 @@
+import { CookieProvider, useCookieContext } from './cookie-provider'
+import { CookieBanner } from './cookie-banner'
+import { CookieDialog } from './cookie-dialog'
+
+export { CookieProvider, useCookieContext, CookieBanner, CookieDialog }
diff --git a/components/plausible-script.tsx b/components/plausible-script.tsx
new file mode 100644
index 00000000..84cdf06d
--- /dev/null
+++ b/components/plausible-script.tsx
@@ -0,0 +1,19 @@
+'use client'
+
+import { useCookiePreferences } from '@/helpers/hooks/useCookies'
+
+export function PlausibleScript() {
+ const { hasAnalytics } = useCookiePreferences()
+
+ if (hasAnalytics()) {
+ return (
+
+ )
+ } else {
+ return null
+ }
+}
diff --git a/helpers/hooks/useCookies.ts b/helpers/hooks/useCookies.ts
index ad5a3c8a..90c49c71 100644
--- a/helpers/hooks/useCookies.ts
+++ b/helpers/hooks/useCookies.ts
@@ -1,15 +1,59 @@
+'use client'
+
import { useIsClient } from '@/helpers/hooks/useIsClient'
+import { useState, useEffect } from 'react'
import { useMemo } from 'react'
export function useCookies() {
- const isClient = useIsClient()
- const cookies_ = isClient ? window?.document?.cookie : ''
-
- return useMemo(() => {
- return cookies_.split(';').reduce((acc, cookie) => {
- const [key, value] = cookie.split('=')
- acc.set(key.trim(), value)
- return acc
- }, new Map())
- }, [cookies_])
+ const isClient = useIsClient()
+ const cookies_ = isClient ? window?.document?.cookie : ''
+
+ return useMemo(() => {
+ return cookies_.split(';').reduce((acc, cookie) => {
+ const [key, value] = cookie.split('=')
+ acc.set(key.trim(), value)
+ return acc
+ }, new Map())
+ }, [cookies_])
+}
+
+export interface CookiePreferences {
+ necessary: boolean
+ analytics: boolean
+}
+
+export const useCookiePreferences = () => {
+ const cookies = useCookies()
+ const [data, setData] = useState({
+ necessary: true,
+ analytics: true
+ })
+ const [showBanner, setShowBanner] = useState(true)
+
+ useEffect(() => {
+ const savedPreferences = cookies.get('cookiePreferences')
+ if (savedPreferences) {
+ setData(JSON.parse(savedPreferences))
+ setShowBanner(false)
+ }
+ }, [cookies])
+
+ const savePreferences = (preferences: typeof data) => {
+ setData(preferences)
+ const expires = new Date(Date.now() + 31 * 864e5).toUTCString()
+ document.cookie = `cookiePreferences=${JSON.stringify(preferences)}; expires=${expires}; path=/`
+ }
+
+ const hasAnalytics = () => {
+ return data.analytics
+ }
+
+ return {
+ data,
+ setData,
+ showBanner,
+ setShowBanner,
+ savePreferences,
+ hasAnalytics
+ }
}
diff --git a/package.json b/package.json
index 0e84f7da..0e61768e 100644
--- a/package.json
+++ b/package.json
@@ -41,11 +41,11 @@
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"cmdk": "1.0.0",
- "framer-motion": "^11.5.4",
"gray-matter": "^4.0.3",
"grey-matter": "^0.0.0",
"lucide-react": "^0.468.0",
"mongoose": "^8.4.0",
+ "motion": "^11.16.0",
"next": "15.1.3",
"next-mdx-remote": "^4.4.1",
"next-sitemap": "^4.2.3",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 65b0c375..01d386a8 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -96,9 +96,6 @@ importers:
cmdk:
specifier: 1.0.0
version: 1.0.0(@types/react-dom@19.0.2(@types/react@19.0.2))(@types/react@19.0.2)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)
- framer-motion:
- specifier: ^11.5.4
- version: 11.15.0(react-dom@19.0.0(react@19.0.0))(react@19.0.0)
gray-matter:
specifier: ^4.0.3
version: 4.0.3
@@ -111,6 +108,9 @@ importers:
mongoose:
specifier: ^8.4.0
version: 8.9.2
+ motion:
+ specifier: ^11.16.0
+ version: 11.16.0(react-dom@19.0.0(react@19.0.0))(react@19.0.0)
next:
specifier: 15.1.3
version: 15.1.3(react-dom@19.0.0(react@19.0.0))(react@19.0.0)
@@ -2110,8 +2110,8 @@ packages:
fraction.js@4.3.7:
resolution: {integrity: sha512-ZsDfxO51wGAXREY55a7la9LScWpwv9RxIrYABrlvOFBlH/ShPnrtsXeuUIfXKKOVicNxQ+o8JTbJvjS4M89yew==}
- framer-motion@11.15.0:
- resolution: {integrity: sha512-MLk8IvZntxOMg7lDBLw2qgTHHv664bYoYmnFTmE0Gm/FW67aOJk0WM3ctMcG+Xhcv+vh5uyyXwxvxhSeJzSe+w==}
+ framer-motion@11.16.0:
+ resolution: {integrity: sha512-oL2AWqLQuw0+CNEUa0sz3mWC/n3i147CckvpQn8bLRs30b+HxTxlRi0YR2FpHHhAbWV7DKjNdHU42KHLfBWh/g==}
peerDependencies:
'@emotion/is-prop-valid': '*'
react: ^18.0.0 || ^19.0.0
@@ -2722,11 +2722,25 @@ packages:
resolution: {integrity: sha512-mLWynmZS1v8HTeMxyLhskQncS1SkrjW1eLNuFDYGQMQ/5QrFrxTLNwWXeCRZeKT2lXyaxW8bnJC9AKPT9jYMkw==}
engines: {node: '>=16.20.1'}
- motion-dom@11.14.3:
- resolution: {integrity: sha512-lW+D2wBy5vxLJi6aCP0xyxTxlTfiu+b+zcpVbGVFUxotwThqhdpPRSmX8xztAgtZMPMeU0WGVn/k1w4I+TbPqA==}
+ motion-dom@11.16.0:
+ resolution: {integrity: sha512-4bmEwajSdrljzDAYpu6ceEdtI4J5PH25fmN8YSx7Qxk6OMrC10CXM0D5y+VO/pFZjhmCvm2bGf7Rus482kwhzA==}
- motion-utils@11.14.3:
- resolution: {integrity: sha512-Xg+8xnqIJTpr0L/cidfTTBFkvRw26ZtGGuIhA94J9PQ2p4mEa06Xx7QVYZH0BP+EpMSaDlu+q0I0mmvwADPsaQ==}
+ motion-utils@11.16.0:
+ resolution: {integrity: sha512-ngdWPjg31rD4WGXFi0eZ00DQQqKKu04QExyv/ymlC+3k+WIgYVFbt6gS5JsFPbJODTF/r8XiE/X+SsoT9c0ocw==}
+
+ motion@11.16.0:
+ resolution: {integrity: sha512-d7EhBRFFBm6Ee6Q81Od45KOr3feA7UL/eAL+OKNZmf6rQJEwiXfvc/nkM522Ahiuvole1/8rNQyOX8JHKr8QoQ==}
+ peerDependencies:
+ '@emotion/is-prop-valid': '*'
+ react: ^18.0.0 || ^19.0.0
+ react-dom: ^18.0.0 || ^19.0.0
+ peerDependenciesMeta:
+ '@emotion/is-prop-valid':
+ optional: true
+ react:
+ optional: true
+ react-dom:
+ optional: true
mpath@0.9.0:
resolution: {integrity: sha512-ikJRQTk8hw5DEoFVxHG1Gn9T/xcjtdnOKIU1JTmGjZZlg9LST2mBLmcX3/ICIbgJydT2GOc15RnNy5mHmzfSew==}
@@ -5327,8 +5341,8 @@ snapshots:
'@typescript-eslint/parser': 6.21.0(eslint@8.57.1)(typescript@5.7.2)
eslint: 8.57.1
eslint-import-resolver-node: 0.3.9
- eslint-import-resolver-typescript: 3.7.0(eslint-plugin-import@2.31.0(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.7.2))(eslint@8.57.1))(eslint@8.57.1)
- eslint-plugin-import: 2.31.0(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.7.2))(eslint-import-resolver-typescript@3.7.0(eslint-plugin-import@2.31.0(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.7.2))(eslint@8.57.1))(eslint@8.57.1))(eslint@8.57.1)
+ eslint-import-resolver-typescript: 3.7.0(eslint-plugin-import@2.31.0)(eslint@8.57.1)
+ eslint-plugin-import: 2.31.0(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.7.2))(eslint-import-resolver-typescript@3.7.0)(eslint@8.57.1)
eslint-plugin-jsx-a11y: 6.10.2(eslint@8.57.1)
eslint-plugin-react: 7.37.3(eslint@8.57.1)
eslint-plugin-react-hooks: 5.1.0(eslint@8.57.1)
@@ -5347,7 +5361,7 @@ snapshots:
transitivePeerDependencies:
- supports-color
- eslint-import-resolver-typescript@3.7.0(eslint-plugin-import@2.31.0(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.7.2))(eslint@8.57.1))(eslint@8.57.1):
+ eslint-import-resolver-typescript@3.7.0(eslint-plugin-import@2.31.0)(eslint@8.57.1):
dependencies:
'@nolyfill/is-core-module': 1.0.39
debug: 4.4.0
@@ -5359,22 +5373,22 @@ snapshots:
is-glob: 4.0.3
stable-hash: 0.0.4
optionalDependencies:
- eslint-plugin-import: 2.31.0(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.7.2))(eslint-import-resolver-typescript@3.7.0(eslint-plugin-import@2.31.0(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.7.2))(eslint@8.57.1))(eslint@8.57.1))(eslint@8.57.1)
+ eslint-plugin-import: 2.31.0(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.7.2))(eslint-import-resolver-typescript@3.7.0)(eslint@8.57.1)
transitivePeerDependencies:
- supports-color
- eslint-module-utils@2.12.0(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.7.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.7.0(eslint-plugin-import@2.31.0(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.7.2))(eslint@8.57.1))(eslint@8.57.1))(eslint@8.57.1):
+ eslint-module-utils@2.12.0(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.7.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.7.0)(eslint@8.57.1):
dependencies:
debug: 3.2.7
optionalDependencies:
'@typescript-eslint/parser': 6.21.0(eslint@8.57.1)(typescript@5.7.2)
eslint: 8.57.1
eslint-import-resolver-node: 0.3.9
- eslint-import-resolver-typescript: 3.7.0(eslint-plugin-import@2.31.0(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.7.2))(eslint@8.57.1))(eslint@8.57.1)
+ eslint-import-resolver-typescript: 3.7.0(eslint-plugin-import@2.31.0)(eslint@8.57.1)
transitivePeerDependencies:
- supports-color
- eslint-plugin-import@2.31.0(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.7.2))(eslint-import-resolver-typescript@3.7.0(eslint-plugin-import@2.31.0(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.7.2))(eslint@8.57.1))(eslint@8.57.1))(eslint@8.57.1):
+ eslint-plugin-import@2.31.0(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.7.2))(eslint-import-resolver-typescript@3.7.0)(eslint@8.57.1):
dependencies:
'@rtsao/scc': 1.1.0
array-includes: 3.1.8
@@ -5385,7 +5399,7 @@ snapshots:
doctrine: 2.1.0
eslint: 8.57.1
eslint-import-resolver-node: 0.3.9
- eslint-module-utils: 2.12.0(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.7.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.7.0(eslint-plugin-import@2.31.0(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.7.2))(eslint@8.57.1))(eslint@8.57.1))(eslint@8.57.1)
+ eslint-module-utils: 2.12.0(@typescript-eslint/parser@6.21.0(eslint@8.57.1)(typescript@5.7.2))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.7.0)(eslint@8.57.1)
hasown: 2.0.2
is-core-module: 2.16.1
is-glob: 4.0.3
@@ -5619,10 +5633,10 @@ snapshots:
fraction.js@4.3.7: {}
- framer-motion@11.15.0(react-dom@19.0.0(react@19.0.0))(react@19.0.0):
+ framer-motion@11.16.0(react-dom@19.0.0(react@19.0.0))(react@19.0.0):
dependencies:
- motion-dom: 11.14.3
- motion-utils: 11.14.3
+ motion-dom: 11.16.0
+ motion-utils: 11.16.0
tslib: 2.8.1
optionalDependencies:
react: 19.0.0
@@ -6430,9 +6444,19 @@ snapshots:
- socks
- supports-color
- motion-dom@11.14.3: {}
+ motion-dom@11.16.0:
+ dependencies:
+ motion-utils: 11.16.0
- motion-utils@11.14.3: {}
+ motion-utils@11.16.0: {}
+
+ motion@11.16.0(react-dom@19.0.0(react@19.0.0))(react@19.0.0):
+ dependencies:
+ framer-motion: 11.16.0(react-dom@19.0.0(react@19.0.0))(react@19.0.0)
+ tslib: 2.8.1
+ optionalDependencies:
+ react: 19.0.0
+ react-dom: 19.0.0(react@19.0.0)
mpath@0.9.0: {}
From 1dd490a2a5adfa697562ca0c1311b721a4ad5584 Mon Sep 17 00:00:00 2001
From: mezotv
Date: Tue, 7 Jan 2025 18:37:30 +0000
Subject: [PATCH 3/3] chore(style): format files
---
app/premium/page.tsx | 48 +--
components/Embeds/MainDiscordEmbed.tsx | 278 +++++++++---------
components/Homepage/Content.tsx | 197 +++++++------
components/Premium/Content.tsx | 390 +++++++++++++------------
components/cookies/cookie-banner.tsx | 128 ++++----
components/cookies/cookie-dialog.tsx | 194 ++++++------
components/cookies/cookie-provider.tsx | 194 ++++++------
helpers/hooks/useCookies.ts | 90 +++---
8 files changed, 771 insertions(+), 748 deletions(-)
diff --git a/app/premium/page.tsx b/app/premium/page.tsx
index 9f922975..7662e731 100644
--- a/app/premium/page.tsx
+++ b/app/premium/page.tsx
@@ -2,34 +2,34 @@ import Content from '@/components/Premium/Content'
import type { Metadata, Viewport } from 'next'
export const metadata: Metadata = {
- metadataBase: new URL('https://wouldyoubot.gg'),
- title: 'Premium - Would You Bot',
- description: 'Get premium for Would You Bot and unlock all features!',
- twitter: {
- title: 'Premium - Would You Bot',
- description: 'Get premium for Would You Bot and unlock all features!'
- },
- openGraph: {
- title: 'Premium - Would You Bot',
- description: 'Get premium for Would You Bot and unlock all features!'
- },
- robots: {
- index: true,
- follow: true
- }
+ metadataBase: new URL('https://wouldyoubot.gg'),
+ title: 'Premium - Would You Bot',
+ description: 'Get premium for Would You Bot and unlock all features!',
+ twitter: {
+ title: 'Premium - Would You Bot',
+ description: 'Get premium for Would You Bot and unlock all features!'
+ },
+ openGraph: {
+ title: 'Premium - Would You Bot',
+ description: 'Get premium for Would You Bot and unlock all features!'
+ },
+ robots: {
+ index: true,
+ follow: true
+ }
}
export const viewport: Viewport = {
- themeColor: '#facc15',
- maximumScale: 5
+ themeColor: '#facc15',
+ maximumScale: 5
}
export default function Premium() {
- return (
- <>
-
-
-
- >
- )
+ return (
+ <>
+
+
+
+ >
+ )
}
diff --git a/components/Embeds/MainDiscordEmbed.tsx b/components/Embeds/MainDiscordEmbed.tsx
index a5b540f1..263a8c07 100644
--- a/components/Embeds/MainDiscordEmbed.tsx
+++ b/components/Embeds/MainDiscordEmbed.tsx
@@ -1,15 +1,15 @@
'use client'
import {
- DiscordActionRow,
- DiscordAttachments,
- DiscordButton,
- DiscordCommand,
- DiscordEmbed,
- DiscordEmbedDescription,
- DiscordEmbedFooter,
- DiscordMessage,
- DiscordMessages
+ DiscordActionRow,
+ DiscordAttachments,
+ DiscordButton,
+ DiscordCommand,
+ DiscordEmbed,
+ DiscordEmbedDescription,
+ DiscordEmbedFooter,
+ DiscordMessage,
+ DiscordMessages
} from '@skyra/discord-components-react'
import { getRandomQuestion } from '@/helpers/getRandomQuestion'
import profiles from '@/data/profiles.json'
@@ -18,140 +18,140 @@ import { motion } from 'motion/react'
import { FC, useState } from 'react'
interface MainProps {
- initialQuestion: string
+ initialQuestion: string
}
const MainDiscordEmbed: FC = ({ initialQuestion }) => {
- const { theme } = useTheme()
- const [replayedRounds, setReplayedRounds] = useState(0)
- const [currentQuestion, setCurrentQuestion] = useState(initialQuestion)
+ const { theme } = useTheme()
+ const [replayedRounds, setReplayedRounds] = useState(0)
+ const [currentQuestion, setCurrentQuestion] = useState(initialQuestion)
- const replay = () => {
- if (replayedRounds < 3) {
- setCurrentQuestion(getRandomQuestion('rather'))
- setReplayedRounds(replayedRounds + 1)
- }
- }
+ const replay = () => {
+ if (replayedRounds < 3) {
+ setCurrentQuestion(getRandomQuestion('rather'))
+ setReplayedRounds(replayedRounds + 1)
+ }
+ }
- return (
-
-
- 0}
- >
-
-
-
- {currentQuestion}
-
-
- Requested by dominikdev | Type: General | ID: 64
-
-
-
-
- Results
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {replayedRounds < 3 ?
- replay()}
- emoji="/emojis/refresh.svg"
- emojiName="refresh"
- >
- New Question
-
- :
- window.open('https://wouldyoubot.gg/invite', '_blank')
- }
- emoji="/emojis/external.svg"
- emojiName="external"
- >
- Invite Would You
-
- }
-
-
-
-
-
- )
+ return (
+
+
+ 0}
+ >
+
+
+
+ {currentQuestion}
+
+
+ Requested by dominikdev | Type: General | ID: 64
+
+
+
+
+ Results
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {replayedRounds < 3 ?
+ replay()}
+ emoji="/emojis/refresh.svg"
+ emojiName="refresh"
+ >
+ New Question
+
+ :
+ window.open('https://wouldyoubot.gg/invite', '_blank')
+ }
+ emoji="/emojis/external.svg"
+ emojiName="external"
+ >
+ Invite Would You
+
+ }
+
+
+
+
+
+ )
}
export default MainDiscordEmbed
diff --git a/components/Homepage/Content.tsx b/components/Homepage/Content.tsx
index effd17dd..7089ee8e 100644
--- a/components/Homepage/Content.tsx
+++ b/components/Homepage/Content.tsx
@@ -4,12 +4,12 @@ import NeverHaveIEverEmbed from '@/components/Embeds/NeverHaveIEverEmbed'
import DailyMessageEmbed from '@/components/Embeds/DailyMessageEmbed'
import HigherLowerEmbed from '@/components/Embeds/HigherLowerEmbed'
import MainDiscordEmbed from '@/components/Embeds/MainDiscordEmbed'
-import { motion } from 'motion/react'
import ServerMarquee from '@/components/ServerMarquee'
import { Button, buttonVariants } from '../ui/button'
import FeatureItem from '@/components/FeatureItem'
import { AvatarGroup } from '../avatar-group'
import { LandingWave } from '../LandingWave'
+import { motion } from 'motion/react'
import { cn } from '@/lib/utils'
import Link from 'next/link'
@@ -36,63 +36,66 @@ export function HomeContent({
].join('/')} - Daily Message`
return (
- <>
-
-
- Entertain Your
-
-
- Discord
- {' '}
-
- Server
-
-
-
- Play fun and entertaining games with Would You, featuring user polls
- and customization. Play Would You Rather, Truth or Dare, Never Have
- I Ever, Higher or Lower, and What Would You Do!
-
-
-
-
- Trusted by your favorite servers!
-
-
-
+
+
- Unleash the Fun
-
+ Entertain Your
+
+
+ Discord
+ {' '}
+
+ Server
+
+
+
+ Play fun and entertaining games with Would You, featuring user polls
+ and customization. Play Would You Rather, Truth or Dare, Never Have
+ I Ever, Higher or Lower, and What Would You Do!
+
+
+
+
+ Trusted by your favorite servers!
+
+
+
-
-
-
-
-
-
+ Unleash the Fun
+
+
+
+
+
+
+
+
@@ -114,14 +117,17 @@ export function HomeContent({
+ speed={40}
+ />
+ direction="right"
+ />
-
+
}
- left={<>
-
- Increase user engagement
-
-
- Keep your community engaged and active with daily "Would
- You Rather" messages!
-
- >} />
+ left={
+ <>
+
+ Increase user engagement
+
+
+ Keep your community engaged and active with daily "Would
+ You Rather" messages!
+
+ >
+ }
+ />
-
- Entertain your server
-
-
- Entertain your discord server with fun and interactive games
- like Would You Rather, Truth or Dare, Never Have I Ever, Higher
- or Lower, and What Would You Do!
-
- >}
- right={ } />
+ left={
+ <>
+
+ Entertain your server
+
+
+ Entertain your discord server with fun and interactive games
+ like Would You Rather, Truth or Dare, Never Have I Ever, Higher
+ or Lower, and What Would You Do!
+
+ >
+ }
+ right={ }
+ />
}
- left={<>
-
- Upgrade your server
-
-
- Upgrade your server with Would You, featuring a wide variety of
- games and customized questions.
-
- >} />
-
+ left={
+ <>
+
+ Upgrade your server
+
+
+ Upgrade your server with Would You, featuring a wide variety of
+ games and customized questions.
+
+ >
+ }
+ />
+
+
>
+
+ >
)
}
diff --git a/components/Premium/Content.tsx b/components/Premium/Content.tsx
index aa2a35d9..471e4ca3 100644
--- a/components/Premium/Content.tsx
+++ b/components/Premium/Content.tsx
@@ -9,6 +9,16 @@ import {
DialogTitle,
DialogTrigger
} from '@/components/ui/dialog'
+import {
+ CloseIcon,
+ StripeSquare,
+ ApplePay,
+ GooglePay,
+ MasterCard,
+ Visa,
+ PayPal,
+ Stripe
+} from '@/app/premium/_components/icons'
import {
Select,
SelectContent,
@@ -17,18 +27,17 @@ import {
SelectValue
} from '@/components/ui/select'
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'
+import PlansComparison from '@/app/premium/_components/PlansComparison'
+import CheckoutButton from '@/app/premium/_components/checkoutButton'
import DiscordLoginButton from '@/components/DiscordLoginButton'
+import { PricingData, DiscordGuild } from '@/app/premium/_types'
+import { ServersListSkeleton } from '@/app/premium/_components'
+import { CheckIcon, Link } from 'lucide-react'
import { useIdToken } from '@/helpers/hooks'
import { Suspense, useState } from 'react'
import { getServer } from '@/lib/redis'
import Image from 'next/image'
import Head from 'next/head'
-import { ServersListSkeleton } from '@/app/premium/_components'
-import CheckoutButton from '@/app/premium/_components/checkoutButton'
-import { CloseIcon, StripeSquare, ApplePay, GooglePay, MasterCard, Visa, PayPal, Stripe } from '@/app/premium/_components/icons'
-import PlansComparison from '@/app/premium/_components/PlansComparison'
-import { PricingData, DiscordGuild } from '@/app/premium/_types'
-import { CheckIcon, Link } from 'lucide-react'
const pricingData: PricingData = {
price: { monthly: 2.99, yearly: 29.99 },
@@ -103,201 +112,198 @@ export default function Premium() {
-
-
-
- Premium
-
-
- Select the plan that suits your needs and benefit from our
- discord bot.
-
-
-
-
-
-
-
- Monthly
+
+
+
+ Premium
+
+
+ Select the plan that suits your needs and benefit from our
+ discord bot.
+
+
+
+
+
+
+
+ Monthly
+
+
+ Yearly
+
+
+
+
+
+
+
+
+ 2 months free
+
+
+ Premium
+
+
+ 2 months free
+
+
+
+ {isMonthly ?
+ pricingData.price.monthly
+ : pricingData.price.yearly}
-
- Yearly
+
+ {isMonthly ? '/ month' : '/ year'}
-
-
-
-
-
-
- 2 months free
-
-
- Premium
-
-
- 2 months free
-
-
-
- {isMonthly ?
- pricingData.price.monthly
- : pricingData.price.yearly}
-
-
- {isMonthly ? '/ month' : '/ year'}
-
-
-
- Experience the full power of our Would You bot.
-
-
- {Object.keys(pricingData['premium']).map(
- (text, index) => (
-
- {(
- pricingData['premium'][
- text as keyof (typeof pricingData)['premium']
- ]
- ) ?
-
- :
- }
- {text}
-
- )
- )}
-
-
- {idToken ?
- {
- fetchData()
- }}
- className="flex w-full items-center justify-center gap-2 rounded-xl bg-green-500 py-2 font-bold leading-loose text-foreground transition hover:bg-green-600 focus:ring-0"
+
+ Experience the full power of our Would You bot.
+
+
+ {Object.keys(pricingData['premium']).map(
+ (text, index) => (
+
- Continue with Stripe
-
-
- :
- }
-
-
-
-
- Buy{' '}
-
- Would
- {' '}
- You
- {isMonthly ? ' Monthly' : ' Yearly'}
-
-
-
-
-
-
-
-
-
- }>
- {serversData.map((server: DiscordGuild) => (
-
-
-
-
+ :
+ }
+ {text}
+
+ )
+ )}
+
+
+ {idToken ?
+ {
+ fetchData()
+ }}
+ className="flex w-full items-center justify-center gap-2 rounded-xl bg-green-500 py-2 font-bold leading-loose text-foreground transition hover:bg-green-600 focus:ring-0"
+ >
+ Continue with Stripe
+
+
+ :
+ }
+
+
+
+
+ Buy{' '}
+ Would {' '}
+ You
+ {isMonthly ? ' Monthly' : ' Yearly'}
+
+
+
+
+
+
+
+
+
+ }>
+ {serversData.map((server: DiscordGuild) => (
+
+
+
+
+
+
-
-
-
-
-
- {server.name}
-
-
-
- ))}
-
-
-
-
-
-
- {idToken ?
-
- Or click{' '}
-
- here
- {' '}
- to manage your subscriptions
-
- : null}
-
-
+
+
+
+ {server.name}
+
+
+
+ ))}
+
+
+
+
+
+
+ {idToken ?
+
+ Or click{' '}
+
+ here
+ {' '}
+ to manage your subscriptions
+
+ : null}
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
+
+
>
diff --git a/components/cookies/cookie-banner.tsx b/components/cookies/cookie-banner.tsx
index 49b356eb..9d98cd93 100644
--- a/components/cookies/cookie-banner.tsx
+++ b/components/cookies/cookie-banner.tsx
@@ -5,74 +5,74 @@ import { Button } from '@/components/ui/button'
import { useState, useEffect } from 'react'
export function CookieBanner() {
- const { setShowBanner, state, setPreferences } = useCookieContext()
- const [showModal, setShowModal] = useState(false)
+ const { setShowBanner, state, setPreferences } = useCookieContext()
+ const [showModal, setShowModal] = useState(false)
- useEffect(() => {
- const cookieString = document.cookie
- const isCookiesSet = cookieString.includes('cookiePreferences=')
- setShowBanner(!isCookiesSet)
- }, [setShowBanner])
+ useEffect(() => {
+ const cookieString = document.cookie
+ const isCookiesSet = cookieString.includes('cookiePreferences=')
+ setShowBanner(!isCookiesSet)
+ }, [setShowBanner])
- const handleAcceptAll = () => {
- const allPreferences = {
- necessary: true,
- analytics: true
- }
- setPreferences(allPreferences)
- setShowBanner(false)
- }
+ const handleAcceptAll = () => {
+ const allPreferences = {
+ necessary: true,
+ analytics: true
+ }
+ setPreferences(allPreferences)
+ setShowBanner(false)
+ }
- const handleRequiredOnly = () => {
- const requiredPreferences = {
- necessary: true,
- analytics: false
- }
- setPreferences(requiredPreferences)
- setShowBanner(false)
- }
+ const handleRequiredOnly = () => {
+ const requiredPreferences = {
+ necessary: true,
+ analytics: false
+ }
+ setPreferences(requiredPreferences)
+ setShowBanner(false)
+ }
- if (!state.preferences.necessary) return null
+ if (!state.preferences.necessary) return null
- return (
- <>
-
-
-
- We use cookies to enhance your browsing experience and analyze our
- traffic.
-
-
- setShowModal(true)}
- >
- Customize
-
-
- Required Only
-
-
- Accept All
-
-
-
-
+ return (
+ <>
+
+
+
+ We use cookies to enhance your browsing experience and analyze our
+ traffic.
+
+
+ setShowModal(true)}
+ >
+ Customize
+
+
+ Required Only
+
+
+ Accept All
+
+
+
+
-
setShowModal(false)}
- />
- >
- )
+ setShowModal(false)}
+ />
+ >
+ )
}
diff --git a/components/cookies/cookie-dialog.tsx b/components/cookies/cookie-dialog.tsx
index 9dfa27f1..ff8b1aea 100644
--- a/components/cookies/cookie-dialog.tsx
+++ b/components/cookies/cookie-dialog.tsx
@@ -1,12 +1,12 @@
'use client'
import {
- Dialog,
- DialogContent,
- DialogHeader,
- DialogTitle,
- DialogDescription,
- DialogFooter
+ Dialog,
+ DialogContent,
+ DialogHeader,
+ DialogTitle,
+ DialogDescription,
+ DialogFooter
} from '@/components/ui/dialog'
import { CookiePreferences } from '@/helpers/hooks/useCookies'
import { Button } from '@/components/ui/button'
@@ -16,103 +16,103 @@ import { useRouter } from 'next/navigation'
import { useState } from 'react'
interface CookieDialogProps {
- preferences: CookiePreferences
- onSave: (preferences: CookiePreferences) => void
- onClose: () => void
- open: boolean
+ preferences: CookiePreferences
+ onSave: (preferences: CookiePreferences) => void
+ onClose: () => void
+ open: boolean
}
export function CookieDialog({
- preferences,
- onSave,
- onClose,
- open
+ preferences,
+ onSave,
+ onClose,
+ open
}: CookieDialogProps) {
- const [localPreferences, setLocalPreferences] = useState(preferences)
- const router = useRouter()
+ const [localPreferences, setLocalPreferences] = useState(preferences)
+ const router = useRouter()
- const handleSavePreferences = () => {
- onSave(localPreferences)
- onClose()
- router.refresh()
- }
+ const handleSavePreferences = () => {
+ onSave(localPreferences)
+ onClose()
+ router.refresh()
+ }
- const handleReset = () => {
- setLocalPreferences({
- necessary: true,
- analytics: true
- })
- }
+ const handleReset = () => {
+ setLocalPreferences({
+ necessary: true,
+ analytics: true
+ })
+ }
- const preferenceDescriptions: Record = {
- necessary: 'All the necessary cookies needed to run the website.',
- analytics: 'Optional analytics used to enhance your analytics.'
- }
+ const preferenceDescriptions: Record = {
+ necessary: 'All the necessary cookies needed to run the website.',
+ analytics: 'Optional analytics used to enhance your analytics.'
+ }
- return (
-
-
-
- Cookie Preferences
-
- Customize your cookie preferences here. You can enable or disable
- different categories of cookies.
-
-
-
- {Object.entries(localPreferences).map(
- ([key, value]: [string, boolean]) => (
-
-
-
- {key}
-
-
- {preferenceDescriptions[key as keyof CookiePreferences]}
-
-
-
- setLocalPreferences((prev) => ({
- ...prev,
- [key]: checked
- }))
- }
- disabled={key === 'necessary'}
- className="data-[state=checked]:bg-brand-primary"
- />
-
- )
- )}
-
-
-
- Reset
-
-
- Save Preferences
-
-
-
-
- )
+ return (
+
+
+
+ Cookie Preferences
+
+ Customize your cookie preferences here. You can enable or disable
+ different categories of cookies.
+
+
+
+ {Object.entries(localPreferences).map(
+ ([key, value]: [string, boolean]) => (
+
+
+
+ {key}
+
+
+ {preferenceDescriptions[key as keyof CookiePreferences]}
+
+
+
+ setLocalPreferences((prev) => ({
+ ...prev,
+ [key]: checked
+ }))
+ }
+ disabled={key === 'necessary'}
+ className="data-[state=checked]:bg-brand-primary"
+ />
+
+ )
+ )}
+
+
+
+ Reset
+
+
+ Save Preferences
+
+
+
+
+ )
}
diff --git a/components/cookies/cookie-provider.tsx b/components/cookies/cookie-provider.tsx
index bac423ac..6bc1bbab 100644
--- a/components/cookies/cookie-provider.tsx
+++ b/components/cookies/cookie-provider.tsx
@@ -1,131 +1,131 @@
'use client'
import React, {
- createContext,
- useContext,
- useReducer,
- useCallback,
- useEffect
+ createContext,
+ useContext,
+ useReducer,
+ useCallback,
+ useEffect
} from 'react'
import { CookieDialog, CookieBanner } from '@/components/cookies'
import { CookiePreferences } from '@/helpers/hooks/useCookies'
const actionTypes = {
- SHOW_DIALOG: 'SHOW_DIALOG',
- HIDE_DIALOG: 'HIDE_DIALOG',
- SET_PREFERENCES: 'SET_PREFERENCES',
- REVOKE_PERMISSIONS: 'REVOKE_PERMISSIONS',
- SET_SHOW_BANNER: 'SET_SHOW_BANNER'
+ SHOW_DIALOG: 'SHOW_DIALOG',
+ HIDE_DIALOG: 'HIDE_DIALOG',
+ SET_PREFERENCES: 'SET_PREFERENCES',
+ REVOKE_PERMISSIONS: 'REVOKE_PERMISSIONS',
+ SET_SHOW_BANNER: 'SET_SHOW_BANNER'
} as const
interface CookieState {
- showDialog: boolean
- showBanner: boolean
- preferences: CookiePreferences
+ showDialog: boolean
+ showBanner: boolean
+ preferences: CookiePreferences
}
const initialState: CookieState = {
- showDialog: false,
- showBanner: false,
- preferences: {
- necessary: true,
- analytics: true
- }
+ showDialog: false,
+ showBanner: false,
+ preferences: {
+ necessary: true,
+ analytics: true
+ }
}
function cookieReducer(state: CookieState, action: any): CookieState {
- switch (action.type) {
- case actionTypes.SHOW_DIALOG:
- return { ...state, showDialog: true }
- case actionTypes.HIDE_DIALOG:
- return { ...state, showDialog: false }
- case actionTypes.SET_PREFERENCES:
- return { ...state, preferences: action.payload, showBanner: false }
- case actionTypes.REVOKE_PERMISSIONS:
- return { ...state, preferences: initialState.preferences }
- case actionTypes.SET_SHOW_BANNER:
- return { ...state, showBanner: action.payload }
- default:
- return state
- }
+ switch (action.type) {
+ case actionTypes.SHOW_DIALOG:
+ return { ...state, showDialog: true }
+ case actionTypes.HIDE_DIALOG:
+ return { ...state, showDialog: false }
+ case actionTypes.SET_PREFERENCES:
+ return { ...state, preferences: action.payload, showBanner: false }
+ case actionTypes.REVOKE_PERMISSIONS:
+ return { ...state, preferences: initialState.preferences }
+ case actionTypes.SET_SHOW_BANNER:
+ return { ...state, showBanner: action.payload }
+ default:
+ return state
+ }
}
const CookieContext = createContext<{
- state: CookieState
- showCookieDialog: () => void
- hideCookieDialog: () => void
- setPreferences: (preferences: CookiePreferences) => void
- setShowBanner: (show: boolean) => void
+ state: CookieState
+ showCookieDialog: () => void
+ hideCookieDialog: () => void
+ setPreferences: (preferences: CookiePreferences) => void
+ setShowBanner: (show: boolean) => void
}>({
- state: initialState,
- showCookieDialog: () => {},
- hideCookieDialog: () => {},
- setPreferences: () => {},
- setShowBanner: () => {}
+ state: initialState,
+ showCookieDialog: () => {},
+ hideCookieDialog: () => {},
+ setPreferences: () => {},
+ setShowBanner: () => {}
})
export const CookieProvider: React.FC<{ children: React.ReactNode }> = ({
- children
+ children
}) => {
- const [state, dispatch] = useReducer(cookieReducer, initialState)
+ const [state, dispatch] = useReducer(cookieReducer, initialState)
- const showCookieDialog = useCallback(
- () => dispatch({ type: actionTypes.SHOW_DIALOG }),
- []
- )
- const hideCookieDialog = useCallback(
- () => dispatch({ type: actionTypes.HIDE_DIALOG }),
- []
- )
+ const showCookieDialog = useCallback(
+ () => dispatch({ type: actionTypes.SHOW_DIALOG }),
+ []
+ )
+ const hideCookieDialog = useCallback(
+ () => dispatch({ type: actionTypes.HIDE_DIALOG }),
+ []
+ )
- const setPreferences = useCallback((preferences: CookiePreferences) => {
- dispatch({ type: actionTypes.SET_PREFERENCES, payload: preferences })
- document.cookie = `cookiePreferences=${JSON.stringify(preferences)}; path=/`
- }, [])
+ const setPreferences = useCallback((preferences: CookiePreferences) => {
+ dispatch({ type: actionTypes.SET_PREFERENCES, payload: preferences })
+ document.cookie = `cookiePreferences=${JSON.stringify(preferences)}; path=/`
+ }, [])
- const setShowBanner = useCallback((show: boolean) => {
- dispatch({ type: actionTypes.SET_SHOW_BANNER, payload: show })
- }, [])
+ const setShowBanner = useCallback((show: boolean) => {
+ dispatch({ type: actionTypes.SET_SHOW_BANNER, payload: show })
+ }, [])
- useEffect(() => {
- const cookieString = document.cookie
- const cookiePreferencesMatch = cookieString.match(
- /cookiePreferences=([^;]+)/
- )
+ useEffect(() => {
+ const cookieString = document.cookie
+ const cookiePreferencesMatch = cookieString.match(
+ /cookiePreferences=([^;]+)/
+ )
- if (cookiePreferencesMatch) {
- const cookiePreferences = JSON.parse(cookiePreferencesMatch[1])
- dispatch({
- type: actionTypes.SET_PREFERENCES,
- payload: cookiePreferences
- })
- } else {
- setShowBanner(true)
- }
- }, [setShowBanner])
+ if (cookiePreferencesMatch) {
+ const cookiePreferences = JSON.parse(cookiePreferencesMatch[1])
+ dispatch({
+ type: actionTypes.SET_PREFERENCES,
+ payload: cookiePreferences
+ })
+ } else {
+ setShowBanner(true)
+ }
+ }, [setShowBanner])
- return (
-
- {children}
- {state.showBanner && }
- {state.showDialog && (
-
- )}
-
- )
+ return (
+
+ {children}
+ {state.showBanner && }
+ {state.showDialog && (
+
+ )}
+
+ )
}
export const useCookieContext = () => useContext(CookieContext)
diff --git a/helpers/hooks/useCookies.ts b/helpers/hooks/useCookies.ts
index 90c49c71..09be593c 100644
--- a/helpers/hooks/useCookies.ts
+++ b/helpers/hooks/useCookies.ts
@@ -5,55 +5,55 @@ import { useState, useEffect } from 'react'
import { useMemo } from 'react'
export function useCookies() {
- const isClient = useIsClient()
- const cookies_ = isClient ? window?.document?.cookie : ''
-
- return useMemo(() => {
- return cookies_.split(';').reduce((acc, cookie) => {
- const [key, value] = cookie.split('=')
- acc.set(key.trim(), value)
- return acc
- }, new Map())
- }, [cookies_])
+ const isClient = useIsClient()
+ const cookies_ = isClient ? window?.document?.cookie : ''
+
+ return useMemo(() => {
+ return cookies_.split(';').reduce((acc, cookie) => {
+ const [key, value] = cookie.split('=')
+ acc.set(key.trim(), value)
+ return acc
+ }, new Map())
+ }, [cookies_])
}
export interface CookiePreferences {
- necessary: boolean
- analytics: boolean
+ necessary: boolean
+ analytics: boolean
}
export const useCookiePreferences = () => {
- const cookies = useCookies()
- const [data, setData] = useState({
- necessary: true,
- analytics: true
- })
- const [showBanner, setShowBanner] = useState(true)
-
- useEffect(() => {
- const savedPreferences = cookies.get('cookiePreferences')
- if (savedPreferences) {
- setData(JSON.parse(savedPreferences))
- setShowBanner(false)
- }
- }, [cookies])
-
- const savePreferences = (preferences: typeof data) => {
- setData(preferences)
- const expires = new Date(Date.now() + 31 * 864e5).toUTCString()
- document.cookie = `cookiePreferences=${JSON.stringify(preferences)}; expires=${expires}; path=/`
- }
-
- const hasAnalytics = () => {
- return data.analytics
- }
-
- return {
- data,
- setData,
- showBanner,
- setShowBanner,
- savePreferences,
- hasAnalytics
- }
+ const cookies = useCookies()
+ const [data, setData] = useState({
+ necessary: true,
+ analytics: true
+ })
+ const [showBanner, setShowBanner] = useState(true)
+
+ useEffect(() => {
+ const savedPreferences = cookies.get('cookiePreferences')
+ if (savedPreferences) {
+ setData(JSON.parse(savedPreferences))
+ setShowBanner(false)
+ }
+ }, [cookies])
+
+ const savePreferences = (preferences: typeof data) => {
+ setData(preferences)
+ const expires = new Date(Date.now() + 31 * 864e5).toUTCString()
+ document.cookie = `cookiePreferences=${JSON.stringify(preferences)}; expires=${expires}; path=/`
+ }
+
+ const hasAnalytics = () => {
+ return data.analytics
+ }
+
+ return {
+ data,
+ setData,
+ showBanner,
+ setShowBanner,
+ savePreferences,
+ hasAnalytics
+ }
}