2024-12-26 12:52:20 +00:00
|
|
|
"use client";
|
|
|
|
|
import SiteBreadcrumb from "@/components/site-breadcrumb";
|
|
|
|
|
import { Button } from "@/components/ui/button";
|
|
|
|
|
import { Calendar } from "@/components/ui/calendar";
|
|
|
|
|
import { Input } from "@/components/ui/input";
|
|
|
|
|
import {
|
|
|
|
|
Popover,
|
|
|
|
|
PopoverContent,
|
|
|
|
|
PopoverTrigger,
|
|
|
|
|
} from "@/components/ui/popover";
|
2024-12-27 14:14:58 +00:00
|
|
|
import { Link, useRouter } from "@/i18n/routing";
|
2024-12-26 12:52:20 +00:00
|
|
|
import { CalendarIcon } from "lucide-react";
|
2024-12-27 14:14:58 +00:00
|
|
|
import React, { useEffect, useRef, useState } from "react";
|
2024-12-26 12:52:20 +00:00
|
|
|
import { cn } from "@/lib/utils";
|
|
|
|
|
import { format } from "date-fns";
|
|
|
|
|
import JoditEditor from "jodit-react";
|
|
|
|
|
import {
|
|
|
|
|
Form,
|
|
|
|
|
FormControl,
|
|
|
|
|
FormDescription,
|
|
|
|
|
FormField,
|
|
|
|
|
FormItem,
|
|
|
|
|
FormLabel,
|
|
|
|
|
FormMessage,
|
|
|
|
|
} from "@/components/ui/form";
|
|
|
|
|
import { z } from "zod";
|
|
|
|
|
import { useForm } from "react-hook-form";
|
|
|
|
|
import { zodResolver } from "@hookform/resolvers/zod";
|
|
|
|
|
import Swal from "sweetalert2";
|
|
|
|
|
import withReactContent from "sweetalert2-react-content";
|
|
|
|
|
import { Checkbox } from "@/components/ui/checkbox";
|
|
|
|
|
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";
|
2024-12-27 14:14:58 +00:00
|
|
|
import {
|
|
|
|
|
Select,
|
|
|
|
|
SelectContent,
|
|
|
|
|
SelectItem,
|
|
|
|
|
SelectTrigger,
|
|
|
|
|
SelectValue,
|
|
|
|
|
} from "@/components/ui/select";
|
|
|
|
|
import {
|
|
|
|
|
getWeeklyPlanList,
|
|
|
|
|
savePlanning,
|
|
|
|
|
} from "@/service/agenda-setting/agenda-setting";
|
|
|
|
|
import { id } from "date-fns/locale";
|
|
|
|
|
import { close, error, loading } from "@/config/swal";
|
|
|
|
|
import { getOnlyDate } from "@/utils/globals";
|
|
|
|
|
import {
|
|
|
|
|
Accordion,
|
|
|
|
|
AccordionContent,
|
|
|
|
|
AccordionItem,
|
|
|
|
|
AccordionTrigger,
|
|
|
|
|
} from "@/components/ui/accordion";
|
|
|
|
|
import {
|
|
|
|
|
Dialog,
|
|
|
|
|
DialogContent,
|
|
|
|
|
DialogHeader,
|
|
|
|
|
DialogTitle,
|
|
|
|
|
DialogTrigger,
|
|
|
|
|
} from "@/components/ui/dialog";
|
|
|
|
|
import { getUserLevelForAssignments } from "@/service/task";
|
2025-05-05 14:53:47 +00:00
|
|
|
import dynamic from "next/dynamic";
|
2024-12-26 12:52:20 +00:00
|
|
|
|
|
|
|
|
const FormSchema = z.object({
|
|
|
|
|
date: z.date({
|
|
|
|
|
required_error: "Required",
|
|
|
|
|
}),
|
|
|
|
|
title: z.string({
|
|
|
|
|
required_error: "Required",
|
|
|
|
|
}),
|
|
|
|
|
detail: z.string({
|
|
|
|
|
required_error: "Required",
|
|
|
|
|
}),
|
|
|
|
|
output: z.array(z.string()).refine((value) => value.some((item) => item), {
|
|
|
|
|
message: "Required",
|
|
|
|
|
}),
|
|
|
|
|
unit: z.array(z.string()).refine((value) => value.some((item) => item), {
|
|
|
|
|
message: "Required",
|
|
|
|
|
}),
|
2024-12-27 14:14:58 +00:00
|
|
|
type: z.string({
|
|
|
|
|
required_error: "Required",
|
|
|
|
|
}),
|
|
|
|
|
parentId: z.string({
|
2024-12-26 12:52:20 +00:00
|
|
|
required_error: "Required",
|
|
|
|
|
}),
|
2024-12-27 14:14:58 +00:00
|
|
|
media: z.array(z.string()).refine((value) => value.some((item) => item), {
|
|
|
|
|
message: "Required",
|
|
|
|
|
}),
|
2024-12-26 12:52:20 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const items = [
|
|
|
|
|
{
|
2024-12-27 14:14:58 +00:00
|
|
|
id: "2",
|
2024-12-26 12:52:20 +00:00
|
|
|
label: "Audio Visual",
|
|
|
|
|
},
|
|
|
|
|
{
|
2024-12-27 14:14:58 +00:00
|
|
|
id: "1",
|
2024-12-26 12:52:20 +00:00
|
|
|
label: "Foto",
|
|
|
|
|
},
|
|
|
|
|
{
|
2024-12-27 14:14:58 +00:00
|
|
|
id: "4",
|
2024-12-26 12:52:20 +00:00
|
|
|
label: "Audio",
|
|
|
|
|
},
|
|
|
|
|
{
|
2024-12-27 14:14:58 +00:00
|
|
|
id: "3",
|
2024-12-26 12:52:20 +00:00
|
|
|
label: "Text",
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
2024-12-27 14:14:58 +00:00
|
|
|
const medias = [
|
|
|
|
|
{
|
|
|
|
|
id: "5",
|
|
|
|
|
label: "X",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: "1",
|
|
|
|
|
label: "Facebook",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: "2",
|
|
|
|
|
label: "Instagram",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: "3",
|
|
|
|
|
label: "Youtube",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: "4",
|
|
|
|
|
label: "Tiktok",
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
2024-12-26 12:52:20 +00:00
|
|
|
const units = [
|
|
|
|
|
{
|
2024-12-27 14:14:58 +00:00
|
|
|
id: "1",
|
2024-12-26 12:52:20 +00:00
|
|
|
label: "Mabes Polri",
|
|
|
|
|
},
|
|
|
|
|
{
|
2024-12-27 14:14:58 +00:00
|
|
|
id: "2",
|
2024-12-26 12:52:20 +00:00
|
|
|
label: "Polda",
|
|
|
|
|
},
|
|
|
|
|
{
|
2024-12-27 14:14:58 +00:00
|
|
|
id: "3",
|
2024-12-26 12:52:20 +00:00
|
|
|
label: "Polres",
|
|
|
|
|
},
|
2025-05-05 14:53:47 +00:00
|
|
|
{
|
|
|
|
|
id: "4",
|
|
|
|
|
label: "Satker",
|
|
|
|
|
},
|
2024-12-26 12:52:20 +00:00
|
|
|
];
|
2025-05-05 14:53:47 +00:00
|
|
|
|
|
|
|
|
const CustomEditor = dynamic(
|
|
|
|
|
() => {
|
|
|
|
|
return import("@/components/editor/custom-editor");
|
|
|
|
|
},
|
|
|
|
|
{ ssr: false }
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
export default function CreateDaily() {
|
2024-12-26 12:52:20 +00:00
|
|
|
const MySwal = withReactContent(Swal);
|
2024-12-27 14:14:58 +00:00
|
|
|
const [weeklyList, setWeeklyList] = useState<any>();
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
const [selected, setSelected] = useState<{ [key: string]: boolean }>({});
|
|
|
|
|
const [selectAll, setSelectAll] = useState<{ [key: string]: boolean }>({});
|
|
|
|
|
const [listDest, setListDest] = useState<any>([]);
|
2024-12-26 12:52:20 +00:00
|
|
|
|
|
|
|
|
const form = useForm<z.infer<typeof FormSchema>>({
|
|
|
|
|
resolver: zodResolver(FormSchema),
|
|
|
|
|
defaultValues: {
|
|
|
|
|
unit: [],
|
|
|
|
|
output: [],
|
|
|
|
|
detail: "",
|
2024-12-27 14:14:58 +00:00
|
|
|
media: [],
|
2024-12-26 12:52:20 +00:00
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
const editor = useRef(null);
|
|
|
|
|
|
2024-12-27 14:14:58 +00:00
|
|
|
useEffect(() => {
|
|
|
|
|
getWeeklyPlanning();
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
async function getWeeklyPlanning() {
|
|
|
|
|
const res = await getWeeklyPlanList(new Date().getDate(), 2);
|
|
|
|
|
|
2025-01-04 17:11:14 +00:00
|
|
|
if (res?.data !== null) {
|
|
|
|
|
const rawUser = res?.data?.data;
|
2024-12-27 14:14:58 +00:00
|
|
|
const optionArr = rawUser.map((option: any) => ({
|
|
|
|
|
id: option.id,
|
|
|
|
|
label: option.title,
|
|
|
|
|
value: String(option.id),
|
|
|
|
|
}));
|
|
|
|
|
setWeeklyList(optionArr);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-26 12:52:20 +00:00
|
|
|
const onSubmit = async (data: z.infer<typeof FormSchema>) => {
|
|
|
|
|
if (form.getValues("detail") == "") {
|
|
|
|
|
form.setError("detail", {
|
|
|
|
|
type: "manual",
|
|
|
|
|
message: "Required",
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
MySwal.fire({
|
|
|
|
|
title: "Simpan Data",
|
|
|
|
|
text: "Apakah Anda yakin ingin menyimpan data ini?",
|
|
|
|
|
icon: "warning",
|
|
|
|
|
showCancelButton: true,
|
|
|
|
|
cancelButtonColor: "#d33",
|
|
|
|
|
confirmButtonColor: "#3085d6",
|
|
|
|
|
confirmButtonText: "Simpan",
|
|
|
|
|
}).then((result) => {
|
|
|
|
|
if (result.isConfirmed) {
|
|
|
|
|
save(data);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const save = async (data: z.infer<typeof FormSchema>) => {
|
2024-12-27 14:14:58 +00:00
|
|
|
const getSelectedString = () => {
|
|
|
|
|
return Object.keys(selected)
|
|
|
|
|
.filter((key) => selected[key])
|
|
|
|
|
.join(", ");
|
|
|
|
|
};
|
|
|
|
|
loading();
|
2024-12-26 12:52:20 +00:00
|
|
|
|
2024-12-27 14:14:58 +00:00
|
|
|
const reqData = {
|
|
|
|
|
planningTypeId: 2,
|
|
|
|
|
time: "1",
|
|
|
|
|
title: data.title,
|
|
|
|
|
assignmentTypeId: data.type, //string
|
|
|
|
|
description: data.detail,
|
|
|
|
|
assignedToLevel: unit?.join(","), //string
|
|
|
|
|
assignmentPurpose: getSelectedString(), //string
|
|
|
|
|
fileTypeOutput: data.output?.join(","), //string
|
|
|
|
|
status: "Open",
|
|
|
|
|
date: getOnlyDate(data.date),
|
|
|
|
|
platformType: data.media?.join(","),
|
|
|
|
|
parentId: Number(data.parentId), //number
|
|
|
|
|
assignmentMainTypeId: 2,
|
|
|
|
|
};
|
2024-12-26 12:52:20 +00:00
|
|
|
|
2024-12-27 14:14:58 +00:00
|
|
|
console.log("req =>", reqData);
|
|
|
|
|
const response = await savePlanning(reqData);
|
|
|
|
|
|
2025-01-01 17:48:57 +00:00
|
|
|
if (response?.error) {
|
|
|
|
|
error(response?.message);
|
2024-12-27 14:14:58 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
close();
|
|
|
|
|
MySwal.fire({
|
|
|
|
|
title: "Sukses",
|
|
|
|
|
icon: "success",
|
|
|
|
|
confirmButtonColor: "#3085d6",
|
|
|
|
|
confirmButtonText: "OK",
|
|
|
|
|
}).then((result) => {
|
|
|
|
|
if (result.isConfirmed) {
|
|
|
|
|
router.push("/curator/task-plan/medsos-mediahub");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
};
|
2024-12-26 12:52:20 +00:00
|
|
|
|
2024-12-27 14:14:58 +00:00
|
|
|
const output = form.watch("output");
|
|
|
|
|
const media = form.watch("media");
|
2024-12-26 12:52:20 +00:00
|
|
|
const unit = form.watch("unit");
|
|
|
|
|
|
2024-12-27 14:14:58 +00:00
|
|
|
const isAllChecked = items.every((item) => output?.includes(item.id));
|
|
|
|
|
const isAllMediaChecked = medias.every((item) => media?.includes(item.id));
|
2024-12-26 12:52:20 +00:00
|
|
|
const isAllUnitChecked = units.every((item) => unit?.includes(item.id));
|
|
|
|
|
|
2024-12-27 14:14:58 +00:00
|
|
|
useEffect(() => {
|
|
|
|
|
async function initState() {
|
|
|
|
|
const response = await getUserLevelForAssignments();
|
2025-01-01 17:48:57 +00:00
|
|
|
setListDest(response?.data?.data.list);
|
2024-12-26 12:52:20 +00:00
|
|
|
}
|
|
|
|
|
|
2024-12-27 14:14:58 +00:00
|
|
|
initState();
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
const handleParentChange = (listId: string) => {
|
|
|
|
|
setSelected((prev) => ({
|
|
|
|
|
...prev,
|
|
|
|
|
[listId]: !prev[listId],
|
|
|
|
|
}));
|
2024-12-26 12:52:20 +00:00
|
|
|
};
|
|
|
|
|
|
2024-12-27 14:14:58 +00:00
|
|
|
const handleSelectAllPolres = (listId: string, isChecked: boolean) => {
|
|
|
|
|
setSelectAll((prev) => ({
|
|
|
|
|
...prev,
|
|
|
|
|
[listId]: isChecked,
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
setSelected((prev) => {
|
|
|
|
|
const updatedState = { ...prev };
|
|
|
|
|
listDest
|
|
|
|
|
.find((list: any) => list.id === listId)
|
|
|
|
|
?.subDestination.forEach((subDes: any) => {
|
|
|
|
|
updatedState[`${listId}${subDes.id}`] = isChecked;
|
|
|
|
|
});
|
|
|
|
|
return updatedState;
|
|
|
|
|
});
|
2024-12-26 12:52:20 +00:00
|
|
|
};
|
|
|
|
|
|
2024-12-27 14:14:58 +00:00
|
|
|
const handleChildChange = (childId: string) => {
|
|
|
|
|
setSelected((prev) => ({
|
|
|
|
|
...prev,
|
|
|
|
|
[childId]: !prev[childId],
|
|
|
|
|
}));
|
2024-12-26 12:52:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div>
|
|
|
|
|
<SiteBreadcrumb />
|
|
|
|
|
<div className="flex flex-col gap-4">
|
|
|
|
|
<div className="flex flex-row justify-center gap-5 mt-10">
|
|
|
|
|
<Link
|
|
|
|
|
href="/curator/task-plan/medsos-mediahub/create-monthly"
|
|
|
|
|
className="bg-slate-200 text-black rounded-full px-5 py-2 text-sm"
|
|
|
|
|
>
|
|
|
|
|
Bulanan
|
|
|
|
|
</Link>
|
|
|
|
|
<Link
|
|
|
|
|
href="/curator/task-plan/medsos-mediahub/create-weekly"
|
|
|
|
|
className="bg-slate-200 text-black rounded-full px-5 py-2 text-sm"
|
|
|
|
|
>
|
|
|
|
|
Mingguan
|
|
|
|
|
</Link>
|
|
|
|
|
|
|
|
|
|
<div className="bg-primary rounded-full px-5 py-2 text-white text-sm">
|
|
|
|
|
Harian
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="flex flex-col bg-white gap-2 p-6">
|
|
|
|
|
<p className="text-lg">Perencanaan MediaHub</p>
|
|
|
|
|
|
|
|
|
|
<Form {...form}>
|
|
|
|
|
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-3">
|
|
|
|
|
<FormField
|
|
|
|
|
control={form.control}
|
|
|
|
|
name="title"
|
|
|
|
|
render={({ field }) => (
|
|
|
|
|
<FormItem>
|
|
|
|
|
<FormLabel>Judul Perencanaan</FormLabel>
|
|
|
|
|
<Input
|
|
|
|
|
value={field.value}
|
|
|
|
|
placeholder="Masukkan Judul Perencanaan"
|
|
|
|
|
onChange={field.onChange}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<FormMessage />
|
|
|
|
|
</FormItem>
|
|
|
|
|
)}
|
|
|
|
|
/>
|
|
|
|
|
<FormField
|
|
|
|
|
control={form.control}
|
|
|
|
|
name="output"
|
|
|
|
|
render={() => (
|
|
|
|
|
<FormItem>
|
|
|
|
|
<div className="mb-4">
|
|
|
|
|
<FormLabel className="text-sm">Output Tugas</FormLabel>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="flex flex-row gap-3 items-center ">
|
|
|
|
|
<div className="flex items-center gap-3">
|
|
|
|
|
<Checkbox
|
|
|
|
|
id="all"
|
|
|
|
|
checked={isAllChecked}
|
2024-12-27 14:14:58 +00:00
|
|
|
onCheckedChange={(checked) => {
|
|
|
|
|
if (checked) {
|
|
|
|
|
form.setValue(
|
|
|
|
|
"output",
|
|
|
|
|
items.map((item) => item.id)
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
form.setValue("output", []);
|
|
|
|
|
}
|
|
|
|
|
}}
|
2024-12-26 12:52:20 +00:00
|
|
|
/>
|
|
|
|
|
<label htmlFor="all" className="text-sm">
|
|
|
|
|
Semua
|
|
|
|
|
</label>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{items.map((item) => (
|
|
|
|
|
<FormField
|
|
|
|
|
key={item.id}
|
|
|
|
|
control={form.control}
|
|
|
|
|
name="output"
|
|
|
|
|
render={({ field }) => {
|
|
|
|
|
return (
|
|
|
|
|
<FormItem
|
|
|
|
|
key={item.id}
|
|
|
|
|
className="flex flex-row items-start space-x-3 space-y-0"
|
|
|
|
|
>
|
|
|
|
|
<FormControl>
|
|
|
|
|
<Checkbox
|
|
|
|
|
checked={output?.includes(item.id)}
|
2024-12-27 14:14:58 +00:00
|
|
|
onCheckedChange={(checked) => {
|
|
|
|
|
form.setValue(
|
|
|
|
|
"output",
|
|
|
|
|
checked
|
|
|
|
|
? [...output, item.id]
|
|
|
|
|
: output.filter(
|
|
|
|
|
(value) => value !== item.id
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}}
|
2024-12-26 12:52:20 +00:00
|
|
|
/>
|
|
|
|
|
</FormControl>
|
|
|
|
|
<FormLabel className="font-normal">
|
|
|
|
|
{item.label}
|
|
|
|
|
</FormLabel>
|
|
|
|
|
</FormItem>
|
|
|
|
|
);
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
<FormMessage />
|
|
|
|
|
</FormItem>
|
|
|
|
|
)}
|
|
|
|
|
/>
|
|
|
|
|
<FormField
|
|
|
|
|
control={form.control}
|
|
|
|
|
name="unit"
|
|
|
|
|
render={() => (
|
|
|
|
|
<FormItem>
|
|
|
|
|
<div className="mb-4">
|
|
|
|
|
<FormLabel className="text-sm">Pelaksana Tugas</FormLabel>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="flex flex-row gap-3 items-center ">
|
|
|
|
|
<div className="flex items-center gap-3">
|
|
|
|
|
<Checkbox
|
|
|
|
|
id="all"
|
|
|
|
|
checked={isAllUnitChecked}
|
2024-12-27 14:14:58 +00:00
|
|
|
onCheckedChange={(checked) => {
|
|
|
|
|
if (checked) {
|
|
|
|
|
form.setValue(
|
|
|
|
|
"unit",
|
|
|
|
|
units.map((item) => item.id)
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
form.setValue("unit", []);
|
|
|
|
|
}
|
|
|
|
|
}}
|
2024-12-26 12:52:20 +00:00
|
|
|
/>
|
|
|
|
|
<label htmlFor="all" className="text-sm">
|
|
|
|
|
Semua
|
|
|
|
|
</label>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{units.map((item) => (
|
|
|
|
|
<FormField
|
|
|
|
|
key={item.id}
|
|
|
|
|
control={form.control}
|
|
|
|
|
name="unit"
|
|
|
|
|
render={({ field }) => {
|
|
|
|
|
return (
|
|
|
|
|
<FormItem
|
|
|
|
|
key={item.id}
|
|
|
|
|
className="flex flex-row items-start space-x-3 space-y-0"
|
|
|
|
|
>
|
|
|
|
|
<FormControl>
|
|
|
|
|
<Checkbox
|
|
|
|
|
checked={unit?.includes(item.id)}
|
|
|
|
|
disabled={
|
|
|
|
|
item.id === "polres" &&
|
|
|
|
|
!unit.includes("polda")
|
|
|
|
|
}
|
2024-12-27 14:14:58 +00:00
|
|
|
onCheckedChange={(checked) => {
|
|
|
|
|
form.setValue(
|
|
|
|
|
"unit",
|
|
|
|
|
checked
|
|
|
|
|
? [...unit, item.id]
|
|
|
|
|
: unit.filter(
|
|
|
|
|
(value) => value !== item.id
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</FormControl>
|
|
|
|
|
<FormLabel className="font-normal">
|
|
|
|
|
{item.label}
|
|
|
|
|
</FormLabel>
|
|
|
|
|
</FormItem>
|
|
|
|
|
);
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
))}
|
|
|
|
|
<Dialog>
|
|
|
|
|
<DialogTrigger asChild>
|
|
|
|
|
<a className="text-primary cursor-pointer text-sm">
|
|
|
|
|
{`[Kustom]`}
|
|
|
|
|
</a>
|
|
|
|
|
</DialogTrigger>
|
|
|
|
|
<DialogContent size="md">
|
|
|
|
|
<DialogHeader>
|
|
|
|
|
<DialogTitle>
|
|
|
|
|
Daftar Wilayah Polda dan Polres
|
|
|
|
|
</DialogTitle>
|
|
|
|
|
</DialogHeader>
|
|
|
|
|
<div className="grid grid-cols-2 gap-4 py-4 px-2 max-h-[600px] overflow-y-auto custom-scrollbar-table">
|
|
|
|
|
{listDest?.map((list: any) => (
|
|
|
|
|
<div key={list.id}>
|
|
|
|
|
<Accordion
|
|
|
|
|
type="single"
|
|
|
|
|
collapsible
|
|
|
|
|
className="h-fit border-none"
|
|
|
|
|
>
|
|
|
|
|
<AccordionItem
|
|
|
|
|
value={list.name}
|
|
|
|
|
className="border-none"
|
|
|
|
|
>
|
|
|
|
|
<div className="flex items-center space-x-2">
|
|
|
|
|
<Checkbox
|
|
|
|
|
id={list.id}
|
|
|
|
|
name={`all${list.id}`}
|
|
|
|
|
checked={
|
|
|
|
|
unit.includes("2")
|
|
|
|
|
? true
|
|
|
|
|
: !!selected[list.id]
|
|
|
|
|
}
|
|
|
|
|
onCheckedChange={() =>
|
|
|
|
|
handleParentChange(list.id)
|
|
|
|
|
}
|
|
|
|
|
disabled={unit.includes("2")}
|
|
|
|
|
/>
|
|
|
|
|
<label
|
|
|
|
|
htmlFor={list.name}
|
|
|
|
|
className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
|
|
|
|
>
|
|
|
|
|
{list.name}
|
|
|
|
|
</label>
|
|
|
|
|
<AccordionTrigger className="w-fit bg-transparent"></AccordionTrigger>
|
|
|
|
|
</div>
|
|
|
|
|
<AccordionContent>
|
|
|
|
|
<div className="flex flex-col gap-1">
|
|
|
|
|
<div className="flex items-center space-x-2">
|
|
|
|
|
<Checkbox
|
|
|
|
|
checked={
|
|
|
|
|
unit.includes("3")
|
|
|
|
|
? true
|
|
|
|
|
: !!selectAll[list.id]
|
|
|
|
|
}
|
|
|
|
|
onCheckedChange={(e) =>
|
|
|
|
|
handleSelectAllPolres(
|
|
|
|
|
list.id,
|
|
|
|
|
Boolean(e)
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
disabled={unit.includes("3")}
|
|
|
|
|
/>
|
|
|
|
|
<label
|
|
|
|
|
htmlFor="all-polres"
|
|
|
|
|
className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
|
|
|
|
>
|
|
|
|
|
Pilih Semua Polres
|
|
|
|
|
</label>
|
|
|
|
|
</div>
|
|
|
|
|
{list.subDestination.map(
|
|
|
|
|
(subDes: any) => (
|
|
|
|
|
<div
|
|
|
|
|
key={subDes.id}
|
|
|
|
|
className="flex items-center space-x-2"
|
|
|
|
|
>
|
|
|
|
|
<Checkbox
|
|
|
|
|
id={`${list.id}${subDes.id}`}
|
|
|
|
|
checked={
|
|
|
|
|
unit.includes("3")
|
|
|
|
|
? true
|
|
|
|
|
: !!selected[
|
|
|
|
|
`${list.id}${subDes.id}`
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
onCheckedChange={() =>
|
|
|
|
|
handleChildChange(
|
|
|
|
|
`${list.id}${subDes.id}`
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
disabled={unit.includes("3")}
|
|
|
|
|
/>
|
|
|
|
|
<label
|
|
|
|
|
htmlFor={`${list.id}${subDes.id}`}
|
|
|
|
|
className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
|
|
|
|
>
|
|
|
|
|
{subDes.name}
|
|
|
|
|
</label>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</AccordionContent>
|
|
|
|
|
</AccordionItem>
|
|
|
|
|
</Accordion>
|
|
|
|
|
</div>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
</DialogContent>
|
|
|
|
|
</Dialog>
|
|
|
|
|
</div>
|
|
|
|
|
<FormMessage />
|
|
|
|
|
</FormItem>
|
|
|
|
|
)}
|
|
|
|
|
/>
|
|
|
|
|
<FormField
|
|
|
|
|
control={form.control}
|
|
|
|
|
name="media"
|
|
|
|
|
render={() => (
|
|
|
|
|
<FormItem>
|
|
|
|
|
<div className="mb-4">
|
|
|
|
|
<FormLabel className="text-sm">Jenis Platform</FormLabel>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="flex flex-row gap-3 items-center ">
|
|
|
|
|
<div className="flex items-center gap-3">
|
|
|
|
|
<Checkbox
|
|
|
|
|
id="all"
|
|
|
|
|
checked={isAllMediaChecked}
|
|
|
|
|
onCheckedChange={(checked) => {
|
|
|
|
|
if (checked) {
|
|
|
|
|
form.setValue(
|
|
|
|
|
"media",
|
|
|
|
|
medias.map((item) => item.id)
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
form.setValue("media", []);
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
<label htmlFor="all" className="text-sm">
|
|
|
|
|
Semua
|
|
|
|
|
</label>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{medias.map((item) => (
|
|
|
|
|
<FormField
|
|
|
|
|
key={item.id}
|
|
|
|
|
control={form.control}
|
|
|
|
|
name="output"
|
|
|
|
|
render={({ field }) => {
|
|
|
|
|
return (
|
|
|
|
|
<FormItem
|
|
|
|
|
key={item.id}
|
|
|
|
|
className="flex flex-row items-start space-x-3 space-y-0"
|
|
|
|
|
>
|
|
|
|
|
<FormControl>
|
|
|
|
|
<Checkbox
|
|
|
|
|
checked={media?.includes(item.id)}
|
|
|
|
|
onCheckedChange={(checked) => {
|
|
|
|
|
form.setValue(
|
|
|
|
|
"media",
|
|
|
|
|
checked
|
|
|
|
|
? [...media, item.id]
|
|
|
|
|
: media.filter(
|
|
|
|
|
(value) => value !== item.id
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}}
|
2024-12-26 12:52:20 +00:00
|
|
|
/>
|
|
|
|
|
</FormControl>
|
|
|
|
|
<FormLabel className="font-normal">
|
|
|
|
|
{item.label}
|
|
|
|
|
</FormLabel>
|
|
|
|
|
</FormItem>
|
|
|
|
|
);
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
<FormMessage />
|
|
|
|
|
</FormItem>
|
|
|
|
|
)}
|
|
|
|
|
/>
|
|
|
|
|
<FormField
|
|
|
|
|
control={form.control}
|
|
|
|
|
name="type"
|
|
|
|
|
render={({ field }) => (
|
|
|
|
|
<FormItem>
|
|
|
|
|
<FormLabel>Jenis Penugasan</FormLabel>
|
|
|
|
|
<FormControl>
|
|
|
|
|
<RadioGroup
|
|
|
|
|
onValueChange={field.onChange}
|
|
|
|
|
defaultValue={field.value}
|
|
|
|
|
className="flex flex-row gap-3"
|
|
|
|
|
>
|
|
|
|
|
<FormItem className="flex items-center space-x-3 space-y-0">
|
|
|
|
|
<FormControl>
|
2024-12-27 14:14:58 +00:00
|
|
|
<RadioGroupItem value="1" />
|
2024-12-26 12:52:20 +00:00
|
|
|
</FormControl>
|
|
|
|
|
<FormLabel className="font-normal">
|
|
|
|
|
Publikasi
|
|
|
|
|
</FormLabel>
|
|
|
|
|
</FormItem>
|
|
|
|
|
<FormItem className="flex items-center space-x-3 space-y-0">
|
|
|
|
|
<FormControl>
|
2024-12-27 14:14:58 +00:00
|
|
|
<RadioGroupItem value="2" />
|
2024-12-26 12:52:20 +00:00
|
|
|
</FormControl>
|
|
|
|
|
<FormLabel className="font-normal">
|
|
|
|
|
Amplifikasi
|
|
|
|
|
</FormLabel>
|
|
|
|
|
</FormItem>
|
|
|
|
|
<FormItem className="flex items-center space-x-3 space-y-0">
|
|
|
|
|
<FormControl>
|
2024-12-27 14:14:58 +00:00
|
|
|
<RadioGroupItem value="3" />
|
2024-12-26 12:52:20 +00:00
|
|
|
</FormControl>
|
|
|
|
|
<FormLabel className="font-normal">Kontra</FormLabel>
|
|
|
|
|
</FormItem>
|
|
|
|
|
</RadioGroup>
|
|
|
|
|
</FormControl>
|
|
|
|
|
<FormMessage />
|
|
|
|
|
</FormItem>
|
|
|
|
|
)}
|
|
|
|
|
/>
|
2024-12-27 14:14:58 +00:00
|
|
|
<FormField
|
|
|
|
|
control={form.control}
|
|
|
|
|
name="parentId"
|
|
|
|
|
render={({ field }) => (
|
|
|
|
|
<FormItem>
|
|
|
|
|
<FormLabel>Perencanaan Mingguan</FormLabel>
|
|
|
|
|
<Select value={field.value} onValueChange={field.onChange}>
|
|
|
|
|
<FormControl>
|
|
|
|
|
<SelectTrigger>
|
|
|
|
|
<SelectValue />
|
|
|
|
|
</SelectTrigger>
|
|
|
|
|
</FormControl>
|
|
|
|
|
<SelectContent>
|
|
|
|
|
{weeklyList?.map((list: any) => (
|
|
|
|
|
<SelectItem key={list.id} value={list.value}>
|
|
|
|
|
{list.label}
|
|
|
|
|
</SelectItem>
|
|
|
|
|
))}
|
|
|
|
|
</SelectContent>
|
|
|
|
|
</Select>
|
|
|
|
|
|
|
|
|
|
<FormMessage />
|
|
|
|
|
</FormItem>
|
|
|
|
|
)}
|
|
|
|
|
/>
|
2024-12-26 12:52:20 +00:00
|
|
|
<FormField
|
|
|
|
|
control={form.control}
|
|
|
|
|
name="date"
|
|
|
|
|
render={({ field }) => (
|
|
|
|
|
<FormItem className="flex flex-col">
|
|
|
|
|
<FormLabel>Pilih Tanggal</FormLabel>
|
|
|
|
|
<Popover>
|
|
|
|
|
<PopoverTrigger asChild>
|
|
|
|
|
<Button
|
|
|
|
|
variant={"outline"}
|
|
|
|
|
className={cn(
|
|
|
|
|
"w-[280px] justify-start text-left font-normal",
|
|
|
|
|
!field.value && "text-muted-foreground"
|
|
|
|
|
)}
|
|
|
|
|
>
|
|
|
|
|
<CalendarIcon className="mr-2 h-4 w-4" />
|
|
|
|
|
{field.value ? (
|
|
|
|
|
format(field.value, "PPP")
|
|
|
|
|
) : (
|
|
|
|
|
<span>Masukkan Tanggal</span>
|
|
|
|
|
)}
|
|
|
|
|
</Button>
|
|
|
|
|
</PopoverTrigger>
|
|
|
|
|
<PopoverContent className="w-auto p-0">
|
|
|
|
|
<Calendar
|
|
|
|
|
mode="single"
|
|
|
|
|
selected={field.value}
|
|
|
|
|
onSelect={field.onChange}
|
|
|
|
|
initialFocus
|
|
|
|
|
/>
|
|
|
|
|
</PopoverContent>
|
|
|
|
|
</Popover>
|
|
|
|
|
<FormMessage />
|
|
|
|
|
</FormItem>
|
|
|
|
|
)}
|
|
|
|
|
/>
|
|
|
|
|
<FormField
|
|
|
|
|
control={form.control}
|
|
|
|
|
name="detail"
|
2025-05-05 14:53:47 +00:00
|
|
|
render={({ field: { onChange, value } }) => (
|
2024-12-26 12:52:20 +00:00
|
|
|
<FormItem>
|
|
|
|
|
<FormLabel>Detail Perencanaan</FormLabel>
|
2025-05-05 14:53:47 +00:00
|
|
|
<CustomEditor onChange={onChange} initialData={value} />
|
2024-12-26 12:52:20 +00:00
|
|
|
|
|
|
|
|
<FormMessage />
|
|
|
|
|
</FormItem>
|
|
|
|
|
)}
|
|
|
|
|
/>
|
|
|
|
|
<div className="flex flex-row gap-2 justify-end mt-4 pt-4">
|
|
|
|
|
<Button type="submit" variant="outline" color="destructive">
|
|
|
|
|
Cancel
|
|
|
|
|
</Button>
|
|
|
|
|
<Button type="submit" color="primary">
|
|
|
|
|
Submit
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
</form>
|
|
|
|
|
</Form>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|