From 07ab9586ccbe4c6736df92105bdb62fc248e6579 Mon Sep 17 00:00:00 2001 From: donpat1to Date: Sat, 1 Nov 2025 15:22:47 +0100 Subject: [PATCH] removed unnecessary comments --- backend/src/controllers/authController.ts | 4 ++-- backend/src/middleware/auth.ts | 2 -- backend/src/models/helpers/employeeHelpers.ts | 10 +++++----- backend/src/models/helpers/shiftPlanHelpers.ts | 2 +- backend/src/models/scheduling.ts | 2 +- backend/src/scripts/applyMigration.ts | 4 ++-- frontend/src/contexts/AuthContext.tsx | 2 +- frontend/src/models/defaults/employeeDefaults.ts | 2 +- frontend/src/models/helpers/employeeHelpers.ts | 10 +++++----- frontend/src/models/helpers/shiftPlanHelpers.ts | 2 +- frontend/src/models/scheduling.ts | 2 +- frontend/src/pages/Auth/Login.tsx | 2 +- .../src/pages/Employees/components/EmployeeList.tsx | 6 +++--- frontend/src/pages/ShiftPlans/ShiftPlanView.tsx | 4 ++-- 14 files changed, 26 insertions(+), 28 deletions(-) diff --git a/backend/src/controllers/authController.ts b/backend/src/controllers/authController.ts index 273cd90..0595868 100644 --- a/backend/src/controllers/authController.ts +++ b/backend/src/controllers/authController.ts @@ -64,7 +64,7 @@ export const login = async (req: Request, res: Response) => { return res.status(400).json({ error: 'E-Mail und Passwort sind erforderlich' }); } - // UPDATED: Get user from database with role from employee_roles table + // Get user from database with role from employee_roles table const user = await db.get( `SELECT e.id, e.email, e.password, e.firstname, e.lastname, @@ -155,7 +155,7 @@ export const getCurrentUser = async (req: Request, res: Response) => { return res.status(401).json({ error: 'Nicht authentifiziert' }); } - // UPDATED: Get user with role from employee_roles table + // Get user with role from employee_roles table const user = await db.get( `SELECT e.id, e.email, e.firstname, e.lastname, diff --git a/backend/src/middleware/auth.ts b/backend/src/middleware/auth.ts index 2fc076d..43a31d8 100644 --- a/backend/src/middleware/auth.ts +++ b/backend/src/middleware/auth.ts @@ -53,7 +53,6 @@ export const requireRole = (roles: string[]) => { }; }; -// Add this function to your existing auth.ts export const getClientIP = (req: Request): string => { const trustedHeader = process.env.TRUSTED_PROXY_HEADER || 'x-forwarded-for'; const forwarded = req.headers[trustedHeader]; @@ -74,7 +73,6 @@ export const getClientIP = (req: Request): string => { return req.socket.remoteAddress || req.ip || 'unknown'; }; -// Add IP-based security checks export const ipSecurityCheck = (req: AuthRequest, res: Response, next: NextFunction): void => { const clientIP = getClientIP(req); diff --git a/backend/src/models/helpers/employeeHelpers.ts b/backend/src/models/helpers/employeeHelpers.ts index 0a1e197..4f47755 100644 --- a/backend/src/models/helpers/employeeHelpers.ts +++ b/backend/src/models/helpers/employeeHelpers.ts @@ -18,7 +18,7 @@ function generateEmail(firstname: string, lastname: string): string { return `${cleanFirstname}.${cleanLastname}@sp.de`; } -// UPDATED: Validation for new employee model with employee types +// Validation for new employee model with employee types export function validateEmployeeData(employee: CreateEmployeeRequest): string[] { const errors: string[] = []; @@ -71,7 +71,7 @@ export function generateEmployeeEmail(firstname: string, lastname: string): stri return generateEmail(firstname, lastname); } -// UPDATED: Business logic helpers for new employee types +// Business logic helpers for new employee types export const isManager = (employee: Employee): boolean => employee.employeeType === 'manager'; @@ -90,7 +90,7 @@ export const isInternal = (employee: Employee): boolean => export const isExternal = (employee: Employee): boolean => employee.employeeType === 'guest'; -// UPDATED: Trainee logic - now based on isTrainee field for personell type +// Trainee logic - now based on isTrainee field for personell type export const isTrainee = (employee: Employee): boolean => employee.employeeType === 'personell' && employee.isTrainee; @@ -107,7 +107,7 @@ export const isMaintenance = (employee: Employee): boolean => export const isUser = (employee: Employee): boolean => employee.roles?.includes('user') || false; -// UPDATED: Work alone permission - managers and experienced personell can work alone +// Work alone permission - managers and experienced personell can work alone export const canEmployeeWorkAlone = (employee: Employee): boolean => employee.canWorkAlone && (isManager(employee) || isExperienced(employee)); @@ -134,7 +134,7 @@ export function validateAvailabilityData(availability: Omit { return isInternal(employee) ? 'internal' : 'external'; }; diff --git a/backend/src/models/helpers/shiftPlanHelpers.ts b/backend/src/models/helpers/shiftPlanHelpers.ts index d28ac03..e6a5992 100644 --- a/backend/src/models/helpers/shiftPlanHelpers.ts +++ b/backend/src/models/helpers/shiftPlanHelpers.ts @@ -78,7 +78,7 @@ export function calculateTotalRequiredEmployees(plan: ShiftPlan): number { return plan.shifts.reduce((total, shift) => total + shift.requiredEmployees, 0); } -// UPDATED: Get scheduled shift by date and time slot +// Get scheduled shift by date and time slot export function getScheduledShiftByDateAndTime( plan: ShiftPlan, date: string, diff --git a/backend/src/models/scheduling.ts b/backend/src/models/scheduling.ts index b8a9c14..0c942ed 100644 --- a/backend/src/models/scheduling.ts +++ b/backend/src/models/scheduling.ts @@ -2,7 +2,7 @@ import { Employee } from './Employee.js'; import { ShiftPlan } from './ShiftPlan.js'; -// Updated Availability interface to match new schema +// Availability interface export interface Availability { id: string; employeeId: string; diff --git a/backend/src/scripts/applyMigration.ts b/backend/src/scripts/applyMigration.ts index ef6832e..889bce2 100644 --- a/backend/src/scripts/applyMigration.ts +++ b/backend/src/scripts/applyMigration.ts @@ -53,7 +53,7 @@ async function markMigrationAsApplied(migrationName: string) { ); } -// UPDATED: Function to handle schema changes for the new employee type system +// Function to handle schema changes for the new employee type system async function applySchemaUpdates() { console.log('🔄 Applying schema updates for new employee type system...'); @@ -80,7 +80,7 @@ async function applySchemaUpdates() { PRAGMA table_info(employees) `); - // FIXED: Check for employee_type column (not roles column) + // Check for employee_type column (not roles column) const hasEmployeeType = employeesTableInfo.some((col: TableColumnInfo) => col.name === 'employee_type'); const hasIsTrainee = employeesTableInfo.some((col: TableColumnInfo) => col.name === 'is_trainee'); diff --git a/frontend/src/contexts/AuthContext.tsx b/frontend/src/contexts/AuthContext.tsx index cb1e727..8ed3eb4 100644 --- a/frontend/src/contexts/AuthContext.tsx +++ b/frontend/src/contexts/AuthContext.tsx @@ -52,7 +52,7 @@ export const AuthProvider: React.FC = ({ children }) => { const startTime = Date.now(); const response = await fetch(`${API_BASE_URL}/setup/status`, { - signal: AbortSignal.timeout(5000) // 5 second timeout + signal: AbortSignal.timeout(5000) }); console.log(`✅ Setup status response received in ${Date.now() - startTime}ms`); diff --git a/frontend/src/models/defaults/employeeDefaults.ts b/frontend/src/models/defaults/employeeDefaults.ts index e80e189..e7d717f 100644 --- a/frontend/src/models/defaults/employeeDefaults.ts +++ b/frontend/src/models/defaults/employeeDefaults.ts @@ -102,7 +102,7 @@ export const AVAILABILITY_PREFERENCES = { } as const; // Default availability for new employees (all shifts unavailable as level 3) -// UPDATED: Now uses shiftId instead of timeSlotId + dayOfWeek +// Now uses shiftId instead of timeSlotId + dayOfWeek export function createDefaultAvailabilities(employeeId: string, planId: string, shiftIds: string[]): Omit[] { const availabilities: Omit[] = []; diff --git a/frontend/src/models/helpers/employeeHelpers.ts b/frontend/src/models/helpers/employeeHelpers.ts index 0a1e197..4f47755 100644 --- a/frontend/src/models/helpers/employeeHelpers.ts +++ b/frontend/src/models/helpers/employeeHelpers.ts @@ -18,7 +18,7 @@ function generateEmail(firstname: string, lastname: string): string { return `${cleanFirstname}.${cleanLastname}@sp.de`; } -// UPDATED: Validation for new employee model with employee types +// Validation for new employee model with employee types export function validateEmployeeData(employee: CreateEmployeeRequest): string[] { const errors: string[] = []; @@ -71,7 +71,7 @@ export function generateEmployeeEmail(firstname: string, lastname: string): stri return generateEmail(firstname, lastname); } -// UPDATED: Business logic helpers for new employee types +// Business logic helpers for new employee types export const isManager = (employee: Employee): boolean => employee.employeeType === 'manager'; @@ -90,7 +90,7 @@ export const isInternal = (employee: Employee): boolean => export const isExternal = (employee: Employee): boolean => employee.employeeType === 'guest'; -// UPDATED: Trainee logic - now based on isTrainee field for personell type +// Trainee logic - now based on isTrainee field for personell type export const isTrainee = (employee: Employee): boolean => employee.employeeType === 'personell' && employee.isTrainee; @@ -107,7 +107,7 @@ export const isMaintenance = (employee: Employee): boolean => export const isUser = (employee: Employee): boolean => employee.roles?.includes('user') || false; -// UPDATED: Work alone permission - managers and experienced personell can work alone +// Work alone permission - managers and experienced personell can work alone export const canEmployeeWorkAlone = (employee: Employee): boolean => employee.canWorkAlone && (isManager(employee) || isExperienced(employee)); @@ -134,7 +134,7 @@ export function validateAvailabilityData(availability: Omit { return isInternal(employee) ? 'internal' : 'external'; }; diff --git a/frontend/src/models/helpers/shiftPlanHelpers.ts b/frontend/src/models/helpers/shiftPlanHelpers.ts index d28ac03..e6a5992 100644 --- a/frontend/src/models/helpers/shiftPlanHelpers.ts +++ b/frontend/src/models/helpers/shiftPlanHelpers.ts @@ -78,7 +78,7 @@ export function calculateTotalRequiredEmployees(plan: ShiftPlan): number { return plan.shifts.reduce((total, shift) => total + shift.requiredEmployees, 0); } -// UPDATED: Get scheduled shift by date and time slot +// Get scheduled shift by date and time slot export function getScheduledShiftByDateAndTime( plan: ShiftPlan, date: string, diff --git a/frontend/src/models/scheduling.ts b/frontend/src/models/scheduling.ts index b8a9c14..a5424e4 100644 --- a/frontend/src/models/scheduling.ts +++ b/frontend/src/models/scheduling.ts @@ -2,7 +2,7 @@ import { Employee } from './Employee.js'; import { ShiftPlan } from './ShiftPlan.js'; -// Updated Availability interface to match new schema +// Availability interface to match export interface Availability { id: string; employeeId: string; diff --git a/frontend/src/pages/Auth/Login.tsx b/frontend/src/pages/Auth/Login.tsx index a800474..454eda8 100644 --- a/frontend/src/pages/Auth/Login.tsx +++ b/frontend/src/pages/Auth/Login.tsx @@ -1,4 +1,4 @@ -// frontend/src/pages/Auth/Login.tsx - UPDATED PASSWORD SECTION +// frontend/src/pages/Auth/Login.tsx import React, { useState, useEffect, useRef } from 'react'; import { useNavigate } from 'react-router-dom'; import { useAuth } from '../../contexts/AuthContext'; diff --git a/frontend/src/pages/Employees/components/EmployeeList.tsx b/frontend/src/pages/Employees/components/EmployeeList.tsx index a09c3db..6e3b699 100644 --- a/frontend/src/pages/Employees/components/EmployeeList.tsx +++ b/frontend/src/pages/Employees/components/EmployeeList.tsx @@ -15,7 +15,7 @@ interface EmployeeListProps { type SortField = 'name' | 'employeeType' | 'canWorkAlone' | 'role' | 'lastLogin'; type SortDirection = 'asc' | 'desc'; -// FIXED: Use the actual employee types from the Employee interface +// Use the actual employee types from the Employee interface type EmployeeType = 'manager' | 'personell' | 'apprentice' | 'guest'; const EmployeeList: React.FC = ({ @@ -130,7 +130,7 @@ const EmployeeList: React.FC = ({ const getEmployeeTypeBadge = (type: EmployeeType, isTrainee: boolean = false) => { const config = EMPLOYEE_TYPE_CONFIG[type]; - // FIXED: Updated color mapping for actual employee types + // Color mapping for actual employee types const bgColor = type === 'manager' ? '#fadbd8' // light red @@ -326,7 +326,7 @@ const EmployeeList: React.FC = ({ {sortedEmployees.map(employee => { - // FIXED: Type assertion to ensure type safety + // Type assertion to ensure type safety const employeeType = getEmployeeTypeBadge(employee.employeeType as EmployeeType, employee.isTrainee); const independence = getIndependenceBadge(employee.canWorkAlone); const roleInfo = getRoleBadge(employee.roles); diff --git a/frontend/src/pages/ShiftPlans/ShiftPlanView.tsx b/frontend/src/pages/ShiftPlans/ShiftPlanView.tsx index 00a3c20..eb83b9c 100644 --- a/frontend/src/pages/ShiftPlans/ShiftPlanView.tsx +++ b/frontend/src/pages/ShiftPlans/ShiftPlanView.tsx @@ -1,4 +1,4 @@ -// frontend/src/pages/ShiftPlans/ShiftPlanView.tsx - UPDATED +// frontend/src/pages/ShiftPlans/ShiftPlanView.tsx import React, { useState, useEffect } from 'react'; import { useParams, useNavigate } from 'react-router-dom'; import { useAuth } from '../../contexts/AuthContext'; @@ -1118,7 +1118,7 @@ const ShiftPlanView: React.FC = () => { )} - {/* Assignment Preview Modal - FIXED CONDITION */} + {/* Assignment Preview Modal */} {(showAssignmentPreview || assignmentResult) && (