diff --git a/src/app/(public)/about/free-time/page.tsx b/src/app/(public)/about/free-time/page.tsx index cb8e3ed..7e425cd 100644 --- a/src/app/(public)/about/free-time/page.tsx +++ b/src/app/(public)/about/free-time/page.tsx @@ -3,6 +3,7 @@ import * as React from 'react'; import Books from '@/components/organisms/about-free-time/Books'; import Music from '@/components/organisms/about-free-time/Music'; import Podcasts from '@/components/organisms/about-free-time/Podcasts'; +import RandomFacts from '@/components/organisms/about-free-time/RandomFacts'; import TvSeries from '@/components/organisms/about-free-time/TvSeries'; import VideoGames from '@/components/organisms/about-free-time/VideoGames'; @@ -67,6 +68,8 @@ const AboutFreeTimePage = async () => { + + diff --git a/src/components/organisms/about-free-time/RandomFacts.tsx b/src/components/organisms/about-free-time/RandomFacts.tsx new file mode 100644 index 0000000..c6c6472 --- /dev/null +++ b/src/components/organisms/about-free-time/RandomFacts.tsx @@ -0,0 +1,79 @@ +'use client'; + +import FormControl from '@mui/material/FormControl'; +import FormControlLabel from '@mui/material/FormControlLabel'; +import Radio from '@mui/material/Radio'; +import RadioGroup from '@mui/material/RadioGroup'; +import * as React from 'react'; +import { useState } from 'react'; + +import Button from '@/components/buttons/Button'; + +const localStorageKey = 'alreadyPlayed'; + +const RandomFacts = () => { + const [selectedAnswer, setSelectedAnswer] = useState(''); + + const [submitted, setSubmitted] = useState(false); + + const [alreadyPlayed, setAlreadyPlayed] = useState(() => { + const alreadyPlayed = localStorage.getItem(localStorageKey); + return alreadyPlayed ? JSON.parse(alreadyPlayed) : false; + }); + + const isButtonDisabled = selectedAnswer === ''; + + const handleChange = (event: React.ChangeEvent) => { + setSelectedAnswer(event.target.value); + }; + + const submitAnswer = () => { + localStorage.setItem(localStorageKey, 'true'); + + setSubmitted(true); + setAlreadyPlayed(true); + }; + + return ( +
+
+

Random facts about me

+
+ + {!submitted && !alreadyPlayed && ( +
+ + + } label='A' /> + } label='B' /> + } label='C' /> + } label='D' /> + + + + +
+ )} + {submitted && alreadyPlayed && ( +
+

Thank you for your submission!

+
+ )} + {!submitted && alreadyPlayed &&
Already played :)
} +
+ ); +}; + +export default RandomFacts;