QUDO-365, QUDO-364, QUDO-362, QUDO-363
This commit is contained in:
parent
8ba5499378
commit
bbed0c29c1
|
|
@ -101,10 +101,8 @@ const useTableColumns = () => {
|
||||||
enableHiding: false,
|
enableHiding: false,
|
||||||
cell: ({ row }) => {
|
cell: ({ row }) => {
|
||||||
const MySwal = withReactContent(Swal);
|
const MySwal = withReactContent(Swal);
|
||||||
const levelNumber = Number(getCookiesDecrypt("ulne")); // 1 = Mabes, 2 = Polda
|
const levelNumber = Number(getCookiesDecrypt("ulne"));
|
||||||
const calendarOwnerLevel = Number(row.original.assignedToLevel); // dari API
|
const userId = Number(getCookiesDecrypt("uie"));
|
||||||
const calendarOwner = row.original.assignedTo; // ID unit Polda/Mabes dari API
|
|
||||||
const myUnit = getCookiesDecrypt("unitId"); // misal ID unit Polda login
|
|
||||||
|
|
||||||
async function doDelete(id: any) {
|
async function doDelete(id: any) {
|
||||||
const response = await deleteCalendar(id);
|
const response = await deleteCalendar(id);
|
||||||
|
|
@ -143,29 +141,6 @@ const useTableColumns = () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// === RULE AKSI ===
|
|
||||||
let canEdit = false;
|
|
||||||
let canDelete = false;
|
|
||||||
const canView = true;
|
|
||||||
|
|
||||||
if (levelNumber === 1) {
|
|
||||||
// Mabes -> bebas
|
|
||||||
canEdit = true;
|
|
||||||
canDelete = true;
|
|
||||||
} else if (levelNumber === 2) {
|
|
||||||
// Polda
|
|
||||||
if (calendarOwnerLevel === 1) {
|
|
||||||
// kalender Mabes -> hanya view
|
|
||||||
canEdit = false;
|
|
||||||
canDelete = false;
|
|
||||||
} else if (calendarOwnerLevel === 2 && calendarOwner === myUnit) {
|
|
||||||
// kalender polda sendiri -> bisa edit/delete
|
|
||||||
canEdit = true;
|
|
||||||
canDelete = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DropdownMenu>
|
<DropdownMenu>
|
||||||
<DropdownMenuTrigger asChild>
|
<DropdownMenuTrigger asChild>
|
||||||
|
|
@ -178,7 +153,7 @@ const useTableColumns = () => {
|
||||||
</Button>
|
</Button>
|
||||||
</DropdownMenuTrigger>
|
</DropdownMenuTrigger>
|
||||||
<DropdownMenuContent className="p-0" align="end">
|
<DropdownMenuContent className="p-0" align="end">
|
||||||
{canView && (
|
|
||||||
<Link
|
<Link
|
||||||
href={`/contributor/schedule/calendar-polri/detail/${row.original.id}`}
|
href={`/contributor/schedule/calendar-polri/detail/${row.original.id}`}
|
||||||
>
|
>
|
||||||
|
|
@ -187,9 +162,9 @@ const useTableColumns = () => {
|
||||||
Detail
|
Detail
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
</Link>
|
</Link>
|
||||||
)}
|
|
||||||
|
|
||||||
{canEdit && (
|
{row.original.createdById === userId && (
|
||||||
<Link
|
<Link
|
||||||
href={`/contributor/schedule/calendar-polri/update/${row.original.id}`}
|
href={`/contributor/schedule/calendar-polri/update/${row.original.id}`}
|
||||||
>
|
>
|
||||||
|
|
@ -200,7 +175,7 @@ const useTableColumns = () => {
|
||||||
</Link>
|
</Link>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{canDelete && (
|
{row.original.createdById === userId && (
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem
|
||||||
onClick={() => handleDeleteCalendars(row.original.id)}
|
onClick={() => handleDeleteCalendars(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"
|
||||||
|
|
@ -214,7 +189,7 @@ const useTableColumns = () => {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
// {
|
// {
|
||||||
// id: "actions",
|
// id: "actions",
|
||||||
// accessorKey: "action",
|
// accessorKey: "action",
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ import {
|
||||||
saveMediaBlastCampaign,
|
saveMediaBlastCampaign,
|
||||||
} from "@/service/broadcast/broadcast";
|
} from "@/service/broadcast/broadcast";
|
||||||
import { error } from "@/config/swal";
|
import { error } from "@/config/swal";
|
||||||
import { useRouter } from "@/i18n/routing";
|
import { Link, useRouter } from "@/i18n/routing";
|
||||||
|
|
||||||
import { useEffect, useRef, useState } from "react";
|
import { useEffect, useRef, useState } from "react";
|
||||||
import { useParams } from "next/navigation";
|
import { useParams } from "next/navigation";
|
||||||
|
|
@ -78,6 +78,11 @@ const FormSchema = z.object({
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
interface Campaign {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
|
||||||
export default function ContentBlast(props: { type: string }) {
|
export default function ContentBlast(props: { type: string }) {
|
||||||
const editor = useRef(null);
|
const editor = useRef(null);
|
||||||
const id = useParams()?.id;
|
const id = useParams()?.id;
|
||||||
|
|
@ -85,7 +90,7 @@ export default function ContentBlast(props: { type: string }) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { type } = props;
|
const { type } = props;
|
||||||
|
|
||||||
const [dataSelectCampaign, setDataSelectCampaign] = useState([]);
|
const [dataSelectCampaign, setDataSelectCampaign] = useState<Campaign[]>([]);
|
||||||
const [openModal, setOpenModal] = useState(false);
|
const [openModal, setOpenModal] = useState(false);
|
||||||
|
|
||||||
const form = useForm<z.infer<typeof FormSchema>>({
|
const form = useForm<z.infer<typeof FormSchema>>({
|
||||||
|
|
@ -295,9 +300,16 @@ export default function ContentBlast(props: { type: string }) {
|
||||||
Untuk melihat Email Terkirim silahkan cek menu “Sent”!
|
Untuk melihat Email Terkirim silahkan cek menu “Sent”!
|
||||||
</div>
|
</div>
|
||||||
<DialogFooter className="flex justify-center">
|
<DialogFooter className="flex justify-center">
|
||||||
<Button type="button" color="success">
|
<Link
|
||||||
Menu "Sent"
|
href={`/admin/broadcast/campaign-list/detail/${
|
||||||
</Button>
|
form.getValues("selected")[0]?.id
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
<Button type="button" color="success">
|
||||||
|
Menu "Sent"
|
||||||
|
</Button>
|
||||||
|
</Link>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={() => router.push("/admin/broadcast")}
|
onClick={() => router.push("/admin/broadcast")}
|
||||||
|
|
|
||||||
|
|
@ -95,11 +95,19 @@ export function CalendarPolriAddDetail() {
|
||||||
const details = response?.data?.data;
|
const details = response?.data?.data;
|
||||||
|
|
||||||
setDetail(details);
|
setDetail(details);
|
||||||
if (details) {
|
// if (details) {
|
||||||
|
// setDate({
|
||||||
|
// from: parseISO(details.startDate),
|
||||||
|
// to: parseISO(details.endDate),
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
if (details?.startDate && details?.endDate) {
|
||||||
setDate({
|
setDate({
|
||||||
from: parseISO(details.startDate),
|
from: parseISO(details.startDate),
|
||||||
to: parseISO(details.endDate),
|
to: parseISO(details.endDate),
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
// atau biarkan kosong sesuai kebutuhan
|
||||||
}
|
}
|
||||||
|
|
||||||
if (details?.assignedTo) {
|
if (details?.assignedTo) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue