fix: table task mabes=>koorkurator

This commit is contained in:
Sabda Yagra 2026-01-22 19:02:16 +07:00
parent c67a0e5a0a
commit 8a88bf6372
3 changed files with 25 additions and 19 deletions

View File

@ -190,7 +190,7 @@ const useTableColumns = (activeTab: "ta" | "daily" | "special" |"mabes-koor") =>
</Button> </Button>
</DropdownMenuTrigger> </DropdownMenuTrigger>
<DropdownMenuContent className="p-0" align="end"> <DropdownMenuContent className="p-0" align="end">
{(roleId == 11 || roleId == 12 || roleId == 19) && ( {(roleId == 11 || roleId == 12 || roleId == 19 || roleId ==3) && (
<Link href={`/contributor/task-ta/detail/${row.original.id}`}> <Link href={`/contributor/task-ta/detail/${row.original.id}`}>
<DropdownMenuItem className="p-2 border-b text-default-700 group focus:bg-default focus:text-primary-foreground rounded-none"> <DropdownMenuItem className="p-2 border-b text-default-700 group focus:bg-default focus:text-primary-foreground rounded-none">
<Eye className="w-4 h-4 me-1.5" /> <Eye className="w-4 h-4 me-1.5" />
@ -198,7 +198,7 @@ const useTableColumns = (activeTab: "ta" | "daily" | "special" |"mabes-koor") =>
</DropdownMenuItem> </DropdownMenuItem>
</Link> </Link>
)} )}
{roleId == 11 && ( {roleId == 11 || roleId ==3 && (
<Link href={`/contributor/task-ta/update/${row.original.id}`}> <Link href={`/contributor/task-ta/update/${row.original.id}`}>
<DropdownMenuItem className="p-2 border-b text-default-700 group focus:bg-default focus:text-primary-foreground rounded-none"> <DropdownMenuItem className="p-2 border-b text-default-700 group focus:bg-default focus:text-primary-foreground rounded-none">
<SquarePen className="w-4 h-4 me-1.5" /> <SquarePen className="w-4 h-4 me-1.5" />
@ -216,7 +216,7 @@ const useTableColumns = (activeTab: "ta" | "daily" | "special" |"mabes-koor") =>
</DropdownMenuItem> </DropdownMenuItem>
</Link> </Link>
)} )}
{roleId == 11 && ( {roleId == 11 || roleId ==3 && (
<DropdownMenuItem <DropdownMenuItem
onClick={() => TaskDelete(row.original.id)} onClick={() => TaskDelete(row.original.id)}
className="p-2 border-b text-destructive bg-destructive/30 focus:bg-destructive focus:text-destructive-foreground rounded-none" className="p-2 border-b text-destructive bg-destructive/30 focus:bg-destructive focus:text-destructive-foreground rounded-none"

View File

@ -91,7 +91,7 @@ export default function TaskTaTable() {
const [page, setPage] = React.useState(1); const [page, setPage] = React.useState(1);
const [totalPage, setTotalPage] = React.useState(1); const [totalPage, setTotalPage] = React.useState(1);
const KOOR_KURATOR_USER_ID = "464"; const KOOR_KURATOR_USER_IDS = ["464", "8258"];
// ✅ columns based on tab // ✅ columns based on tab
const columns = useTableColumns(activeTab); const columns = useTableColumns(activeTab);
@ -135,7 +135,7 @@ export default function TaskTaTable() {
activeTab, activeTab,
]); ]);
const isKoorKurator = String(userId) === KOOR_KURATOR_USER_ID; const isKoorKurator = KOOR_KURATOR_USER_IDS.includes(String(userId));
async function fetchData() { async function fetchData() {
const formattedStartDate = dateFilter const formattedStartDate = dateFilter
@ -208,7 +208,10 @@ export default function TaskTaTable() {
if (activeTab === "ta") { if (activeTab === "ta") {
contentData = contentData.filter((item: any) => { contentData = contentData.filter((item: any) => {
const assignedUsers = String(item?.assignedToUsers || ""); const assignedUsers = String(item?.assignedToUsers || "");
return !assignedUsers.split(",").includes(KOOR_KURATOR_USER_ID); // return !assignedUsers.split(",").includes(KOOR_KURATOR_USER_ID);
return !assignedUsers
.split(",")
.some((id) => KOOR_KURATOR_USER_IDS.includes(id.trim()));
}); });
} }
@ -253,7 +256,10 @@ export default function TaskTaTable() {
return ( return (
/MABES/i.test(createdByLevel) && /MABES/i.test(createdByLevel) &&
assignedUsers.split(",").includes(KOOR_KURATOR_USER_ID) // assignedUsers.split(",").includes(KOOR_KURATOR_USER_ID)
assignedUsers
.split(",")
.some((id) => KOOR_KURATOR_USER_IDS.includes(id.trim()))
); );
}); });
} }

View File

