fixing
This commit is contained in:
parent
a01825a40a
commit
8058f42f2f
|
|
@ -1,22 +1,10 @@
|
|||
"use client";
|
||||
import { HumasLayout } from "@/components/layout/humas-layout";
|
||||
import ListEnewsPolri from "@/components/table/tabel-emajalah-polri";
|
||||
import React, { Suspense, useEffect, useState } from "react";
|
||||
|
||||
export default function ListEnewsPage() {
|
||||
const [hasMounted, setHasMounted] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
setHasMounted(true);
|
||||
}, []);
|
||||
|
||||
// Render
|
||||
if (!hasMounted) return null;
|
||||
return (
|
||||
<HumasLayout>
|
||||
<Suspense>
|
||||
<ListEnewsPolri />
|
||||
</Suspense>
|
||||
<ListEnewsPolri />
|
||||
</HumasLayout>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ export default function Home() {
|
|||
<HeaderNews />
|
||||
<BodyLayout />
|
||||
<Suspense>
|
||||
<FooterNew />
|
||||
<FooterNew margin={true} />
|
||||
</Suspense>
|
||||
</section>
|
||||
</>
|
||||
|
|
|
|||
|
|
@ -110,6 +110,7 @@ export default function EditArticleForm(props: { isDetail: boolean }) {
|
|||
const params = useParams();
|
||||
const id = params?.id;
|
||||
const username = Cookies.get("username");
|
||||
const userId = Cookies.get("uie");
|
||||
const animatedComponents = makeAnimated();
|
||||
const MySwal = withReactContent(Swal);
|
||||
const router = useRouter();
|
||||
|
|
@ -235,6 +236,44 @@ export default function EditArticleForm(props: { isDetail: boolean }) {
|
|||
});
|
||||
};
|
||||
|
||||
const doPublish = async () => {
|
||||
MySwal.fire({
|
||||
title: "Publish Artikel?",
|
||||
text: "",
|
||||
icon: "warning",
|
||||
showCancelButton: true,
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonColor: "#3085d6",
|
||||
confirmButtonText: "Submit",
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
publish();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const publish = async () => {
|
||||
const response = await updateArticle(String(id), {
|
||||
id: Number(id),
|
||||
isPublish: true,
|
||||
title: detailData?.title,
|
||||
typeId: 1,
|
||||
slug: detailData?.slug,
|
||||
categoryIds: getValues("category")
|
||||
.map((val) => val.id)
|
||||
.join(","),
|
||||
tags: getValues("tags").join(","),
|
||||
description: htmlToString(getValues("description")),
|
||||
htmlDescription: getValues("description"),
|
||||
});
|
||||
|
||||
if (response?.error) {
|
||||
error(response.message);
|
||||
return false;
|
||||
}
|
||||
successSubmit("/admin/article");
|
||||
};
|
||||
|
||||
const save = async (values: z.infer<typeof createArticleSchema>) => {
|
||||
loading();
|
||||
const formData = {
|
||||
|
|
@ -889,6 +928,7 @@ export default function EditArticleForm(props: { isDetail: boolean }) {
|
|||
</Button>
|
||||
)}
|
||||
{isDetail &&
|
||||
username === "admin-mabes" &&
|
||||
(detailData?.statusId === 1 || detailData?.statusId === null) && (
|
||||
<Button
|
||||
color="danger"
|
||||
|
|
@ -906,6 +946,14 @@ export default function EditArticleForm(props: { isDetail: boolean }) {
|
|||
Simpan
|
||||
</Button>
|
||||
)}
|
||||
{isDetail &&
|
||||
detailData?.isPublish === false &&
|
||||
detailData?.statusId !== 1 &&
|
||||
Number(userId) === detailData?.createdById && (
|
||||
<Button color="primary" onPress={doPublish}>
|
||||
Publish
|
||||
</Button>
|
||||
)}
|
||||
{/* {!isDetail && (
|
||||
<Button color="success" type="button">
|
||||
<p className="text-white">Draft</p>
|
||||
|
|
|
|||
|
|
@ -315,12 +315,14 @@ export default function HeaderNews() {
|
|||
</div>
|
||||
))}
|
||||
</ScrollShadow>
|
||||
<Button
|
||||
className="w-full bg-gradient-to-r from-red-700 to-[#bb3523] text-white font-bold rounded-md focus:outline-none"
|
||||
radius="none"
|
||||
>
|
||||
Lihat Semua
|
||||
</Button>
|
||||
<Link href="/news/all">
|
||||
<Button
|
||||
className="w-full bg-gradient-to-r from-red-700 to-[#bb3523] text-white font-bold rounded-md focus:outline-none"
|
||||
radius="none"
|
||||
>
|
||||
Lihat Semua
|
||||
</Button>
|
||||
</Link>
|
||||
</div>
|
||||
) : (
|
||||
<div className="lg:!h-[50vh] p-2 dark:bg-stone-800 bg-[#f0f0f0] text-black dark:text-white rounded-lg">
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ export default function NewsTicker() {
|
|||
}, [article]);
|
||||
|
||||
return (
|
||||
<div className="fixed bottom-0 z-50 flex flex-row h-[60px] lg:h-[7vh] gap-3 w-full justify-between dark:bg-stone-800 bg-gray-50">
|
||||
<div className="fixed bottom-0 z-50 flex flex-row h-[60px] gap-3 w-full justify-between dark:bg-stone-800 bg-gray-50">
|
||||
<div className="relative px-4 py-2 font-semibold text-xs lg:text-sm flex items-center bg-[#bb3523] text-white w-[30%] lg:w-[10%]">
|
||||
<span className="mr-2"></span> BREAKING NEWS
|
||||
<div className="absolute right-0 top-0 h-full w-4 bg-[#bb3523] transform translate-x-full clipPath-triangle"></div>
|
||||
|
|
|
|||
|
|
@ -15,12 +15,16 @@ import { useTranslations } from "next-intl";
|
|||
import { useEffect, useState } from "react";
|
||||
import Image from "next/image";
|
||||
|
||||
export default function FooterNew() {
|
||||
export default function FooterNew(props: { margin?: boolean }) {
|
||||
const t2 = useTranslations("Navbar");
|
||||
const t3 = useTranslations("LandingInformasiPublik");
|
||||
|
||||
return (
|
||||
<div className="mb-[60px] relative text-xs leading-4 md:leading-loose lg:leading-8 font-semibold">
|
||||
<div
|
||||
className={`${
|
||||
props?.margin ? "mb-[60px]" : ""
|
||||
} relative text-xs leading-4 md:leading-loose lg:leading-8 font-semibold`}
|
||||
>
|
||||
<div className="py-10 w-full lg:w-[70%] flex flex-col gap-4 px-6 lg:px-0 lg:mx-auto">
|
||||
<div className="flex justify-center text-xl lg:text-2xl">
|
||||
Channel Humas Polri
|
||||
|
|
|
|||
|
|
@ -61,6 +61,9 @@ export default function SocialMediaNew() {
|
|||
selectedKey={selectedTab}
|
||||
onSelectionChange={setSelectedTab}
|
||||
>
|
||||
<Tab key="fb" title="Facebook">
|
||||
<FacebookWidgetNew />
|
||||
</Tab>
|
||||
<Tab key="x" title="X">
|
||||
<TwitterWidget />
|
||||
</Tab>
|
||||
|
|
@ -70,9 +73,7 @@ export default function SocialMediaNew() {
|
|||
<Tab key="yt" title="Youtube">
|
||||
<YoutubeWidget />
|
||||
</Tab>
|
||||
<Tab key="fb" title="Facebook">
|
||||
<FacebookWidgetNew />
|
||||
</Tab>
|
||||
|
||||
<Tab key="tiktok" title="Tiktok">
|
||||
<TiktokWidget />
|
||||
</Tab>
|
||||
|
|
|
|||
|
|
@ -20,14 +20,14 @@ export const HumasLayout = ({ children }: Props) => {
|
|||
// Render
|
||||
if (!hasMounted) return null;
|
||||
return (
|
||||
<section className="flex flex-col">
|
||||
<section className="flex flex-col !min-h-screen">
|
||||
<NavbarHumas size="sm" />
|
||||
<NavbarHumas size="lg" />
|
||||
<NewsTicker />
|
||||
{/* <NewsTicker /> */}
|
||||
|
||||
{children}
|
||||
<Suspense>
|
||||
<FooterNew />
|
||||
<FooterNew margin={false} />
|
||||
</Suspense>
|
||||
</section>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -58,9 +58,9 @@ export default function EMagazineDetail() {
|
|||
}
|
||||
};
|
||||
return (
|
||||
<div className="w-auto bg-[#E2E2E2] text-black">
|
||||
<div className="p-1 md:p-5 lg:px-36">
|
||||
<div className="flex flex-row gap-4 items-end text-black">
|
||||
<div className="bg-white dark:bg-stone-900">
|
||||
<div className="px-5 lg:px-0 lg:w-[75vw] lg:mx-auto py-8">
|
||||
<div className="flex flex-row gap-4 items-end ">
|
||||
<Link href="/" className=" font-semibold text-lg">
|
||||
Beranda
|
||||
</Link>
|
||||
|
|
@ -141,13 +141,15 @@ export default function EMagazineDetail() {
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<Button
|
||||
className="w-full bg-[#DD8306] text-sm font-semibold text-white mt-2"
|
||||
radius="sm"
|
||||
onPress={() => doDownload(file?.fileName, file?.title)}
|
||||
>
|
||||
Download
|
||||
</Button>
|
||||
<Link href={file?.fileUrl} target="_blank">
|
||||
<Button
|
||||
className="w-full bg-[#DD8306] text-sm font-semibold text-white mt-2"
|
||||
radius="sm"
|
||||
// onPress={() => doDownload(file?.fileName, file?.title)}
|
||||
>
|
||||
File
|
||||
</Button>
|
||||
</Link>
|
||||
</AccordionItem>
|
||||
</Accordion>
|
||||
))}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import {
|
|||
BreadcrumbItem,
|
||||
Breadcrumbs,
|
||||
Button,
|
||||
Image,
|
||||
Input,
|
||||
Pagination,
|
||||
} from "@heroui/react";
|
||||
|
|
@ -19,7 +20,6 @@ import Link from "next/link";
|
|||
import { useEffect, useRef, useState } from "react";
|
||||
import { getListArticle } from "@/service/article";
|
||||
import { formatMonthString, htmlToString, textEllipsis } from "@/utils/global";
|
||||
import Image from "next/image";
|
||||
import {
|
||||
useParams,
|
||||
usePathname,
|
||||
|
|
@ -52,8 +52,13 @@ export default function ListNews() {
|
|||
page: page,
|
||||
search: searchValue || "",
|
||||
limit: "9",
|
||||
category: String(category),
|
||||
// isPublish: pathname.includes("polda") ? false : true,
|
||||
isPublish: true,
|
||||
sort: "desc",
|
||||
categorySlug:
|
||||
pathname.includes("polda") || pathname.includes("satker")
|
||||
? String(category)
|
||||
: "",
|
||||
};
|
||||
const response = await getListArticle(req);
|
||||
setArticle(response?.data?.data);
|
||||
|
|
@ -121,9 +126,8 @@ export default function ListNews() {
|
|||
: news.thumbnailUrl
|
||||
}
|
||||
width={1920}
|
||||
height={1080}
|
||||
alt="thumbnail"
|
||||
className="rounded-t-md h-[27vh] w-full object-cover"
|
||||
className="rounded-b-none h-[27vh] w-full object-cover"
|
||||
/>
|
||||
</div>
|
||||
<div className="p-2 lg:p-5 bg-[#f0f0f0] rounded-b-md">
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import {
|
|||
EyeIconMdi,
|
||||
SearchIcon,
|
||||
} from "@/components/icons";
|
||||
import { error, success, successToast } from "@/config/swal";
|
||||
import { close, error, loading, success, successToast } from "@/config/swal";
|
||||
import {
|
||||
deleteArticle,
|
||||
getArticleByCategory,
|
||||
|
|
@ -53,6 +53,15 @@ const columns = [
|
|||
{ name: "Status", uid: "isPublish" },
|
||||
{ name: "Aksi", uid: "actions" },
|
||||
];
|
||||
const columnsOtherRole = [
|
||||
{ name: "No", uid: "no" },
|
||||
{ name: "Judul", uid: "title" },
|
||||
{ name: "Kategori", uid: "category" },
|
||||
{ name: "Tanggal Unggah", uid: "createdAt" },
|
||||
{ name: "Kreator", uid: "createdByName" },
|
||||
{ name: "Status", uid: "isPublish" },
|
||||
{ name: "Aksi", uid: "actions" },
|
||||
];
|
||||
|
||||
interface Category {
|
||||
id: number;
|
||||
|
|
@ -68,13 +77,14 @@ type ArticleData = Article & {
|
|||
export default function ArticleTable() {
|
||||
const MySwal = withReactContent(Swal);
|
||||
const username = Cookies.get("username");
|
||||
const userId = Cookies.get("uie");
|
||||
|
||||
const [page, setPage] = useState(1);
|
||||
const [totalPage, setTotalPage] = useState(1);
|
||||
const [article, setArticle] = useState<any[]>([]);
|
||||
const [showData, setShowData] = useState("10");
|
||||
const [search, setSearch] = useState("");
|
||||
const [categories, setCategoies] = useState<any>([]);
|
||||
const [categories, setCategories] = useState<any>([]);
|
||||
const [selectedCategories, setSelectedCategories] = useState<any>([]);
|
||||
const [startDateValue, setStartDateValue] = useState({
|
||||
startDate: null,
|
||||
|
|
@ -92,27 +102,29 @@ export default function ArticleTable() {
|
|||
async function getCategories() {
|
||||
const res = await getArticleByCategory();
|
||||
const data = res?.data?.data;
|
||||
setCategoies(data);
|
||||
setCategories(data);
|
||||
}
|
||||
|
||||
async function initState() {
|
||||
loading();
|
||||
const req = {
|
||||
limit: showData,
|
||||
page: page,
|
||||
search: search,
|
||||
startDate:
|
||||
startDateValue.startDate === null ? "" : startDateValue.startDate,
|
||||
endDate: startDateValue.endDate === null ? "" : startDateValue.endDate,
|
||||
category: Array.from(selectedCategories).join(","),
|
||||
// startDate:
|
||||
// startDateValue.startDate === null ? "" : startDateValue.startDate,
|
||||
// endDate: startDateValue.endDate === null ? "" : startDateValue.endDate,
|
||||
categorySlug: Array.from(selectedCategories).join(","),
|
||||
sort: "desc",
|
||||
sortBy: "created_at",
|
||||
};
|
||||
const res = await getListArticle(req);
|
||||
getTableNumber(parseInt(showData), res.data?.data);
|
||||
await getTableNumber(parseInt(showData), res.data?.data);
|
||||
setTotalPage(res?.data?.meta?.totalPage);
|
||||
close();
|
||||
}
|
||||
|
||||
const getTableNumber = (limit: number, data: Article[]) => {
|
||||
const getTableNumber = async (limit: number, data: Article[]) => {
|
||||
if (data) {
|
||||
const startIndex = limit * (page - 1);
|
||||
let iterate = 0;
|
||||
|
|
@ -227,11 +239,22 @@ export default function ArticleTable() {
|
|||
Detail
|
||||
</Link>
|
||||
</DropdownItem>
|
||||
<DropdownItem key="edit">
|
||||
<Link href={`/admin/article/edit/${article.id}`}>
|
||||
<CreateIconIon className="inline mr-2 mb-1" />
|
||||
Edit
|
||||
</Link>
|
||||
<DropdownItem
|
||||
key="edit"
|
||||
className={
|
||||
username === "admin-mabes" ||
|
||||
Number(userId) === article.createdById
|
||||
? ""
|
||||
: "hidden"
|
||||
}
|
||||
>
|
||||
{(username === "admin-mabes" ||
|
||||
Number(userId) === article.createdById) && (
|
||||
<Link href={`/admin/article/edit/${article.id}`}>
|
||||
<CreateIconIon className="inline mr-2 mb-1" />
|
||||
Edit
|
||||
</Link>
|
||||
)}
|
||||
</DropdownItem>
|
||||
<DropdownItem
|
||||
key="setBanner"
|
||||
|
|
@ -252,13 +275,25 @@ export default function ArticleTable() {
|
|||
<DropdownItem
|
||||
key="delete"
|
||||
onPress={() => handleDelete(article.id)}
|
||||
className={
|
||||
username === "admin-mabes" ||
|
||||
Number(userId) === article.createdById
|
||||
? ""
|
||||
: "hidden"
|
||||
}
|
||||
>
|
||||
<DeleteIcon
|
||||
color="red"
|
||||
size={18}
|
||||
className="inline ml-1 mr-2 mb-1"
|
||||
/>
|
||||
Delete
|
||||
{(username === "admin-mabes" ||
|
||||
Number(userId) === article.createdById) && (
|
||||
<>
|
||||
{" "}
|
||||
<DeleteIcon
|
||||
color="red"
|
||||
size={18}
|
||||
className="inline ml-1 mr-2 mb-1"
|
||||
/>
|
||||
Delete
|
||||
</>
|
||||
)}
|
||||
</DropdownItem>
|
||||
</DropdownMenu>
|
||||
</Dropdown>
|
||||
|
|
@ -269,7 +304,7 @@ export default function ArticleTable() {
|
|||
return cellValue;
|
||||
}
|
||||
},
|
||||
[article]
|
||||
[article, page]
|
||||
);
|
||||
|
||||
let typingTimer: NodeJS.Timeout;
|
||||
|
|
@ -285,6 +320,7 @@ export default function ArticleTable() {
|
|||
};
|
||||
|
||||
async function doneTyping() {
|
||||
setPage(1);
|
||||
initState();
|
||||
}
|
||||
|
||||
|
|
@ -346,7 +382,7 @@ export default function ArticleTable() {
|
|||
variant="bordered"
|
||||
labelPlacement="outside"
|
||||
placeholder="Kategori"
|
||||
selectionMode="multiple"
|
||||
selectionMode="single"
|
||||
selectedKeys={selectedCategories}
|
||||
className="w-full"
|
||||
items={categories}
|
||||
|
|
@ -358,13 +394,13 @@ export default function ArticleTable() {
|
|||
key={item.props?.value}
|
||||
className="text-black dark:text-white text-xs"
|
||||
>
|
||||
{item.textValue},
|
||||
{item.textValue}
|
||||
</span>
|
||||
));
|
||||
}}
|
||||
>
|
||||
{categories?.map((category: any) => (
|
||||
<SelectItem key={category?.slug} value={category?.id}>
|
||||
<SelectItem key={category?.slug} value={category?.slug}>
|
||||
{category?.title}
|
||||
</SelectItem>
|
||||
))}
|
||||
|
|
@ -390,7 +426,9 @@ export default function ArticleTable() {
|
|||
"min-h-[50px] bg-transpararent text-black dark:text-white ",
|
||||
}}
|
||||
>
|
||||
<TableHeader columns={columns}>
|
||||
<TableHeader
|
||||
columns={username === "admin-mabes" ? columns : columnsOtherRole}
|
||||
>
|
||||
{(column) => (
|
||||
<TableColumn key={column.uid}>{column.name}</TableColumn>
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ import {
|
|||
getFeedbacks,
|
||||
getFeedbacksById,
|
||||
} from "@/service/feedbacks";
|
||||
import * as XLSX from "xlsx";
|
||||
|
||||
const columns = [
|
||||
{ name: "No", uid: "no" },
|
||||
|
|
@ -301,6 +302,51 @@ export default function SuggestionsTable() {
|
|||
);
|
||||
const [typeDate, setTypeDate] = useState("monthly");
|
||||
|
||||
const doExport = async () => {
|
||||
const res = await getFeedbacks({ limit: showData, search: search });
|
||||
if (res?.data?.data) {
|
||||
exportRecap(res?.data?.data);
|
||||
}
|
||||
};
|
||||
|
||||
const exportRecap = (data: any) => {
|
||||
let temp: any = [];
|
||||
let no = 0;
|
||||
|
||||
const worksheet = XLSX.utils.json_to_sheet([]);
|
||||
|
||||
data.map((list: any) => {
|
||||
no += 1;
|
||||
const now = [
|
||||
no,
|
||||
list.commentFromName,
|
||||
list.commentFromEmail,
|
||||
list.message,
|
||||
];
|
||||
temp.push(now);
|
||||
});
|
||||
|
||||
XLSX.utils.sheet_add_aoa(
|
||||
worksheet,
|
||||
[["No", "Nama", "Email", "Kritik & Saran"]],
|
||||
{
|
||||
origin: "A1",
|
||||
}
|
||||
);
|
||||
XLSX.utils.sheet_add_json(worksheet, temp, {
|
||||
origin: "A2",
|
||||
skipHeader: true,
|
||||
});
|
||||
|
||||
worksheet["!cols"] = [{ wch: 7 }, { wch: 24 }, { wch: 24 }, { wch: 48 }];
|
||||
|
||||
const workbook = XLSX.utils.book_new();
|
||||
|
||||
XLSX.utils.book_append_sheet(workbook, worksheet, "ethic");
|
||||
|
||||
XLSX.writeFile(workbook, `Kritik Saran.xlsx`);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="flex flex-row gap-2 items-center">
|
||||
|
|
@ -399,7 +445,7 @@ export default function SuggestionsTable() {
|
|||
</SelectItem>
|
||||
</Select>
|
||||
</div>
|
||||
<Button color="primary" className="text-white">
|
||||
<Button color="primary" className="text-white" onPress={doExport}>
|
||||
Export
|
||||
</Button>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -102,167 +102,122 @@ export default function ListEnewsPolri() {
|
|||
}
|
||||
|
||||
return (
|
||||
<div className="md:flex ">
|
||||
<div className="w-auto bg-[#E2E2E2] md:w-2/3 lg:w-[75%] text-black">
|
||||
<div className="p-1 md:py-5 lg:px-36">
|
||||
<div className="flex flex-row gap-4 items-end text-black">
|
||||
<Link href="/" className=" font-semibold text-lg">
|
||||
Beranda
|
||||
</Link>
|
||||
<ChevronRightIcon />
|
||||
<p className=" font-semibold text-lg">E-Majalah Polri</p>
|
||||
</div>
|
||||
<div className="pt-4 space-y-5 ">
|
||||
{/* <div className="font-semibold text-lg border-b-4 border-red-700 leading-loose">
|
||||
E-majalah Polri
|
||||
</div> */}
|
||||
<div className="flex items-end gap-3 flex-col md:flex-row">
|
||||
<Input
|
||||
aria-label="Search"
|
||||
classNames={{
|
||||
input: [
|
||||
"w-full",
|
||||
"bg-transparent",
|
||||
"h-[20px]",
|
||||
"!text-black",
|
||||
],
|
||||
mainWrapper: ["w-full", "bg-transparent"],
|
||||
innerWrapper: ["bg-transparent", "h-[20px]"],
|
||||
inputWrapper: [
|
||||
"bg-white",
|
||||
"dark:bg-white",
|
||||
"hover:!bg-gray-300",
|
||||
"dark:hover:bg-gray-300",
|
||||
"group-data-[focused=true]:bg-transparent",
|
||||
"dark:group-data-[focused=true]:bg-transaparent",
|
||||
"group-data-[focused=false]:bg-transparent",
|
||||
"focus-within:!bg-transparent",
|
||||
"h-[20px]",
|
||||
"dark:focus-within:!bg-gray-100",
|
||||
],
|
||||
}}
|
||||
labelPlacement="outside"
|
||||
type="text"
|
||||
onChange={(e) => setSearch(e.target.value)}
|
||||
startContent={
|
||||
<SearchIcon className="text-base text-default-400 pointer-events-none flex-shrink-0" />
|
||||
}
|
||||
endContent={
|
||||
<Button
|
||||
size="sm"
|
||||
className="bg-[#DD8306] font-semibold text-white"
|
||||
onPress={getMagazines}
|
||||
>
|
||||
Cari
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
{/* <Select
|
||||
label="Sort By"
|
||||
size="sm"
|
||||
className="w-1/5"
|
||||
classNames={{
|
||||
// base: "bg-red-500",
|
||||
// mainWrapper: "border-2 border-red-500",
|
||||
label: "text-black",
|
||||
value: "!text-black",
|
||||
trigger: "bg-white hover:!bg-gray-100",
|
||||
// innerWrapper: "bg-red-500"
|
||||
// selectorIcon: "bg-red-500"
|
||||
// listboxWrapper: "bg-red-500"
|
||||
// listbox: "bg-red-500"
|
||||
popoverContent: "bg-white",
|
||||
}}
|
||||
listboxProps={{
|
||||
itemClasses: {
|
||||
base: "text-black",
|
||||
wrapper: "!bg-white ",
|
||||
},
|
||||
}}
|
||||
// onChange={onChangeFilterEnterprising}
|
||||
>
|
||||
<SelectSection>
|
||||
{category.map((list: any) => (
|
||||
<SelectItem key={list.id}>{list.label}</SelectItem>
|
||||
))}
|
||||
</SelectSection>
|
||||
</Select> */}
|
||||
<div className="flex flex-col gap-1 w-full md:w-[240px]">
|
||||
<p className="font-semibold text-xs md:text-sm">
|
||||
Tanggal Publikasi
|
||||
</p>
|
||||
<Datepicker
|
||||
value={startDateValue}
|
||||
displayFormat="DD/MM/YYYY"
|
||||
useRange={false}
|
||||
asSingle={true}
|
||||
onChange={(e: any) => setStartDateValue(e)}
|
||||
inputClassName="z-50 w-full text-sm bg-white border-1 border-gray-200 px-2 py-[6px] rounded-xl h-[40px] text-black"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div className="flex flex-col gap-3">
|
||||
<Table
|
||||
color="warning"
|
||||
aria-label="Example static collection table"
|
||||
classNames={{
|
||||
wrapper: "bg-white",
|
||||
base: "font-bold",
|
||||
// th: " border-2 border-red-500 text-xs",
|
||||
td: "font-medium",
|
||||
}}
|
||||
<div className="bg-white dark:bg-stone-900">
|
||||
<div className="px-5 lg:px-0 lg:w-[75vw] lg:mx-auto py-8">
|
||||
<div className="flex flex-row gap-4 items-end ">
|
||||
<Link href="/" className=" font-semibold text-lg">
|
||||
Beranda
|
||||
</Link>
|
||||
<ChevronRightIcon />
|
||||
<p className=" font-semibold text-lg">E-Majalah Polri</p>
|
||||
</div>
|
||||
<div className="pt-4 space-y-5 ">
|
||||
<div className="flex items-end gap-3 flex-col md:flex-row">
|
||||
<Input
|
||||
aria-label="Search"
|
||||
classNames={{
|
||||
input: ["w-full", "bg-transparent", "h-[20px]", "!text-black"],
|
||||
mainWrapper: ["w-full", "bg-transparent"],
|
||||
innerWrapper: ["bg-transparent", "h-[20px]"],
|
||||
inputWrapper: [
|
||||
"bg-white",
|
||||
"dark:bg-white",
|
||||
"hover:!bg-gray-300",
|
||||
"dark:hover:bg-gray-300",
|
||||
"group-data-[focused=true]:bg-transparent",
|
||||
"dark:group-data-[focused=true]:bg-transaparent",
|
||||
"group-data-[focused=false]:bg-transparent",
|
||||
"focus-within:!bg-transparent",
|
||||
"h-[20px]",
|
||||
"dark:focus-within:!bg-gray-100",
|
||||
],
|
||||
}}
|
||||
labelPlacement="outside"
|
||||
type="text"
|
||||
onChange={(e) => setSearch(e.target.value)}
|
||||
startContent={
|
||||
<SearchIcon className="text-base text-default-400 pointer-events-none flex-shrink-0" />
|
||||
}
|
||||
endContent={
|
||||
<Button
|
||||
size="sm"
|
||||
className="bg-[#DD8306] font-semibold text-white"
|
||||
onPress={getMagazines}
|
||||
>
|
||||
<TableHeader columns={header}>
|
||||
{(column) => (
|
||||
<TableColumn
|
||||
className=" bg-[#DD8306] text-white text-md w-full"
|
||||
key={column.key}
|
||||
>
|
||||
{column.label}
|
||||
</TableColumn>
|
||||
)}
|
||||
</TableHeader>
|
||||
<TableBody items={magazines}>
|
||||
{(item: any) => (
|
||||
<TableRow key={item.id}>
|
||||
<TableCell>
|
||||
<Link href={`/e-majalah-polri/detail/${item.id}`}>
|
||||
{item.title}
|
||||
</Link>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<Link href={`/e-majalah-polri/detail/${item.key}`}>
|
||||
<EyeFilledIcon color="#DD8306" />
|
||||
</Link>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
)}
|
||||
</TableBody>
|
||||
</Table>
|
||||
<div className="my-2 w-full flex justify-center">
|
||||
<Pagination
|
||||
isCompact
|
||||
showControls
|
||||
showShadow
|
||||
color="primary"
|
||||
classNames={{
|
||||
base: "bg-transparent",
|
||||
wrapper: "bg-transparent",
|
||||
}}
|
||||
page={page}
|
||||
total={totalPage}
|
||||
onChange={(page) => setPage(page)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
Cari
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
|
||||
<div className="flex flex-col gap-1 w-full md:w-[240px]">
|
||||
<p className="font-semibold text-xs md:text-sm">
|
||||
Tanggal Publikasi
|
||||
</p>
|
||||
{/* <Datepicker
|
||||
value={startDateValue}
|
||||
displayFormat="DD/MM/YYYY"
|
||||
useRange={false}
|
||||
asSingle={true}
|
||||
onChange={(e: any) => setStartDateValue(e)}
|
||||
inputClassName="z-50 w-full text-sm bg-white border-1 border-gray-200 px-2 py-[6px] rounded-xl h-[40px] text-black"
|
||||
/> */}
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex flex-col gap-3">
|
||||
<Table
|
||||
color="warning"
|
||||
aria-label="Example static collection table"
|
||||
classNames={{
|
||||
wrapper: "bg-white",
|
||||
base: "font-bold",
|
||||
td: "font-medium",
|
||||
}}
|
||||
>
|
||||
<TableHeader columns={header}>
|
||||
{(column) => (
|
||||
<TableColumn
|
||||
className=" bg-[#DD8306] text-white text-md w-full"
|
||||
key={column.key}
|
||||
>
|
||||
{column.label}
|
||||
</TableColumn>
|
||||
)}
|
||||
</TableHeader>
|
||||
<TableBody items={magazines}>
|
||||
{(item: any) => (
|
||||
<TableRow key={item.id}>
|
||||
<TableCell>
|
||||
<Link href={`/e-majalah-polri/detail/${item.id}`}>
|
||||
{item.title}
|
||||
</Link>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<Link href={`/e-majalah-polri/detail/${item.key}`}>
|
||||
<EyeFilledIcon color="#DD8306" />
|
||||
</Link>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
)}
|
||||
</TableBody>
|
||||
</Table>
|
||||
<div className="my-2 w-full flex justify-center">
|
||||
<Pagination
|
||||
isCompact
|
||||
showControls
|
||||
showShadow
|
||||
color="primary"
|
||||
classNames={{
|
||||
base: "bg-transparent",
|
||||
wrapper: "bg-transparent",
|
||||
}}
|
||||
page={page}
|
||||
total={totalPage}
|
||||
onChange={(page) => setPage(page)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="w-auto md:w-1/3 lg:w-[25%] px-2 md:px-4 py-2 text-black">
|
||||
<SidebarNav />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,14 +16,10 @@ const PolriTvWidget = () => {
|
|||
}, []);
|
||||
|
||||
return (
|
||||
<div className="h-[310px]">
|
||||
<iframe
|
||||
style={{ width: "100%", height: "100%" }}
|
||||
className="rounded-lg"
|
||||
scrolling="no"
|
||||
src="https://embedsocial.com/api/pro_hashtag/e025d6147bb208952ae5db84f99e54f2388cea0d"
|
||||
></iframe>
|
||||
</div>
|
||||
<div
|
||||
className="embedsocial-hashtag rounded-md"
|
||||
data-ref="90ea1c42f039ca15d1076e1bd873b215411dfcb3"
|
||||
></div>
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -143,6 +143,10 @@ export const siteConfig = {
|
|||
label: "UU & Peraturan",
|
||||
href: "https://sisdivkum.id/library/peraturan-kepolisian",
|
||||
},
|
||||
{
|
||||
label: "E-Magazine",
|
||||
href: "/e-majalah-polri/daftar-majalah",
|
||||
},
|
||||
],
|
||||
},
|
||||
// {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,5 @@
|
|||
import { PaginationRequest } from "@/types/globals";
|
||||
import {
|
||||
httpDeleteInterceptor,
|
||||
httpGet,
|
||||
httpPost,
|
||||
httpPut,
|
||||
} from "./http-config/axios-base-service";
|
||||
import { httpGet, httpPost, httpPut } from "./http-config/axios-base-service";
|
||||
|
||||
export async function saveActivity(data: any, token?: string) {
|
||||
const headers = token
|
||||
|
|
|
|||
|
|
@ -1,9 +1,4 @@
|
|||
import {
|
||||
httpDeleteInterceptor,
|
||||
httpGet,
|
||||
httpPost,
|
||||
httpPut,
|
||||
} from "./http-config/axios-base-service";
|
||||
import { httpGet, httpPost, httpPut } from "./http-config/axios-base-service";
|
||||
import Cookies from "js-cookie";
|
||||
|
||||
const token = Cookies.get("access_token");
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ export async function getListArticle(props: PaginationRequest) {
|
|||
category,
|
||||
sortBy,
|
||||
sort,
|
||||
categorySlug,
|
||||
} = props;
|
||||
const headers = {
|
||||
"content-type": "application/json",
|
||||
|
|
@ -30,7 +31,7 @@ export async function getListArticle(props: PaginationRequest) {
|
|||
endDate || ""
|
||||
}&categoryId=${category || ""}&sortBy=${sortBy || "created_at"}&sort=${
|
||||
sort || "asc"
|
||||
}`,
|
||||
}&category=${categorySlug || ""}`,
|
||||
headers
|
||||
);
|
||||
}
|
||||
|
|
@ -85,7 +86,10 @@ export async function getArticleById(id: any) {
|
|||
}
|
||||
|
||||
export async function deleteArticle(id: string) {
|
||||
return await httpDeleteInterceptor(`articles/${id}`);
|
||||
const headers = {
|
||||
"content-type": "application/json",
|
||||
};
|
||||
return await httpDeleteInterceptor(`articles/${id}`, headers);
|
||||
}
|
||||
|
||||
export async function getArticleByCategory() {
|
||||
|
|
@ -121,7 +125,10 @@ export async function uploadArticleThumbnail(id: string, data: any) {
|
|||
}
|
||||
|
||||
export async function deleteArticleFiles(id: number) {
|
||||
return await httpDeleteInterceptor(`article-files/${id}`);
|
||||
const headers = {
|
||||
"content-type": "multipart/form-data",
|
||||
};
|
||||
return await httpDeleteInterceptor(`article-files/${id}`, headers);
|
||||
}
|
||||
|
||||
export async function getUserLevelDataStat(startDate: string, endDate: string) {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,10 @@ export async function getComments(data: any) {
|
|||
}
|
||||
|
||||
export async function deleteComment(id: number) {
|
||||
return await httpDeleteInterceptor(`/article-comments/${id}`);
|
||||
const headers = {
|
||||
"content-type": "application/json",
|
||||
};
|
||||
return await httpDeleteInterceptor(`/article-comments/${id}`, headers);
|
||||
}
|
||||
|
||||
export async function getCommentById(id: number) {
|
||||
|
|
|
|||
|
|
@ -34,5 +34,8 @@ export async function getFeedbacksById(id: number) {
|
|||
return await httpGet(pathUrl, headers);
|
||||
}
|
||||
export async function deleteFeedback(id: number) {
|
||||
return await httpDeleteInterceptor(`/feedbacks/${id}`);
|
||||
const headers = {
|
||||
"content-type": "application/json",
|
||||
};
|
||||
return await httpDeleteInterceptor(`/feedbacks/${id}`, headers);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,114 +2,113 @@ import axiosBaseInstance from "./http-base-service";
|
|||
import mediahubBaseInstance from "./mediahub-base-service";
|
||||
|
||||
export async function httpPost(pathUrl: any, headers: any, data?: any) {
|
||||
const response = await axiosBaseInstance
|
||||
.post(pathUrl, data, { headers })
|
||||
.catch(function (error: any) {
|
||||
console.log(error);
|
||||
return error.response;
|
||||
});
|
||||
console.log("Response base svc : ", response);
|
||||
if (response?.status == 200 || response?.status == 201) {
|
||||
return {
|
||||
error: false,
|
||||
message: "success",
|
||||
data: response?.data,
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
error: true,
|
||||
message: response?.data?.message || response?.data || null,
|
||||
data: null,
|
||||
};
|
||||
}
|
||||
const response = await axiosBaseInstance
|
||||
.post(pathUrl, data, { headers })
|
||||
.catch(function (error: any) {
|
||||
console.log(error);
|
||||
return error.response;
|
||||
});
|
||||
console.log("Response base svc : ", response);
|
||||
if (response?.status == 200 || response?.status == 201) {
|
||||
return {
|
||||
error: false,
|
||||
message: "success",
|
||||
data: response?.data,
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
error: true,
|
||||
message: response?.data?.message || response?.data || null,
|
||||
data: null,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function httpGet(pathUrl: any, headers: any) {
|
||||
const response = await axiosBaseInstance
|
||||
.get(pathUrl, { headers })
|
||||
.catch(function (error: any) {
|
||||
console.log(error);
|
||||
return error.response;
|
||||
});
|
||||
console.log("Response base svc : ", response);
|
||||
if (response?.status == 200 || response?.status == 201) {
|
||||
return {
|
||||
error: false,
|
||||
message: "success",
|
||||
data: response?.data,
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
error: true,
|
||||
message: response?.data?.message || response?.data || null,
|
||||
data: null,
|
||||
};
|
||||
}
|
||||
const response = await axiosBaseInstance
|
||||
.get(pathUrl, { headers })
|
||||
.catch(function (error: any) {
|
||||
console.log(error);
|
||||
return error.response;
|
||||
});
|
||||
console.log("Response base svc : ", response);
|
||||
if (response?.status == 200 || response?.status == 201) {
|
||||
return {
|
||||
error: false,
|
||||
message: "success",
|
||||
data: response?.data,
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
error: true,
|
||||
message: response?.data?.message || response?.data || null,
|
||||
data: null,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function httpPut(pathUrl: any, headers: any, data?: any) {
|
||||
const response = await axiosBaseInstance
|
||||
.put(pathUrl, data, { headers })
|
||||
.catch(function (error: any) {
|
||||
console.log(error);
|
||||
return error.response;
|
||||
});
|
||||
console.log("Response base svc : ", response);
|
||||
if (response?.status == 200 || response?.status == 201) {
|
||||
return {
|
||||
error: false,
|
||||
message: "success",
|
||||
data: response?.data,
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
error: true,
|
||||
message: response?.data?.message || response?.data || null,
|
||||
data: null,
|
||||
};
|
||||
}
|
||||
const response = await axiosBaseInstance
|
||||
.put(pathUrl, data, { headers })
|
||||
.catch(function (error: any) {
|
||||
console.log(error);
|
||||
return error.response;
|
||||
});
|
||||
console.log("Response base svc : ", response);
|
||||
if (response?.status == 200 || response?.status == 201) {
|
||||
return {
|
||||
error: false,
|
||||
message: "success",
|
||||
data: response?.data,
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
error: true,
|
||||
message: response?.data?.message || response?.data || null,
|
||||
data: null,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function httpDeleteInterceptor(pathUrl: any) {
|
||||
const response = await axiosBaseInstance
|
||||
.delete(pathUrl)
|
||||
.catch((error) => error.response);
|
||||
console.log("Response interceptor : ", response);
|
||||
if (response?.status == 200 || response?.status == 201) {
|
||||
return {
|
||||
error: false,
|
||||
message: "success",
|
||||
data: response?.data,
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
error: true,
|
||||
message: response?.data?.message || response?.data || null,
|
||||
data: null,
|
||||
};
|
||||
}
|
||||
export async function httpDeleteInterceptor(pathUrl: any, headers: any) {
|
||||
const response = await axiosBaseInstance
|
||||
.delete(pathUrl, headers)
|
||||
.catch((error) => error.response);
|
||||
console.log("Response interceptor : ", response);
|
||||
if (response?.status == 200 || response?.status == 201) {
|
||||
return {
|
||||
error: false,
|
||||
message: "success",
|
||||
data: response?.data,
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
error: true,
|
||||
message: response?.data?.message || response?.data || null,
|
||||
data: null,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export async function mediahubGet(pathUrl: any, headers: any) {
|
||||
const response = await mediahubBaseInstance
|
||||
.get(pathUrl, { headers })
|
||||
.catch(function (error: any) {
|
||||
console.log(error);
|
||||
return error.response;
|
||||
});
|
||||
console.log("Response base svc : ", response);
|
||||
if (response?.status == 200 || response?.status == 201) {
|
||||
return {
|
||||
error: false,
|
||||
message: "success",
|
||||
data: response?.data,
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
error: true,
|
||||
message: response?.data?.message || response?.data || null,
|
||||
data: null,
|
||||
};
|
||||
}
|
||||
const response = await mediahubBaseInstance
|
||||
.get(pathUrl, { headers })
|
||||
.catch(function (error: any) {
|
||||
console.log(error);
|
||||
return error.response;
|
||||
});
|
||||
console.log("Response base svc : ", response);
|
||||
if (response?.status == 200 || response?.status == 201) {
|
||||
return {
|
||||
error: false,
|
||||
message: "success",
|
||||
data: response?.data,
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
error: true,
|
||||
message: response?.data?.message || response?.data || null,
|
||||
data: null,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,10 @@ export async function getMagazineById(id: string) {
|
|||
}
|
||||
|
||||
export async function deleteMagazine(id: string) {
|
||||
return await httpDeleteInterceptor(`magazines/${id}`);
|
||||
const headers = {
|
||||
"content-type": "application/json",
|
||||
};
|
||||
return await httpDeleteInterceptor(`magazines/${id}`, headers);
|
||||
}
|
||||
|
||||
export async function uploadMagazineFile(id: string, data: any) {
|
||||
|
|
@ -65,5 +68,8 @@ export async function uploadMagazineThumbnail(id: string, data: any) {
|
|||
}
|
||||
|
||||
export async function deleteMagazineFiles(id: number) {
|
||||
return await httpDeleteInterceptor(`magazine-files/${id}`);
|
||||
const headers = {
|
||||
"content-type": "multipart/form-data",
|
||||
};
|
||||
return await httpDeleteInterceptor(`magazine-files/${id}`, headers);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,10 @@ export async function getCategoryById(id: number) {
|
|||
}
|
||||
|
||||
export async function deleteCategory(id: number) {
|
||||
return await httpDeleteInterceptor(`article-categories/${id}`);
|
||||
const headers = {
|
||||
"content-type": "application/json",
|
||||
};
|
||||
return await httpDeleteInterceptor(`article-categories/${id}`, headers);
|
||||
}
|
||||
|
||||
export async function uploadCategoryThumbnail(id: string, data: any) {
|
||||
|
|
|
|||
|
|
@ -35,5 +35,8 @@ export async function getMasterUserRoleById(id: any) {
|
|||
}
|
||||
|
||||
export async function deleteMasterUserRole(id: string) {
|
||||
return await httpDeleteInterceptor(`/user-roles/${id}`);
|
||||
const headers = {
|
||||
"content-type": "application/json",
|
||||
};
|
||||
return await httpDeleteInterceptor(`/user-roles/${id}`, headers);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,10 @@ export async function editMasterUsers(data: any, id: string) {
|
|||
}
|
||||
|
||||
export async function deleteMasterUser(id: string) {
|
||||
return await httpDeleteInterceptor(`/users/${id}`);
|
||||
const headers = {
|
||||
"content-type": "application/json",
|
||||
};
|
||||
return await httpDeleteInterceptor(`/users/${id}`, headers);
|
||||
}
|
||||
|
||||
export async function postSignIn(data: any) {
|
||||
|
|
@ -132,5 +135,8 @@ export async function getArticleComment(id: string) {
|
|||
}
|
||||
|
||||
export async function deleteArticleComment(id: number) {
|
||||
return await httpDeleteInterceptor(`/article-comments/${id}`);
|
||||
const headers = {
|
||||
"content-type": "application/json",
|
||||
};
|
||||
return await httpDeleteInterceptor(`/article-comments/${id}`, headers);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,4 +65,5 @@ export type PaginationRequest = {
|
|||
category?: string;
|
||||
sortBy?: string;
|
||||
sort?: string;
|
||||
categorySlug?: string;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue