feat: update list sidebar polda

This commit is contained in:
hanif salafi 2025-06-01 02:00:00 +07:00
parent 53d291c31d
commit af5b8000cd
3 changed files with 16 additions and 13 deletions

View File

@ -14,20 +14,13 @@ import Image from "next/image";
export default function SidebarDetail() {
const [articleMabes, setArticleMabes] = useState<any>([]);
const [article, setArticle] = useState<any>([]);
const [articlePolda, setArticlePolda] = useState<any>([]);
useEffect(() => {
getArticle();
getArticleMabes();
getArticlePolda();
}, []);
async function getArticle() {
const req = { page: 1, search: "", limit: "10", isPublish: true };
const response = await getListArticle(req);
setArticle(response?.data?.data);
}
async function getArticleMabes() {
const req = {
page: 1,
@ -40,6 +33,14 @@ export default function SidebarDetail() {
const response = await getListArticle(req);
setArticleMabes(response?.data?.data);
}
async function getArticlePolda() {
const req = { page: 1, search: "", limit: "10", isPublish: true, isPolda: true };
const response = await getListArticle(req);
setArticlePolda(response?.data?.data);
}
return (
<div className="mt-2 space-y-5">
<div className="font-semibold flex flex-col items-center py-3 rounded-lg">
@ -109,7 +110,7 @@ export default function SidebarDetail() {
</div>
</div>
<div className="w-full mt-3">
{article?.length < 1 ? (
{articlePolda?.length < 1 ? (
<Skeleton className="rounded-lg">
<div className="h-[320px] rounded-lg bg-default-300" />
</Skeleton>
@ -129,7 +130,7 @@ export default function SidebarDetail() {
className="mySwiper"
slidesPerView={1}
>
{article?.map((newsItem: any) => (
{articlePolda?.map((newsItem: any) => (
<SwiperSlide key={newsItem.id}>
<div className=" h-[320px] flex flex-col gap-2 bg-gray-100 dark:bg-black p-4 rounded-lg">
<Image

View File

@ -24,12 +24,13 @@ export async function getListArticle(props: PaginationRequest) {
isBanner,
categoryIds,
createdByIds,
isPolda,
} = props;
const headers = {
"content-type": "application/json",
};
return await httpGet(
`/articles?limit=${limit}&page=${page}&isPublish=${
`/articles/public?limit=${limit}&page=${page}&isPublish=${
isPublish === undefined ? "" : isPublish
}&title=${search}&startDate=${startDate || ""}&endDate=${
endDate || ""
@ -37,7 +38,7 @@ export async function getListArticle(props: PaginationRequest) {
sort || "desc"
}&category=${categorySlug || ""}&isBanner=${isBanner || ""}&categoryIds=${
categoryIds || ""
}&createdByIds=${createdByIds || ""}`,
}&createdByIds=${createdByIds || ""}&isPolda=${isPolda || ""}`,
headers
);
}

View File

@ -69,4 +69,5 @@ export type PaginationRequest = {
isBanner?: boolean;
categoryIds?: string;
createdByIds?: string;
isPolda?: boolean;
};