mirror of
https://github.com/donpat1to/Schichtenplaner.git
synced 2025-11-30 22:45:46 +01:00
Compare commits
2 Commits
3ad497dd76
...
v1.0.10
| Author | SHA1 | Date | |
|---|---|---|---|
| cae2b83649 | |||
| a69e934075 |
@@ -65,7 +65,7 @@ export async function initializeDatabase(): Promise<void> {
|
||||
|
||||
console.log('Existing tables found:', existingTables.map(t => t.name).join(', ') || 'none');
|
||||
|
||||
// UPDATED: Drop tables in correct dependency order for new schema
|
||||
// Drop tables in correct dependency order for new schema
|
||||
const tablesToDrop = [
|
||||
'employee_availability',
|
||||
'shift_assignments',
|
||||
@@ -95,16 +95,40 @@ export async function initializeDatabase(): Promise<void> {
|
||||
// Continue with schema creation even if table dropping fails
|
||||
}
|
||||
|
||||
// Execute schema creation in a transaction
|
||||
await db.run('BEGIN EXCLUSIVE TRANSACTION');
|
||||
|
||||
// Execute each statement separately for better error reporting
|
||||
const statements = schema
|
||||
// NEU: PRAGMA-Anweisungen außerhalb der Transaktion ausführen
|
||||
console.log('Executing PRAGMA statements outside transaction...');
|
||||
const pragmaStatements = schema
|
||||
.split(';')
|
||||
.map(stmt => stmt.trim())
|
||||
.filter(stmt => stmt.length > 0)
|
||||
.filter(stmt => stmt.toUpperCase().startsWith('PRAGMA'))
|
||||
.map(stmt => {
|
||||
return stmt.split('\n')
|
||||
.filter(line => !line.trim().startsWith('--'))
|
||||
.join('\n')
|
||||
.trim();
|
||||
});
|
||||
|
||||
for (const statement of pragmaStatements) {
|
||||
try {
|
||||
console.log('Executing PRAGMA:', statement);
|
||||
await db.run(statement);
|
||||
} catch (error) {
|
||||
console.warn('PRAGMA statement might have failed:', statement, error);
|
||||
// Continue even if PRAGMA fails
|
||||
}
|
||||
}
|
||||
|
||||
// Schema-Erstellung in Transaktion
|
||||
await db.run('BEGIN EXCLUSIVE TRANSACTION');
|
||||
|
||||
// Nur die CREATE TABLE und andere Anweisungen (ohne PRAGMA)
|
||||
const schemaStatements = schema
|
||||
.split(';')
|
||||
.map(stmt => stmt.trim())
|
||||
.filter(stmt => stmt.length > 0)
|
||||
.filter(stmt => !stmt.toUpperCase().startsWith('PRAGMA'))
|
||||
.map(stmt => {
|
||||
// Remove any single-line comments
|
||||
return stmt.split('\n')
|
||||
.filter(line => !line.trim().startsWith('--'))
|
||||
.join('\n')
|
||||
@@ -112,7 +136,7 @@ export async function initializeDatabase(): Promise<void> {
|
||||
})
|
||||
.filter(stmt => stmt.length > 0);
|
||||
|
||||
for (const statement of statements) {
|
||||
for (const statement of schemaStatements) {
|
||||
try {
|
||||
console.log('Executing statement:', statement.substring(0, 50) + '...');
|
||||
await db.run(statement);
|
||||
@@ -124,7 +148,7 @@ export async function initializeDatabase(): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
// UPDATED: Insert default data in correct order
|
||||
// Insert default data in correct order
|
||||
try {
|
||||
console.log('Inserting default employee types...');
|
||||
await db.run(`INSERT OR IGNORE INTO employee_types (type, category, has_contract_type) VALUES ('manager', 'internal', 1)`);
|
||||
|
||||
@@ -265,7 +265,7 @@ const useEmployeeForm = (mode: 'create' | 'edit', employee?: Employee) => {
|
||||
|
||||
// Determine if can work alone based on employee type
|
||||
const canWorkAlone = employeeType === 'manager' ||
|
||||
(employeeType === 'personell' && !formData.isTrainee);
|
||||
(employeeType === 'personell' && !formData.isTrainee);
|
||||
|
||||
// Reset isTrainee if not personell
|
||||
const isTrainee = employeeType === 'personell' ? formData.isTrainee : false;
|
||||
@@ -343,7 +343,8 @@ const useEmployeeForm = (mode: 'create' | 'edit', employee?: Employee) => {
|
||||
await executeWithValidation(() =>
|
||||
employeeService.changePassword(employee.id, {
|
||||
currentPassword: '',
|
||||
newPassword: passwordForm.newPassword
|
||||
newPassword: passwordForm.newPassword,
|
||||
confirmPassword: passwordForm.confirmPassword
|
||||
})
|
||||
);
|
||||
}
|
||||
@@ -365,8 +366,8 @@ const useEmployeeForm = (mode: 'create' | 'edit', employee?: Employee) => {
|
||||
switch (stepIndex) {
|
||||
case 0:
|
||||
return !!formData.firstname.trim() &&
|
||||
!!formData.lastname.trim();
|
||||
// REMOVE: (mode === 'edit' || formData.password.length >= 6)
|
||||
!!formData.lastname.trim();
|
||||
// REMOVE: (mode === 'edit' || formData.password.length >= 6)
|
||||
case 1:
|
||||
return !!formData.employeeType;
|
||||
case 2:
|
||||
@@ -711,7 +712,7 @@ const Step2Content: React.FC<StepContentProps> = ({
|
||||
{contractTypeOptions.map(contract => {
|
||||
const isFlexibleDisabled = contract.value === 'flexible' && formData.employeeType === 'personell';
|
||||
const isSmallLargeDisabled = (contract.value === 'small' || contract.value === 'large') &&
|
||||
(formData.employeeType === 'manager' || formData.employeeType === 'apprentice');
|
||||
(formData.employeeType === 'manager' || formData.employeeType === 'apprentice');
|
||||
const isDisabled = isFlexibleDisabled || isSmallLargeDisabled;
|
||||
|
||||
return (
|
||||
@@ -867,8 +868,8 @@ const Step3Content: React.FC<StepContentProps> = ({
|
||||
{formData.employeeType === 'manager'
|
||||
? 'Chefs sind automatisch als eigenständig markiert.'
|
||||
: formData.employeeType === 'personell' && formData.isTrainee
|
||||
? 'Auszubildende können nicht als eigenständig markiert werden.'
|
||||
: 'Dieser Mitarbeiter kann komplexe Aufgaben eigenständig lösen und benötigt keine ständige Betreuung.'
|
||||
? 'Auszubildende können nicht als eigenständig markiert werden.'
|
||||
: 'Dieser Mitarbeiter kann komplexe Aufgaben eigenständig lösen und benötigt keine ständige Betreuung.'
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user