@ -98,7 +98,7 @@ const CustomEditor = dynamic(
() => { () => {
return import("@/components/editor/custom-editor"); return import("@/components/editor/custom-editor");
}, },
{ ssr: false } { ssr: false },
); );
export default function FormTaskTa() { export default function FormTaskTa() {
@ -136,7 +136,7 @@ export default function FormTaskTa() {
const [userLevels, setUserLevels] = useState<any>(); const [userLevels, setUserLevels] = useState<any>();
const [userCompetencies, setUserCompetencies] = useState<any[]>([]); const [userCompetencies, setUserCompetencies] = useState<any[]>([]);
const [selectedCompetencies, setSelectedCompetencies] = useState<Set<number>>( const [selectedCompetencies, setSelectedCompetencies] = useState<Set<number>>(
new Set() new Set(),
); );
const [listExpert, setListExpert] = useState<any[]>([]); const [listExpert, setListExpert] = useState<any[]>([]);
const [checkedLevels, setCheckedLevels] = useState<Set<number>>(new Set()); const [checkedLevels, setCheckedLevels] = useState<Set<number>>(new Set());
@ -245,7 +245,7 @@ export default function FormTaskTa() {
} }
const uniqueExperts = Array.from( const uniqueExperts = Array.from(
new Map(allExperts.map((e) => [e.id, e])).values() new Map(allExperts.map((e) => [e.id, e])).values(),
); );
setListExpert(uniqueExperts); setListExpert(uniqueExperts);
@ -449,7 +449,7 @@ export default function FormTaskTa() {
const requestData = { const requestData = {
...data, ...data,
// assignedToUsers: isMabesApprover ? "464" : handleExpertChange(), // assignedToUsers: isMabesApprover ? "464" : handleExpertChange(),
assignedToUsers: isMabesApprover ? "464" : handleExpertChange(), assignedToUsers: isMabesApprover ? "464,8258" : handleExpertChange(),
assignmentType: taskType, assignmentType: taskType,
assignmentTypeId: type, assignmentTypeId: type,
expertCompetencies: Array.from(selectedCompetencies).join(","), expertCompetencies: Array.from(selectedCompetencies).join(","),
@ -467,19 +467,19 @@ export default function FormTaskTa() {
const uploads: Promise<any>[] = []; const uploads: Promise<any>[] = [];
imageFiles.forEach((file, i) => imageFiles.forEach((file, i) =>
uploads.push(uploadResumableFile(i, assignmentId, file, "1", "0")) uploads.push(uploadResumableFile(i, assignmentId, file, "1", "0")),
); );
videoFiles.forEach((file, i) => videoFiles.forEach((file, i) =>
uploads.push(uploadResumableFile(i, assignmentId, file, "2", "0")) uploads.push(uploadResumableFile(i, assignmentId, file, "2", "0")),
); );
textFiles.forEach((file, i) => textFiles.forEach((file, i) =>
uploads.push(uploadResumableFile(i, assignmentId, file, "3", "0")) uploads.push(uploadResumableFile(i, assignmentId, file, "3", "0")),
); );
audioFiles.forEach((file, i) => audioFiles.forEach((file, i) =>
uploads.push(uploadResumableFile(i, assignmentId, file, "4", "0")) uploads.push(uploadResumableFile(i, assignmentId, file, "4", "0")),
); );
await Promise.all(uploads); await Promise.all(uploads);
@ -557,7 +557,7 @@ export default function FormTaskTa() {
// Convert Blob to File and add preview // Convert Blob to File and add preview
const fileWithPreview: FileWithPreview = Object.assign( const fileWithPreview: FileWithPreview = Object.assign(
new File([blob], "voiceNote.webm", { type: "audio/webm" }), new File([blob], "voiceNote.webm", { type: "audio/webm" }),
{ preview: url } { preview: url },
); );
// Add to state // Add to state
@ -687,7 +687,7 @@ export default function FormTaskTa() {
id: string, id: string,
file: File, file: File,
fileTypeId: string, fileTypeId: string,
duration: string duration: string,
) { ) {
return new Promise(async (resolve, reject) => { return new Promise(async (resolve, reject) => {
try { try {
@ -829,7 +829,7 @@ export default function FormTaskTa() {
variant={"outline"} variant={"outline"}
className={cn( className={cn(
"w-[280px] lg:w-[250px] justify-start text-left font-normal border border-slate-300 px-0 md:px-0 lg:px-4", "w-[280px] lg:w-[250px] justify-start text-left font-normal border border-slate-300 px-0 md:px-0 lg:px-4",
!date && "text-muted-foreground" !date && "text-muted-foreground",
)} )}
> >
<CalendarIcon size={15} className="mr-3" /> <CalendarIcon size={15} className="mr-3" />
@ -928,7 +928,7 @@ export default function FormTaskTa() {
<div className="flex flex-wrap gap-2"> <div className="flex flex-wrap gap-2">
{Array.from(checkedLevels).map((expertId) => { {Array.from(checkedLevels).map((expertId) => {
const expert = listExpert?.find( const expert = listExpert?.find(
(exp: any) => exp.id === expertId (exp: any) => exp.id === expertId,
); );
return expert ? ( return expert ? (
<div <div