diff --git a/client/src/App.css b/client/src/App.css index b9d355d..35709b8 100644 --- a/client/src/App.css +++ b/client/src/App.css @@ -1,8 +1,15 @@ #root { - max-width: 1280px; - margin: 0 auto; - padding: 2rem; - text-align: center; + width: 100%; + height: 100vh; + margin: 0; + padding: 0; +} + +.app { + width: 100%; + height: 100vh; + margin: 0; + padding: 0; } .logo { diff --git a/client/src/App.tsx b/client/src/App.tsx index c82b294..1a63a45 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -1,87 +1,99 @@ -import { CssBaseline, ThemeProvider, createTheme, CircularProgress, Box } from '@mui/material' -import { useDeviceType } from './hooks/useDeviceType' -import { useTaskData } from './hooks/useTaskData' -import { DesktopLayout } from './layouts/DesktopLayout' -import { MobileLayout } from './layouts/MobileLayout' -import { StepDetails } from './components/StepDetails' -import type { GroupWithTasks, TaskWithSteps, StepWithNotes } from './types' - -const theme = createTheme() +import React, { useCallback } from 'react'; +import { ApolloProvider } from '@apollo/client'; +import { client } from './graphql/client'; +import { DesktopLayout } from './layouts/DesktopLayout'; +import { MobileLayout } from './layouts/MobileLayout'; +import { UserSelection } from './components/UserSelection'; +import { useTaskData } from './hooks/useTaskData'; +import { useDeviceType } from './hooks/useDeviceType'; +import { useUserSelection } from './hooks/useUserSelection'; +import './App.css'; export function App() { - const deviceType = useDeviceType() + const { selectedUser, users, selectUser } = useUserSelection(); + const deviceType = useDeviceType(); const { + loading, groups, step, - loading, selectedGroup, selectedTask, selectedStep, setSelectedGroup, setSelectedTask, setSelectedStep, - handlePrintStep, handlePrintTask, - handleAddNote, - } = useTaskData() + handlePrintStep, + handleAddNote + } = useTaskData(); - const handleBack = () => { + const handleBack = useCallback(() => { if (selectedStep) { - setSelectedStep(undefined) + setSelectedStep(undefined); } else if (selectedTask) { - setSelectedTask(undefined) + setSelectedTask(undefined); } else if (selectedGroup) { - setSelectedGroup(undefined) + setSelectedGroup(undefined); } - } + }, [selectedStep, selectedTask, selectedGroup, setSelectedStep, setSelectedTask, setSelectedGroup]); - if (loading) { + console.log('App render:', { + selectedUser, + deviceType, + loading, + groups, + step, + selectedGroup, + selectedTask, + selectedStep + }); + + console.log('App rendering main content, conditions:', { + hasUser: selectedUser !== null, + deviceType, + hasGroups: groups.length > 0, + hasStep: step !== null + }); + + if (!selectedUser) { return ( - - - - ) +
+ +
+ ); } return ( - - - {deviceType === 'desktop' ? ( - - ) : ( - <> - {selectedStep ? ( - handlePrintStep(String(selectedStep.id), '1')} // TODO: Get real user ID - onAddNote={(content) => handleAddNote(content, '1')} // TODO: Get real user ID - onBack={handleBack} - /> - ) : ( - - )} - - )} - - ) + +
+ {deviceType === 'desktop' ? ( + + ) : ( + + )} +
+
+ ); } diff --git a/client/src/layouts/MobileLayout.tsx b/client/src/layouts/MobileLayout.tsx index b711b05..360c814 100644 --- a/client/src/layouts/MobileLayout.tsx +++ b/client/src/layouts/MobileLayout.tsx @@ -1,5 +1,6 @@ -import { Box, Paper, Typography, IconButton } from '@mui/material'; +import { Box, Paper, Typography, IconButton, TextField, Button } from '@mui/material'; import ArrowBackIcon from '@mui/icons-material/ArrowBack'; +import PrintIcon from '@mui/icons-material/Print'; import type { GroupWithTasks, TaskWithSteps, StepWithNotes } from '../types'; import { CreateButtons } from '../components/CreateButtons'; @@ -24,6 +25,8 @@ export function MobileLayout({ onTaskSelect, onStepSelect, onBack, + onPrintStep, + onAddNote }: { groups: GroupWithTasks[]; selectedGroup?: GroupWithTasks; @@ -33,6 +36,8 @@ export function MobileLayout({ onTaskSelect: (task: TaskWithSteps | undefined) => void; onStepSelect: (step: StepWithNotes | undefined) => void; onBack: () => void; + onPrintStep?: (stepId: string, userId: string) => void; + onAddNote?: (content: string) => void; }) { const groupList: GroupWithTasks[] = groups; const taskList: TaskWithSteps[] = (selectedGroup?.tasks as TaskWithSteps[]) ?? []; @@ -41,7 +46,7 @@ export function MobileLayout({ return ( {/* Header with back button */} - {selectedGroup && ( + {selectedGroup && !selectedTask && ( @@ -65,6 +70,14 @@ export function MobileLayout({ {selectedStep.name} + {onPrintStep && ( + onPrintStep(String(selectedStep.id), '1')} // TODO: Get real user ID + sx={{ ml: 'auto' }} + > + + + )} )} @@ -142,6 +155,39 @@ export function MobileLayout({ )} + + {selectedStep && ( + <> + {selectedStep.instructions} + + + + Notes ({selectedStep.notes.length}) + + {selectedStep.notes.map((note) => ( + + {note.user?.name} + {note.content} + + ))} + + + + + {onAddNote && ( + + )} + + + )} );