diff --git a/src/app/api/project-tasks/route.js b/src/app/api/project-tasks/route.js index 9429832..d954d4f 100644 --- a/src/app/api/project-tasks/route.js +++ b/src/app/api/project-tasks/route.js @@ -47,10 +47,19 @@ async function createProjectTaskHandler(req) { const taskData = { ...data, created_by: req.user?.id || null, - // If no assigned_to is specified, default to the creator - assigned_to: data.assigned_to || req.user?.id || null, }; + // Set assigned_to: if specified, use it; otherwise default to creator only if they're not admin + if (data.assigned_to) { + taskData.assigned_to = data.assigned_to; + } else if (req.user?.id) { + // Check if the creator is an admin - if so, don't assign to them + const userRole = db.prepare('SELECT role FROM users WHERE id = ?').get(req.user.id); + taskData.assigned_to = userRole?.role === 'admin' ? null : req.user.id; + } else { + taskData.assigned_to = null; + } + const result = createProjectTask(taskData); return NextResponse.json({ success: true, id: result.lastInsertRowid }); } catch (error) { diff --git a/src/app/projects/page.js b/src/app/projects/page.js index b63d5a6..60811fb 100644 --- a/src/app/projects/page.js +++ b/src/app/projects/page.js @@ -449,15 +449,15 @@ export default function ProjectListPage() { {t('projects.projectName')} + + {t('projects.address')} + WP {t('projects.city')} - - {t('projects.address')} - {t('projects.plot')} @@ -471,7 +471,7 @@ export default function ProjectListPage() { {t('common.status') || 'Status'} - {t('common.actions') || 'Akcje'} + Placeholder @@ -504,6 +504,12 @@ export default function ProjectListPage() { + + {project.address || "N/A"} + {project.city || "N/A"} - - {project.address || "N/A"} - - - - + Placeholder ))} diff --git a/src/lib/queries/projects.js b/src/lib/queries/projects.js index 6bd59e9..555350a 100644 --- a/src/lib/queries/projects.js +++ b/src/lib/queries/projects.js @@ -146,7 +146,7 @@ export function getAllUsersForAssignment() { ` SELECT id, name, username, role FROM users - WHERE is_active = 1 + WHERE is_active = 1 AND role != 'admin' ORDER BY name ` ) diff --git a/src/lib/queries/tasks.js b/src/lib/queries/tasks.js index 6e6b974..7d2cecd 100644 --- a/src/lib/queries/tasks.js +++ b/src/lib/queries/tasks.js @@ -296,7 +296,7 @@ export function getAllUsersForTaskAssignment() { ` SELECT id, name, username, role FROM users - WHERE is_active = 1 + WHERE is_active = 1 AND role != 'admin' ORDER BY name ASC ` )