From f35e89bdfd1b1c9b85f2b8e998a8c2264f5ee50b Mon Sep 17 00:00:00 2001 From: WelldoneM Date: Thu, 17 Oct 2024 16:30:10 -0500 Subject: [PATCH] adding code so that after the user saves their preferences the app navigates back to the profile page. --- .../Profile/TimePreferencesPage.jsx | 64 ++++++++++--------- 1 file changed, 35 insertions(+), 29 deletions(-) diff --git a/src/components/Profile/TimePreferencesPage.jsx b/src/components/Profile/TimePreferencesPage.jsx index 808843c..4e61993 100644 --- a/src/components/Profile/TimePreferencesPage.jsx +++ b/src/components/Profile/TimePreferencesPage.jsx @@ -4,38 +4,44 @@ import { useTimePreferences } from '@data/useTimePreferences'; import { Box, Typography, Button, CircularProgress } from '@mui/material'; import TimePreferencesGrid from './TimePreferencesGrid'; +import { useAuthState } from '@auth/useAuthState'; +import { useNavigate } from "react-router-dom"; export default function TimePreferencesPage() { - const { selectedTimes, setSelectedTimes, loading, savePreferences } = useTimePreferences(); + const [user] = useAuthState(); + const { selectedTimes, setSelectedTimes, loading, savePreferences } = useTimePreferences(); + const navigate = useNavigate(); + + // Function to save preferences and navigate back to profile page + const handleSavePreferences = async () => { + await savePreferences(); + navigate(`/profile/${user.uid}`); + + }; + + if (loading) { + return ( + + + + ); + } - // Function to save preferences and navigate back to profile page - const handleSavePreferences = async () => { - await savePreferences(); - }; - - if (loading) { return ( - - - + + + Time Preferences + + + + + + + + ); - } - - return ( - - - Time Preferences - - - - - - - - - ); }