Skip to content

Commit

Permalink
Revert "adding code so that after the user saves their preferences th…
Browse files Browse the repository at this point in the history
…e app navigates back to the profile page."

This reverts commit f35e89b.
  • Loading branch information
ZL-Asica committed Oct 17, 2024
1 parent f35e89b commit 16b3449
Showing 1 changed file with 29 additions and 35 deletions.
64 changes: 29 additions & 35 deletions src/components/Profile/TimePreferencesPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,38 @@ 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 [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 (
<Box
sx={{ display: 'flex', justifyContent: 'center', alignItems: 'center', height: '100vh' }}
>
<CircularProgress />
</Box>
);
}
const { selectedTimes, setSelectedTimes, loading, savePreferences } = useTimePreferences();

// Function to save preferences and navigate back to profile page
const handleSavePreferences = async () => {
await savePreferences();
};

if (loading) {
return (
<Box sx={{ maxWidth: 800, margin: 'auto', padding: 3, alignItems: 'center' }}>
<Typography variant="h4" align="center" gutterBottom>
Time Preferences
</Typography>

<TimePreferencesGrid selectedTimes={selectedTimes} setSelectedTimes={setSelectedTimes} />

<Box sx={{ display: 'flex', justifyContent: 'center', marginTop: 2 }}>
<Button variant="contained" onClick={handleSavePreferences}>
Save Preferences
</Button>
</Box>
</Box>
<Box
sx={{ display: 'flex', justifyContent: 'center', alignItems: 'center', height: '100vh' }}
>
<CircularProgress />
</Box>
);
}

return (
<Box sx={{ maxWidth: 800, margin: 'auto', padding: 3, alignItems: 'center' }}>
<Typography variant="h4" align="center" gutterBottom>
Time Preferences
</Typography>

<TimePreferencesGrid selectedTimes={selectedTimes} setSelectedTimes={setSelectedTimes} />

<Box sx={{ display: 'flex', justifyContent: 'center', marginTop: 2 }}>
<Button variant="contained" onClick={handleSavePreferences}>
Save Preferences
</Button>
</Box>
</Box>
);
}

0 comments on commit 16b3449

Please sign in to comment.