fix: form create task-ta
This commit is contained in:
parent
ec2d7eb203
commit
7c721dcc96
|
|
@ -43,7 +43,7 @@ import { getCsrfToken } from "@/service/auth";
|
|||
import { loading } from "@/lib/swal";
|
||||
import { useTranslations } from "next-intl";
|
||||
import dynamic from "next/dynamic";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { cn, getCookiesDecrypt } from "@/lib/utils";
|
||||
import {
|
||||
Popover,
|
||||
PopoverContent,
|
||||
|
|
@ -181,6 +181,32 @@ export default function FormTaskTa() {
|
|||
mode: "all",
|
||||
});
|
||||
|
||||
const [profile, setProfile] = useState<any>(null);
|
||||
const userLevelId = Number(getCookiesDecrypt("ulie"));
|
||||
const roleId = Number(getCookiesDecrypt("urie"));
|
||||
const userId = Number(getCookiesDecrypt("uie"));
|
||||
|
||||
const MABES_LEVEL_ID = 216;
|
||||
const APPROVER_ROLE_ID = 3;
|
||||
const isMabes = userLevelId === MABES_LEVEL_ID;
|
||||
const isApprover = roleId === APPROVER_ROLE_ID;
|
||||
|
||||
const isMabesApprover =
|
||||
userLevelId === MABES_LEVEL_ID && roleId === APPROVER_ROLE_ID;
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
async function fetchUserLevel() {
|
||||
try {
|
||||
const res = await getUserLevelForAssignments();
|
||||
setProfile(res?.data?.data);
|
||||
} catch (e) {
|
||||
console.error("Failed fetch user level", e);
|
||||
}
|
||||
}
|
||||
fetchUserLevel();
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
getDataAdditional();
|
||||
}, []);
|
||||
|
|
@ -360,12 +386,20 @@ export default function FormTaskTa() {
|
|||
const requestData = {
|
||||
...data,
|
||||
assignedToUsers: handleExpertChange(),
|
||||
// assignedToUsers: isMabesApprover ? "464" : handleExpertChange(),
|
||||
assignmentType: taskType,
|
||||
assignmentTypeId: type,
|
||||
expertCompetencies: Array.from(selectedCompetencies).join(","),
|
||||
attachmentUrl: cleanedLinks,
|
||||
};
|
||||
|
||||
console.log("FINAL ASSIGNED TO:", {
|
||||
isMabesApprover,
|
||||
assignedToUsers: isMabesApprover
|
||||
? String(roleId)
|
||||
: handleExpertChange(),
|
||||
});
|
||||
|
||||
const response = await createTaskTa(requestData);
|
||||
const id = String(response?.data?.data.id);
|
||||
|
||||
|
|
@ -718,6 +752,7 @@ export default function FormTaskTa() {
|
|||
</PopoverContent>
|
||||
</Popover>
|
||||
</div>
|
||||
{!isMabesApprover && (
|
||||
<div className="mt-5 space-y-2">
|
||||
<Label>
|
||||
{t("areas-expertise", { defaultValue: "Areas Expertise" })}
|
||||
|
|
@ -735,6 +770,8 @@ export default function FormTaskTa() {
|
|||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{!isMabesApprover && (
|
||||
<div className="mt-5 space-y-2">
|
||||
<Label>
|
||||
{t("choose-expert", { defaultValue: "Choose Expert" })}
|
||||
|
|
@ -762,8 +799,12 @@ export default function FormTaskTa() {
|
|||
className="mr-3"
|
||||
/>
|
||||
<div className="flex flex-col gap-2">
|
||||
<div className="font-bold">{expert.fullname}</div>
|
||||
<div className="italic">({expert.username})</div>
|
||||
<div className="font-bold">
|
||||
{expert.fullname}
|
||||
</div>
|
||||
<div className="italic">
|
||||
({expert.username})
|
||||
</div>
|
||||
</div>
|
||||
</Label>
|
||||
</div>
|
||||
|
|
@ -813,6 +854,7 @@ export default function FormTaskTa() {
|
|||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
<div className="mt-5 space-y-2">
|
||||
<Label>{t("description", { defaultValue: "Description" })}</Label>
|
||||
<Controller
|
||||
|
|
|
|||
|
|
@ -168,6 +168,13 @@ export function getMenuList(pathname: string, t: any): Group[] {
|
|||
icon: "heroicons:shopping-cart",
|
||||
children: [],
|
||||
},
|
||||
{
|
||||
href: "/contributor/task-ta",
|
||||
label: "penugasan TA",
|
||||
active: pathname.includes("/contributor/task-ta"),
|
||||
icon: "heroicons:shopping-cart",
|
||||
children: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
|
|
|
|||
Loading…
Reference in New Issue