From 541af0afeef6db88fc5cf2108c2ddf444e2d11e6 Mon Sep 17 00:00:00 2001 From: donpat1to Date: Fri, 10 Oct 2025 18:58:48 +0200 Subject: [PATCH] fixed backend port for shifts --- .../migrations/002_add_employee_fields.sql | 3 +- backend/src/database/schema.sql | 2 +- backend/src/scripts/checkTemplates.ts | 28 +++++++++++++++++++ backend/src/server.ts | 5 +--- backend/tsconfig.json | 1 - frontend/src/services/shiftPlanService.ts | 2 +- frontend/src/services/shiftTemplateService.ts | 2 +- 7 files changed, 34 insertions(+), 9 deletions(-) create mode 100644 backend/src/scripts/checkTemplates.ts diff --git a/backend/src/database/migrations/002_add_employee_fields.sql b/backend/src/database/migrations/002_add_employee_fields.sql index ecffe0b..bec67e1 100644 --- a/backend/src/database/migrations/002_add_employee_fields.sql +++ b/backend/src/database/migrations/002_add_employee_fields.sql @@ -1,3 +1,4 @@ -- Add employee fields ALTER TABLE users ADD COLUMN employee_type TEXT CHECK(employee_type IN ('chef', 'neuling', 'erfahren')); -ALTER TABLE users ADD COLUMN is_sufficiently_independent BOOLEAN DEFAULT FALSE; \ No newline at end of file +ALTER TABLE users ADD COLUMN is_sufficiently_independent BOOLEAN DEFAULT FALSE; +ALTER TABLE users ADD COLUMN last_login TEXT DEFAULT NULL; \ No newline at end of file diff --git a/backend/src/database/schema.sql b/backend/src/database/schema.sql index 9e75351..cad6333 100644 --- a/backend/src/database/schema.sql +++ b/backend/src/database/schema.sql @@ -9,7 +9,7 @@ CREATE TABLE IF NOT EXISTS users ( is_sufficiently_independent BOOLEAN DEFAULT FALSE, is_active BOOLEAN DEFAULT TRUE, created_at DATETIME DEFAULT CURRENT_TIMESTAMP, - last_login DATETIME + last_login TEXT || NULL ); -- Tabelle für Schichtvorlagen diff --git a/backend/src/scripts/checkTemplates.ts b/backend/src/scripts/checkTemplates.ts new file mode 100644 index 0000000..77cdc21 --- /dev/null +++ b/backend/src/scripts/checkTemplates.ts @@ -0,0 +1,28 @@ +import { db } from '../services/databaseService.js'; +import { ShiftTemplate } from '../models/ShiftTemplate.js'; + +async function checkTemplates() { + try { + const templates = await db.all( + `SELECT st.*, u.name as created_by_name + FROM shift_templates st + LEFT JOIN users u ON st.created_by = u.id` + ); + + console.log('Templates:', templates); + + for (const template of templates) { + const shifts = await db.all( + `SELECT * FROM template_shifts WHERE template_id = ?`, + [template.id] + ); + console.log(`Shifts for template ${template.id}:`, shifts); + } + } catch (error) { + console.error('Error:', error); + } finally { + process.exit(); + } +} + +checkTemplates(); \ No newline at end of file diff --git a/backend/src/server.ts b/backend/src/server.ts index 4a43468..726f199 100644 --- a/backend/src/server.ts +++ b/backend/src/server.ts @@ -15,10 +15,7 @@ const app = express(); const PORT = 3002; // CORS und Middleware -app.use(cors({ - origin: 'http://localhost:3000', - credentials: true -})); +app.use(cors()); app.use(express.json()); // API Routes diff --git a/backend/tsconfig.json b/backend/tsconfig.json index f77716b..b06c0d9 100644 --- a/backend/tsconfig.json +++ b/backend/tsconfig.json @@ -4,7 +4,6 @@ "target": "ES2022", "module": "NodeNext", "moduleResolution": "NodeNext", - "ignoreDeprecations": "6.0", "allowSyntheticDefaultImports": true, "esModuleInterop": true, "allowJs": true, diff --git a/frontend/src/services/shiftPlanService.ts b/frontend/src/services/shiftPlanService.ts index 2c0f35f..1c260ff 100644 --- a/frontend/src/services/shiftPlanService.ts +++ b/frontend/src/services/shiftPlanService.ts @@ -1,7 +1,7 @@ // frontend/src/services/shiftPlanService.ts import { authService } from './authService'; -const API_BASE = 'http://localhost:3001/api/shift-plans'; +const API_BASE = 'http://localhost:3002/api/shift-plans'; export interface CreateShiftPlanRequest { name: string; diff --git a/frontend/src/services/shiftTemplateService.ts b/frontend/src/services/shiftTemplateService.ts index c8781cf..a4a52f9 100644 --- a/frontend/src/services/shiftTemplateService.ts +++ b/frontend/src/services/shiftTemplateService.ts @@ -2,7 +2,7 @@ import { ShiftTemplate, TemplateShift } from '../types/shiftTemplate'; import { authService } from './authService'; -const API_BASE = 'http://localhost:3001/api/shift-templates'; +const API_BASE = 'http://localhost:3002/api/shift-templates'; export const shiftTemplateService = { async getTemplates(): Promise {