|
1 | 1 | 'use client'; |
2 | 2 |
|
3 | | -import { X } from 'lucide-react'; |
4 | 3 | import { useEffect, useState } from 'react'; |
5 | 4 |
|
6 | 5 | import { CONSENT_STORAGE_KEY, CONSENT_VERSION, ConsentSettings, gdprConsentStore } from '@lib/gdpr-consent-store'; |
@@ -33,81 +32,54 @@ export default function GDPRConsentPanel() { |
33 | 32 | }, []); |
34 | 33 |
|
35 | 34 | const handleAcceptAll = () => { |
36 | | - const allConsent: ConsentSettings = { |
37 | | - necessary: true, |
38 | | - analytics: true, |
39 | | - marketing: true, |
40 | | - preferences: true, |
41 | | - }; |
42 | | - saveConsent(allConsent); |
| 35 | + saveConsent({ necessary: true, analytics: true, marketing: true, preferences: true }); |
43 | 36 | }; |
44 | 37 |
|
45 | 38 | const handleRejectAll = () => { |
46 | | - const minimalConsent: ConsentSettings = { |
47 | | - necessary: true, |
48 | | - analytics: false, |
49 | | - marketing: false, |
50 | | - preferences: false, |
51 | | - }; |
52 | | - saveConsent(minimalConsent); |
| 39 | + saveConsent({ necessary: true, analytics: false, marketing: false, preferences: false }); |
53 | 40 | }; |
54 | 41 |
|
55 | 42 | const saveConsent = (settings: ConsentSettings) => { |
56 | 43 | localStorage.setItem( |
57 | 44 | CONSENT_STORAGE_KEY, |
58 | | - JSON.stringify({ |
59 | | - version: CONSENT_VERSION, |
60 | | - timestamp: new Date().toISOString(), |
61 | | - settings, |
62 | | - }) |
| 45 | + JSON.stringify({ version: CONSENT_VERSION, timestamp: new Date().toISOString(), settings }) |
63 | 46 | ); |
64 | 47 | setIsVisible(false); |
65 | 48 | setIsManuallyOpened(false); |
66 | 49 | }; |
67 | 50 |
|
68 | | - const handleClose = () => { |
69 | | - setIsVisible(false); |
70 | | - setIsManuallyOpened(false); |
71 | | - }; |
72 | | - |
73 | 51 | if (!isVisible) return null; |
74 | 52 |
|
75 | 53 | return ( |
76 | | - <div className="fixed bottom-0 left-0 right-0 z-50 p-4 sm:p-6 max-w-[100vw]"> |
77 | | - <div className="mx-auto max-w-7xl"> |
78 | | - <div className="bg-white dark:bg-gray-900 rounded-lg shadow-lg border border-gray-200 dark:border-gray-800 p-4 sm:p-6 relative"> |
79 | | - {isManuallyOpened && ( |
80 | | - <button |
81 | | - onClick={handleClose} |
82 | | - className="absolute top-2 right-2 text-gray-400 hover:text-gray-500 dark:hover:text-gray-300" |
83 | | - aria-label="Close" |
84 | | - > |
85 | | - <X className="h-5 w-5" /> |
86 | | - </button> |
87 | | - )} |
88 | | - <div className="flex flex-col md:flex-row md:items-center md:justify-between gap-4"> |
89 | | - <div className="flex-1 pr-6 md:pr-0"> |
90 | | - <p className="text-sm text-gray-600 dark:text-gray-300"> |
91 | | - We use cookies to enhance your browsing experience and analyze our traffic. By clicking "Accept All", |
92 | | - you consent to our use of cookies. |
93 | | - </p> |
94 | | - </div> |
95 | | - <div className="flex gap-3 flex-wrap"> |
96 | | - <button |
97 | | - onClick={handleRejectAll} |
98 | | - className="px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700 rounded-lg transition-colors flex-1 md:flex-none whitespace-nowrap" |
99 | | - > |
100 | | - Only Necessary |
101 | | - </button> |
102 | | - <button |
103 | | - onClick={handleAcceptAll} |
104 | | - className="px-4 py-2 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 rounded-lg transition-colors flex-1 md:flex-none whitespace-nowrap" |
105 | | - > |
106 | | - Accept All |
107 | | - </button> |
108 | | - </div> |
109 | | - </div> |
| 54 | + <div className="fixed bottom-4 left-1/2 -translate-x-1/2 z-50 w-full max-w-md px-4"> |
| 55 | + <div className="bg-white rounded-2xl shadow-xl border border-gray-100 px-5 py-4 flex items-center gap-4"> |
| 56 | + <span className="text-2xl select-none" aria-hidden="true">🍪</span> |
| 57 | + <p className="flex-1 text-sm text-gray-500 leading-snug"> |
| 58 | + We use cookies to understand how people use Archestra and make it better. |
| 59 | + </p> |
| 60 | + <div className="flex items-center gap-2 flex-shrink-0"> |
| 61 | + <button |
| 62 | + onClick={handleRejectAll} |
| 63 | + className="text-sm text-gray-400 hover:text-gray-600 transition-colors px-1 whitespace-nowrap" |
| 64 | + > |
| 65 | + No thanks |
| 66 | + </button> |
| 67 | + <button |
| 68 | + onClick={handleAcceptAll} |
| 69 | + className="text-sm font-semibold text-white bg-gray-900 hover:bg-gray-700 transition-colors rounded-lg px-4 py-2 whitespace-nowrap" |
| 70 | + > |
| 71 | + Accept |
| 72 | + </button> |
110 | 73 | </div> |
| 74 | + {isManuallyOpened && ( |
| 75 | + <button |
| 76 | + onClick={() => { setIsVisible(false); setIsManuallyOpened(false); }} |
| 77 | + className="absolute top-2 right-2 text-gray-300 hover:text-gray-500 transition-colors" |
| 78 | + aria-label="Close" |
| 79 | + > |
| 80 | + × |
| 81 | + </button> |
| 82 | + )} |
111 | 83 | </div> |
112 | 84 | </div> |
113 | 85 | ); |
|
0 commit comments