Initial commit: Helpdesk application setup

- Backend: Node.js/TypeScript with Prisma ORM
- Frontend: Vite + TypeScript
- Project configuration and documentation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-03 08:53:22 +01:00
commit e4f63a135e
103 changed files with 19913 additions and 0 deletions

260
backend/prisma/seed.ts Normal file
View File

@@ -0,0 +1,260 @@
import { PrismaClient } from '@prisma/client';
import bcrypt from 'bcryptjs';
const prisma = new PrismaClient();
async function seed() {
console.log('Seeding database...');
// ===== USER ROLES =====
console.log('Creating user roles...');
const roles = await Promise.all([
prisma.userRole.upsert({
where: { code: 'ROOT' },
update: {},
create: {
code: 'ROOT',
name: 'Root Správca',
level: 1,
order: 1,
permissions: {
projects: ['*'],
tasks: ['*'],
equipment: ['*'],
rma: ['*'],
customers: ['*'],
settings: ['*'],
users: ['*'],
logs: ['*'],
},
},
}),
prisma.userRole.upsert({
where: { code: 'ADMIN' },
update: {},
create: {
code: 'ADMIN',
name: 'Administrátor',
level: 2,
order: 2,
permissions: {
projects: ['create', 'read', 'update', 'delete', 'all'],
tasks: ['create', 'read', 'update', 'delete', 'all'],
equipment: ['create', 'read', 'update', 'delete', 'all'],
rma: ['create', 'read', 'update', 'delete', 'approve'],
customers: ['create', 'read', 'update', 'delete'],
users: ['read'],
},
},
}),
prisma.userRole.upsert({
where: { code: 'USER' },
update: {},
create: {
code: 'USER',
name: 'Používateľ',
level: 3,
order: 3,
permissions: {
projects: ['read', 'update'],
tasks: ['create', 'read', 'update'],
equipment: ['read', 'update'],
rma: ['create', 'read', 'update'],
customers: ['read'],
},
},
}),
prisma.userRole.upsert({
where: { code: 'CUSTOMER' },
update: {},
create: {
code: 'CUSTOMER',
name: 'Zákazník',
level: 4,
order: 4,
permissions: {
projects: ['read'],
tasks: ['read'],
equipment: ['read'],
rma: ['create', 'read'],
},
},
}),
]);
// ===== EQUIPMENT TYPES =====
console.log('Creating equipment types...');
await prisma.equipmentType.createMany({
skipDuplicates: true,
data: [
{ code: 'EPS', name: 'Elektrická požiarna signalizácia', color: '#3B82F6', order: 1 },
{ code: 'HSP', name: 'Hasiaci systém', color: '#EF4444', order: 2 },
{ code: 'CAMERA', name: 'Kamerový systém', color: '#10B981', order: 3 },
{ code: 'ACCESS', name: 'Prístupový systém', color: '#F59E0B', order: 4 },
{ code: 'OTHER', name: 'Iné zariadenie', color: '#6B7280', order: 5 },
],
});
// ===== REVISION TYPES =====
console.log('Creating revision types...');
await prisma.revisionType.createMany({
skipDuplicates: true,
data: [
{ code: 'QUARTERLY', name: 'Štvrťročná revízia', intervalDays: 90, reminderDays: 14, color: '#FFA500', order: 1 },
{ code: 'BIANNUAL', name: 'Polročná revízia', intervalDays: 180, reminderDays: 21, color: '#FBBF24', order: 2 },
{ code: 'ANNUAL', name: 'Ročná revízia', intervalDays: 365, reminderDays: 30, color: '#DC2626', order: 3 },
{ code: 'EMERGENCY', name: 'Mimoriadna revízia', intervalDays: 0, reminderDays: 0, color: '#DC2626', order: 4 },
],
});
// ===== RMA STATUSES =====
console.log('Creating RMA statuses...');
await prisma.rMAStatus.createMany({
skipDuplicates: true,
data: [
{ code: 'NEW', name: 'Nová reklamácia', color: '#10B981', isInitial: true, canTransitionTo: ['IN_ASSESSMENT', 'REJECTED'], order: 1 },
{ code: 'IN_ASSESSMENT', name: 'V posúdzovaní', color: '#F59E0B', canTransitionTo: ['APPROVED', 'REJECTED'], order: 2 },
{ code: 'APPROVED', name: 'Schválená', color: '#3B82F6', canTransitionTo: ['IN_REPAIR', 'REPLACED', 'REFUNDED'], order: 3 },
{ code: 'REJECTED', name: 'Zamietnutá', color: '#EF4444', isFinal: true, order: 4 },
{ code: 'IN_REPAIR', name: 'V oprave', color: '#8B5CF6', canTransitionTo: ['REPAIRED', 'COMPLETED'], order: 5 },
{ code: 'REPAIRED', name: 'Opravené', color: '#059669', canTransitionTo: ['COMPLETED'], order: 6 },
{ code: 'REPLACED', name: 'Vymenené', color: '#059669', canTransitionTo: ['COMPLETED'], order: 7 },
{ code: 'REFUNDED', name: 'Vrátené peniaze', color: '#059669', canTransitionTo: ['COMPLETED'], order: 8 },
{ code: 'COMPLETED', name: 'Uzatvorená', color: '#059669', isFinal: true, order: 9 },
],
});
// ===== RMA SOLUTIONS =====
console.log('Creating RMA solutions...');
await prisma.rMASolution.createMany({
skipDuplicates: true,
data: [
{ code: 'ASSESSMENT', name: 'Posúdzovanie', color: '#F59E0B', order: 1 },
{ code: 'REPAIR', name: 'Oprava', color: '#3B82F6', order: 2 },
{ code: 'REPLACEMENT', name: 'Výmena', color: '#10B981', order: 3 },
{ code: 'REFUND', name: 'Vrátenie peňazí', color: '#8B5CF6', order: 4 },
{ code: 'REJECTED', name: 'Zamietnutie', color: '#EF4444', order: 5 },
{ code: 'OTHER', name: 'Iné riešenie', color: '#6B7280', order: 6 },
],
});
// ===== TASK STATUSES =====
console.log('Creating task statuses...');
await prisma.taskStatus.createMany({
skipDuplicates: true,
data: [
{ code: 'NEW', name: 'Nová úloha', swimlaneColumn: 'NEW', color: '#10B981', isInitial: true, order: 1 },
{ code: 'IN_PROGRESS', name: 'V riešení', swimlaneColumn: 'DOING', color: '#F59E0B', order: 2 },
{ code: 'REVIEW', name: 'Na kontrolu', swimlaneColumn: 'DOING', color: '#8B5CF6', order: 3 },
{ code: 'COMPLETED', name: 'Dokončená', swimlaneColumn: 'DONE', color: '#059669', isFinal: true, order: 4 },
],
});
// ===== PRIORITIES =====
console.log('Creating priorities...');
await prisma.priority.createMany({
skipDuplicates: true,
data: [
{ code: 'LOW', name: 'Nízka priorita', color: '#10B981', level: 1, order: 1 },
{ code: 'MEDIUM', name: 'Stredná priorita', color: '#F59E0B', level: 5, order: 2 },
{ code: 'HIGH', name: 'Vysoká priorita', color: '#EF4444', level: 8, order: 3 },
{ code: 'URGENT', name: 'Urgentná', color: '#DC2626', level: 10, order: 4 },
],
});
// ===== SYSTEM SETTINGS =====
console.log('Creating system settings...');
await prisma.systemSetting.createMany({
skipDuplicates: true,
data: [
{
key: 'REVISION_REMINDER_DAYS',
value: 14,
category: 'NOTIFICATIONS',
label: 'Pripomenúť revíziu X dní dopredu',
dataType: 'number',
validation: { min: 1, max: 365 },
},
{
key: 'RMA_NUMBER_FORMAT',
value: 'RMA-{YYYY}{MM}{DD}{XXX}',
category: 'RMA',
label: 'Formát RMA čísla',
dataType: 'string',
},
{
key: 'RMA_CUSTOMER_REQUIRES_APPROVAL',
value: true,
category: 'RMA',
label: 'Reklamácie od zákazníkov vyžadujú schválenie',
dataType: 'boolean',
},
{
key: 'ADMIN_NOTIFICATION_EMAILS',
value: ['admin@firma.sk'],
category: 'NOTIFICATIONS',
label: 'Email adresy pre admin notifikácie',
dataType: 'json',
},
{
key: 'ENABLE_WEBSOCKET',
value: false,
category: 'GENERAL',
label: 'Zapnúť real-time aktualizácie (WebSocket)',
dataType: 'boolean',
},
],
});
// ===== DEMO USERS =====
console.log('Creating demo users...');
const rootRole = roles.find(r => r.code === 'ROOT');
const adminRole = roles.find(r => r.code === 'ADMIN');
const userRole = roles.find(r => r.code === 'USER');
if (rootRole && adminRole && userRole) {
await prisma.user.upsert({
where: { email: 'root@helpdesk.sk' },
update: { password: await bcrypt.hash('root123', 10) },
create: {
email: 'root@helpdesk.sk',
password: await bcrypt.hash('root123', 10),
name: 'Root Admin',
roleId: rootRole.id,
},
});
await prisma.user.upsert({
where: { email: 'admin@helpdesk.sk' },
update: { password: await bcrypt.hash('admin123', 10) },
create: {
email: 'admin@helpdesk.sk',
password: await bcrypt.hash('admin123', 10),
name: 'Peter Admin',
roleId: adminRole.id,
},
});
await prisma.user.upsert({
where: { email: 'user@helpdesk.sk' },
update: { password: await bcrypt.hash('user123', 10) },
create: {
email: 'user@helpdesk.sk',
password: await bcrypt.hash('user123', 10),
name: 'Martin Používateľ',
roleId: userRole.id,
},
});
}
console.log('Seeding completed!');
}
seed()
.catch((error) => {
console.error('Seeding failed:', error);
process.exit(1);
})
.finally(async () => {
await prisma.$disconnect();
});