fixing
This commit is contained in:
parent
74265cb797
commit
3bf251b53c
|
|
@ -138,28 +138,27 @@ export default function EditCategoryModal(props: {
|
||||||
maxFiles: 1,
|
maxFiles: 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
// useEffect(() => {
|
||||||
const initFetch = async () => {
|
// initFetch();
|
||||||
const req = await getCategoryDetail(id);
|
// }, [id]);
|
||||||
const data = req?.data?.data;
|
|
||||||
console.log("dataC", data);
|
|
||||||
form.setValue("id", String(data?.id));
|
|
||||||
form.setValue("title", String(data?.name));
|
|
||||||
form.setValue("description", String(data?.description));
|
|
||||||
form.setValue("contentType", data?.mediaTypes?.split(",") || []);
|
|
||||||
form.setValue(
|
|
||||||
"selectedUser",
|
|
||||||
removeAndReturn(data?.publishedFor, [2, 3, 4])
|
|
||||||
);
|
|
||||||
form.setValue("publishTo", data?.publishedLocation?.split(",") || []);
|
|
||||||
form.setValue("file", thumbnailLink);
|
|
||||||
|
|
||||||
setUnitData(filterString(data?.publishedLocationLevel, "under"));
|
const initFetch = async () => {
|
||||||
setSatkerData(filterString(data?.publishedLocationLevel, "above"));
|
const req = await getCategoryDetail(id);
|
||||||
};
|
const data = req?.data?.data;
|
||||||
|
form.setValue("id", String(data?.id));
|
||||||
|
form.setValue("title", String(data?.name));
|
||||||
|
form.setValue("description", String(data?.description));
|
||||||
|
form.setValue("contentType", data?.mediaTypes?.split(",") || []);
|
||||||
|
form.setValue(
|
||||||
|
"selectedUser",
|
||||||
|
removeAndReturn(data?.publishedFor, [2, 3, 4])
|
||||||
|
);
|
||||||
|
form.setValue("publishTo", data?.publishedLocation?.split(",") || []);
|
||||||
|
form.setValue("file", thumbnailLink);
|
||||||
|
|
||||||
initFetch();
|
setUnitData(filterString(data?.publishedLocationLevel, "under"));
|
||||||
}, [id]);
|
setSatkerData(filterString(data?.publishedLocationLevel, "above"));
|
||||||
|
};
|
||||||
|
|
||||||
function removeAndReturn(inputString: string, toRemove: number[]) {
|
function removeAndReturn(inputString: string, toRemove: number[]) {
|
||||||
const numbers = inputString?.split(",").map(Number);
|
const numbers = inputString?.split(",").map(Number);
|
||||||
|
|
@ -183,17 +182,16 @@ export default function EditCategoryModal(props: {
|
||||||
}
|
}
|
||||||
|
|
||||||
const contentType = form.watch("contentType");
|
const contentType = form.watch("contentType");
|
||||||
const isAllContentChecked = contentType && listContent.every((item) =>
|
const isAllContentChecked =
|
||||||
contentType.includes(item.id)
|
contentType && listContent.every((item) => contentType.includes(item.id));
|
||||||
);
|
|
||||||
|
|
||||||
const users = form.watch("selectedUser");
|
const users = form.watch("selectedUser");
|
||||||
const isAllUserChecked = users && userList.every((item) => users.includes(item.id));
|
const isAllUserChecked =
|
||||||
|
users && userList.every((item) => users.includes(item.id));
|
||||||
|
|
||||||
const target = form.watch("publishTo");
|
const target = form.watch("publishTo");
|
||||||
const isAllTargetChecked = target && publishToList.every((item) =>
|
const isAllTargetChecked =
|
||||||
target.includes(item.id)
|
target && publishToList.every((item) => target.includes(item.id));
|
||||||
);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getRoles();
|
getRoles();
|
||||||
|
|
@ -213,6 +211,7 @@ export default function EditCategoryModal(props: {
|
||||||
const uniqueNumbers = Array.from(new Set(numbers));
|
const uniqueNumbers = Array.from(new Set(numbers));
|
||||||
return uniqueNumbers.join(",");
|
return uniqueNumbers.join(",");
|
||||||
}
|
}
|
||||||
|
|
||||||
const onSubmit = async (data: z.infer<typeof FormSchema>) => {
|
const onSubmit = async (data: z.infer<typeof FormSchema>) => {
|
||||||
const formMedia = new FormData();
|
const formMedia = new FormData();
|
||||||
|
|
||||||
|
|
@ -263,7 +262,9 @@ export default function EditCategoryModal(props: {
|
||||||
<Dialog open={isOpen} onOpenChange={setIsOpen}>
|
<Dialog open={isOpen} onOpenChange={setIsOpen}>
|
||||||
<DialogTrigger>
|
<DialogTrigger>
|
||||||
<a
|
<a
|
||||||
onClick={() => setIsOpen(true)}
|
onClick={() =>{
|
||||||
|
initFetch()
|
||||||
|
setIsOpen(true); } }
|
||||||
className="hover:underline cursor-pointer"
|
className="hover:underline cursor-pointer"
|
||||||
>
|
>
|
||||||
{isDetail ? "Detail" : "Edit"}
|
{isDetail ? "Detail" : "Edit"}
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ import {
|
||||||
} from "@/components/ui/dropdown-menu";
|
} from "@/components/ui/dropdown-menu";
|
||||||
import { Label } from "@/components/ui/label";
|
import { Label } from "@/components/ui/label";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
import { format } from "date-fns";
|
import { format, parseISO } from "date-fns";
|
||||||
import useTableColumns from "./columns";
|
import useTableColumns from "./columns";
|
||||||
import Swal from "sweetalert2";
|
import Swal from "sweetalert2";
|
||||||
import withReactContent from "sweetalert2-react-content";
|
import withReactContent from "sweetalert2-react-content";
|
||||||
|
|
@ -159,22 +159,28 @@ const TableSPIT = () => {
|
||||||
}
|
}
|
||||||
}, [searchParams]);
|
}, [searchParams]);
|
||||||
|
|
||||||
React.useEffect(() => {
|
// React.useEffect(() => {
|
||||||
fetchData();
|
// fetchData();
|
||||||
}, [showData, page, search, statusFilter, dateFilter]);
|
// }, [showData, page, search, statusFilter, dateFilter]);
|
||||||
|
|
||||||
|
// React.useEffect(() => {
|
||||||
|
// fetchData();
|
||||||
|
// getCategories();
|
||||||
|
// }, [
|
||||||
|
// // categoryFilter,
|
||||||
|
// statusFilter,
|
||||||
|
// page,
|
||||||
|
// showData,
|
||||||
|
// search,
|
||||||
|
// // startDate,
|
||||||
|
// // endDate,
|
||||||
|
// ]);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
fetchData();
|
fetchData();
|
||||||
getCategories();
|
getCategories();
|
||||||
}, [
|
console.log("TRIGGERRRR");
|
||||||
// categoryFilter,
|
}, [statusFilter, page, showData, search, dateFilter]);
|
||||||
statusFilter,
|
|
||||||
page,
|
|
||||||
showData,
|
|
||||||
search,
|
|
||||||
// startDate,
|
|
||||||
// endDate,
|
|
||||||
]);
|
|
||||||
|
|
||||||
async function getCategories() {
|
async function getCategories() {
|
||||||
const category = await listEnableCategory("4");
|
const category = await listEnableCategory("4");
|
||||||
|
|
@ -193,7 +199,7 @@ const TableSPIT = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const formattedStartDate = dateFilter
|
const formattedStartDate = dateFilter
|
||||||
? format(new Date(dateFilter), "yyyy-MM-dd")
|
? format(parseISO(dateFilter), "yyyy-MM-dd")
|
||||||
: "";
|
: "";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
@ -211,8 +217,6 @@ const TableSPIT = () => {
|
||||||
item.no = (page - 1) * Number(showData) + index + 1;
|
item.no = (page - 1) * Number(showData) + index + 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("contentData : ", contentData);
|
|
||||||
|
|
||||||
setSpitTable(contentData);
|
setSpitTable(contentData);
|
||||||
setTotalData(data?.totalElements);
|
setTotalData(data?.totalElements);
|
||||||
setTotalPage(data?.totalPages);
|
setTotalPage(data?.totalPages);
|
||||||
|
|
@ -371,36 +375,35 @@ const TableSPIT = () => {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{table.getSelectedRowModel().rows.length > 0 && (
|
{table.getSelectedRowModel().rows.length > 0 && (
|
||||||
<div className="mt-4 px-5">
|
<div className="mt-4 px-5">
|
||||||
<Button
|
<Button
|
||||||
variant="default"
|
variant="default"
|
||||||
size="sm"
|
size="sm"
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
const ids = table
|
const ids = table
|
||||||
.getSelectedRowModel()
|
.getSelectedRowModel()
|
||||||
.rows.map((row) => row.original.contentId);
|
.rows.map((row) => row.original.contentId);
|
||||||
|
|
||||||
const confirm = await MySwal.fire({
|
const confirm = await MySwal.fire({
|
||||||
title: "Yakin ingin menghapus?",
|
title: "Yakin ingin menghapus?",
|
||||||
text: `Anda akan menghapus ${ids.length} item.`,
|
text: `Anda akan menghapus ${ids.length} item.`,
|
||||||
icon: "warning",
|
icon: "warning",
|
||||||
showCancelButton: true,
|
showCancelButton: true,
|
||||||
confirmButtonText: "Ya, hapus",
|
confirmButtonText: "Ya, hapus",
|
||||||
cancelButtonText: "Batal",
|
cancelButtonText: "Batal",
|
||||||
});
|
});
|
||||||
|
|
||||||
if (confirm.isConfirmed) {
|
|
||||||
onSubmitDelete(ids);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
className="bg-red-600 text-white"
|
|
||||||
>
|
|
||||||
<Trash2 className="w-4 h-4 mr-2" />
|
|
||||||
Hapus yang dipilih ({table.getSelectedRowModel().rows.length})
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
|
if (confirm.isConfirmed) {
|
||||||
|
onSubmitDelete(ids);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
className="bg-red-600 text-white"
|
||||||
|
>
|
||||||
|
<Trash2 className="w-4 h-4 mr-2" />
|
||||||
|
Hapus yang dipilih ({table.getSelectedRowModel().rows.length})
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
<Table className="overflow-hidden mt-3">
|
<Table className="overflow-hidden mt-3">
|
||||||
<TableHeader>
|
<TableHeader>
|
||||||
|
|
|
||||||
|
|
@ -418,7 +418,7 @@ export default function FilterPage() {
|
||||||
if (searchTitle == "" || searchTitle == undefined) {
|
if (searchTitle == "" || searchTitle == undefined) {
|
||||||
router.push("?title=");
|
router.push("?title=");
|
||||||
} else {
|
} else {
|
||||||
router.push(`?title=${searchTitle}`);
|
router.push(`?title=${searchTitle.toLowerCase()}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -569,7 +569,7 @@ export default function FormConvertSPIT() {
|
||||||
if (pnmhTags.length > 1) {
|
if (pnmhTags.length > 1) {
|
||||||
MySwal.fire({
|
MySwal.fire({
|
||||||
title: "Error",
|
title: "Error",
|
||||||
text: "Tags penugasan hanya diperbolehkan 1 (satu) saja.",
|
text: "Tags penugasan hanya diperbolehkan 1 (satu) saja.",
|
||||||
icon: "error",
|
icon: "error",
|
||||||
confirmButtonColor: "#3085d6",
|
confirmButtonColor: "#3085d6",
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -123,7 +123,6 @@ export default function IndeksCarouselComponent(props: {
|
||||||
? getOnlyMonthAndYear(monthYearFilter)?.split("/")[1]
|
? getOnlyMonthAndYear(monthYearFilter)?.split("/")[1]
|
||||||
: "";
|
: "";
|
||||||
|
|
||||||
// Gunakan group hanya jika asPath mengandung /polda/ atau /satker/, selain itu kosongkan
|
|
||||||
let filterGroup = "";
|
let filterGroup = "";
|
||||||
if (asPath.includes("/polda/") || asPath.includes("/satker/")) {
|
if (asPath.includes("/polda/") || asPath.includes("/satker/")) {
|
||||||
filterGroup = group ?? asPath.split("/")[2];
|
filterGroup = group ?? asPath.split("/")[2];
|
||||||
|
|
@ -132,15 +131,15 @@ export default function IndeksCarouselComponent(props: {
|
||||||
try {
|
try {
|
||||||
loading();
|
loading();
|
||||||
const response = await getIndeksDataFilter(
|
const response = await getIndeksDataFilter(
|
||||||
"4", // type
|
"4",
|
||||||
name, // title
|
name,
|
||||||
filter, // kategori
|
filter,
|
||||||
12, // size
|
12,
|
||||||
0, // page
|
0,
|
||||||
sortByOpt, // sortBy
|
sortByOpt,
|
||||||
"",
|
"",
|
||||||
"", // provinceId, cityId
|
"",
|
||||||
filterGroup, // group
|
filterGroup,
|
||||||
startDateString,
|
startDateString,
|
||||||
endDateString,
|
endDateString,
|
||||||
month,
|
month,
|
||||||
|
|
|
||||||
|
|
@ -251,7 +251,7 @@ const Navbar = () => {
|
||||||
|
|
||||||
<PopoverContent className="flex flex-col gap-2 w-fit px-6 py-4 rounded-md shadow-md bg-white dark:bg-black">
|
<PopoverContent className="flex flex-col gap-2 w-fit px-6 py-4 rounded-md shadow-md bg-white dark:bg-black">
|
||||||
<Link
|
<Link
|
||||||
href={prefixPath + "/image/filter"}
|
href={prefixPath + "image/filter"}
|
||||||
// onClick={() => router.push(prefixPath + "/image/filter")}
|
// onClick={() => router.push(prefixPath + "/image/filter")}
|
||||||
className="flex items-center text-slate-600 dark:text-white hover:text-[#bb3523]"
|
className="flex items-center text-slate-600 dark:text-white hover:text-[#bb3523]"
|
||||||
>
|
>
|
||||||
|
|
@ -259,7 +259,7 @@ const Navbar = () => {
|
||||||
{t("image", { defaultValue: "Image" })}
|
{t("image", { defaultValue: "Image" })}
|
||||||
</Link>
|
</Link>
|
||||||
<Link
|
<Link
|
||||||
href={prefixPath + "/video/filter"}
|
href={prefixPath + "video/filter"}
|
||||||
// onClick={() => router.push(prefixPath + "/video/filter")}
|
// onClick={() => router.push(prefixPath + "/video/filter")}
|
||||||
className="flex items-center text-slate-600 dark:text-white hover:text-[#bb3523]"
|
className="flex items-center text-slate-600 dark:text-white hover:text-[#bb3523]"
|
||||||
>
|
>
|
||||||
|
|
@ -267,7 +267,7 @@ const Navbar = () => {
|
||||||
{t("video", { defaultValue: "Video" })}
|
{t("video", { defaultValue: "Video" })}
|
||||||
</Link>
|
</Link>
|
||||||
<Link
|
<Link
|
||||||
href={prefixPath + "/document/filter"}
|
href={prefixPath + "document/filter"}
|
||||||
// onClick={() => router.push(prefixPath + "/document/filter")}
|
// onClick={() => router.push(prefixPath + "/document/filter")}
|
||||||
className="flex items-center text-slate-600 dark:text-white hover:text-[#bb3523]"
|
className="flex items-center text-slate-600 dark:text-white hover:text-[#bb3523]"
|
||||||
>
|
>
|
||||||
|
|
@ -275,7 +275,7 @@ const Navbar = () => {
|
||||||
{t("text", { defaultValue: "Text" })}
|
{t("text", { defaultValue: "Text" })}
|
||||||
</Link>
|
</Link>
|
||||||
<Link
|
<Link
|
||||||
href={prefixPath + "/audio/filter"}
|
href={prefixPath + "audio/filter"}
|
||||||
// onClick={() => router.push(prefixPath + "/audio/filter")}
|
// onClick={() => router.push(prefixPath + "/audio/filter")}
|
||||||
className="flex items-center text-slate-600 dark:text-white hover:text-[#bb3523]"
|
className="flex items-center text-slate-600 dark:text-white hover:text-[#bb3523]"
|
||||||
>
|
>
|
||||||
|
|
|
||||||
|
|
@ -135,7 +135,7 @@ export async function listSPIT(
|
||||||
isPublish: any
|
isPublish: any
|
||||||
) {
|
) {
|
||||||
return await httpGetInterceptor(
|
return await httpGetInterceptor(
|
||||||
`media/spit/pagination?enablePage=1&page=${page}&size=${size}&sort=desc&sortBy=contentTitleId&title=${title}& contentCreatedDate=${contentCreatedDate}&isPublish=${isPublish}`
|
`media/spit/pagination?enablePage=1&page=${page}&size=${size}&sort=desc&sortBy=contentTitleId&title=${title}&startDate=${contentCreatedDate}&endDate=${contentCreatedDate}&isPublish=${isPublish}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,10 +30,12 @@ export async function getUserRoles() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getCategoryDetail(id: string) {
|
export async function getCategoryDetail(id: string) {
|
||||||
const url = `media/categories/${id}`;
|
const timestamp = Date.now();
|
||||||
|
const url = `media/categories/${id}?timemilis=${timestamp}`;
|
||||||
return httpGetInterceptor(url);
|
return httpGetInterceptor(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export async function postCategory(data: any) {
|
export async function postCategory(data: any) {
|
||||||
const url = "media/categories";
|
const url = "media/categories";
|
||||||
const headers = {
|
const headers = {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue