feat(rfa): complete RFA Approval Refactor - all 9 phases (T001-T080)
Phase 1-2: Setup, SQL schema, enums, queue constants, base entities
Phase 3 (US1): ReviewTeam, ReviewTeamMember, ReviewTask, TaskCreationService
Phase 4 (US2): ResponseCode, ResponseCodeRule, ImplicationsService, NotificationTriggerService
Phase 5 (US3): Delegation entity, CircularDetectionService, DelegationService/Controller/Module
Phase 6 (US4): ReminderRule, SchedulerService, EscalationService, ReminderProcessor, ReminderModule
Phase 7 (US5): DistributionMatrix, DistributionRecipient, ApprovalListenerService (Strangler),
TransmittalCreatorService, DistributionProcessor, DistributionModule
Phase 8 (US6): MatrixManagementService, InheritanceService (global→project override)
Phase 9 (Polish): AggregateStatusService, ConsensusService, VetoOverrideService,
ParallelGatewayHandler, review-validators, optimistic locking in completeReview,
test stubs (unit/integration/e2e), jest.config.js updated for tests/ directory
Frontend: ReviewTaskInbox, ParallelProgress, VetoOverrideDialog, DelegationForm,
DelegatedBadge, MatrixEditor, ProjectOverrideManager, DistributionStatus,
ReminderHistory, ResponseCodeSelector, CodeImplications, CompleteReviewForm,
ReviewTeamForm, ReviewTeamSelector, TeamMemberManager
Closes #1
This commit is contained in:
@@ -0,0 +1,120 @@
|
||||
'use client';
|
||||
|
||||
// File: app/(dashboard)/settings/delegation/page.tsx
|
||||
// หน้าจัดการ Delegation ของตัวเอง (FR-011)
|
||||
import { useState } from 'react';
|
||||
import { Plus, ArrowRightLeft, Trash2 } from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
DialogTrigger,
|
||||
} from '@/components/ui/dialog';
|
||||
import { useMyDelegations, useCreateDelegation, useRevokeDelegation, Delegation } from '@/hooks/use-delegation';
|
||||
import { DelegationForm } from '@/components/delegation/DelegationForm';
|
||||
|
||||
export default function DelegationPage() {
|
||||
const [createOpen, setCreateOpen] = useState(false);
|
||||
|
||||
const { data: delegations = [], isLoading } = useMyDelegations();
|
||||
const createDelegation = useCreateDelegation();
|
||||
const revokeDelegation = useRevokeDelegation();
|
||||
|
||||
const today = new Date().toISOString().split('T')[0];
|
||||
|
||||
return (
|
||||
<div className="p-6 space-y-6">
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<h1 className="text-2xl font-bold">Delegation Settings</h1>
|
||||
<p className="text-muted-foreground text-sm mt-1">
|
||||
มอบหมายหน้าที่ตรวจสอบให้ผู้อื่นในช่วงที่ไม่อยู่
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<Dialog open={createOpen} onOpenChange={setCreateOpen}>
|
||||
<DialogTrigger asChild>
|
||||
<Button>
|
||||
<Plus className="h-4 w-4 mr-2" />
|
||||
New Delegation
|
||||
</Button>
|
||||
</DialogTrigger>
|
||||
<DialogContent className="max-w-md">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Create Delegation</DialogTitle>
|
||||
</DialogHeader>
|
||||
<DelegationForm
|
||||
availableUsers={[]}
|
||||
onSubmit={(dto) =>
|
||||
createDelegation.mutate(dto, {
|
||||
onSuccess: () => setCreateOpen(false),
|
||||
})
|
||||
}
|
||||
isLoading={createDelegation.isPending}
|
||||
/>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</div>
|
||||
|
||||
{isLoading && (
|
||||
<div className="text-center text-muted-foreground py-8">Loading delegations...</div>
|
||||
)}
|
||||
|
||||
<div className="space-y-3">
|
||||
{(delegations as Delegation[]).map((d: Delegation) => {
|
||||
const isActive =
|
||||
d.isActive && d.startDate <= today && d.endDate >= today;
|
||||
const isPast = d.endDate < today;
|
||||
|
||||
return (
|
||||
<Card key={d.publicId}>
|
||||
<CardHeader className="pb-2">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-3">
|
||||
<ArrowRightLeft className="h-4 w-4 text-muted-foreground" />
|
||||
<CardTitle className="text-base">
|
||||
→ {d.delegate?.fullName ?? d.delegate?.email ?? '—'}
|
||||
</CardTitle>
|
||||
{isActive && <Badge variant="default">Active</Badge>}
|
||||
{isPast && <Badge variant="secondary">Expired</Badge>}
|
||||
{!isActive && !isPast && (
|
||||
<Badge variant="outline">Scheduled</Badge>
|
||||
)}
|
||||
<Badge variant="outline" className="text-xs">{d.scope}</Badge>
|
||||
</div>
|
||||
{!isPast && d.isActive && (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
onClick={() => revokeDelegation.mutate(d.publicId)}
|
||||
disabled={revokeDelegation.isPending}
|
||||
>
|
||||
<Trash2 className="h-4 w-4 text-destructive" />
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent className="pt-0">
|
||||
<p className="text-xs text-muted-foreground">
|
||||
{d.startDate} → {d.endDate}
|
||||
{d.reason && ` • ${d.reason}`}
|
||||
</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
})}
|
||||
|
||||
{!isLoading && delegations.length === 0 && (
|
||||
<div className="text-center py-12 text-muted-foreground">
|
||||
<ArrowRightLeft className="h-12 w-12 mx-auto mb-3 opacity-30" />
|
||||
<p>No delegations set. Create one when you need a proxy reviewer.</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
'use client';
|
||||
|
||||
// File: app/(dashboard)/settings/review-teams/page.tsx
|
||||
// หน้าจัดการ Review Teams (FR-001, FR-002)
|
||||
import { useState } from 'react';
|
||||
import { Plus, Users, ChevronDown, ChevronUp } from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
DialogTrigger,
|
||||
} from '@/components/ui/dialog';
|
||||
import { useReviewTeams, useCreateReviewTeam, useUpdateReviewTeam } from '@/hooks/use-review-teams';
|
||||
import { ReviewTeamForm } from '@/components/review-team/ReviewTeamForm';
|
||||
import { TeamMemberManager } from '@/components/review-team/TeamMemberManager';
|
||||
import { ReviewTeam } from '@/types/review-team';
|
||||
|
||||
// TODO: ดึง projectPublicId จาก context หรือ URL param จริง
|
||||
const MOCK_PROJECT_ID = 'current-project-public-id';
|
||||
|
||||
export default function ReviewTeamsPage() {
|
||||
const [expandedTeam, setExpandedTeam] = useState<string | null>(null);
|
||||
const [createOpen, setCreateOpen] = useState(false);
|
||||
const [editTeam, setEditTeam] = useState<ReviewTeam | null>(null);
|
||||
|
||||
const { data: teams = [], isLoading } = useReviewTeams({
|
||||
projectPublicId: MOCK_PROJECT_ID,
|
||||
});
|
||||
|
||||
const createTeam = useCreateReviewTeam();
|
||||
const updateTeam = useUpdateReviewTeam();
|
||||
|
||||
return (
|
||||
<div className="p-6 space-y-6">
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<h1 className="text-2xl font-bold">Review Teams</h1>
|
||||
<p className="text-muted-foreground text-sm mt-1">
|
||||
จัดการทีมตรวจสอบแยกตาม Discipline สำหรับ Parallel Review
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<Dialog open={createOpen} onOpenChange={setCreateOpen}>
|
||||
<DialogTrigger asChild>
|
||||
<Button>
|
||||
<Plus className="h-4 w-4 mr-2" />
|
||||
New Team
|
||||
</Button>
|
||||
</DialogTrigger>
|
||||
<DialogContent>
|
||||
<DialogHeader>
|
||||
<DialogTitle>Create Review Team</DialogTitle>
|
||||
</DialogHeader>
|
||||
<ReviewTeamForm
|
||||
projectPublicId={MOCK_PROJECT_ID}
|
||||
onSubmit={(values) =>
|
||||
createTeam.mutate(values, {
|
||||
onSuccess: () => setCreateOpen(false),
|
||||
})
|
||||
}
|
||||
isLoading={createTeam.isPending}
|
||||
/>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</div>
|
||||
|
||||
{isLoading && (
|
||||
<div className="text-center text-muted-foreground py-8">Loading teams...</div>
|
||||
)}
|
||||
|
||||
<div className="space-y-3">
|
||||
{(teams as ReviewTeam[]).map((team) => (
|
||||
<Card key={team.publicId}>
|
||||
<CardHeader className="pb-2">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-3">
|
||||
<Users className="h-5 w-5 text-muted-foreground" />
|
||||
<CardTitle className="text-base">{team.name}</CardTitle>
|
||||
{!team.isActive && (
|
||||
<Badge variant="secondary">Inactive</Badge>
|
||||
)}
|
||||
{(team.defaultForRfaTypes ?? []).map((type) => (
|
||||
<Badge key={type} variant="outline" className="text-xs">
|
||||
{type}
|
||||
</Badge>
|
||||
))}
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() => setEditTeam(team)}
|
||||
>
|
||||
Edit
|
||||
</Button>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
onClick={() =>
|
||||
setExpandedTeam(expandedTeam === team.publicId ? null : team.publicId)
|
||||
}
|
||||
>
|
||||
{expandedTeam === team.publicId ? (
|
||||
<ChevronUp className="h-4 w-4" />
|
||||
) : (
|
||||
<ChevronDown className="h-4 w-4" />
|
||||
)}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
{team.description && (
|
||||
<p className="text-xs text-muted-foreground mt-1">{team.description}</p>
|
||||
)}
|
||||
</CardHeader>
|
||||
|
||||
{expandedTeam === team.publicId && (
|
||||
<CardContent>
|
||||
<div className="text-sm font-medium mb-3">
|
||||
Members ({(team.members ?? []).length})
|
||||
</div>
|
||||
<TeamMemberManager
|
||||
teamPublicId={team.publicId}
|
||||
members={team.members ?? []}
|
||||
availableUsers={[]}
|
||||
availableDisciplines={[]}
|
||||
/>
|
||||
</CardContent>
|
||||
)}
|
||||
</Card>
|
||||
))}
|
||||
|
||||
{!isLoading && (teams as ReviewTeam[]).length === 0 && (
|
||||
<div className="text-center py-12 text-muted-foreground">
|
||||
<Users className="h-12 w-12 mx-auto mb-3 opacity-30" />
|
||||
<p>No Review Teams yet. Create one to enable Parallel Review.</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Edit Dialog */}
|
||||
<Dialog open={!!editTeam} onOpenChange={() => setEditTeam(null)}>
|
||||
<DialogContent>
|
||||
<DialogHeader>
|
||||
<DialogTitle>Edit Review Team</DialogTitle>
|
||||
</DialogHeader>
|
||||
{editTeam && (
|
||||
<ReviewTeamForm
|
||||
projectPublicId={MOCK_PROJECT_ID}
|
||||
defaultValues={editTeam}
|
||||
onSubmit={(values) =>
|
||||
updateTeam.mutate(
|
||||
{ publicId: editTeam.publicId, data: values },
|
||||
{ onSuccess: () => setEditTeam(null) },
|
||||
)
|
||||
}
|
||||
isLoading={updateTeam.isPending}
|
||||
/>
|
||||
)}
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user