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