pass user when printing, add checkboxes

This commit is contained in:
Sean Sube 2025-06-14 20:01:16 -05:00
parent ba2f7fb612
commit 5fde9f667b
No known key found for this signature in database
GPG Key ID: 3EED7B957D362AF1
5 changed files with 23 additions and 19 deletions

View File

@ -40,8 +40,8 @@ export const CREATE_STEP = gql`
`;
export const PRINT_TASK = gql`
mutation PrintTask($id: ID!) {
printTask(id: $id) {
mutation PrintTask($id: ID!, $userId: ID!) {
printTask(id: $id, userId: $userId) {
id
print_count
}
@ -49,8 +49,8 @@ export const PRINT_TASK = gql`
`;
export const PRINT_STEP = gql`
mutation PrintStep($id: ID!) {
printStep(id: $id) {
mutation PrintStep($id: ID!, $userId: ID!) {
printStep(id: $id, userId: $userId) {
id
print_count
}

View File

@ -2,6 +2,7 @@ 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';
import { useUserSelection } from '../hooks/useUserSelection';
interface DesktopLayoutProps {
groups: GroupWithTasks[];
@ -28,11 +29,14 @@ export function DesktopLayout({
onPrintStep,
onAddNote,
}: DesktopLayoutProps) {
const { selectedUser } = useUserSelection();
console.log('DesktopLayout render:', {
groups,
selectedGroup,
selectedTask,
selectedStep
selectedStep,
selectedUser
});
return (
@ -84,12 +88,12 @@ export function DesktopLayout({
<Box onClick={() => onTaskSelect(task)} sx={{ flex: 1 }}>
<Typography>{task.name}</Typography>
</Box>
{onPrintTask && (
{onPrintTask && selectedUser && (
<IconButton
size="small"
onClick={(e) => {
e.stopPropagation();
onPrintTask(String(task.id), '1'); // TODO: Get real user ID
onPrintTask(String(task.id), String(selectedUser.id));
}}
>
<PrintIcon />
@ -123,12 +127,12 @@ export function DesktopLayout({
<Box onClick={() => onStepSelect(step)} sx={{ flex: 1 }}>
<Typography>{step.name}</Typography>
</Box>
{onPrintStep && (
{onPrintStep && selectedUser && (
<IconButton
size="small"
onClick={(e) => {
e.stopPropagation();
onPrintStep(String(step.id), '1'); // TODO: Get real user ID
onPrintStep(String(step.id), String(selectedUser.id));
}}
>
<PrintIcon />
@ -144,9 +148,9 @@ export function DesktopLayout({
<Box sx={{ flex: 1, p: 2, overflow: 'auto' }}>
<Box sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', mb: 2 }}>
<Typography variant="h6">{selectedStep.name}</Typography>
{onPrintStep && (
{onPrintStep && selectedUser && (
<IconButton
onClick={() => onPrintStep(String(selectedStep.id), '1')} // TODO: Get real user ID
onClick={() => onPrintStep(String(selectedStep.id), String(selectedUser.id))}
>
<PrintIcon />
</IconButton>

View File

@ -101,7 +101,7 @@ export const typeDefs = gql`
createImage(stepId: ID!, originalPath: String!, bwPath: String!, order: Int!): Image!
createUser(name: String!): User!
createNote(content: String!, stepId: ID!): Note!
printTask(id: ID!): Task!
printStep(id: ID!): Step!
printTask(id: ID!, userId: ID!): Task!
printStep(id: ID!, userId: ID!): Step!
}
`;

View File

@ -57,7 +57,7 @@ export class SerialPrinter implements PrinterInterface {
.align('ct')
.style('b')
.size(1, 1) // Normal size (0.08 x 2.13 mm)
.text(`Task: ${task.name}`)
.text(`[ ] Task: ${task.name}`)
.text('='.repeat(32))
.text('')
.align('lt');
@ -73,7 +73,7 @@ export class SerialPrinter implements PrinterInterface {
const step = taskSteps[i];
await this.printer
.size(1, 1) // Normal size for step header
.text(`Step ${i + 1}: ${step.name}`)
.text(`[ ] Step ${i + 1}: ${step.name}`)
.text('-'.repeat(32))
.size(0, 0) // Smaller size for instructions (0.08 x 2.13 mm)
.text(step.instructions)
@ -115,7 +115,7 @@ export class SerialPrinter implements PrinterInterface {
.align('ct')
.style('b')
.size(1, 1) // Normal size (0.08 x 2.13 mm)
.text(`Step: ${step.name}`)
.text(`[ ] Step: ${step.name}`)
.text('='.repeat(32))
.text('')
.align('lt')

View File

@ -35,11 +35,11 @@ export class TestPrinter implements Printer {
const filename = path.join(this.outputDir, `task-${task.id}-${timestamp}.txt`);
const content = [
`Task: ${task.name}`,
`[ ] Task: ${task.name}`,
'='.repeat(40),
'',
...taskSteps.map((step, index) => [
`Step ${index + 1}: ${step.name}`,
`[ ] Step ${index + 1}: ${step.name}`,
'-'.repeat(40),
step.instructions,
'',
@ -62,7 +62,7 @@ export class TestPrinter implements Printer {
const filename = path.join(this.outputDir, `step-${step.id}-${timestamp}.txt`);
const content = [
`Step: ${step.name}`,
`[ ] Step: ${step.name}`,
'='.repeat(40),
'',
step.instructions,