task_receipts/client/src/layouts/DesktopLayout.tsx

109 lines
3.6 KiB
TypeScript
Raw Normal View History

2025-06-14 20:57:24 +00:00
import { Box, Typography } from '@mui/material';
import type { GroupWithTasks, TaskWithSteps, StepWithNotes } from '../types';
2025-06-14 22:19:39 +00:00
import { CreateButtons } from '../components/CreateButtons';
2025-06-14 20:57:24 +00:00
interface DesktopLayoutProps {
groups: GroupWithTasks[];
selectedGroup?: GroupWithTasks;
selectedTask?: TaskWithSteps;
selectedStep?: StepWithNotes;
onGroupSelect: (group: GroupWithTasks | undefined) => void;
onTaskSelect: (task: TaskWithSteps | undefined) => void;
onStepSelect: (step: StepWithNotes | undefined) => void;
}
export function DesktopLayout({
groups,
selectedGroup,
selectedTask,
selectedStep,
onGroupSelect,
onTaskSelect,
onStepSelect,
}: DesktopLayoutProps) {
return (
<Box sx={{ display: 'flex', height: '100vh' }}>
{/* Groups panel */}
<Box sx={{ width: 250, borderRight: 1, borderColor: 'divider', p: 2 }}>
2025-06-14 22:19:39 +00:00
<Box sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', mb: 2 }}>
<Typography variant="h6">Groups</Typography>
<CreateButtons type="group" />
</Box>
{/* Groups List */}
2025-06-14 20:57:24 +00:00
{groups.map((group) => (
<Box
key={group.id}
sx={{
p: 2,
cursor: 'pointer',
bgcolor: selectedGroup?.id === group.id ? 'action.selected' : 'transparent',
'&:hover': { bgcolor: 'action.hover' },
}}
onClick={() => onGroupSelect(group)}
>
<Typography>{group.name}</Typography>
</Box>
))}
</Box>
{/* Tasks panel */}
{selectedGroup && (
<Box sx={{ width: 250, borderRight: 1, borderColor: 'divider', p: 2 }}>
2025-06-14 22:19:39 +00:00
<Box sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', mb: 2 }}>
<Typography variant="h6">Tasks</Typography>
{selectedGroup.id > 0 && <CreateButtons type="task" parentId={String(selectedGroup.id)} />}
2025-06-14 22:19:39 +00:00
</Box>
2025-06-14 20:57:24 +00:00
{selectedGroup.tasks.map((task) => (
<Box
key={task.id}
sx={{
p: 2,
cursor: 'pointer',
bgcolor: selectedTask?.id === task.id ? 'action.selected' : 'transparent',
'&:hover': { bgcolor: 'action.hover' },
}}
onClick={() => onTaskSelect(task)}
>
<Typography>{task.name}</Typography>
</Box>
))}
</Box>
)}
{/* Steps panel */}
{selectedTask && (
<Box sx={{ width: 250, borderRight: 1, borderColor: 'divider', p: 2 }}>
2025-06-14 22:19:39 +00:00
<Box sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', mb: 2 }}>
<Typography variant="h6">Steps</Typography>
<CreateButtons type="step" parentId={String(selectedTask.id)} />
</Box>
2025-06-14 20:57:24 +00:00
{selectedTask.steps.map((step) => (
<Box
key={step.id}
sx={{
p: 2,
cursor: 'pointer',
bgcolor: selectedStep?.id === step.id ? 'action.selected' : 'transparent',
'&:hover': { bgcolor: 'action.hover' },
}}
onClick={() => onStepSelect(step)}
>
<Typography>{step.name}</Typography>
</Box>
))}
</Box>
)}
{/* Step details panel */}
{selectedStep && (
<Box sx={{ flex: 1, p: 2 }}>
<Typography variant="h6" sx={{ mb: 2 }}>
{selectedStep.name}
</Typography>
<Typography>{selectedStep.instructions}</Typography>
</Box>
)}
</Box>
);
}