Add multiselect.
This commit is contained in:
parent
843d2a8c7b
commit
b09a072fb9
7 changed files with 235 additions and 21 deletions
|
|
@ -1,27 +1,46 @@
|
|||
import type { Route } from './+types/home'
|
||||
import { Box, Typography, Container } from '@mui/material'
|
||||
import { TaskList } from '~/components/TaskList'
|
||||
import type { Task } from '~/types/task'
|
||||
|
||||
export function meta(_: Route.MetaArgs) {
|
||||
return [
|
||||
{ title: "Captain's Log - Tasks" },
|
||||
{ name: 'description', content: 'GTD-inspired task management system' },
|
||||
{ name: 'description', content: 'Task Dashboard' },
|
||||
]
|
||||
}
|
||||
|
||||
export default function Home() {
|
||||
export async function loader(): Promise<{ tasks: Task[] }> {
|
||||
try {
|
||||
// Fetch tasks from the backend API during SSR
|
||||
const apiUrl = process.env.API_URL || 'http://localhost:3000'
|
||||
const response = await fetch(`${apiUrl}/api/tasks`, {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
})
|
||||
|
||||
if (!response.ok) {
|
||||
console.error('Failed to fetch tasks:', response.statusText)
|
||||
return { tasks: [] }
|
||||
}
|
||||
|
||||
const tasks = await response.json()
|
||||
return { tasks }
|
||||
} catch (error) {
|
||||
console.error('Error fetching tasks during SSR:', error)
|
||||
return { tasks: [] }
|
||||
}
|
||||
}
|
||||
|
||||
export default function Home({ loaderData }: Route.ComponentProps) {
|
||||
return (
|
||||
<Container maxWidth="lg">
|
||||
<Box sx={{ py: 4 }}>
|
||||
<Typography variant="h1" component="h1" gutterBottom>
|
||||
Tasks
|
||||
</Typography>
|
||||
<Typography variant="body1" color="text.secondary" sx={{ mb: 4 }}>
|
||||
Your GTD-inspired task management system. Capture everything, see only
|
||||
what matters.
|
||||
</Typography>
|
||||
|
||||
<TaskList />
|
||||
<TaskList initialTasks={loaderData.tasks} />
|
||||
</Box>
|
||||
</Container>
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue