From c6a647202b1829b4cac1d31d3575bd923e7f2b57 Mon Sep 17 00:00:00 2001 From: Sean Sube Date: Sat, 14 Jun 2025 19:00:59 -0500 Subject: [PATCH] add missing buttons --- client/src/App.tsx | 33 +++++----- client/src/components/StepDetails.tsx | 14 +++-- client/src/graphql/mutations.ts | 5 +- client/src/hooks/useTaskData.ts | 10 +-- client/src/layouts/DesktopLayout.tsx | 91 ++++++++++++++++++++++++--- 5 files changed, 117 insertions(+), 36 deletions(-) diff --git a/client/src/App.tsx b/client/src/App.tsx index f963da2..c82b294 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -4,6 +4,7 @@ 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() @@ -20,6 +21,7 @@ export function App() { setSelectedTask, setSelectedStep, handlePrintStep, + handlePrintTask, handleAddNote, } = useTaskData() @@ -46,13 +48,16 @@ export function App() { {deviceType === 'desktop' ? ( ) : ( <> @@ -65,13 +70,13 @@ export function App() { /> ) : ( )} diff --git a/client/src/components/StepDetails.tsx b/client/src/components/StepDetails.tsx index 4e9dc33..afdbbcf 100644 --- a/client/src/components/StepDetails.tsx +++ b/client/src/components/StepDetails.tsx @@ -1,5 +1,6 @@ import { Box, Typography, Button, TextField, IconButton } from '@mui/material'; import ArrowBackIcon from '@mui/icons-material/ArrowBack'; +import PrintIcon from '@mui/icons-material/Print'; import type { StepWithNotes } from '../types'; interface StepDetailsProps { @@ -16,13 +17,18 @@ export function StepDetails({ step, onPrint, onAddNote, onBack }: StepDetailsPro - {step.name} + + {step.name} + + + + {step.instructions} - Notes + Notes ({step.notes.length}) {step.notes.map((note) => ( @@ -44,10 +50,6 @@ export function StepDetails({ step, onPrint, onAddNote, onBack }: StepDetailsPro Add Note - - ); } \ No newline at end of file diff --git a/client/src/graphql/mutations.ts b/client/src/graphql/mutations.ts index b30b96d..43ad416 100644 --- a/client/src/graphql/mutations.ts +++ b/client/src/graphql/mutations.ts @@ -63,9 +63,12 @@ export const CREATE_NOTE = gql` id content step_id - user_id created_at updated_at + user { + id + name + } } } `; \ No newline at end of file diff --git a/client/src/hooks/useTaskData.ts b/client/src/hooks/useTaskData.ts index e27feb4..9ee1deb 100644 --- a/client/src/hooks/useTaskData.ts +++ b/client/src/hooks/useTaskData.ts @@ -156,9 +156,9 @@ export function useTaskData() { } }; - const handleAddNote = async (content: string, userId: string) => { - if (!selectedStep?.id || !userId) { - console.error('Cannot add note: missing stepId or userId'); + const handleAddNote = async (content: string) => { + if (!selectedStep?.id) { + console.error('Cannot add note: missing stepId'); return; } @@ -166,10 +166,10 @@ export function useTaskData() { await createNote({ variables: { content, - stepId: selectedStep.id, - userId, + stepId: String(selectedStep.id), }, }); + await refetchStep({ id: String(selectedStep.id) }); } catch (error) { console.error('Error adding note:', error); } diff --git a/client/src/layouts/DesktopLayout.tsx b/client/src/layouts/DesktopLayout.tsx index bf0bbcb..61e1f0b 100644 --- a/client/src/layouts/DesktopLayout.tsx +++ b/client/src/layouts/DesktopLayout.tsx @@ -1,4 +1,5 @@ -import { Box, Typography } from '@mui/material'; +import { Box, Typography, IconButton, TextField, Button } from '@mui/material'; +import PrintIcon from '@mui/icons-material/Print'; import type { GroupWithTasks, TaskWithSteps, StepWithNotes } from '../types'; import { CreateButtons } from '../components/CreateButtons'; @@ -10,6 +11,9 @@ interface DesktopLayoutProps { onGroupSelect: (group: GroupWithTasks | undefined) => void; onTaskSelect: (task: TaskWithSteps | undefined) => void; onStepSelect: (step: StepWithNotes | undefined) => void; + onPrintTask?: (taskId: string, userId: string) => void; + onPrintStep?: (stepId: string, userId: string) => void; + onAddNote?: (content: string) => void; } export function DesktopLayout({ @@ -20,6 +24,9 @@ export function DesktopLayout({ onGroupSelect, onTaskSelect, onStepSelect, + onPrintTask, + onPrintStep, + onAddNote, }: DesktopLayoutProps) { return ( @@ -62,10 +69,25 @@ export function DesktopLayout({ cursor: 'pointer', bgcolor: selectedTask?.id === task.id ? 'action.selected' : 'transparent', '&:hover': { bgcolor: 'action.hover' }, + display: 'flex', + justifyContent: 'space-between', + alignItems: 'center', }} - onClick={() => onTaskSelect(task)} > - {task.name} + onTaskSelect(task)} sx={{ flex: 1 }}> + {task.name} + + {onPrintTask && ( + { + e.stopPropagation(); + onPrintTask(String(task.id), '1'); // TODO: Get real user ID + }} + > + + + )} ))} @@ -86,10 +108,25 @@ export function DesktopLayout({ cursor: 'pointer', bgcolor: selectedStep?.id === step.id ? 'action.selected' : 'transparent', '&:hover': { bgcolor: 'action.hover' }, + display: 'flex', + justifyContent: 'space-between', + alignItems: 'center', }} - onClick={() => onStepSelect(step)} > - {step.name} + onStepSelect(step)} sx={{ flex: 1 }}> + {step.name} + + {onPrintStep && ( + { + e.stopPropagation(); + onPrintStep(String(step.id), '1'); // TODO: Get real user ID + }} + > + + + )} ))} @@ -97,11 +134,45 @@ export function DesktopLayout({ {/* Step details panel */} {selectedStep && ( - - - {selectedStep.name} - - {selectedStep.instructions} + + + {selectedStep.name} + {onPrintStep && ( + onPrintStep(String(selectedStep.id), '1')} // TODO: Get real user ID + > + + + )} + + {selectedStep.instructions} + + + + Notes ({selectedStep.notes.length}) + + {selectedStep.notes.map((note) => ( + + {note.user?.name} + {note.content} + + ))} + + + + + {onAddNote && ( + + )} + )}