|
1 | | -import { Box, Typography, Grid, Paper } from '@mui/material'; |
| 1 | +import { Box, Typography, Grid, Paper, Button } from '@mui/material'; |
| 2 | +import { Add as AddIcon } from '@mui/icons-material'; |
| 3 | +import TripList from '../components/trips/TripList'; |
| 4 | +import { useAuth } from '../context/AuthContext'; |
| 5 | +import travelingSvg from '../assets/undraw_traveling_yhxq.svg'; |
2 | 6 |
|
3 | 7 | const Dashboard = () => { |
| 8 | + const { user } = useAuth(); |
| 9 | + |
| 10 | + const WelcomeMessage = () => ( |
| 11 | + <Box |
| 12 | + sx={{ |
| 13 | + textAlign: 'center', |
| 14 | + py: 6, |
| 15 | + px: 2, |
| 16 | + display: 'flex', |
| 17 | + flexDirection: 'column', |
| 18 | + alignItems: 'center', |
| 19 | + gap: 3 |
| 20 | + }} |
| 21 | + > |
| 22 | + <img |
| 23 | + src={travelingSvg} |
| 24 | + alt="Start your journey" |
| 25 | + style={{ |
| 26 | + maxWidth: '300px', |
| 27 | + width: '100%', |
| 28 | + height: 'auto', |
| 29 | + marginBottom: '1rem' |
| 30 | + }} |
| 31 | + /> |
| 32 | + <Typography variant="h4" component="h2" gutterBottom> |
| 33 | + Welcome to Planventure! |
| 34 | + </Typography> |
| 35 | + <Typography variant="body1" color="text.secondary" sx={{ maxWidth: '600px', mb: 3 }}> |
| 36 | + Ready to start planning your next adventure? Create your first trip and let us help you organize everything from destinations to activities. |
| 37 | + </Typography> |
| 38 | + <Button |
| 39 | + variant="contained" |
| 40 | + size="large" |
| 41 | + startIcon={<AddIcon />} |
| 42 | + onClick={() => navigate('/trips/new')} |
| 43 | + > |
| 44 | + Plan Your First Trip |
| 45 | + </Button> |
| 46 | + </Box> |
| 47 | + ); |
| 48 | + |
| 49 | + const ErrorState = () => ( |
| 50 | + <Box |
| 51 | + sx={{ |
| 52 | + textAlign: 'center', |
| 53 | + py: 6, |
| 54 | + px: 2, |
| 55 | + display: 'flex', |
| 56 | + flexDirection: 'column', |
| 57 | + alignItems: 'center', |
| 58 | + gap: 3 |
| 59 | + }} |
| 60 | + > |
| 61 | + <img |
| 62 | + src={travelingSvg} |
| 63 | + alt="Error loading trips" |
| 64 | + style={{ |
| 65 | + maxWidth: '300px', |
| 66 | + width: '100%', |
| 67 | + height: 'auto', |
| 68 | + marginBottom: '1rem', |
| 69 | + opacity: 0.7 |
| 70 | + }} |
| 71 | + /> |
| 72 | + <Typography variant="h5" component="h2" gutterBottom> |
| 73 | + Oops! Looks like our compass is spinning! 🧭 |
| 74 | + </Typography> |
| 75 | + <Typography variant="body1" color="text.secondary" sx={{ maxWidth: '600px', mb: 3 }}> |
| 76 | + We're having trouble loading your adventures. Don't worry, even the best travelers sometimes lose their way! Try refreshing the page or come back later. |
| 77 | + </Typography> |
| 78 | + <Button |
| 79 | + variant="contained" |
| 80 | + onClick={() => window.location.reload()} |
| 81 | + > |
| 82 | + Try Again |
| 83 | + </Button> |
| 84 | + </Box> |
| 85 | + ); |
| 86 | + |
4 | 87 | return ( |
5 | | - <Box> |
| 88 | + <Box sx={{ maxWidth: 1200, mx: 'auto', p: { xs: 2, sm: 3 } }}> |
6 | 89 | <Typography variant="h4" component="h1" gutterBottom> |
7 | | - Dashboard |
| 90 | + My Trips |
8 | 91 | </Typography> |
9 | | - <Grid container spacing={3}> |
10 | | - <Grid item xs={12} md={6} lg={4}> |
11 | | - <Paper |
12 | | - elevation={2} |
13 | | - sx={{ |
14 | | - p: 3, |
15 | | - display: 'flex', |
16 | | - flexDirection: 'column', |
17 | | - height: 240, |
18 | | - }} |
19 | | - > |
20 | | - <Typography variant="h6" gutterBottom> |
21 | | - Upcoming Trips |
22 | | - </Typography> |
23 | | - {/* Add content here */} |
24 | | - </Paper> |
25 | | - </Grid> |
26 | | - <Grid item xs={12} md={6} lg={4}> |
27 | | - <Paper |
28 | | - elevation={2} |
29 | | - sx={{ |
30 | | - p: 3, |
31 | | - display: 'flex', |
32 | | - flexDirection: 'column', |
33 | | - height: 240, |
34 | | - }} |
35 | | - > |
36 | | - <Typography variant="h6" gutterBottom> |
37 | | - Recent Activities |
38 | | - </Typography> |
39 | | - {/* Add content here */} |
40 | | - </Paper> |
41 | | - </Grid> |
42 | | - </Grid> |
| 92 | + <Paper |
| 93 | + elevation={2} |
| 94 | + sx={{ |
| 95 | + p: 3, |
| 96 | + display: 'flex', |
| 97 | + flexDirection: 'column', |
| 98 | + minHeight: '60vh' |
| 99 | + }} |
| 100 | + > |
| 101 | + <TripList |
| 102 | + WelcomeMessage={WelcomeMessage} |
| 103 | + ErrorState={ErrorState} |
| 104 | + /> |
| 105 | + </Paper> |
43 | 106 | </Box> |
44 | 107 | ); |
45 | 108 | }; |
|
0 commit comments