Merge branch 'dev-sabda-v2' of https://gitlab.com/hanifsalafi/mediahub_redesign
This commit is contained in:
commit
e5e32496ab
|
|
@ -237,7 +237,6 @@ export default function TaskTaTable() {
|
|||
contentData = contentData.filter((item: any) => {
|
||||
const createdByLevel = item?.createdBy?.userLevel?.name || "";
|
||||
|
||||
// KOOR KURATOR = user id 464 (sesuai create kamu)
|
||||
const assignedUsers = String(item?.assignedToUsers || "");
|
||||
|
||||
return (
|
||||
|
|
@ -307,6 +306,17 @@ export default function TaskTaTable() {
|
|||
Atensi Khusus Mabes
|
||||
</button>
|
||||
|
||||
<button
|
||||
onClick={() => setActiveTab("mabes-koor")}
|
||||
className={`px-4 py-1 rounded transition ${
|
||||
activeTab === "mabes-koor"
|
||||
? "bg-default-900 text-white dark:text-black"
|
||||
: "border dark:text-default-700"
|
||||
}`}
|
||||
>
|
||||
Atensi Khusus Mabes → Koor Kurator
|
||||
</button>
|
||||
|
||||
<button
|
||||
onClick={() => setActiveTab("ta")}
|
||||
className={`px-4 py-1 rounded transition ${
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ interface Detail {
|
|||
youtubeUrl: string;
|
||||
needApprovalFrom: number;
|
||||
uploadedById: number;
|
||||
statusId?: number;
|
||||
}
|
||||
|
||||
export default function FormDetailLiveReport() {
|
||||
|
|
@ -176,21 +177,68 @@ export default function FormDetailLiveReport() {
|
|||
statusId: Number(status),
|
||||
message: description,
|
||||
isPublish: status === "2",
|
||||
placements: schedulePlacements?.filter((val) => val != "all")?.join(","),
|
||||
placements: schedulePlacements?.filter((val) => val !== "all")?.join(","),
|
||||
};
|
||||
|
||||
loading();
|
||||
const response = await postApprovalSchedule(data);
|
||||
close();
|
||||
setModalOpen(false);
|
||||
|
||||
if (response?.error) {
|
||||
error(response?.message);
|
||||
return false;
|
||||
error(response?.message || "Gagal menyimpan data");
|
||||
return;
|
||||
}
|
||||
initState();
|
||||
return false;
|
||||
|
||||
// ✅ update UI lokal (optimistic)
|
||||
setDetail((prev) =>
|
||||
prev
|
||||
? {
|
||||
...prev,
|
||||
statusId: Number(status),
|
||||
}
|
||||
: prev,
|
||||
);
|
||||
|
||||
Swal.fire({
|
||||
icon: "success",
|
||||
title: "Berhasil",
|
||||
text:
|
||||
status === "2"
|
||||
? "Jadwal berhasil disetujui"
|
||||
: status === "3"
|
||||
? "Jadwal dikembalikan untuk revisi"
|
||||
: "Jadwal berhasil ditolak",
|
||||
confirmButtonText: "OK",
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
router.push("/contributor/schedule/live-report");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// async function save() {
|
||||
// const data = {
|
||||
// scheduleId: Number(id),
|
||||
// statusId: Number(status),
|
||||
// message: description,
|
||||
// isPublish: status === "2",
|
||||
// placements: schedulePlacements?.filter((val) => val != "all")?.join(","),
|
||||
// };
|
||||
|
||||
// loading();
|
||||
// const response = await postApprovalSchedule(data);
|
||||
// close();
|
||||
// setModalOpen(false);
|
||||
|
||||
// if (response?.error) {
|
||||
// error(response?.message);
|
||||
// return false;
|
||||
// }
|
||||
// initState();
|
||||
// return false;
|
||||
// }
|
||||
|
||||
const [schedulePlacements, setSchedulePlacements] = useState<string[]>([]);
|
||||
|
||||
const setupPlacement = (placement: string, checked: boolean) => {
|
||||
|
|
@ -224,6 +272,15 @@ export default function FormDetailLiveReport() {
|
|||
setSchedulePlacements(temp);
|
||||
};
|
||||
|
||||
const isCreator = Number(detail?.uploadedById) === Number(userId);
|
||||
|
||||
const isApprover =
|
||||
Number(detail?.needApprovalFrom) === Number(userLevelId) &&
|
||||
Number(userLevelNumber) < 2;
|
||||
|
||||
const isAlreadyProcessed =
|
||||
detail?.statusId === 2 || detail?.statusId === 3 || detail?.statusId === 4;
|
||||
|
||||
return (
|
||||
<div className="flex flex-col lg:flex-row gap-2">
|
||||
<Card className="w-full lg:w-9/12">
|
||||
|
|
@ -284,7 +341,7 @@ export default function FormDetailLiveReport() {
|
|||
variant={"outline"}
|
||||
className={cn(
|
||||
"w-[280px] lg:w-[250px] justify-start text-left font-normal px-0 md:px-0 lg:px-4",
|
||||
!date && "text-muted-foreground"
|
||||
!date && "text-muted-foreground",
|
||||
)}
|
||||
>
|
||||
<CalendarIcon size={15} className="mr-3" />
|
||||
|
|
@ -494,7 +551,38 @@ export default function FormDetailLiveReport() {
|
|||
</AccordionItem>
|
||||
</Accordion>
|
||||
|
||||
{Number(detail?.needApprovalFrom) == Number(userLevelId) &&
|
||||
{(isApprover || isCreator) && !isAlreadyProcessed && (
|
||||
<div className="flex flex-col gap-2 p-3">
|
||||
<Button
|
||||
onClick={() => actionApproval("2")}
|
||||
color="primary"
|
||||
type="button"
|
||||
>
|
||||
<Icon icon="fa:check" className="mr-3" />
|
||||
{t("accept", { defaultValue: "Accept" })}
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
onClick={() => actionApproval("3")}
|
||||
className="bg-orange-400 hover:bg-orange-300"
|
||||
type="button"
|
||||
>
|
||||
<Icon icon="fa:comment-o" className="mr-3" />
|
||||
{t("revision", { defaultValue: "Revision" })}
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
onClick={() => actionApproval("4")}
|
||||
color="destructive"
|
||||
type="button"
|
||||
>
|
||||
<Icon icon="fa:times" className="mr-3" />
|
||||
{t("reject", { defaultValue: "Reject" })}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* {Number(detail?.needApprovalFrom) == Number(userLevelId) &&
|
||||
Number(userLevelNumber) < 2 ? (
|
||||
Number(detail?.uploadedById) == Number(userId) ? (
|
||||
""
|
||||
|
|
@ -527,13 +615,15 @@ export default function FormDetailLiveReport() {
|
|||
)
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
)} */}
|
||||
</Card>
|
||||
|
||||
<Dialog open={modalOpen} onOpenChange={setModalOpen}>
|
||||
<DialogContent className="overflow-y-auto">
|
||||
<DialogHeader>
|
||||
<DialogTitle>{t("leave-comment", { defaultValue: "Leave Comment" })}</DialogTitle>
|
||||
<DialogTitle>
|
||||
{t("leave-comment", { defaultValue: "Leave Comment" })}
|
||||
</DialogTitle>
|
||||
</DialogHeader>
|
||||
<div className="flex flex-col gap-1 text-sm">
|
||||
<p>
|
||||
|
|
@ -544,15 +634,15 @@ export default function FormDetailLiveReport() {
|
|||
status === "2"
|
||||
? "text-primary"
|
||||
: status === "3"
|
||||
? "text-warning"
|
||||
: "text-destructive"
|
||||
? "text-warning"
|
||||
: "text-destructive"
|
||||
}
|
||||
>
|
||||
{status === "2"
|
||||
? "Disetujui"
|
||||
: status === "3"
|
||||
? "Revisi"
|
||||
: "Ditolak"}
|
||||
? "Revisi"
|
||||
: "Ditolak"}
|
||||
</span>
|
||||
</p>
|
||||
{status === "2" && (
|
||||
|
|
|
|||
|
|
@ -449,9 +449,7 @@ export default function FormTaskTa() {
|
|||
const requestData = {
|
||||
...data,
|
||||
// assignedToUsers: isMabesApprover ? "464" : handleExpertChange(),
|
||||
assignedToUsers: isMabesApprover
|
||||
? ["464", "8258"]
|
||||
: handleExpertChange(),
|
||||
assignedToUsers: isMabesApprover ? "464" : handleExpertChange(),
|
||||
assignmentType: taskType,
|
||||
assignmentTypeId: type,
|
||||
expertCompetencies: Array.from(selectedCompetencies).join(","),
|
||||
|
|
|
|||
Loading…
Reference in New Issue