[QUDO-64,QUDO-63] feat:update modal tracking berita,Fix UI On Landing (responsive tablet belum sesuai)

This commit is contained in:
Anang Yusman 2025-05-15 18:18:33 +08:00
parent ba67105497
commit 63a88c0b94
6 changed files with 894 additions and 806 deletions

View File

@ -26,6 +26,7 @@ import {
} from "@/components/ui/table";
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
import {
ChevronDown,
ChevronLeft,
ChevronRight,
Eye,
@ -40,6 +41,7 @@ import {
import { cn } from "@/lib/utils";
import {
DropdownMenu,
DropdownMenuCheckboxItem,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuRadioGroup,
@ -68,12 +70,16 @@ import SearchDocumentComponent from "@/components/form/media-tracking/search-doc
import SearchAudioComponent from "@/components/form/media-tracking/search-audio-card";
import TrackingMediaModal from "./modal";
import { getMediaTracking } from "@/service/media-tracking/media-tracking";
import { group } from "console";
import router from "next/router";
import { title } from "process";
import { InputGroup, InputGroupText } from "@/components/ui/input-group";
import { Input } from "@/components/ui/input";
const NewsTable = () => {
const router = useRouter();
const asPath = usePathname();
const searchParams = useSearchParams();
const [search, setSearch] = React.useState("");
const [showData, setShowData] = React.useState("10");
const [categories, setCategories] = React.useState<any>();
const [dataTable, setDataTable] = React.useState<any[]>([]);
@ -96,10 +102,11 @@ const NewsTable = () => {
const [page, setPage] = React.useState(1);
const [imageData, setImageData] = React.useState<any>();
const [totalData, setTotalData] = React.useState<number>(1);
const [totalPage, setTotalPage] = React.useState<number>(1);
const [totalPage, setTotalPage] = React.useState(1);
const [contentAll, setContentAll] = React.useState([]);
const [formatFilter, setFormatFilter] = React.useState<any>([]);
const [totalContent, setTotalContent] = React.useState();
const [search, setSearch] = React.useState<string>("");
const group = searchParams?.get("group");
const title = searchParams?.get("title");
const categorie = searchParams?.get("category");
@ -144,25 +151,22 @@ const NewsTable = () => {
React.useEffect(() => {
getDataTable();
}, []);
}, [page, showData, search]);
const getDataTable = async () => {
const res = await getMediaTracking({ page: page - 1, size: 10 });
const res = await getMediaTracking(page - 1, search, showData);
const data = res?.data?.data;
console.log;
if (data) {
const startIndex = 10 * (page - 1);
let iterate = 0;
const newData = data.content.map((value: any) => {
iterate++;
value.no = startIndex + iterate;
return value;
const newData = data?.content;
newData.forEach((item: any, index: number) => {
item.no = (page - 1) * Number(showData) + index + 1;
});
setDataTable(newData);
setTotalData(data.totalElements);
setTotalData(data?.totalElements);
setTotalPage(data?.totalPages);
setTotalContent(data.totalElements);
}
};
async function getCategories() {
@ -203,33 +207,38 @@ const NewsTable = () => {
router.push(`?category=&title=`);
};
async function getData() {
if (asPath?.includes("/polda/") == true) {
if (asPath?.split("/")[2] !== "[polda_name]") {
const filter =
categoryFilter?.length > 0
? categoryFilter?.sort().join(",")
: categorie || "";
// async function getData() {
// if (asPath?.includes("/polda/") == true) {
// if (asPath?.split("/")[2] !== "[polda_name]") {
// const filter =
// categoryFilter?.length > 0
// ? categoryFilter?.sort().join(",")
// : categorie || "";
const name = title == undefined ? "" : title;
const format = formatFilter == undefined ? "" : formatFilter?.join(",");
const filterGroup = group == undefined ? asPath.split("/")[2] : group;
loading();
const response = await listDataAll("", name, filter, "");
close();
// setGetTotalPage(response?.data?.data?.totalPages);
// setContentImage(response?.data?.data?.content);
// const name = title == undefined ? "" : title;
// const format = formatFilter == undefined ? "" : formatFilter?.join(",");
// const filterGroup = group == undefined ? asPath.split("/")[2] : group;
// loading();
// const response = await listDataAll("", name, filter, "");
// close();
// // setGetTotalPage(response?.data?.data?.totalPages);
// // setContentImage(response?.data?.data?.content);
// // setTotalContent(response?.data?.data?.totalElements);
// const data = response?.data?.data;
// const contentData = data?.content;
// setImageData(contentData);
// setTotalData(data?.totalElements);
// setContentAll(response?.data?.data?.content);
// setTotalPage(data?.totalPages);
// setTotalContent(response?.data?.data?.totalElements);
const data = response?.data?.data;
const contentData = data?.content;
setImageData(contentData);
setTotalData(data?.totalElements);
setContentAll(response?.data?.data?.content);
setTotalPage(data?.totalPages);
setTotalContent(response?.data?.data?.totalElements);
}
}
}
// }
// }
// }
const handleSearch = (e: React.ChangeEvent<HTMLInputElement>) => {
setSearch(e.target.value);
table.getColumn("judul")?.setFilterValue(e.target.value);
};
const handleKeyUp = () => {
clearTimeout(typingTimer);
@ -255,50 +264,72 @@ const NewsTable = () => {
Tracking Berita hari ini!
</p>
</div>
<div className="flex flex-col sm:flex-row lg:flex-row justify-between sm:items-center md:items-center lg:items-center px-1">
<TrackingMediaModal triggerFetch={() => getDataTable()} />
{/* <Dialog>
<DialogTrigger asChild>
<Button className="bg-blue-600" size="md">
Tracking Berita
<div className=" flex flex-row items-center gap-3">
<div className="flex items-center py-2">
<div className="mx-3">
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button size="md" variant="outline">
1 - {showData} Data
</Button>
</DialogTrigger>
<DialogContent className="overflow-y-auto h-[500px] min-w-max mx-5">
<DialogHeader>
<DialogTitle>Form Tracking Berita</DialogTitle>
</DialogHeader>
<div className="grid gap-4 py-4 px-5">
<div className="space-y-2 flex flex-col">
<Label htmlFor="link" className="text-sm font-medium">
Masukkan Link <span className="text-red-500">*</span>
</Label>
<input
value={searchTitle}
onChange={(e) => setSearchTitle(e.target.value)}
onKeyUp={handleKeyUp}
onKeyDown={handleKeyDown}
type="text"
placeholder="Search..."
className="pl-4 pr-4 py-1 w-full h-10 text-[15px] border focus:outline-none dark:text-white"
/>
</div>
<div className="flex flex-col gap-2 w-full">
<SearchImageComponent categoryFilter={categoryFilter} />
<SearchVideoComponent categoryFilter={categoryFilter} />
<SearchDocumentComponent categoryFilter={categoryFilter} />
<SearchAudioComponent categoryFilter={categoryFilter} />
</DropdownMenuTrigger>
<DropdownMenuContent className="w-56 text-sm">
<DropdownMenuRadioGroup
value={showData}
onValueChange={setShowData}
>
<DropdownMenuRadioItem value="10">
1 - 10 Data
</DropdownMenuRadioItem>
<DropdownMenuRadioItem value="50">
1 - 50 Data
</DropdownMenuRadioItem>
<DropdownMenuRadioItem value="100">
1 - 100 Data
</DropdownMenuRadioItem>
<DropdownMenuRadioItem value="250">
1 - 250 Data
</DropdownMenuRadioItem>
</DropdownMenuRadioGroup>
</DropdownMenuContent>
</DropdownMenu>
</div>
</div>
<DialogFooter className="flex justify-end gap-2">
<Button onClick={cleanCheckbox} variant="outline">
Riset Filter
<div className="flex items-center py-4">
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="outline" className="ml-auto" size="md">
Columns <ChevronDown />
</Button>
<Button className="bg-blue-600 text-white">Tracking Berita</Button>
</DialogFooter>
</DialogContent>
</Dialog> */}
<Table className="overflow-hidden mt-4">
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
{table
.getAllColumns()
.filter((column) => column.getCanHide())
.map((column) => {
return (
<DropdownMenuCheckboxItem
key={column.id}
className="capitalize"
checked={column.getIsVisible()}
onCheckedChange={(value) =>
column.toggleVisibility(!!value)
}
>
{column.id}
</DropdownMenuCheckboxItem>
);
})}
</DropdownMenuContent>
</DropdownMenu>
</div>
</div>
</div>
<Table className="overflow-hidden">
<TableHeader>
{table.getHeaderGroups().map((headerGroup) => (
<TableRow key={headerGroup.id} className="bg-default-200">

View File

@ -58,6 +58,7 @@ import { error } from "@/lib/swal";
import dynamic from "next/dynamic";
import { useRouter } from "@/i18n/routing";
import { useTranslations } from "next-intl";
import { UnitMapping } from "@/app/[locale]/(protected)/contributor/agenda-setting/unit-mapping";
const imageSchema = z.object({
title: z.string().min(1, { message: "Judul diperlukan" }),
@ -142,6 +143,15 @@ export default function FormImageDetail() {
const [selectedTarget, setSelectedTarget] = useState("");
const [files, setFiles] = useState<FileType[]>([]);
const [rejectedFiles, setRejectedFiles] = useState<number[]>([]);
const [wilayahPublish, setWilayahPublish] = React.useState({
semua: false,
nasional: false,
polda: false,
polres: false,
satker: false,
international: false,
});
const [selectedPolda, setSelectedPolda] = React.useState([]);
let fileTypeId = "1";
@ -776,6 +786,15 @@ export default function FormImageDetail() {
>
Wilayah
</label>
{wilayahPublish.polda && (
<UnitMapping
unit="Polda"
isDetail={false}
sendDataToParent={(data: any) =>
setSelectedPolda(data)
}
/>
)}
</div>
<div className="flex items-center space-x-2">

View File

@ -438,7 +438,7 @@ const Hero: React.FC = () => {
className="w-full h-[73px] object-cover rounded-lg"
/>
</div>
<div className="w-[280px] lg:w-auto">
<div className="w-[280px] lg:w-[200px]">
<span className="text-white bg-[#bb3523] px-4 py-1 rounded-lg flex text-[8px] font-bold uppercase w-fit">
{item?.categoryName}
</span>
@ -487,7 +487,7 @@ const Hero: React.FC = () => {
className="w-full h-[73px] object-cover rounded-lg"
/>
</div>
<div className="w-[280px] lg:w-auto">
<div className="w-[280px] lg:w-[200px]">
<span className="text-white bg-[#bb3523] px-4 py-1 rounded-lg flex text-[8px] font-bold uppercase w-fit">
{item?.categoryName}
</span>
@ -534,7 +534,7 @@ const Hero: React.FC = () => {
className="w-full h-[73px] object-cover rounded-lg"
/>
</div>
<div className="w-[280px] lg:w-auto">
<div className="w-[280px] lg:w-[200px]">
<span className="text-white bg-[#bb3523] px-4 py-1 rounded-lg flex text-[8px] font-bold uppercase w-fit">
{item?.categoryName}
</span>

View File

@ -187,20 +187,24 @@ const Navbar = () => {
return (
<div className="bg-[#f7f7f7] dark:bg-black shadow-md sticky top-0 z-50">
<div className="flex items-center justify-between px-4 lg:px-20 py-0 gap-3">
<div className="flex flex-row gap-8">
{/* Logo */}
<div className="flex items-center justify-between px-4 lg:px-16 py-2 gap-3">
<div className="flex flex-row gap-2">
<Link href={prefixPath} className="flex items-center">
<Image src="/assets/mediahub-logo.gif" alt="Media Hub Logo" width={2560} height={1440} className="w-[125px] lg:w-[250px] h-[115px] lg:h-full object-contain" />
<Image
src="/assets/mediahub-logo.gif"
alt="Media Hub Logo"
width={2560}
height={1440}
className=" w-[200px] h-full shrink-0 object-contain"
/>
</Link>
{/* Nav Menu */}
<div className="hidden lg:flex items-center gap-5">
<div className="hidden custom-lg-button:flex items-center gap-5">
<NavigationMenu>
<NavigationMenuList>
<NavigationMenuItem>
<NavigationMenuTrigger>
<a className="dark:text-white text-black flex flex-row justify-center items-center cursor-pointer">
<a className="dark:text-white text-black flex flex-row justify-center items-center cursor-pointer ">
<svg
className="mx-2 dark:"
width="25"
@ -271,9 +275,7 @@ const Navbar = () => {
</NavigationMenuItem>
<NavigationMenuItem>
<Link href={prefixPath + "/schedule"} legacyBehavior passHref>
<NavigationMenuLink
className={navigationMenuTriggerStyle()}
>
<NavigationMenuLink className="group inline-flex h-10 w-max items-center justify-center rounded-md bg-[#f7f7f7] dark:bg-black xl:px-4 py-2 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground focus:outline-none disabled:pointer-events-none disabled:opacity-50 data-[active]:bg-accent/50 data-[state=open]:bg-accent/50">
<span>
<svg
className="mr-2"
@ -295,9 +297,7 @@ const Navbar = () => {
</NavigationMenuItem>
<NavigationMenuItem>
<Link href={prefixPath + "/indeks"} legacyBehavior passHref>
<NavigationMenuLink
className={navigationMenuTriggerStyle()}
>
<NavigationMenuLink className="group inline-flex h-10 w-max items-center justify-center rounded-md bg-[#f7f7f7] dark:bg-black xl:px-4 py-2 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground focus:outline-none disabled:pointer-events-none disabled:opacity-50 data-[active]:bg-accent/50 data-[state=open]:bg-accent/50">
<span>
<svg
className="mr-2"
@ -325,39 +325,9 @@ const Navbar = () => {
</div>
{/* Mobile Menu Toggle */}
<button
className="text-black dark:text-white right-0 size-20 h-10 w-10 lg:hidden"
onClick={() => setMenuOpen(!menuOpen)}
>
{menuOpen ? (
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
>
<path
fill="currentColor"
d="m13.41 12l4.3-4.29a1 1 0 1 0-1.42-1.42L12 10.59l-4.29-4.3a1 1 0 0 0-1.42 1.42l4.3 4.29l-4.3 4.29a1 1 0 0 0 0 1.42a1 1 0 0 0 1.42 0l4.29-4.3l4.29 4.3a1 1 0 0 0 1.42 0a1 1 0 0 0 0-1.42Z"
/>
</svg>
) : (
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
>
<path
fill="currentColor"
d="M4 6a1 1 0 0 1 1-1h14a1 1 0 1 1 0 2H5a1 1 0 0 1-1-1m0 6a1 1 0 0 1 1-1h14a1 1 0 1 1 0 2H5a1 1 0 0 1-1-1m1 5a1 1 0 1 0 0 2h14a1 1 0 1 0 0-2z"
/>
</svg>
)}
</button>
{/* Desktop Navigation */}
<div className="hidden lg:flex items-center gap-5">
<div className="hidden custom-lg-button:flex lg:flex items-center xl:gap-5">
{roleId == undefined ? (
""
) : (
@ -398,7 +368,7 @@ const Navbar = () => {
<span className="w-2 h-2 bg-red-500 rounded-full"></span>
<span className="font-medium">{t("live")}</span>
</Link> */}
<div className="flex items-center w-[100px] h-[120px]">
<div className="hidden custom-lg-button:flex items-center w-[100px] h-[120px]">
<a href="https://tvradio.polri.go.id/">
<Image
src="/assets/polriTv.png"
@ -411,14 +381,16 @@ const Navbar = () => {
</div>
{/* Languange */}
<div className="relative inline-block text-left">
<div className="hidden custom-lg-button:flex relative text-left">
<LocalSwitcher />
</div>
{/* Dark Mode */}
<div className="hidden custom-lg-button:flex text-left">
<ThemeSwitcher />
</div>
<div className="relative text-gray-600 dark:text-white hidden custom-lg:block">
<div className="hidden custom-lg-button:relative text-gray-600 dark:text-white ">
{/* <input
value={onSearch}
onChange={(e) => setOnSearch(e.target.value)}
@ -952,7 +924,7 @@ const Navbar = () => {
</>
) : (
// Masuk and Daftar buttons for roleId === null
<div className="flex flex-wrap justify-center items-center gap-5">
<div className="hidden custom-lg-button:flex flex-row justify-center items-center gap-5">
<Link
href="/auth"
className="w-full lg:w-max px-4 py-1 bg-[#bb3523] text-white font-semibold rounded-md hover:bg-red-700 text-center"
@ -1005,11 +977,42 @@ const Navbar = () => {
</div>
)}
</div>
<button
className="text-black dark:text-white right-0 size-20 h-10 w-10 custom-lg-button:hidden flex justify-end"
onClick={() => setMenuOpen(!menuOpen)}
>
{menuOpen ? (
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
>
<path
fill="currentColor"
d="m13.41 12l4.3-4.29a1 1 0 1 0-1.42-1.42L12 10.59l-4.29-4.3a1 1 0 0 0-1.42 1.42l4.3 4.29l-4.3 4.29a1 1 0 0 0 0 1.42a1 1 0 0 0 1.42 0l4.29-4.3l4.29 4.3a1 1 0 0 0 1.42 0a1 1 0 0 0 0-1.42Z"
/>
</svg>
) : (
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
>
<path
fill="currentColor"
d="M4 6a1 1 0 0 1 1-1h14a1 1 0 1 1 0 2H5a1 1 0 0 1-1-1m0 6a1 1 0 0 1 1-1h14a1 1 0 1 1 0 2H5a1 1 0 0 1-1-1m1 5a1 1 0 1 0 0 2h14a1 1 0 1 0 0-2z"
/>
</svg>
)}
</button>
</div>
{/* Mobile Menu */}
{menuOpen && (
<div className="lg:hidden absolute bg-[#f7f7f7] dark:bg-slate-600 px-4 py-3 w-full space-y-3 z-50">
<div className="custom-lg-button:hidden absolute bg-[#f7f7f7] dark:bg-slate-600 px-4 py-3 w-full space-y-3 z-50 ">
<div className="flex flex-row pl-5 ">
<NavigationMenu>
<NavigationMenuList>
<NavigationMenuItem>
@ -1062,7 +1065,9 @@ const Navbar = () => {
)}
</NavigationMenuLink>
<NavigationMenuLink
onClick={() => router.push(prefixPath + "/document/filter")}
onClick={() =>
router.push(prefixPath + "/document/filter")
}
className="flex place-items-start gap-1.5 p-2"
>
<p className="text-slate-600 text-left dark:text-white hover:text-[#bb3523] flex flex-row justify-center items-center py-2 cursor-pointer">
@ -1083,7 +1088,9 @@ const Navbar = () => {
</NavigationMenuItem>
<NavigationMenuItem>
<Link href={prefixPath + "/schedule"} legacyBehavior passHref>
<NavigationMenuLink className={navigationMenuTriggerStyle()}>
<NavigationMenuLink
className={navigationMenuTriggerStyle()}
>
<span>
<svg
className="mr-2"
@ -1105,7 +1112,9 @@ const Navbar = () => {
</NavigationMenuItem>
<NavigationMenuItem>
<Link href={prefixPath + "/indeks"} legacyBehavior passHref>
<NavigationMenuLink className={navigationMenuTriggerStyle()}>
<NavigationMenuLink
className={navigationMenuTriggerStyle()}
>
<span>
<svg
className="mr-2"
@ -1129,7 +1138,6 @@ const Navbar = () => {
</NavigationMenuItem>
</NavigationMenuList>
</NavigationMenu>
<div className="flex flex-row justify-between mx-3">
{roleId == undefined ? (
""
@ -1225,6 +1233,7 @@ const Navbar = () => {
className="pl-8 pr-4 py-1 w-28 text-[13px] border rounded-full focus:outline-none dark:text-white"
/>{" "}
</div>
<div className="flex justify-center items-center mx-3 gap-5">
{/* {fullName ? (
<>
@ -1427,7 +1436,9 @@ const Navbar = () => {
</div>
<div>
<small>
{`${new Date(list?.createdAt).getDate()}/${
{`${new Date(
list?.createdAt
).getDate()}/${
new Date(list?.createdAt).getMonth() + 1
}/${new Date(
list?.createdAt
@ -1516,7 +1527,10 @@ const Navbar = () => {
className="w-full flex items-center gap-2"
onClick={onLogout}
>
<Icon icon="heroicons:power" className="w-4 h-4" />
<Icon
icon="heroicons:power"
className="w-4 h-4"
/>
{t("logOut")}
</button>
</Link>
@ -1744,7 +1758,10 @@ const Navbar = () => {
className="w-full flex items-center gap-2"
onClick={onLogout}
>
<Icon icon="heroicons:power" className="w-4 h-4" />
<Icon
icon="heroicons:power"
className="w-4 h-4"
/>
{t("logOut")}
</button>
</Link>
@ -1755,7 +1772,7 @@ const Navbar = () => {
</>
) : (
// Masuk and Daftar buttons for roleId === null
<div className="flex justify-center items-center mx-3 gap-5">
<div className="flex justify-center items-center mx-3 gap-1 lg:gap-1 xl:gap-5">
<Link
href="/auth"
className="w-full lg:w-max px-4 py-1 bg-[#bb3523] text-white font-semibold rounded-md hover:bg-red-700 text-center"
@ -1764,7 +1781,10 @@ const Navbar = () => {
</Link>
<Dialog>
<DialogTrigger asChild>
<Button className="w-full lg:w-fit px-4 h-8 border bg-white border-[#bb3523] text-[#bb3523] font-semibold rounded-md hover:bg-[#bb3523] hover:text-white">
<Button
size="sm"
className="w-full lg:w-fit px-4 h-8 border bg-white border-[#bb3523] text-[#bb3523] font-semibold rounded-md hover:bg-[#bb3523] hover:text-white"
>
{t("register")}
</Button>
</DialogTrigger>
@ -1773,7 +1793,9 @@ const Navbar = () => {
<p className="text-lg font-semibold text-center">
{t("categoryReg")}
</p>
<p className="text-base text-center">{t("selectOne")}</p>
<p className="text-base text-center">
{t("selectOne")}
</p>
</div>
<div>
{role?.map((row: any) => (
@ -1789,7 +1811,10 @@ const Navbar = () => {
setCategory(event.target.value)
}
/>
<label className="ml-2" htmlFor={`category${row.id}`}>
<label
className="ml-2"
htmlFor={`category${row.id}`}
>
{row.name}
</label>
</div>
@ -1811,6 +1836,7 @@ const Navbar = () => {
)}
</div>
</div>
</div>
)}
</div>
);

View File

@ -18,13 +18,24 @@ export async function mediaTrackingSave(data: any) {
return httpPostInterceptor(url, data);
}
export async function getMediaTracking(data: any) {
// const url = `/media/tracking/monitoring/pagination`;
const url = `/media/tracking/monitoring/pagination?enablePagination=1&page=${
data.page || 0
}&size=${data?.size || 10}`;
return httpGetInterceptor(url);
export async function getMediaTracking(
page: any,
title: string = "",
size: any
) {
return httpGetInterceptor(
`/media/tracking/monitoring/pagination?enablePagination=1&size=${size}&page=${page}&title=${title}`
);
}
// export async function getMediaTracking(data: any) {
// // const url = `/media/tracking/monitoring/pagination`;
// const url = `/media/tracking/monitoring/pagination?enablePagination=1&page=${
// data.page || 0
// }&size=${data?.size || 10}`;
// return httpGetInterceptor(url);
// }
export async function getMediaTrackingResult(data: any) {
// const url = `/media/tracking/monitoring/pagination`;
const url = `/media/tracking/monitoring/results/pagination?trackingId=${

View File

@ -21,6 +21,7 @@ const config = {
extend: {
screens: {
"custom-lg": "1090px",
"custom-lg-button": "1030px",
},
fontFamily: {
sans: ["DM Sans", "sans-serif"],