diff --git a/client/src/pages/Form.css b/client/src/pages/Form.css index 0cf05f3..b776b39 100644 --- a/client/src/pages/Form.css +++ b/client/src/pages/Form.css @@ -49,4 +49,7 @@ textarea { .thanks { display: flex; flex-direction: column; + text-align: center; + background-color: #66a7bf; + color:white; } \ No newline at end of file diff --git a/client/src/pages/Form.jsx b/client/src/pages/Form.jsx index cf51c9a..1a7ee41 100644 --- a/client/src/pages/Form.jsx +++ b/client/src/pages/Form.jsx @@ -10,7 +10,6 @@ import DropdownMenu from '../components/DropdownMenu'; import Radio from '../components/Radio'; import "./Form.css"; - // this object will get sent to the server with data for database const reviewData = { provider_id: "", @@ -110,20 +109,47 @@ const Form = () => { setServerResponse(response.data); }; - // USE EFFECT - + // unique components for Form.jsx + const Notice = ({res}) => { + // Control redirect homepage action at the Thankyou component + const [timeLeft, setTimeLeft] = useState(7) + useEffect(()=>{ + // control clicked home button + const myTimeout = setTimeout(()=>{ + handleRedirect(); + }, Number(timeLeft*1000)); + + return () => { + clearTimeout(myTimeout); + } + }, []); + + useEffect(()=>{ + const timer = timeLeft > 0 && setInterval(()=> {setTimeLeft(timeLeft -1)}, 1000); + return () => clearInterval(timer) + },[timeLeft]) + + const handleRedirect = () => { + navigate('/'); + } + + return ( +