feat:update agenda setting, detail penugasan
This commit is contained in:
parent
c9592c0d25
commit
a331460cef
|
|
@ -10,7 +10,7 @@ import { Label } from "@/components/ui/label";
|
||||||
import ExternalDraggingevent from "./dragging-events";
|
import ExternalDraggingevent from "./dragging-events";
|
||||||
import { Calendar } from "@/components/ui/calendar";
|
import { Calendar } from "@/components/ui/calendar";
|
||||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||||
import { Book, Plus } from "lucide-react";
|
import { Book, CheckSquare2, CheckSquare2Icon, Plus } from "lucide-react";
|
||||||
import { Checkbox } from "@/components/ui/checkbox";
|
import { Checkbox } from "@/components/ui/checkbox";
|
||||||
import { EventContentArg } from "@fullcalendar/core";
|
import { EventContentArg } from "@fullcalendar/core";
|
||||||
import EventModal from "./event-modal";
|
import EventModal from "./event-modal";
|
||||||
|
|
@ -334,11 +334,17 @@ const CalendarView = ({ categories }: CalendarViewProps) => {
|
||||||
|
|
||||||
const renderEventContent = (eventInfo: any) => {
|
const renderEventContent = (eventInfo: any) => {
|
||||||
const { title } = eventInfo.event;
|
const { title } = eventInfo.event;
|
||||||
|
const { isPublish } = eventInfo.event.extendedProps;
|
||||||
const { createdByName } = eventInfo.event.extendedProps;
|
const { createdByName } = eventInfo.event.extendedProps;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
<div className="flex flex-row">
|
||||||
|
{" "}
|
||||||
|
{isPublish && <CheckSquare2 />}
|
||||||
<p className="ml-1">{title}</p>
|
<p className="ml-1">{title}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
<p className="ml-1 text-xs text-start mt-2">
|
<p className="ml-1 text-xs text-start mt-2">
|
||||||
Created By : {createdByName}
|
Created By : {createdByName}
|
||||||
</p>
|
</p>
|
||||||
|
|
@ -437,7 +443,10 @@ const CalendarView = ({ categories }: CalendarViewProps) => {
|
||||||
className={`w-full p-1 mb-2 rounded-md text-white text-sm ${bgColor}`}
|
className={`w-full p-1 mb-2 rounded-md text-white text-sm ${bgColor}`}
|
||||||
onClick={() => handleClickListItem(item)}
|
onClick={() => handleClickListItem(item)}
|
||||||
>
|
>
|
||||||
|
<div className="flex flex-row items-center">
|
||||||
|
<CheckSquare2Icon />
|
||||||
<p className="ml-1">{text}</p>
|
<p className="ml-1">{text}</p>
|
||||||
|
</div>
|
||||||
<p className="ml-1 text-xs text-start mt-2">Created By: {createdBy}</p>
|
<p className="ml-1 text-xs text-start mt-2">Created By: {createdBy}</p>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,7 @@ import { postSchedule } from "@/service/schedule/schedule";
|
||||||
import {
|
import {
|
||||||
deleteAgendaSettings,
|
deleteAgendaSettings,
|
||||||
getAgendaSettingsById,
|
getAgendaSettingsById,
|
||||||
|
publishAgendaSettings,
|
||||||
saveAgendaSettings,
|
saveAgendaSettings,
|
||||||
} from "@/service/agenda-setting/agenda-setting";
|
} from "@/service/agenda-setting/agenda-setting";
|
||||||
import { Checkbox } from "@/components/ui/checkbox";
|
import { Checkbox } from "@/components/ui/checkbox";
|
||||||
|
|
@ -153,6 +154,7 @@ const EventModal = ({
|
||||||
const [selectedPolres, setSelectedPolres] = React.useState([]);
|
const [selectedPolres, setSelectedPolres] = React.useState([]);
|
||||||
const [wavesurfer, setWavesurfer] = useState<WaveSurfer>();
|
const [wavesurfer, setWavesurfer] = useState<WaveSurfer>();
|
||||||
const [isPlaying, setIsPlaying] = useState(false);
|
const [isPlaying, setIsPlaying] = useState(false);
|
||||||
|
const [isPublishing, setIsPublishing] = useState(false);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
register,
|
register,
|
||||||
|
|
@ -293,7 +295,7 @@ const EventModal = ({
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const save = async (data: any) => {
|
const save = async (data: any, publish = false) => {
|
||||||
const publishTo = [];
|
const publishTo = [];
|
||||||
if (wilayahPublish.semua) publishTo.push("all");
|
if (wilayahPublish.semua) publishTo.push("all");
|
||||||
if (wilayahPublish.nasional) publishTo.push("mabes");
|
if (wilayahPublish.nasional) publishTo.push("mabes");
|
||||||
|
|
@ -356,6 +358,18 @@ const EventModal = ({
|
||||||
"0" // Optional: Replace with actual duration if available
|
"0" // Optional: Replace with actual duration if available
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
if (publish) {
|
||||||
|
setIsPublishing(true);
|
||||||
|
const publishResponse = await publishAgendaSettings(id);
|
||||||
|
setIsPublishing(false);
|
||||||
|
|
||||||
|
if (publishResponse?.error) {
|
||||||
|
error(publishResponse?.message);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
success("Agenda berhasil dipublikasikan!");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSubmit = (data: any) => {
|
const onSubmit = (data: any) => {
|
||||||
|
|
@ -1120,9 +1134,18 @@ const EventModal = ({
|
||||||
</div>
|
</div>
|
||||||
{detailData && (
|
{detailData && (
|
||||||
<div>
|
<div>
|
||||||
<Button variant={"outline"} color="primary">
|
{roleId == 11 || roleId == 12 ? (
|
||||||
Kirim Ke Mabes
|
<Button
|
||||||
|
variant={"outline"}
|
||||||
|
color="primary"
|
||||||
|
onClick={() => save(detailData, true)}
|
||||||
|
disabled={isPublishing}
|
||||||
|
>
|
||||||
|
{isPublishing ? "Publishing..." : "Kirim Ke Mabes"}
|
||||||
</Button>
|
</Button>
|
||||||
|
) : (
|
||||||
|
""
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ import {
|
||||||
getAcceptance,
|
getAcceptance,
|
||||||
getAcceptanceAssignmentStatus,
|
getAcceptanceAssignmentStatus,
|
||||||
getAssignmentResponseList,
|
getAssignmentResponseList,
|
||||||
|
getMediaUpload,
|
||||||
getTask,
|
getTask,
|
||||||
getUserLevelForAssignments,
|
getUserLevelForAssignments,
|
||||||
} from "@/service/task";
|
} from "@/service/task";
|
||||||
|
|
@ -192,6 +193,7 @@ export default function FormTaskDetail() {
|
||||||
|
|
||||||
const userLevelNumber = getCookiesDecrypt("ulne");
|
const userLevelNumber = getCookiesDecrypt("ulne");
|
||||||
const userId = getCookiesDecrypt("uie");
|
const userId = getCookiesDecrypt("uie");
|
||||||
|
const userLevelId = getCookiesDecrypt("ulie");
|
||||||
|
|
||||||
// State for various form fields
|
// State for various form fields
|
||||||
const [taskOutput, setTaskOutput] = useState({
|
const [taskOutput, setTaskOutput] = useState({
|
||||||
|
|
@ -227,6 +229,9 @@ export default function FormTaskDetail() {
|
||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const [totalPage, setTotalPage] = React.useState(1);
|
||||||
|
const [dataTable, setDataTable] = React.useState<any[]>([]);
|
||||||
|
const [totalData, setTotalData] = React.useState<number>(1);
|
||||||
const [imageFiles, setImageFiles] = useState<FileWithPreview[]>([]);
|
const [imageFiles, setImageFiles] = useState<FileWithPreview[]>([]);
|
||||||
const [videoFiles, setVideoFiles] = useState<FileWithPreview[]>([]);
|
const [videoFiles, setVideoFiles] = useState<FileWithPreview[]>([]);
|
||||||
const [textFiles, setTextFiles] = useState<FileWithPreview[]>([]);
|
const [textFiles, setTextFiles] = useState<FileWithPreview[]>([]);
|
||||||
|
|
@ -322,6 +327,19 @@ export default function FormTaskDetail() {
|
||||||
fetchPoldaPolres();
|
fetchPoldaPolres();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const fetchFilteredData = async (selectedLevels: any[]) => {
|
||||||
|
try {
|
||||||
|
const levels =
|
||||||
|
selectedLevels.length === 0 ? userLevelId : selectedLevels.join(",");
|
||||||
|
|
||||||
|
const response = await getMediaUpload(id, levels);
|
||||||
|
|
||||||
|
setUploadResults(response?.data?.data || []);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error fetching filtered data:", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function initState() {
|
async function initState() {
|
||||||
if (id) {
|
if (id) {
|
||||||
|
|
@ -330,9 +348,9 @@ export default function FormTaskDetail() {
|
||||||
|
|
||||||
setDetail(details);
|
setDetail(details);
|
||||||
|
|
||||||
if (details) {
|
// if (details) {
|
||||||
setUploadResults(details.uploadResults || []);
|
// setUploadResults(details.uploadResults || []);
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (details?.urls) {
|
if (details?.urls) {
|
||||||
// Extract attachmentUrl from each object in urls
|
// Extract attachmentUrl from each object in urls
|
||||||
|
|
@ -432,6 +450,25 @@ export default function FormTaskDetail() {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleCheckboxChangeFilter = async (id: number) => {
|
||||||
|
setCheckedLevels((prev: any) => {
|
||||||
|
const updatedLevels = new Set(prev);
|
||||||
|
|
||||||
|
if (updatedLevels.has(id)) {
|
||||||
|
updatedLevels.delete(id);
|
||||||
|
} else {
|
||||||
|
updatedLevels.add(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("Checked Levels:", Array.from(updatedLevels));
|
||||||
|
|
||||||
|
// Fetch data dengan filter userLevelId
|
||||||
|
fetchFilteredData(Array.from(updatedLevels));
|
||||||
|
|
||||||
|
return updatedLevels;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const toggleExpand = (poldaId: any) => {
|
const toggleExpand = (poldaId: any) => {
|
||||||
setExpandedPolda((prev: any) => ({
|
setExpandedPolda((prev: any) => ({
|
||||||
...prev,
|
...prev,
|
||||||
|
|
@ -1417,10 +1454,9 @@ export default function FormTaskDetail() {
|
||||||
<div key={polda.id} className="border p-2">
|
<div key={polda.id} className="border p-2">
|
||||||
<Label className="flex items-center">
|
<Label className="flex items-center">
|
||||||
<Checkbox
|
<Checkbox
|
||||||
disabled
|
|
||||||
checked={checkedLevels.has(polda.id)}
|
checked={checkedLevels.has(polda.id)}
|
||||||
onCheckedChange={() =>
|
onCheckedChange={() =>
|
||||||
handleCheckboxChange(polda.id)
|
handleCheckboxChangeFilter(polda.id)
|
||||||
}
|
}
|
||||||
className="mr-3"
|
className="mr-3"
|
||||||
/>
|
/>
|
||||||
|
|
@ -1440,7 +1476,6 @@ export default function FormTaskDetail() {
|
||||||
<div className="ml-6 mt-2">
|
<div className="ml-6 mt-2">
|
||||||
<Label className="block">
|
<Label className="block">
|
||||||
<Checkbox
|
<Checkbox
|
||||||
disabled
|
|
||||||
checked={polda?.subDestination?.every(
|
checked={polda?.subDestination?.every(
|
||||||
(polres: any) =>
|
(polres: any) =>
|
||||||
checkedLevels.has(polres.id)
|
checkedLevels.has(polres.id)
|
||||||
|
|
@ -1467,10 +1502,9 @@ export default function FormTaskDetail() {
|
||||||
{polda?.subDestination?.map((polres: any) => (
|
{polda?.subDestination?.map((polres: any) => (
|
||||||
<Label key={polres.id} className="block mt-1">
|
<Label key={polres.id} className="block mt-1">
|
||||||
<Checkbox
|
<Checkbox
|
||||||
disabled
|
|
||||||
checked={checkedLevels.has(polres.id)}
|
checked={checkedLevels.has(polres.id)}
|
||||||
onCheckedChange={() =>
|
onCheckedChange={() =>
|
||||||
handleCheckboxChange(polres.id)
|
handleCheckboxChangeFilter(polres.id)
|
||||||
}
|
}
|
||||||
className="mr-2"
|
className="mr-2"
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,11 @@ export async function saveAgendaSettings(data: any) {
|
||||||
return httpPostInterceptor(url, data);
|
return httpPostInterceptor(url, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function publishAgendaSettings(id: any) {
|
||||||
|
const url = `agenda-settings/publish?id=${id}`;
|
||||||
|
return httpPostInterceptor(url);
|
||||||
|
}
|
||||||
|
|
||||||
export async function getPlanningDailyByTypeId(
|
export async function getPlanningDailyByTypeId(
|
||||||
page: number,
|
page: number,
|
||||||
size = 10,
|
size = 10,
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,11 @@ export async function getTask(id: any) {
|
||||||
return httpGetInterceptor(url);
|
return httpGetInterceptor(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function getMediaUpload(id: any, userLevelId: any) {
|
||||||
|
const url = `/assignment/media-uploads?id=${id}&userLevelId=${userLevelId}`;
|
||||||
|
return httpGetInterceptor(url);
|
||||||
|
}
|
||||||
|
|
||||||
export async function forwardTask(data: any) {
|
export async function forwardTask(data: any) {
|
||||||
const url = "assignment/forward";
|
const url = "assignment/forward";
|
||||||
return httpPostInterceptor(url, data);
|
return httpPostInterceptor(url, data);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue