diff --git a/backend/src/admin/approvals.controller.ts b/backend/src/admin/approvals.controller.ts index 958de9c4..d113b78d 100644 --- a/backend/src/admin/approvals.controller.ts +++ b/backend/src/admin/approvals.controller.ts @@ -151,18 +151,65 @@ export class ApprovalsController { throw new NotFoundException(`Approval request ${id} not found`); } + if (dto.decision === "REJECTED") { + // 5. رد توسط مدیرعامل: تسک و درخواست کلاً از سیستم پاکسازی کامل می‌شوند + await (this.prisma as any).departmentTask.deleteMany({ + where: { approvalId: id }, + }); + await (this.prisma as any).approvalRequest.delete({ + where: { id }, + }); + return { + success: true, + message: "درخواست با موفقیت رد و از سیستم پاکسازی شد.", + }; + } + + // 1. تایید مدیرعامل: وضعیت درخواست APPROVED و وضعیت تسک در صف اقدام به TODO تغییر می‌یابد const updated = await (this.prisma as any).approvalRequest.update({ where: { id }, data: { - status: dto.decision, + status: "APPROVED", ceoNotes: dto.ceoNotes || null, - executedAt: dto.decision === "APPROVED" ? new Date() : null, + executedAt: new Date(), }, }); + // جستجو یا ایجاد تسک متناظر با استاتوس TODO + const existingTask = await (this.prisma as any).departmentTask.findFirst({ + where: { approvalId: id }, + }); + + if (existingTask) { + await (this.prisma as any).departmentTask.update({ + where: { id: existingTask.id }, + data: { + status: "TODO", + description: dto.ceoNotes ? (existingTask.description || "") + " + +[یادداشت مدیرعامل]: " + dto.ceoNotes : existingTask.description, + }, + }); + } else { + await (this.prisma as any).departmentTask.create({ + data: { + code: "TSK-" + Date.now().toString().slice(-6), + department: item.department, + title: item.title, + description: dto.ceoNotes ? (item.title + " + +[یادداشت مدیرعامل]: " + dto.ceoNotes) : item.title, + status: "TODO", + priority: "HIGH", + assignee: "AI_AGENT", + approvalId: item.id, + }, + }); + } + return { success: true, - message: dto.decision === "APPROVED" ? "درخواست با موفقیت تایید شد." : "درخواست رد شد.", + message: "درخواست تایید شد و مأموریت به صف اقدام (TODO) دپارتمان منتقل گردید.", data: updated, }; } diff --git a/backend/src/admin/department-tasks.controller.ts b/backend/src/admin/department-tasks.controller.ts index f9612734..2566dccc 100644 --- a/backend/src/admin/department-tasks.controller.ts +++ b/backend/src/admin/department-tasks.controller.ts @@ -73,6 +73,10 @@ export class DepartmentTasksController { }); const statusCounts: Record = { + TODO: 0, + IN_PROGRESS: 0, + TEST: 0, + DONE: 0, BACKLOG: 0, IN_PROGRESS: 0, IN_REVIEW: 0, @@ -117,7 +121,7 @@ export class DepartmentTasksController { department: body.department, title: body.title, description: body.description || null, - status: body.status || "BACKLOG", + status: body.status || "TODO", priority: body.priority || "MEDIUM", assignee: body.assignee || "AI_AGENT", acceptanceCriteria: body.acceptanceCriteria || null, @@ -170,6 +174,12 @@ export class DepartmentTasksController { if (body.deliverableUrl) updateData.deliverableUrl = body.deliverableUrl; if (body.status === "IN_PROGRESS" && !existing.startedAt) updateData.startedAt = new Date(); if (body.status === "DONE") updateData.completedAt = new Date(); + // اگر تست QA ناموفق بود و به TODO برگشت، لاگ اصلاح ضمیمه می‌شود + if (body.status === "TODO" && body.logNote) { + updateData.description = (existing.description || "") + " + +[اصلاحات و تضمین کیفیت QA]: " + body.logNote; + } const updated = await (this.prisma as any).departmentTask.update({ where: { id }, diff --git a/frontend/admin-panel/src/pages/TasksManagementPage.tsx b/frontend/admin-panel/src/pages/TasksManagementPage.tsx index a149aa69..3996a94c 100644 --- a/frontend/admin-panel/src/pages/TasksManagementPage.tsx +++ b/frontend/admin-panel/src/pages/TasksManagementPage.tsx @@ -25,7 +25,7 @@ interface DepartmentTask { department: string; title: string; description?: string; - status: 'BACKLOG' | 'IN_PROGRESS' | 'IN_REVIEW' | 'APPROVED' | 'DEPLOYING' | 'DONE'; + status: 'TODO' | 'IN_PROGRESS' | 'TEST' | 'DONE' | 'BACKLOG' | 'IN_REVIEW' | 'APPROVED' | 'DEPLOYING'; priority: 'LOW' | 'MEDIUM' | 'HIGH' | 'CRITICAL'; assignee: string; acceptanceCriteria?: string; @@ -101,18 +101,16 @@ export default function TasksManagementPage() { const getStatusBadge = (status: string) => { switch (status) { + case 'TODO': case 'BACKLOG': - return بک‌لاگ (Backlog); + return ۱. صف اقدام (TODO); case 'IN_PROGRESS': - return در حال انجام (In Progress); + return ۲. در حال توسعه (IN_PROGRESS); + case 'TEST': case 'IN_REVIEW': - return در انتظار بررسی (Review); - case 'APPROVED': - return تایید شده (Approved); - case 'DEPLOYING': - return درحال استقرار (Deploying); + return ۳. تست استیج و QA (TEST); case 'DONE': - return تکمیل شده (Done); + return ۴. مستقر پروداکشن (DONE); default: return {status}; } @@ -207,7 +205,10 @@ export default function TasksManagementPage() { className="w-full px-3 py-2 text-xs bg-gray-50 border border-gray-200 rounded-xl focus:bg-white focus:outline-none focus:border-purple-500 font-bold text-gray-700" > - + + + + @@ -339,7 +340,7 @@ export default function TasksManagementPage() {
- {['BACKLOG', 'IN_PROGRESS', 'IN_REVIEW', 'APPROVED', 'DEPLOYING', 'DONE'].map((st) => ( + {['TODO', 'IN_PROGRESS', 'TEST', 'DONE'].map((st) => (