-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…kies-local-storage Frontend/#171 cookies consent in local storage
- Loading branch information
Showing
5 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { useState } from 'react'; | ||
import { getLocalStorage, setLocalStorage } from '../../utils/localStorage'; | ||
|
||
function CookiesDesclaimer() { | ||
const hasCookie = getLocalStorage('cookies-consent'); | ||
const [cookiesConsent, setCookiesConsent] = useState(hasCookie); | ||
const handleCookies = () => { | ||
setLocalStorage('cookies-consent', true); | ||
setCookiesConsent(true); | ||
}; | ||
return !cookiesConsent ? ( | ||
<div className="cookies"> | ||
<div className="cookies-text"> | ||
<h3>This website uses cookies</h3> | ||
<p> | ||
We use cookies to give you the best online experience. Please let us | ||
know if you agree. | ||
</p> | ||
<div className="button__group"> | ||
<button className="button--submit" onClick={handleCookies}> | ||
Accept | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
) : null; | ||
} | ||
|
||
export default CookiesDesclaimer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
export const setLocalStorage = (key, value) => { | ||
localStorage.setItem(key, value); | ||
}; | ||
|
||
// Retrieve information from local storage | ||
export const getLocalStorage = (key) => { | ||
const reservationValue = JSON.parse(localStorage.getItem(key)); | ||
return reservationValue; | ||
}; | ||
|
||
// Remove information from local storage | ||
export const removeLocalStorage = (key) => { | ||
localStorage.removeItem(key); | ||
}; |