mirror of
https://github.com/donpat1to/Schichtenplaner.git
synced 2025-12-01 06:55:45 +01:00
Compare commits
32 Commits
09e08ff615
...
v0.0.16
| Author | SHA1 | Date | |
|---|---|---|---|
| 92840c2424 | |||
| ce1c6b08b1 | |||
| b9a88bce1c | |||
| b60e5ccdd2 | |||
| f5aa376e31 | |||
| e82e584f76 | |||
| e177c3d2a6 | |||
| de23ea00ee | |||
| d78ba474d8 | |||
| 5c7786bc19 | |||
| 15107cdc63 | |||
| 22266c765b | |||
| a66609a40c | |||
| 87dda38bc3 | |||
| 9de501c7eb | |||
| 5c6a50ddcf | |||
| 017f5fb2e0 | |||
| 527954befd | |||
| e7d30151b7 | |||
| 4a006a2e69 | |||
| 4b699b05d3 | |||
| dcac0307a2 | |||
| a0cc859935 | |||
| 49afd75ed3 | |||
| ebb9e3f4fe | |||
| 48f140f930 | |||
| b6b31659e3 | |||
| 42e343777a | |||
| aa7af272d8 | |||
| a0d96925c5 | |||
|
|
28283fa8bc | ||
|
|
fdff2853bd |
17
.github/workflows/docker.yml
vendored
17
.github/workflows/docker.yml
vendored
@@ -1,10 +1,10 @@
|
|||||||
name: CI/CD Pipeline
|
name: CI/CD Pipeline
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
push:
|
push:
|
||||||
branches: [ main, master, development ]
|
branches: [ "development", "main", "staging" ]
|
||||||
pull_request:
|
tags: [ "v*.*.*" ]
|
||||||
branches: [ main, master, development ]
|
|
||||||
|
|
||||||
env:
|
env:
|
||||||
REGISTRY: ghcr.io
|
REGISTRY: ghcr.io
|
||||||
@@ -110,8 +110,9 @@ jobs:
|
|||||||
if: github.event_name == 'push'
|
if: github.event_name == 'push'
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: write
|
||||||
packages: write
|
packages: write
|
||||||
|
id-token: write
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
@@ -163,7 +164,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Display pushed images
|
- name: Display pushed images
|
||||||
run: |
|
run: |
|
||||||
echo "✅ Docker images pushed successfully!"
|
echo "Docker images pushed successfully!"
|
||||||
echo "📦 Image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}"
|
echo "- Image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}"
|
||||||
echo "🏷️ Tags: ${{ steps.meta.outputs.tags }}"
|
echo "- Tags: ${{ steps.meta.outputs.tags }}"
|
||||||
echo "🚀 New version: ${{ needs.set-tag.outputs.tag_name }}"
|
echo "- New version: ${{ needs.set-tag.outputs.tag_name }}"
|
||||||
|
|||||||
42
Dockerfile
42
Dockerfile
@@ -5,7 +5,7 @@ WORKDIR /app/backend
|
|||||||
|
|
||||||
# Install Python + OR-Tools
|
# Install Python + OR-Tools
|
||||||
RUN apt-get update && apt-get install -y python3 python3-pip build-essential \
|
RUN apt-get update && apt-get install -y python3 python3-pip build-essential \
|
||||||
&& pip install --no-cache-dir ortools
|
&& pip install --no-cache-dir ortools
|
||||||
|
|
||||||
# Create symlink so python3 is callable as python
|
# Create symlink so python3 is callable as python
|
||||||
RUN ln -sf /usr/bin/python3 /usr/bin/python
|
RUN ln -sf /usr/bin/python3 /usr/bin/python
|
||||||
@@ -23,13 +23,12 @@ COPY backend/src/ ./src/
|
|||||||
# Build backend
|
# Build backend
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
|
# Copy database files manually
|
||||||
|
RUN cp -r src/database/ dist/database/
|
||||||
|
|
||||||
# Verify Python and OR-Tools installation
|
# Verify Python and OR-Tools installation
|
||||||
RUN python -c "from ortools.sat.python import cp_model; print('OR-Tools installed successfully')"
|
RUN python -c "from ortools.sat.python import cp_model; print('OR-Tools installed successfully')"
|
||||||
|
|
||||||
#RUN python3 -c "from ortools.sat.python import cp_model; print('OR-Tools installed successfully')"
|
|
||||||
|
|
||||||
|
|
||||||
# Frontend build stage
|
# Frontend build stage
|
||||||
FROM node:20-bullseye AS frontend-builder
|
FROM node:20-bullseye AS frontend-builder
|
||||||
|
|
||||||
@@ -50,45 +49,42 @@ COPY frontend/public/ ./public/
|
|||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
# Production stage
|
# Production stage
|
||||||
FROM node:20-alpine
|
FROM node:20-bookworm
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Install Python and OR-Tools for production
|
|
||||||
#RUN apk add --no-cache \
|
|
||||||
# python \
|
|
||||||
# py3-pip \
|
|
||||||
# && pip3 install ortools
|
|
||||||
|
|
||||||
# Install PM2 for process management
|
# Install PM2 for process management
|
||||||
RUN npm install -g pm2
|
RUN npm install -g pm2
|
||||||
|
|
||||||
|
# Create data directory for SQLite database with proper permissions
|
||||||
|
RUN mkdir -p /app/data
|
||||||
|
|
||||||
# Copy backend built files
|
# Copy backend built files
|
||||||
COPY --from=backend-builder /app/backend/package*.json ./
|
COPY --from=backend-builder /app/backend/package*.json ./
|
||||||
COPY --from=backend-builder /app/backend/dist/ ./dist/
|
COPY --from=backend-builder /app/backend/dist/ ./dist/
|
||||||
COPY --from=backend-builder /app/backend/node_modules/ ./node_modules/
|
COPY --from=backend-builder /app/backend/node_modules/ ./node_modules/
|
||||||
# COPY --from=backend-builder /app/backend/python-scripts/ ./python-scripts/
|
|
||||||
|
|
||||||
# Copy frontend built files
|
# Copy frontend built files
|
||||||
COPY --from=frontend-builder /app/frontend/build/ ./frontend-build/
|
COPY --from=frontend-builder /app/frontend/build/ ./frontend-build/
|
||||||
|
|
||||||
# Copy PM2 configuration
|
# Copy PM2 configuration
|
||||||
COPY ecosystem.config.js ./
|
COPY ecosystem.config.cjs ./
|
||||||
|
|
||||||
# Create a non-root user
|
# Create a non-root user and group - DEBIAN STYLE
|
||||||
RUN addgroup -g 1001 -S nodejs && \
|
RUN groupadd -g 1001 nodejs && \
|
||||||
adduser -S schichtplan -u 1001 && \
|
useradd -m -u 1001 -s /bin/bash -g nodejs schichtplan && \
|
||||||
chown -R schichtplan:nodejs /app
|
chown -R schichtplan:nodejs /app && \
|
||||||
|
chmod 755 /app && \
|
||||||
|
chmod 775 /app/data
|
||||||
|
|
||||||
|
# Set PM2 to use app directory instead of home directory
|
||||||
|
ENV PM2_HOME=/app/.pm2
|
||||||
|
|
||||||
USER schichtplan
|
USER schichtplan
|
||||||
|
|
||||||
# Verify installations
|
EXPOSE 3002
|
||||||
#RUN python --version && \
|
|
||||||
# python -c "from ortools.sat.python import cp_model; print('OR-Tools verified')"
|
|
||||||
|
|
||||||
EXPOSE 3000 3002
|
|
||||||
|
|
||||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
|
||||||
CMD wget --no-verbose --tries=1 --spider http://localhost:3002/api/health || exit 1
|
CMD wget --no-verbose --tries=1 --spider http://localhost:3002/api/health || exit 1
|
||||||
|
|
||||||
CMD ["pm2-runtime", "ecosystem.config.js"]
|
CMD ["pm2-runtime", "ecosystem.config.cjs"]
|
||||||
21
LICENSE-COMMERCIAL
Normal file
21
LICENSE-COMMERCIAL
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
COMMERCIAL LICENSE AGREEMENT
|
||||||
|
Copyright (c) 2025 Patrick Mahnke-Hartmann
|
||||||
|
|
||||||
|
This software, "Schichtenplaner", is offered under a dual licensing model.
|
||||||
|
|
||||||
|
1. Open-Source License
|
||||||
|
You may use this software under the terms of the MIT License
|
||||||
|
(see LICENSE file) for non-commercial, personal, or educational use.
|
||||||
|
|
||||||
|
2. Commercial License
|
||||||
|
Commercial use of this software requires a separate paid license.
|
||||||
|
This includes, but is not limited to:
|
||||||
|
- Use in proprietary, for-profit, or internal business applications
|
||||||
|
- Use within paid services or SaaS offerings
|
||||||
|
- Integration into commercial software or distributions
|
||||||
|
|
||||||
|
To obtain a commercial license, please contact:
|
||||||
|
📧 patrick@mahnke-hartmann.dev
|
||||||
|
or open an inquiry via GitHub: https://github.com/donpat1to/Schichtenplaner
|
||||||
|
|
||||||
|
Without a valid commercial license, all commercial rights are reserved.
|
||||||
12
README.md
12
README.md
@@ -2,4 +2,14 @@
|
|||||||
Aufteilung der Schichten unter Mitarbeitern
|
Aufteilung der Schichten unter Mitarbeitern
|
||||||
|
|
||||||
|
|
||||||
du knlich
|
## 🧾 License
|
||||||
|
|
||||||
|
This project uses a **dual license model**:
|
||||||
|
|
||||||
|
- **Community Edition:** Licensed under [MIT](./LICENSE) for personal and non-commercial use.
|
||||||
|
- **Commercial Edition:** A [commercial license](./LICENSE-COMMERCIAL) is required for any for-profit or business use.
|
||||||
|
|
||||||
|
To obtain a commercial license, contact:
|
||||||
|
📧 patrick@mahnke-hartmann.dev
|
||||||
|
|
||||||
|
[](#license)
|
||||||
|
|||||||
@@ -8,7 +8,30 @@ const __filename = fileURLToPath(import.meta.url);
|
|||||||
const __dirname = path.dirname(__filename);
|
const __dirname = path.dirname(__filename);
|
||||||
|
|
||||||
export async function initializeDatabase(): Promise<void> {
|
export async function initializeDatabase(): Promise<void> {
|
||||||
const schemaPath = path.join(__dirname, '../database/schema.sql');
|
const possiblePaths = [
|
||||||
|
path.join(__dirname, '../database/schema.sql'),
|
||||||
|
path.join(__dirname, '../../database/schema.sql'),
|
||||||
|
path.join(process.cwd(), 'database/schema.sql'),
|
||||||
|
path.join(process.cwd(), 'src/database/schema.sql'),
|
||||||
|
path.join(process.cwd(), 'dist/database/schema.sql')
|
||||||
|
];
|
||||||
|
|
||||||
|
let schemaPath: string | null = null;
|
||||||
|
|
||||||
|
for (const p of possiblePaths) {
|
||||||
|
if (fs.existsSync(p)) {
|
||||||
|
schemaPath = p;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!schemaPath) {
|
||||||
|
throw new Error(
|
||||||
|
`❌ schema.sql not found in any of the tested paths:\n${possiblePaths.join('\n')}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`✅ Using schema at: ${schemaPath}`);
|
||||||
const schema = fs.readFileSync(schemaPath, 'utf8');
|
const schema = fs.readFileSync(schemaPath, 'utf8');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
// backend/src/server.ts
|
// backend/src/server.ts
|
||||||
import express from 'express';
|
import express from 'express';
|
||||||
import cors from 'cors';
|
import path from 'path';
|
||||||
|
import { fileURLToPath } from 'url';
|
||||||
import { initializeDatabase } from './scripts/initializeDatabase.js';
|
import { initializeDatabase } from './scripts/initializeDatabase.js';
|
||||||
|
import fs from 'fs';
|
||||||
|
|
||||||
// Route imports
|
// Route imports
|
||||||
import authRoutes from './routes/auth.js';
|
import authRoutes from './routes/auth.js';
|
||||||
@@ -11,11 +13,13 @@ import setupRoutes from './routes/setup.js';
|
|||||||
import scheduledShifts from './routes/scheduledShifts.js';
|
import scheduledShifts from './routes/scheduledShifts.js';
|
||||||
import schedulingRoutes from './routes/scheduling.js';
|
import schedulingRoutes from './routes/scheduling.js';
|
||||||
|
|
||||||
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
|
const __dirname = path.dirname(__filename);
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
const PORT = 3002;
|
const PORT = 3002;
|
||||||
|
|
||||||
// CORS und Middleware
|
// Middleware
|
||||||
app.use(cors());
|
|
||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
|
|
||||||
// API Routes
|
// API Routes
|
||||||
@@ -26,17 +30,6 @@ app.use('/api/shift-plans', shiftPlanRoutes);
|
|||||||
app.use('/api/scheduled-shifts', scheduledShifts);
|
app.use('/api/scheduled-shifts', scheduledShifts);
|
||||||
app.use('/api/scheduling', schedulingRoutes);
|
app.use('/api/scheduling', schedulingRoutes);
|
||||||
|
|
||||||
// Error handling middleware should come after routes
|
|
||||||
app.use((err: any, req: express.Request, res: express.Response, next: express.NextFunction) => {
|
|
||||||
console.error('Unhandled error:', err);
|
|
||||||
res.status(500).json({ error: 'Internal server error' });
|
|
||||||
});
|
|
||||||
|
|
||||||
// 404 handler for API routes
|
|
||||||
app.use('/api/*', (req, res) => {
|
|
||||||
res.status(404).json({ error: 'API endpoint not found' });
|
|
||||||
});
|
|
||||||
|
|
||||||
// Health route
|
// Health route
|
||||||
app.get('/api/health', (req: any, res: any) => {
|
app.get('/api/health', (req: any, res: any) => {
|
||||||
res.json({
|
res.json({
|
||||||
@@ -46,49 +39,82 @@ app.get('/api/health', (req: any, res: any) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Setup status route (additional endpoint for clarity)
|
// 🆕 STATIC FILE SERVING FÜR FRONTEND
|
||||||
app.get('/api/initial-setup', async (req: any, res: any) => {
|
const frontendBuildPath = path.join(__dirname, '../frontend-build');
|
||||||
try {
|
console.log('📁 Frontend build path:', frontendBuildPath);
|
||||||
const { db } = await import('./services/databaseService.js');
|
|
||||||
|
|
||||||
const adminExists = await db.get<{ 'COUNT(*)': number }>(
|
// Überprüfe ob das Verzeichnis existiert
|
||||||
'SELECT COUNT(*) FROM employees WHERE role = ?',
|
if (fs.existsSync(frontendBuildPath)) {
|
||||||
['admin']
|
console.log('✅ Frontend build directory exists');
|
||||||
);
|
const files = fs.readdirSync(frontendBuildPath);
|
||||||
|
console.log('📄 Files in frontend-build:', files);
|
||||||
|
|
||||||
res.json({
|
// Serviere statische Dateien
|
||||||
needsInitialSetup: !adminExists || adminExists['COUNT(*)'] === 0
|
app.use(express.static(frontendBuildPath));
|
||||||
});
|
|
||||||
} catch (error) {
|
console.log('✅ Static file serving configured');
|
||||||
console.error('Error checking initial setup:', error);
|
} else {
|
||||||
res.status(500).json({ error: 'Internal server error' });
|
console.log('❌ Frontend build directory NOT FOUND:', frontendBuildPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
app.get('/', (req, res) => {
|
||||||
|
const indexPath = path.join(frontendBuildPath, 'index.html');
|
||||||
|
console.log('📄 Serving index.html from:', indexPath);
|
||||||
|
|
||||||
|
if (fs.existsSync(indexPath)) {
|
||||||
|
res.sendFile(indexPath);
|
||||||
|
} else {
|
||||||
|
console.error('❌ index.html not found at:', indexPath);
|
||||||
|
res.status(404).send('Frontend not found - index.html missing');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.get('*', (req, res) => {
|
||||||
|
// Ignoriere API Routes
|
||||||
|
if (req.path.startsWith('/api/')) {
|
||||||
|
return res.status(404).json({ error: 'API endpoint not found' });
|
||||||
|
}
|
||||||
|
|
||||||
|
const indexPath = path.join(frontendBuildPath, 'index.html');
|
||||||
|
console.log('🔄 Client-side routing for:', req.path, '-> index.html');
|
||||||
|
|
||||||
|
if (fs.existsSync(indexPath)) {
|
||||||
|
res.sendFile(indexPath);
|
||||||
|
} else {
|
||||||
|
console.error('❌ index.html not found for client-side routing');
|
||||||
|
res.status(404).json({ error: 'Frontend application not found' });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Error handling middleware
|
||||||
|
app.use((err: any, req: express.Request, res: express.Response, next: express.NextFunction) => {
|
||||||
|
console.error('Unhandled error:', err);
|
||||||
|
res.status(500).json({ error: 'Internal server error' });
|
||||||
|
});
|
||||||
|
|
||||||
// Initialize the application
|
// Initialize the application
|
||||||
const initializeApp = async () => {
|
const initializeApp = async () => {
|
||||||
try {
|
try {
|
||||||
// Initialize database with base schema
|
// Initialize database with base schema
|
||||||
await initializeDatabase();
|
await initializeDatabase();
|
||||||
//console.log('✅ Database initialized successfully');
|
|
||||||
|
|
||||||
// Apply any pending migrations
|
// Apply any pending migrations
|
||||||
const { applyMigration } = await import('./scripts/applyMigration.js');
|
const { applyMigration } = await import('./scripts/applyMigration.js');
|
||||||
await applyMigration();
|
await applyMigration();
|
||||||
//console.log('✅ Database migrations applied');
|
|
||||||
|
|
||||||
// Start server only after successful initialization
|
// Start server only after successful initialization
|
||||||
app.listen(PORT, () => {
|
app.listen(PORT, () => {
|
||||||
console.log('🎉 BACKEND STARTED SUCCESSFULLY!');
|
console.log('🎉 APPLICATION STARTED SUCCESSFULLY!');
|
||||||
console.log(`📍 Port: ${PORT}`);
|
console.log(`📍 Port: ${PORT}`);
|
||||||
console.log(`📍 Health: http://localhost:${PORT}/api/health`);
|
console.log(`📍 Frontend: http://localhost:${PORT}`);
|
||||||
|
console.log(`📍 API: http://localhost:${PORT}/api`);
|
||||||
console.log('');
|
console.log('');
|
||||||
console.log(`🔧 Setup ready at: http://localhost:${PORT}/api/setup/status`);
|
console.log(`🔧 Setup: http://localhost:${PORT}/api/setup/status`);
|
||||||
console.log('📝 Create your admin account on first launch');
|
console.log('📝 Create your admin account on first launch');
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('❌ Error during initialization:', error);
|
console.error('❌ Error during initialization:', error);
|
||||||
process.exit(1); // Exit if initialization fails
|
process.exit(1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,19 @@
|
|||||||
|
// backend/src/services/databaseService
|
||||||
import sqlite3 from 'sqlite3';
|
import sqlite3 from 'sqlite3';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
|
import fs from 'fs';
|
||||||
|
|
||||||
const __filename = fileURLToPath(import.meta.url);
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
const __dirname = path.dirname(__filename);
|
const __dirname = path.dirname(__filename);
|
||||||
const dbPath = path.join(__dirname, '../../database/schichtplan.db');
|
|
||||||
|
const dbPath = process.env.DB_PATH || '/app/data/schichtplan.db';
|
||||||
|
|
||||||
|
// Stelle sicher, dass das Verzeichnis existiert
|
||||||
|
const dbDir = path.dirname(dbPath);
|
||||||
|
if (!fs.existsSync(dbDir)) {
|
||||||
|
fs.mkdirSync(dbDir, { recursive: true });
|
||||||
|
}
|
||||||
|
|
||||||
class Database {
|
class Database {
|
||||||
private db: sqlite3.Database;
|
private db: sqlite3.Database;
|
||||||
|
|||||||
18
ecosystem.config.cjs
Normal file
18
ecosystem.config.cjs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
// ecosystem.config.cjs
|
||||||
|
module.exports = {
|
||||||
|
apps: [
|
||||||
|
{
|
||||||
|
name: 'schichtplaner',
|
||||||
|
script: './dist/server.js',
|
||||||
|
instances: 1,
|
||||||
|
exec_mode: 'fork',
|
||||||
|
env: {
|
||||||
|
NODE_ENV: 'production',
|
||||||
|
PORT: 3002
|
||||||
|
},
|
||||||
|
error_file: './logs/app-err.log',
|
||||||
|
out_file: './logs/app-out.log',
|
||||||
|
time: true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
apps: [
|
|
||||||
{
|
|
||||||
name: 'backend',
|
|
||||||
script: './dist/server.js',
|
|
||||||
instances: 1,
|
|
||||||
exec_mode: 'fork',
|
|
||||||
env: {
|
|
||||||
NODE_ENV: 'production',
|
|
||||||
PORT: 3002
|
|
||||||
},
|
|
||||||
error_file: './logs/backend-err.log',
|
|
||||||
out_file: './logs/backend-out.log',
|
|
||||||
time: true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'frontend',
|
|
||||||
script: 'npx',
|
|
||||||
args: 'serve -s frontend-build -l 3000',
|
|
||||||
instances: 1,
|
|
||||||
exec_mode: 'fork',
|
|
||||||
env: {
|
|
||||||
NODE_ENV: 'production'
|
|
||||||
},
|
|
||||||
error_file: './logs/frontend-err.log',
|
|
||||||
out_file: './logs/frontend-out.log',
|
|
||||||
time: true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
};
|
|
||||||
4
frontend/.env.development
Normal file
4
frontend/.env.development
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
# frontend/.env.development
|
||||||
|
BROWSER=none
|
||||||
|
FAST_REFRESH=true
|
||||||
|
DANGEROUSLY_DISABLE_HOST_CHECK=true
|
||||||
1546
frontend/package-lock.json
generated
1546
frontend/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -2,6 +2,7 @@
|
|||||||
"name": "frontend",
|
"name": "frontend",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
|
"proxy": "http://localhost:3002",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@testing-library/dom": "^10.4.1",
|
"@testing-library/dom": "^10.4.1",
|
||||||
"@testing-library/jest-dom": "^6.9.1",
|
"@testing-library/jest-dom": "^6.9.1",
|
||||||
@@ -15,7 +16,6 @@
|
|||||||
"react": "^19.2.0",
|
"react": "^19.2.0",
|
||||||
"react-dom": "^19.2.0",
|
"react-dom": "^19.2.0",
|
||||||
"react-router-dom": "^7.9.3",
|
"react-router-dom": "^7.9.3",
|
||||||
"react-scripts": "5.0.1",
|
|
||||||
"typescript": "^4.9.5",
|
"typescript": "^4.9.5",
|
||||||
"web-vitals": "^2.1.4"
|
"web-vitals": "^2.1.4"
|
||||||
},
|
},
|
||||||
@@ -42,5 +42,9 @@
|
|||||||
"last 1 firefox version",
|
"last 1 firefox version",
|
||||||
"last 1 safari version"
|
"last 1 safari version"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"http-proxy-middleware": "^3.0.5",
|
||||||
|
"react-scripts": "^5.0.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ interface AuthContextType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const AuthContext = createContext<AuthContextType | undefined>(undefined);
|
const AuthContext = createContext<AuthContextType | undefined>(undefined);
|
||||||
|
const API_BASE_URL = process.env.REACT_APP_API_BASE_URL || '/api';
|
||||||
|
|
||||||
interface AuthProviderProps {
|
interface AuthProviderProps {
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
@@ -48,7 +49,7 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children }) => {
|
|||||||
const checkSetupStatus = async (): Promise<void> => {
|
const checkSetupStatus = async (): Promise<void> => {
|
||||||
try {
|
try {
|
||||||
console.log('🔍 Checking setup status...');
|
console.log('🔍 Checking setup status...');
|
||||||
const response = await fetch('http://localhost:3002/api/setup/status');
|
const response = await fetch(`${API_BASE_URL}/setup/status`);
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error('Setup status check failed');
|
throw new Error('Setup status check failed');
|
||||||
}
|
}
|
||||||
@@ -72,7 +73,7 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children }) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await fetch('http://localhost:3002/api/auth/me', {
|
const response = await fetch(`${API_BASE_URL}/auth/me`, {
|
||||||
headers: {
|
headers: {
|
||||||
'Authorization': `Bearer ${token}`
|
'Authorization': `Bearer ${token}`
|
||||||
}
|
}
|
||||||
@@ -104,7 +105,7 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children }) => {
|
|||||||
try {
|
try {
|
||||||
console.log('🔐 Attempting login for:', credentials.email);
|
console.log('🔐 Attempting login for:', credentials.email);
|
||||||
|
|
||||||
const response = await fetch('http://localhost:3002/api/auth/login', {
|
const response = await fetch(`${API_BASE_URL}/auth/login`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
|||||||
@@ -1,18 +1,21 @@
|
|||||||
// frontend/src/pages/Auth/Login.tsx - KORRIGIERT
|
// frontend/src/pages/Auth/Login.tsx - UPDATED PASSWORD SECTION
|
||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect, useRef } from 'react';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
import { useAuth } from '../../contexts/AuthContext';
|
import { useAuth } from '../../contexts/AuthContext';
|
||||||
import { useNotification } from '../../contexts/NotificationContext';
|
import { useNotification } from '../../contexts/NotificationContext';
|
||||||
import { employeeService } from '../../services/employeeService';
|
|
||||||
|
|
||||||
const Login: React.FC = () => {
|
const Login: React.FC = () => {
|
||||||
const [email, setEmail] = useState('');
|
const [email, setEmail] = useState('');
|
||||||
const [password, setPassword] = useState('');
|
const [password, setPassword] = useState('');
|
||||||
|
const [showPassword, setShowPassword] = useState(false);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const { login, user } = useAuth();
|
const { login, user } = useAuth();
|
||||||
const { showNotification } = useNotification();
|
const { showNotification } = useNotification();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
const holdTimeoutRef = useRef<NodeJS.Timeout | null>(null);
|
||||||
|
const passwordInputRef = useRef<HTMLInputElement>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (user) {
|
if (user) {
|
||||||
console.log('✅ User already logged in, redirecting to dashboard');
|
console.log('✅ User already logged in, redirecting to dashboard');
|
||||||
@@ -20,6 +23,47 @@ const Login: React.FC = () => {
|
|||||||
}
|
}
|
||||||
}, [user, navigate]);
|
}, [user, navigate]);
|
||||||
|
|
||||||
|
// Cleanup timeouts on unmount
|
||||||
|
useEffect(() => {
|
||||||
|
return () => {
|
||||||
|
if (holdTimeoutRef.current) {
|
||||||
|
clearTimeout(holdTimeoutRef.current);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const handleMouseDown = () => {
|
||||||
|
// Start timeout to show password after a brief delay (300ms)
|
||||||
|
holdTimeoutRef.current = setTimeout(() => {
|
||||||
|
setShowPassword(true);
|
||||||
|
}, 300);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleMouseUp = () => {
|
||||||
|
// Clear the timeout if user releases before delay completes
|
||||||
|
if (holdTimeoutRef.current) {
|
||||||
|
clearTimeout(holdTimeoutRef.current);
|
||||||
|
holdTimeoutRef.current = null;
|
||||||
|
}
|
||||||
|
// Always hide password on release
|
||||||
|
setShowPassword(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleTouchStart = (e: React.TouchEvent) => {
|
||||||
|
e.preventDefault(); // Prevent context menu on mobile
|
||||||
|
handleMouseDown();
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleTouchEnd = (e: React.TouchEvent) => {
|
||||||
|
e.preventDefault();
|
||||||
|
handleMouseUp();
|
||||||
|
};
|
||||||
|
|
||||||
|
// Prevent context menu on long press
|
||||||
|
const handleContextMenu = (e: React.MouseEvent) => {
|
||||||
|
e.preventDefault();
|
||||||
|
};
|
||||||
|
|
||||||
const handleSubmit = async (e: React.FormEvent) => {
|
const handleSubmit = async (e: React.FormEvent) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
@@ -35,7 +79,6 @@ const Login: React.FC = () => {
|
|||||||
message: `Willkommen zurück!`
|
message: `Willkommen zurück!`
|
||||||
});
|
});
|
||||||
|
|
||||||
// Navigiere zur Startseite
|
|
||||||
navigate('/');
|
navigate('/');
|
||||||
|
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
@@ -50,7 +93,6 @@ const Login: React.FC = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Wenn bereits eingeloggt, zeige Ladeanzeige
|
|
||||||
if (user) {
|
if (user) {
|
||||||
return (
|
return (
|
||||||
<div style={{ textAlign: 'center', padding: '40px' }}>
|
<div style={{ textAlign: 'center', padding: '40px' }}>
|
||||||
@@ -77,7 +119,7 @@ const Login: React.FC = () => {
|
|||||||
}}>
|
}}>
|
||||||
<h2 style={{ textAlign: 'center', marginBottom: '30px' }}>Anmeldung</h2>
|
<h2 style={{ textAlign: 'center', marginBottom: '30px' }}>Anmeldung</h2>
|
||||||
|
|
||||||
<div style={{ marginBottom: '20px' }}>
|
<div style={{ marginBottom: '20px', width: '100%' }}>
|
||||||
<label style={{ display: 'block', marginBottom: '8px', fontWeight: 'bold' }}>
|
<label style={{ display: 'block', marginBottom: '8px', fontWeight: 'bold' }}>
|
||||||
E-Mail
|
E-Mail
|
||||||
</label>
|
</label>
|
||||||
@@ -87,7 +129,7 @@ const Login: React.FC = () => {
|
|||||||
onChange={(e) => setEmail(e.target.value)}
|
onChange={(e) => setEmail(e.target.value)}
|
||||||
required
|
required
|
||||||
style={{
|
style={{
|
||||||
width: '100%',
|
width: '94.5%',
|
||||||
padding: '10px',
|
padding: '10px',
|
||||||
border: '1px solid #ddd',
|
border: '1px solid #ddd',
|
||||||
borderRadius: '4px',
|
borderRadius: '4px',
|
||||||
@@ -97,24 +139,57 @@ const Login: React.FC = () => {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style={{ marginBottom: '30px' }}>
|
<div style={{ marginBottom: '30px', width: '100%' }}>
|
||||||
<label style={{ display: 'block', marginBottom: '8px', fontWeight: 'bold' }}>
|
<label style={{ display: 'block', marginBottom: '8px', fontWeight: 'bold' }}>
|
||||||
Passwort
|
Passwort
|
||||||
</label>
|
</label>
|
||||||
<input
|
<div style={{ position: 'relative' }}>
|
||||||
type="password"
|
<input
|
||||||
value={password}
|
ref={passwordInputRef}
|
||||||
onChange={(e) => setPassword(e.target.value)}
|
type={showPassword ? 'text' : 'password'}
|
||||||
required
|
value={password}
|
||||||
style={{
|
onChange={(e) => setPassword(e.target.value)}
|
||||||
width: '100%',
|
required
|
||||||
padding: '10px',
|
style={{
|
||||||
border: '1px solid #ddd',
|
width: '94.5%',
|
||||||
borderRadius: '4px',
|
padding: '10px',
|
||||||
fontSize: '16px'
|
paddingRight: '10px',
|
||||||
}}
|
border: '1px solid #ddd',
|
||||||
placeholder="Ihr Passwort"
|
borderRadius: '4px',
|
||||||
/>
|
fontSize: '16px'
|
||||||
|
}}
|
||||||
|
placeholder="Ihr Passwort"
|
||||||
|
/>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onMouseDown={handleMouseDown}
|
||||||
|
onMouseUp={handleMouseUp}
|
||||||
|
onMouseLeave={handleMouseUp} // Handle mouse leaving while pressed
|
||||||
|
onTouchStart={handleTouchStart}
|
||||||
|
onTouchEnd={handleTouchEnd}
|
||||||
|
onTouchCancel={handleTouchEnd} // Handle touch cancellation
|
||||||
|
onContextMenu={handleContextMenu}
|
||||||
|
style={{
|
||||||
|
position: 'absolute',
|
||||||
|
right: '10px',
|
||||||
|
top: '50%',
|
||||||
|
transform: 'translateY(-50%)',
|
||||||
|
background: 'none',
|
||||||
|
border: 'none',
|
||||||
|
cursor: 'pointer',
|
||||||
|
padding: '1px',
|
||||||
|
borderRadius: '1px',
|
||||||
|
backgroundColor: showPassword ? '#e0e0e0' : 'transparent',
|
||||||
|
transition: 'background-color 0.2s',
|
||||||
|
userSelect: 'none',
|
||||||
|
WebkitUserSelect: 'none',
|
||||||
|
touchAction: 'manipulation'
|
||||||
|
}}
|
||||||
|
title="Gedrückt halten zum Anzeigen des Passworts"
|
||||||
|
>
|
||||||
|
{showPassword ? '👁' : '👁'}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
@@ -123,7 +198,7 @@ const Login: React.FC = () => {
|
|||||||
style={{
|
style={{
|
||||||
width: '100%',
|
width: '100%',
|
||||||
padding: '12px',
|
padding: '12px',
|
||||||
backgroundColor: loading ? '#ccc' : '#007bff',
|
backgroundColor: loading ? '#ccc' : '#51258f',
|
||||||
color: 'white',
|
color: 'white',
|
||||||
border: 'none',
|
border: 'none',
|
||||||
borderRadius: '4px',
|
borderRadius: '4px',
|
||||||
|
|||||||
@@ -1,81 +1,46 @@
|
|||||||
// frontend/src/pages/Help/Help.tsx
|
// frontend/src/pages/Help/Help.tsx
|
||||||
import React, { useState, useEffect } from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
const Help: React.FC = () => {
|
const Help: React.FC = () => {
|
||||||
const [currentStage, setCurrentStage] = useState(0);
|
const businessRules = [
|
||||||
const [isAnimating, setIsAnimating] = useState(false);
|
{ rule: "Mitarbeiter werden nur Schichten zugewiesen, für die sie sich eingetragen haben", critical: true },
|
||||||
|
{ rule: "Maximal 1 Schicht pro Tag pro Mitarbeiter", critical: true },
|
||||||
|
{ rule: "Schichten haben Mindest- und Maximalkapazitäten", critical: true },
|
||||||
|
{ rule: "Trainees benötigen erfahrene Begleitung in jeder Schicht", critical: true },
|
||||||
|
{ rule: "Mitarbeiter, die nicht alleine arbeiten können, müssen Begleitung haben", critical: true },
|
||||||
|
{ rule: "Vertragslimits: Klein=1 Schicht/Woche, Groß=2 Schichten/Woche", critical: true },
|
||||||
|
{ rule: "Manager werden automatisch ihren bevorzugten Schichten zugewiesen", critical: false }
|
||||||
|
];
|
||||||
|
|
||||||
const algorithmStages = [
|
const schedulingStages = [
|
||||||
{
|
{
|
||||||
title: "📊 Phase A: Reguläre Mitarbeiterplanung",
|
title: "1. Verfügbarkeitsprüfung",
|
||||||
description: "Zuweisung aller Mitarbeiter außer Manager",
|
description: "Nur Mitarbeiter, die sich für Schichten eingetragen haben (Verfügbarkeit 1 oder 2), werden berücksichtigt."
|
||||||
steps: [
|
|
||||||
"Grundabdeckung: Mindestens 1 Mitarbeiter pro Schicht",
|
|
||||||
"Erfahrene Mitarbeiter werden bevorzugt",
|
|
||||||
"Verhindere 'Neu allein' Situationen",
|
|
||||||
"Fülle Schichten bis zur Zielbesetzung"
|
|
||||||
],
|
|
||||||
color: "#3498db"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "👑 Phase B: Manager-Einfügung",
|
title: "2. Modellaufbau",
|
||||||
description: "Manager wird seinen bevorzugten Schichten zugewiesen",
|
description: "Das System erstellt ein mathematisches Modell mit allen Variablen und Constraints."
|
||||||
steps: [
|
|
||||||
"Manager wird festen Schichten zugewiesen",
|
|
||||||
"Erfahrene Mitarbeiter werden zu Manager-Schichten hinzugefügt",
|
|
||||||
"Bei Problemen: Austausch oder Bewegung von Mitarbeitern",
|
|
||||||
"Fallback: Nicht-erfahrene als Backup"
|
|
||||||
],
|
|
||||||
color: "#e74c3c"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "🔧 Phase C: Reparatur & Validierung",
|
title: "3. CP-SAT Optimierung",
|
||||||
description: "Probleme erkennen und automatisch beheben",
|
description: "Google's Constraint Programming Solver findet die beste Zuordnung unter allen Regeln."
|
||||||
steps: [
|
|
||||||
"Überbesetzte erfahrene Mitarbeiter identifizieren",
|
|
||||||
"Mitarbeiter-Pool für Neuverteilung erstellen",
|
|
||||||
"Priorisierte Zuweisung zu Problem-Schichten",
|
|
||||||
"Finale Validierung aller Geschäftsregeln"
|
|
||||||
],
|
|
||||||
color: "#2ecc71"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "✅ Finale Prüfung",
|
title: "4. Manager-Zuweisung",
|
||||||
description: "Zusammenfassung und Freigabe",
|
description: "Manager werden automatisch ihren Wunschschichten (Verfügbarkeit 1) zugeordnet."
|
||||||
steps: [
|
},
|
||||||
"Reparatur-Bericht generieren",
|
{
|
||||||
"Kritische vs. nicht-kritische Probleme klassifizieren",
|
title: "5. Validierung",
|
||||||
"Veröffentlichungsstatus bestimmen",
|
description: "Die Lösung wird auf Regelverletzungen geprüft und ein Bericht generiert."
|
||||||
"Benutzerfreundliche Zusammenfassung anzeigen"
|
|
||||||
],
|
|
||||||
color: "#f39c12"
|
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
const businessRules = [
|
const preferenceLevels = [
|
||||||
{ rule: "Manager darf nicht allein arbeiten", critical: true },
|
{ level: 1, label: "Bevorzugt", description: "Mitarbeiter möchte diese Schicht unbedingt arbeiten", color: "#27ae60" },
|
||||||
{ rule: "Erfahrene mit canWorkAlone: false dürfen nicht allein arbeiten", critical: true },
|
{ level: 2, label: "Verfügbar", description: "Mitarbeiter ist verfügbar für diese Schicht", color: "#f39c12" },
|
||||||
{ rule: "Keine leeren Schichten", critical: true },
|
{ level: 3, label: "Nicht verfügbar", description: "Mitarbeiter kann diese Schicht nicht arbeiten", color: "#e74c3c" }
|
||||||
{ rule: "Keine 'Neu allein' Situationen", critical: true },
|
|
||||||
{ rule: "Manager sollte mit erfahrenem Mitarbeiter arbeiten", critical: false },
|
|
||||||
{ rule: "Vertragslimits einhalten", critical: true },
|
|
||||||
{ rule: "Nicht zu viele erfahrene Mitarbeiter in einer Schicht", critical: false }
|
|
||||||
];
|
];
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const interval = setInterval(() => {
|
|
||||||
if (isAnimating) {
|
|
||||||
setCurrentStage((prev) => (prev + 1) % algorithmStages.length);
|
|
||||||
}
|
|
||||||
}, 3000);
|
|
||||||
|
|
||||||
return () => clearInterval(interval);
|
|
||||||
}, [isAnimating]);
|
|
||||||
|
|
||||||
const toggleAnimation = () => {
|
|
||||||
setIsAnimating(!isAnimating);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={{ padding: '20px', maxWidth: '1200px', margin: '0 auto' }}>
|
<div style={{ padding: '20px', maxWidth: '1200px', margin: '0 auto' }}>
|
||||||
<h1>❓ Hilfe & Support - Scheduling Algorithmus</h1>
|
<h1>❓ Hilfe & Support - Scheduling Algorithmus</h1>
|
||||||
@@ -89,7 +54,7 @@ const Help: React.FC = () => {
|
|||||||
boxShadow: '0 4px 6px rgba(0,0,0,0.1)',
|
boxShadow: '0 4px 6px rgba(0,0,0,0.1)',
|
||||||
border: '1px solid #e0e0e0'
|
border: '1px solid #e0e0e0'
|
||||||
}}>
|
}}>
|
||||||
<h2 style={{ color: '#2c3e50', marginBottom: '20px' }}>📋 Validierungs Regeln</h2>
|
<h2 style={{ color: '#2c3e50', marginBottom: '20px' }}>📋 Geschäftsregeln</h2>
|
||||||
<div style={{ display: 'grid', gap: '10px' }}>
|
<div style={{ display: 'grid', gap: '10px' }}>
|
||||||
{businessRules.map((rule, index) => (
|
{businessRules.map((rule, index) => (
|
||||||
<div
|
<div
|
||||||
@@ -120,14 +85,14 @@ const Help: React.FC = () => {
|
|||||||
color: rule.critical ? '#e74c3c' : '#f39c12',
|
color: rule.critical ? '#e74c3c' : '#f39c12',
|
||||||
fontWeight: 'bold'
|
fontWeight: 'bold'
|
||||||
}}>
|
}}>
|
||||||
{rule.critical ? 'KRITISCH' : 'WARNUNG'}
|
{rule.critical ? 'HART' : 'WEICH'}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Algorithm Explanation */}
|
{/* Scheduling Process */}
|
||||||
<div style={{
|
<div style={{
|
||||||
backgroundColor: 'white',
|
backgroundColor: 'white',
|
||||||
borderRadius: '12px',
|
borderRadius: '12px',
|
||||||
@@ -136,45 +101,125 @@ const Help: React.FC = () => {
|
|||||||
boxShadow: '0 4px 6px rgba(0,0,0,0.1)',
|
boxShadow: '0 4px 6px rgba(0,0,0,0.1)',
|
||||||
border: '1px solid #e0e0e0'
|
border: '1px solid #e0e0e0'
|
||||||
}}>
|
}}>
|
||||||
<h2 style={{ color: '#2c3e50', marginBottom: '20px' }}>🎯 Wie der Algorithmus funktioniert</h2>
|
<h2 style={{ color: '#2c3e50', marginBottom: '20px' }}>⚙️ Scheduling-Prozess</h2>
|
||||||
|
|
||||||
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(300px, 1fr))', gap: '20px' }}>
|
<div style={{ display: 'grid', gap: '15px' }}>
|
||||||
|
{schedulingStages.map((stage, index) => (
|
||||||
|
<div key={index} style={{
|
||||||
|
padding: '20px',
|
||||||
|
backgroundColor: '#f8f9fa',
|
||||||
|
borderRadius: '8px',
|
||||||
|
border: '2px solid #e9ecef',
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'flex-start'
|
||||||
|
}}>
|
||||||
|
<div style={{
|
||||||
|
backgroundColor: '#3498db',
|
||||||
|
color: 'white',
|
||||||
|
borderRadius: '50%',
|
||||||
|
width: '30px',
|
||||||
|
height: '30px',
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
fontWeight: 'bold',
|
||||||
|
marginRight: '15px',
|
||||||
|
flexShrink: 0
|
||||||
|
}}>
|
||||||
|
{index + 1}
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<h4 style={{ color: '#2c3e50', margin: '0 0 8px 0' }}>{stage.title}</h4>
|
||||||
|
<p style={{ color: '#6c757d', margin: 0 }}>{stage.description}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Preference Levels */}
|
||||||
|
<div style={{
|
||||||
|
backgroundColor: 'white',
|
||||||
|
borderRadius: '12px',
|
||||||
|
padding: '30px',
|
||||||
|
marginTop: '20px',
|
||||||
|
boxShadow: '0 4px 6px rgba(0,0,0,0.1)',
|
||||||
|
border: '1px solid #e0e0e0'
|
||||||
|
}}>
|
||||||
|
<h2 style={{ color: '#2c3e50', marginBottom: '20px' }}>🎯 Verfügbarkeits-Level</h2>
|
||||||
|
|
||||||
|
<div style={{ display: 'grid', gap: '12px' }}>
|
||||||
|
{preferenceLevels.map((pref) => (
|
||||||
|
<div key={pref.level} style={{
|
||||||
|
padding: '15px',
|
||||||
|
backgroundColor: `${pref.color}15`,
|
||||||
|
border: `2px solid ${pref.color}`,
|
||||||
|
borderRadius: '8px',
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center'
|
||||||
|
}}>
|
||||||
|
<div style={{
|
||||||
|
backgroundColor: pref.color,
|
||||||
|
color: 'white',
|
||||||
|
borderRadius: '6px',
|
||||||
|
padding: '8px 12px',
|
||||||
|
fontWeight: 'bold',
|
||||||
|
marginRight: '15px',
|
||||||
|
minWidth: '120px',
|
||||||
|
textAlign: 'center'
|
||||||
|
}}>
|
||||||
|
Level {pref.level}: {pref.label}
|
||||||
|
</div>
|
||||||
|
<span style={{ color: '#2c3e50' }}>{pref.description}</span>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Tips */}
|
||||||
|
<div style={{
|
||||||
|
marginTop: '25px',
|
||||||
|
padding: '25px',
|
||||||
|
backgroundColor: '#e8f4fd',
|
||||||
|
borderRadius: '12px',
|
||||||
|
border: '2px solid #b8d4f0'
|
||||||
|
}}>
|
||||||
|
<h3 style={{ color: '#2980b9', marginTop: 0 }}>💡 Best Practices für erfolgreiches Scheduling</h3>
|
||||||
|
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(300px, 1fr))', gap: '15px', marginTop: '15px' }}>
|
||||||
<div>
|
<div>
|
||||||
<h4 style={{ color: '#3498db' }}>🏗️ Phasen-basierter Ansatz</h4>
|
<h4 style={{ color: '#2980b9' }}>Vor dem Scheduling</h4>
|
||||||
<p>Der Algorithmus arbeitet in klar definierten Phasen, um komplexe Probleme schrittweise zu lösen und Stabilität zu gewährleisten.</p>
|
<ul style={{ margin: 0, paddingLeft: '20px', color: '#2c3e50' }}>
|
||||||
|
<li>Stellen Sie sicher, dass alle Mitarbeiter ihre Verfügbarkeit eingetragen haben</li>
|
||||||
|
<li>Überprüfen Sie die Mitarbeiterprofile (Trainee/Erfahren, Alleinarbeit möglich)</li>
|
||||||
|
<li>Bestätigen Sie die Vertragstypen und Schichtanforderungen</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<h4 style={{ color: '#2980b9' }}>Nach dem Scheduling</h4>
|
||||||
|
<ul style={{ margin: 0, paddingLeft: '20px', color: '#2c3e50' }}>
|
||||||
|
<li>Prüfen Sie den Lösungsbericht auf Verletzungen</li>
|
||||||
|
<li>Kontrollieren Sie unterbesetzte Schichten</li>
|
||||||
|
<li>Validieren Sie Trainee-Betreuung und Alleinarbeits-Regeln</li>
|
||||||
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* Technical Info */}
|
||||||
<div style={{
|
<div style={{
|
||||||
marginTop: '25px',
|
marginTop: '25px',
|
||||||
padding: '20px',
|
padding: '20px',
|
||||||
backgroundColor: '#e8f4fd',
|
backgroundColor: '#fff3cd',
|
||||||
borderRadius: '8px',
|
borderRadius: '8px',
|
||||||
border: '1px solid #b8d4f0'
|
border: '1px solid #ffeaa7'
|
||||||
}}>
|
}}>
|
||||||
<h4 style={{ color: '#2980b9', marginTop: 0 }}>💡 Tipps für beste Ergebnisse</h4>
|
<h4 style={{ color: '#856404', marginTop: 0 }}>🔧 Technische Informationen</h4>
|
||||||
<ul style={{ margin: 0, paddingLeft: '20px' }}>
|
<p style={{ color: '#856404', margin: 0 }}>
|
||||||
<li>Stellen Sie sicher, dass alle Mitarbeiter ihre Verfügbarkeit eingetragen haben</li>
|
<strong>Lösungsalgorithmus:</strong> Google OR-Tools CP-SAT Solver •
|
||||||
<li>Überprüfen Sie die Vertragstypen (klein = 1 Schicht/Woche, groß = 2 Schichten/Woche)</li>
|
<strong> Fallback:</strong> TypeScript-basierter Solver •
|
||||||
<li>Markieren Sie erfahrene Mitarbeiter, die alleine arbeiten können</li>
|
<strong> Maximale Laufzeit:</strong> 105 Sekunden
|
||||||
<li>Planen Sie Manager-Verfügbarkeit im Voraus</li>
|
</p>
|
||||||
</ul>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<style>{`
|
|
||||||
@keyframes pulse {
|
|
||||||
0% { transform: scale(1); }
|
|
||||||
50% { transform: scale(1.02); }
|
|
||||||
100% { transform: scale(1); }
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes glow {
|
|
||||||
0% { box-shadow: 0 0 5px rgba(52, 152, 219, 0.5); }
|
|
||||||
50% { box-shadow: 0 0 20px rgba(52, 152, 219, 0.8); }
|
|
||||||
100% { box-shadow: 0 0 5px rgba(52, 152, 219, 0.5); }
|
|
||||||
}
|
|
||||||
`}</style>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// frontend/src/pages/Settings/Settings.tsx
|
// frontend/src/pages/Settings/Settings.tsx - UPDATED WITH NEW STYLES
|
||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect, useRef } from 'react';
|
||||||
import { useAuth } from '../../contexts/AuthContext';
|
import { useAuth } from '../../contexts/AuthContext';
|
||||||
import { employeeService } from '../../services/employeeService';
|
import { employeeService } from '../../services/employeeService';
|
||||||
import { useNotification } from '../../contexts/NotificationContext';
|
import { useNotification } from '../../contexts/NotificationContext';
|
||||||
@@ -27,6 +27,16 @@ const Settings: React.FC = () => {
|
|||||||
confirmPassword: ''
|
confirmPassword: ''
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Password visibility states
|
||||||
|
const [showCurrentPassword, setShowCurrentPassword] = useState(false);
|
||||||
|
const [showNewPassword, setShowNewPassword] = useState(false);
|
||||||
|
const [showConfirmPassword, setShowConfirmPassword] = useState(false);
|
||||||
|
|
||||||
|
// Refs for timeout management
|
||||||
|
const currentPasswordTimeoutRef = useRef<NodeJS.Timeout | null>(null);
|
||||||
|
const newPasswordTimeoutRef = useRef<NodeJS.Timeout | null>(null);
|
||||||
|
const confirmPasswordTimeoutRef = useRef<NodeJS.Timeout | null>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (currentUser) {
|
if (currentUser) {
|
||||||
setProfileForm({
|
setProfileForm({
|
||||||
@@ -36,6 +46,17 @@ const Settings: React.FC = () => {
|
|||||||
}
|
}
|
||||||
}, [currentUser]);
|
}, [currentUser]);
|
||||||
|
|
||||||
|
// Cleanup timeouts on unmount
|
||||||
|
useEffect(() => {
|
||||||
|
return () => {
|
||||||
|
[currentPasswordTimeoutRef, newPasswordTimeoutRef, confirmPasswordTimeoutRef].forEach(ref => {
|
||||||
|
if (ref.current) {
|
||||||
|
clearTimeout(ref.current);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
const handleProfileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
const handleProfileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
const { name, value } = e.target;
|
const { name, value } = e.target;
|
||||||
setProfileForm(prev => ({
|
setProfileForm(prev => ({
|
||||||
@@ -52,6 +73,67 @@ const Settings: React.FC = () => {
|
|||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Password visibility handlers for current password
|
||||||
|
const handleCurrentPasswordMouseDown = () => {
|
||||||
|
currentPasswordTimeoutRef.current = setTimeout(() => {
|
||||||
|
setShowCurrentPassword(true);
|
||||||
|
}, 300);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleCurrentPasswordMouseUp = () => {
|
||||||
|
if (currentPasswordTimeoutRef.current) {
|
||||||
|
clearTimeout(currentPasswordTimeoutRef.current);
|
||||||
|
currentPasswordTimeoutRef.current = null;
|
||||||
|
}
|
||||||
|
setShowCurrentPassword(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Password visibility handlers for new password
|
||||||
|
const handleNewPasswordMouseDown = () => {
|
||||||
|
newPasswordTimeoutRef.current = setTimeout(() => {
|
||||||
|
setShowNewPassword(true);
|
||||||
|
}, 300);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleNewPasswordMouseUp = () => {
|
||||||
|
if (newPasswordTimeoutRef.current) {
|
||||||
|
clearTimeout(newPasswordTimeoutRef.current);
|
||||||
|
newPasswordTimeoutRef.current = null;
|
||||||
|
}
|
||||||
|
setShowNewPassword(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Password visibility handlers for confirm password
|
||||||
|
const handleConfirmPasswordMouseDown = () => {
|
||||||
|
confirmPasswordTimeoutRef.current = setTimeout(() => {
|
||||||
|
setShowConfirmPassword(true);
|
||||||
|
}, 300);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleConfirmPasswordMouseUp = () => {
|
||||||
|
if (confirmPasswordTimeoutRef.current) {
|
||||||
|
clearTimeout(confirmPasswordTimeoutRef.current);
|
||||||
|
confirmPasswordTimeoutRef.current = null;
|
||||||
|
}
|
||||||
|
setShowConfirmPassword(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Touch event handlers
|
||||||
|
const handleTouchStart = (setter: () => void) => (e: React.TouchEvent) => {
|
||||||
|
e.preventDefault();
|
||||||
|
setter();
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleTouchEnd = (cleanup: () => void) => (e: React.TouchEvent) => {
|
||||||
|
e.preventDefault();
|
||||||
|
cleanup();
|
||||||
|
};
|
||||||
|
|
||||||
|
// Prevent context menu
|
||||||
|
const handleContextMenu = (e: React.MouseEvent) => {
|
||||||
|
e.preventDefault();
|
||||||
|
};
|
||||||
|
|
||||||
const handleProfileUpdate = async (e: React.FormEvent) => {
|
const handleProfileUpdate = async (e: React.FormEvent) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (!currentUser) return;
|
if (!currentUser) return;
|
||||||
@@ -180,11 +262,6 @@ const Settings: React.FC = () => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get full name for display
|
|
||||||
const getFullName = () => {
|
|
||||||
return `${currentUser.firstname || ''} ${currentUser.lastname || ''}`.trim();
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={styles.container}>
|
<div style={styles.container}>
|
||||||
{/* Left Sidebar with Tabs */}
|
{/* Left Sidebar with Tabs */}
|
||||||
@@ -443,77 +520,137 @@ const Settings: React.FC = () => {
|
|||||||
|
|
||||||
<form onSubmit={handlePasswordUpdate} style={{ marginTop: '2rem' }}>
|
<form onSubmit={handlePasswordUpdate} style={{ marginTop: '2rem' }}>
|
||||||
<div style={styles.formGridCompact}>
|
<div style={styles.formGridCompact}>
|
||||||
|
{/* Current Password Field */}
|
||||||
<div style={styles.field}>
|
<div style={styles.field}>
|
||||||
<label style={styles.fieldLabel}>
|
<label style={styles.fieldLabel}>
|
||||||
Aktuelles Passwort *
|
Aktuelles Passwort *
|
||||||
</label>
|
</label>
|
||||||
<input
|
<div style={styles.fieldInputContainer}>
|
||||||
type="password"
|
<input
|
||||||
name="currentPassword"
|
type={showCurrentPassword ? 'text' : 'password'}
|
||||||
value={passwordForm.currentPassword}
|
name="currentPassword"
|
||||||
onChange={handlePasswordChange}
|
value={passwordForm.currentPassword}
|
||||||
required
|
onChange={handlePasswordChange}
|
||||||
style={styles.fieldInput}
|
required
|
||||||
placeholder="Aktuelles Passwort"
|
style={styles.fieldInputWithIcon}
|
||||||
onFocus={(e) => {
|
placeholder="Aktuelles Passwort"
|
||||||
e.target.style.borderColor = '#1a1325';
|
onFocus={(e) => {
|
||||||
e.target.style.boxShadow = '0 0 0 3px rgba(26, 19, 37, 0.1)';
|
e.target.style.borderColor = '#1a1325';
|
||||||
}}
|
e.target.style.boxShadow = '0 0 0 3px rgba(26, 19, 37, 0.1)';
|
||||||
onBlur={(e) => {
|
}}
|
||||||
e.target.style.borderColor = '#e8e8e8';
|
onBlur={(e) => {
|
||||||
e.target.style.boxShadow = 'none';
|
e.target.style.borderColor = '#e8e8e8';
|
||||||
}}
|
e.target.style.boxShadow = 'none';
|
||||||
/>
|
}}
|
||||||
|
/>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onMouseDown={handleCurrentPasswordMouseDown}
|
||||||
|
onMouseUp={handleCurrentPasswordMouseUp}
|
||||||
|
onMouseLeave={handleCurrentPasswordMouseUp}
|
||||||
|
onTouchStart={handleTouchStart(handleCurrentPasswordMouseDown)}
|
||||||
|
onTouchEnd={handleTouchEnd(handleCurrentPasswordMouseUp)}
|
||||||
|
onTouchCancel={handleTouchEnd(handleCurrentPasswordMouseUp)}
|
||||||
|
onContextMenu={handleContextMenu}
|
||||||
|
style={{
|
||||||
|
...styles.passwordToggleButton,
|
||||||
|
backgroundColor: showCurrentPassword ? 'rgba(26, 19, 37, 0.1)' : 'transparent'
|
||||||
|
}}
|
||||||
|
title="Gedrückt halten zum Anzeigen des Passworts"
|
||||||
|
>
|
||||||
|
{showCurrentPassword ? '👁' : '👁'}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* New Password Field */}
|
||||||
<div style={styles.field}>
|
<div style={styles.field}>
|
||||||
<label style={styles.fieldLabel}>
|
<label style={styles.fieldLabel}>
|
||||||
Neues Passwort *
|
Neues Passwort *
|
||||||
</label>
|
</label>
|
||||||
<input
|
<div style={styles.fieldInputContainer}>
|
||||||
type="password"
|
<input
|
||||||
name="newPassword"
|
type={showNewPassword ? 'text' : 'password'}
|
||||||
value={passwordForm.newPassword}
|
name="newPassword"
|
||||||
onChange={handlePasswordChange}
|
value={passwordForm.newPassword}
|
||||||
required
|
onChange={handlePasswordChange}
|
||||||
minLength={6}
|
required
|
||||||
style={styles.fieldInput}
|
minLength={6}
|
||||||
placeholder="Mindestens 6 Zeichen"
|
style={styles.fieldInputWithIcon}
|
||||||
onFocus={(e) => {
|
placeholder="Mindestens 6 Zeichen"
|
||||||
e.target.style.borderColor = '#1a1325';
|
onFocus={(e) => {
|
||||||
e.target.style.boxShadow = '0 0 0 3px rgba(26, 19, 37, 0.1)';
|
e.target.style.borderColor = '#1a1325';
|
||||||
}}
|
e.target.style.boxShadow = '0 0 0 3px rgba(26, 19, 37, 0.1)';
|
||||||
onBlur={(e) => {
|
}}
|
||||||
e.target.style.borderColor = '#e8e8e8';
|
onBlur={(e) => {
|
||||||
e.target.style.boxShadow = 'none';
|
e.target.style.borderColor = '#e8e8e8';
|
||||||
}}
|
e.target.style.boxShadow = 'none';
|
||||||
/>
|
}}
|
||||||
|
/>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onMouseDown={handleNewPasswordMouseDown}
|
||||||
|
onMouseUp={handleNewPasswordMouseUp}
|
||||||
|
onMouseLeave={handleNewPasswordMouseUp}
|
||||||
|
onTouchStart={handleTouchStart(handleNewPasswordMouseDown)}
|
||||||
|
onTouchEnd={handleTouchEnd(handleNewPasswordMouseUp)}
|
||||||
|
onTouchCancel={handleTouchEnd(handleNewPasswordMouseUp)}
|
||||||
|
onContextMenu={handleContextMenu}
|
||||||
|
style={{
|
||||||
|
...styles.passwordToggleButton,
|
||||||
|
backgroundColor: showNewPassword ? 'rgba(26, 19, 37, 0.1)' : 'transparent'
|
||||||
|
}}
|
||||||
|
title="Gedrückt halten zum Anzeigen des Passworts"
|
||||||
|
>
|
||||||
|
{showNewPassword ? '👁' : '👁'}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
<div style={styles.fieldHint}>
|
<div style={styles.fieldHint}>
|
||||||
Das Passwort muss mindestens 6 Zeichen lang sein.
|
Das Passwort muss mindestens 6 Zeichen lang sein.
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* Confirm Password Field */}
|
||||||
<div style={styles.field}>
|
<div style={styles.field}>
|
||||||
<label style={styles.fieldLabel}>
|
<label style={styles.fieldLabel}>
|
||||||
Neues Passwort bestätigen *
|
Neues Passwort bestätigen *
|
||||||
</label>
|
</label>
|
||||||
<input
|
<div style={styles.fieldInputContainer}>
|
||||||
type="password"
|
<input
|
||||||
name="confirmPassword"
|
type={showConfirmPassword ? 'text' : 'password'}
|
||||||
value={passwordForm.confirmPassword}
|
name="confirmPassword"
|
||||||
onChange={handlePasswordChange}
|
value={passwordForm.confirmPassword}
|
||||||
required
|
onChange={handlePasswordChange}
|
||||||
style={styles.fieldInput}
|
required
|
||||||
placeholder="Passwort wiederholen"
|
style={styles.fieldInputWithIcon}
|
||||||
onFocus={(e) => {
|
placeholder="Passwort wiederholen"
|
||||||
e.target.style.borderColor = '#1a1325';
|
onFocus={(e) => {
|
||||||
e.target.style.boxShadow = '0 0 0 3px rgba(26, 19, 37, 0.1)';
|
e.target.style.borderColor = '#1a1325';
|
||||||
}}
|
e.target.style.boxShadow = '0 0 0 3px rgba(26, 19, 37, 0.1)';
|
||||||
onBlur={(e) => {
|
}}
|
||||||
e.target.style.borderColor = '#e8e8e8';
|
onBlur={(e) => {
|
||||||
e.target.style.boxShadow = 'none';
|
e.target.style.borderColor = '#e8e8e8';
|
||||||
}}
|
e.target.style.boxShadow = 'none';
|
||||||
/>
|
}}
|
||||||
|
/>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onMouseDown={handleConfirmPasswordMouseDown}
|
||||||
|
onMouseUp={handleConfirmPasswordMouseUp}
|
||||||
|
onMouseLeave={handleConfirmPasswordMouseUp}
|
||||||
|
onTouchStart={handleTouchStart(handleConfirmPasswordMouseDown)}
|
||||||
|
onTouchEnd={handleTouchEnd(handleConfirmPasswordMouseUp)}
|
||||||
|
onTouchCancel={handleTouchEnd(handleConfirmPasswordMouseUp)}
|
||||||
|
onContextMenu={handleContextMenu}
|
||||||
|
style={{
|
||||||
|
...styles.passwordToggleButton,
|
||||||
|
backgroundColor: showConfirmPassword ? 'rgba(26, 19, 37, 0.1)' : 'transparent'
|
||||||
|
}}
|
||||||
|
title="Gedrückt halten zum Anzeigen des Passworts"
|
||||||
|
>
|
||||||
|
{showConfirmPassword ? '👁' : '👁'}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
export const styles = {
|
// frontend/src/pages/Settings/type/SettingsType.tsx - CORRECTED
|
||||||
|
export const styles = {
|
||||||
container: {
|
container: {
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
minHeight: 'calc(100vh - 120px)',
|
minHeight: 'calc(100vh - 120px)',
|
||||||
@@ -121,11 +122,17 @@
|
|||||||
display: 'flex',
|
display: 'flex',
|
||||||
flexDirection: 'column' as const,
|
flexDirection: 'column' as const,
|
||||||
gap: '0.5rem',
|
gap: '0.5rem',
|
||||||
|
width: '100%',
|
||||||
},
|
},
|
||||||
fieldLabel: {
|
fieldLabel: {
|
||||||
fontSize: '0.9rem',
|
fontSize: '0.9rem',
|
||||||
fontWeight: 600,
|
fontWeight: 600,
|
||||||
color: '#161718',
|
color: '#161718',
|
||||||
|
width: '100%',
|
||||||
|
},
|
||||||
|
fieldInputContainer: {
|
||||||
|
position: 'relative' as const,
|
||||||
|
width: '100%',
|
||||||
},
|
},
|
||||||
fieldInput: {
|
fieldInput: {
|
||||||
padding: '0.875rem 1rem',
|
padding: '0.875rem 1rem',
|
||||||
@@ -135,6 +142,20 @@
|
|||||||
background: '#FBFAF6',
|
background: '#FBFAF6',
|
||||||
transition: 'all 0.3s cubic-bezier(0.4, 0, 0.2, 1)',
|
transition: 'all 0.3s cubic-bezier(0.4, 0, 0.2, 1)',
|
||||||
color: '#161718',
|
color: '#161718',
|
||||||
|
width: '100%',
|
||||||
|
boxSizing: 'border-box' as const,
|
||||||
|
},
|
||||||
|
fieldInputWithIcon: {
|
||||||
|
padding: '0.875rem 1rem',
|
||||||
|
border: '1.5px solid #e8e8e8',
|
||||||
|
borderRadius: '8px',
|
||||||
|
fontSize: '0.95rem',
|
||||||
|
background: '#FBFAF6',
|
||||||
|
transition: 'all 0.3s cubic-bezier(0.4, 0, 0.2, 1)',
|
||||||
|
color: '#161718',
|
||||||
|
width: '100%',
|
||||||
|
paddingRight: '40px',
|
||||||
|
boxSizing: 'border-box' as const,
|
||||||
},
|
},
|
||||||
fieldInputDisabled: {
|
fieldInputDisabled: {
|
||||||
padding: '0.875rem 1rem',
|
padding: '0.875rem 1rem',
|
||||||
@@ -144,11 +165,29 @@
|
|||||||
background: 'rgba(26, 19, 37, 0.05)',
|
background: 'rgba(26, 19, 37, 0.05)',
|
||||||
color: '#666',
|
color: '#666',
|
||||||
cursor: 'not-allowed',
|
cursor: 'not-allowed',
|
||||||
|
width: '100%',
|
||||||
|
boxSizing: 'border-box' as const,
|
||||||
},
|
},
|
||||||
fieldHint: {
|
fieldHint: {
|
||||||
fontSize: '0.8rem',
|
fontSize: '0.8rem',
|
||||||
color: '#888',
|
color: '#888',
|
||||||
marginTop: '0.25rem',
|
marginTop: '0.25rem',
|
||||||
|
width: '100%',
|
||||||
|
},
|
||||||
|
passwordToggleButton: {
|
||||||
|
position: 'absolute' as const,
|
||||||
|
right: '10px',
|
||||||
|
top: '50%',
|
||||||
|
transform: 'translateY(-50%)',
|
||||||
|
background: 'none',
|
||||||
|
border: 'none',
|
||||||
|
cursor: 'pointer',
|
||||||
|
padding: '5px',
|
||||||
|
borderRadius: '4px',
|
||||||
|
transition: 'background-color 0.2s',
|
||||||
|
userSelect: 'none' as const,
|
||||||
|
WebkitUserSelect: 'none' as const,
|
||||||
|
touchAction: 'manipulation' as const,
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { useAuth } from '../../contexts/AuthContext';
|
import { useAuth } from '../../contexts/AuthContext';
|
||||||
|
|
||||||
|
const API_BASE_URL = '/api';
|
||||||
|
|
||||||
const Setup: React.FC = () => {
|
const Setup: React.FC = () => {
|
||||||
const [step, setStep] = useState(1);
|
const [step, setStep] = useState(1);
|
||||||
const [formData, setFormData] = useState({
|
const [formData, setFormData] = useState({
|
||||||
@@ -73,7 +75,7 @@ const Setup: React.FC = () => {
|
|||||||
|
|
||||||
console.log('🚀 Sending setup request...', payload);
|
console.log('🚀 Sending setup request...', payload);
|
||||||
|
|
||||||
const response = await fetch('http://localhost:3002/api/setup/admin', {
|
const response = await fetch(`${API_BASE_URL}/setup/admin`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// frontend/src/services/authService.ts
|
// frontend/src/services/authService.ts
|
||||||
import { Employee } from '../models/Employee';
|
import { Employee } from '../models/Employee';
|
||||||
const API_BASE = 'http://localhost:3002/api';
|
const API_BASE = process.env.REACT_APP_API_BASE_URL || '/api';
|
||||||
|
|
||||||
export interface LoginRequest {
|
export interface LoginRequest {
|
||||||
email: string;
|
email: string;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// frontend/src/services/employeeService.ts
|
// frontend/src/services/employeeService.ts
|
||||||
import { Employee, CreateEmployeeRequest, UpdateEmployeeRequest, EmployeeAvailability } from '../models/Employee';
|
import { Employee, CreateEmployeeRequest, UpdateEmployeeRequest, EmployeeAvailability } from '../models/Employee';
|
||||||
|
|
||||||
const API_BASE_URL = 'http://localhost:3002/api';
|
const API_BASE_URL = '/api';
|
||||||
|
|
||||||
const getAuthHeaders = () => {
|
const getAuthHeaders = () => {
|
||||||
const token = localStorage.getItem('token');
|
const token = localStorage.getItem('token');
|
||||||
|
|||||||
@@ -4,9 +4,7 @@ import { Employee, EmployeeAvailability } from '../models/Employee';
|
|||||||
import { authService } from './authService';
|
import { authService } from './authService';
|
||||||
import { AssignmentResult, ScheduleRequest } from '../models/scheduling';
|
import { AssignmentResult, ScheduleRequest } from '../models/scheduling';
|
||||||
|
|
||||||
const API_BASE_URL = 'http://localhost:3002/api';
|
const API_BASE_URL = '/api';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Helper function to get auth headers
|
// Helper function to get auth headers
|
||||||
const getAuthHeaders = () => {
|
const getAuthHeaders = () => {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { authService } from './authService';
|
|||||||
import { ShiftPlan, CreateShiftPlanRequest, ScheduledShift, CreateShiftFromTemplateRequest } from '../models/ShiftPlan';
|
import { ShiftPlan, CreateShiftPlanRequest, ScheduledShift, CreateShiftFromTemplateRequest } from '../models/ShiftPlan';
|
||||||
import { TEMPLATE_PRESETS } from '../models/defaults/shiftPlanDefaults';
|
import { TEMPLATE_PRESETS } from '../models/defaults/shiftPlanDefaults';
|
||||||
|
|
||||||
const API_BASE = 'http://localhost:3002/api/shift-plans';
|
const API_BASE_URL = '/api/shift-plans';
|
||||||
|
|
||||||
// Helper function to get auth headers
|
// Helper function to get auth headers
|
||||||
const getAuthHeaders = () => {
|
const getAuthHeaders = () => {
|
||||||
@@ -25,7 +25,7 @@ const handleResponse = async (response: Response) => {
|
|||||||
|
|
||||||
export const shiftPlanService = {
|
export const shiftPlanService = {
|
||||||
async getShiftPlans(): Promise<ShiftPlan[]> {
|
async getShiftPlans(): Promise<ShiftPlan[]> {
|
||||||
const response = await fetch(API_BASE, {
|
const response = await fetch(API_BASE_URL, {
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
...authService.getAuthHeaders()
|
...authService.getAuthHeaders()
|
||||||
@@ -50,7 +50,7 @@ export const shiftPlanService = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
async getShiftPlan(id: string): Promise<ShiftPlan> {
|
async getShiftPlan(id: string): Promise<ShiftPlan> {
|
||||||
const response = await fetch(`${API_BASE}/${id}`, {
|
const response = await fetch(`${API_BASE_URL}/${id}`, {
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
...authService.getAuthHeaders()
|
...authService.getAuthHeaders()
|
||||||
@@ -69,7 +69,7 @@ export const shiftPlanService = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
async createShiftPlan(plan: CreateShiftPlanRequest): Promise<ShiftPlan> {
|
async createShiftPlan(plan: CreateShiftPlanRequest): Promise<ShiftPlan> {
|
||||||
const response = await fetch(API_BASE, {
|
const response = await fetch(API_BASE_URL, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
@@ -90,7 +90,7 @@ export const shiftPlanService = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
async updateShiftPlan(id: string, plan: Partial<ShiftPlan>): Promise<ShiftPlan> {
|
async updateShiftPlan(id: string, plan: Partial<ShiftPlan>): Promise<ShiftPlan> {
|
||||||
const response = await fetch(`${API_BASE}/${id}`, {
|
const response = await fetch(`${API_BASE_URL}/${id}`, {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
@@ -111,7 +111,7 @@ export const shiftPlanService = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
async deleteShiftPlan(id: string): Promise<void> {
|
async deleteShiftPlan(id: string): Promise<void> {
|
||||||
const response = await fetch(`${API_BASE}/${id}`, {
|
const response = await fetch(`${API_BASE_URL}/${id}`, {
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
@@ -130,7 +130,7 @@ export const shiftPlanService = {
|
|||||||
|
|
||||||
// Get specific template or plan
|
// Get specific template or plan
|
||||||
getTemplate: async (id: string): Promise<ShiftPlan> => {
|
getTemplate: async (id: string): Promise<ShiftPlan> => {
|
||||||
const response = await fetch(`${API_BASE}/${id}`, {
|
const response = await fetch(`${API_BASE_URL}/${id}`, {
|
||||||
headers: getAuthHeaders()
|
headers: getAuthHeaders()
|
||||||
});
|
});
|
||||||
return handleResponse(response);
|
return handleResponse(response);
|
||||||
@@ -142,7 +142,7 @@ export const shiftPlanService = {
|
|||||||
console.log('🔄 Attempting to regenerate scheduled shifts...');
|
console.log('🔄 Attempting to regenerate scheduled shifts...');
|
||||||
|
|
||||||
// You'll need to add this API endpoint to your backend
|
// You'll need to add this API endpoint to your backend
|
||||||
const response = await fetch(`${API_BASE}/${planId}/regenerate-shifts`, {
|
const response = await fetch(`${API_BASE_URL}/${planId}/regenerate-shifts`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
@@ -162,7 +162,7 @@ export const shiftPlanService = {
|
|||||||
|
|
||||||
// Create new plan
|
// Create new plan
|
||||||
createPlan: async (data: CreateShiftPlanRequest): Promise<ShiftPlan> => {
|
createPlan: async (data: CreateShiftPlanRequest): Promise<ShiftPlan> => {
|
||||||
const response = await fetch(`${API_BASE}`, {
|
const response = await fetch(`${API_BASE_URL}`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: getAuthHeaders(),
|
headers: getAuthHeaders(),
|
||||||
body: JSON.stringify(data),
|
body: JSON.stringify(data),
|
||||||
@@ -177,7 +177,7 @@ export const shiftPlanService = {
|
|||||||
endDate: string;
|
endDate: string;
|
||||||
isTemplate?: boolean;
|
isTemplate?: boolean;
|
||||||
}): Promise<ShiftPlan> => {
|
}): Promise<ShiftPlan> => {
|
||||||
const response = await fetch(`${API_BASE}/from-preset`, {
|
const response = await fetch(`${API_BASE_URL}/from-preset`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: getAuthHeaders(),
|
headers: getAuthHeaders(),
|
||||||
body: JSON.stringify(data),
|
body: JSON.stringify(data),
|
||||||
@@ -204,7 +204,7 @@ export const shiftPlanService = {
|
|||||||
try {
|
try {
|
||||||
console.log('🔄 Clearing assignments for plan:', planId);
|
console.log('🔄 Clearing assignments for plan:', planId);
|
||||||
|
|
||||||
const response = await fetch(`${API_BASE}/${planId}/clear-assignments`, {
|
const response = await fetch(`${API_BASE_URL}/${planId}/clear-assignments`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
"esnext"
|
"esnext"
|
||||||
],
|
],
|
||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
"skipLibCheck": true,
|
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"allowSyntheticDefaultImports": true,
|
"allowSyntheticDefaultImports": true,
|
||||||
"strict": true,
|
"strict": true,
|
||||||
|
|||||||
6
package-lock.json
generated
6
package-lock.json
generated
@@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "Schichtenplaner",
|
|
||||||
"lockfileVersion": 3,
|
|
||||||
"requires": true,
|
|
||||||
"packages": {}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user