feat: update list sidebar polda
This commit is contained in:
parent
53d291c31d
commit
af5b8000cd
|
|
@ -14,20 +14,13 @@ import Image from "next/image";
|
||||||
|
|
||||||
export default function SidebarDetail() {
|
export default function SidebarDetail() {
|
||||||
const [articleMabes, setArticleMabes] = useState<any>([]);
|
const [articleMabes, setArticleMabes] = useState<any>([]);
|
||||||
const [article, setArticle] = useState<any>([]);
|
const [articlePolda, setArticlePolda] = useState<any>([]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getArticle();
|
|
||||||
getArticleMabes();
|
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() {
|
async function getArticleMabes() {
|
||||||
const req = {
|
const req = {
|
||||||
page: 1,
|
page: 1,
|
||||||
|
|
@ -40,6 +33,14 @@ export default function SidebarDetail() {
|
||||||
const response = await getListArticle(req);
|
const response = await getListArticle(req);
|
||||||
setArticleMabes(response?.data?.data);
|
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 (
|
return (
|
||||||
<div className="mt-2 space-y-5">
|
<div className="mt-2 space-y-5">
|
||||||
<div className="font-semibold flex flex-col items-center py-3 rounded-lg">
|
<div className="font-semibold flex flex-col items-center py-3 rounded-lg">
|
||||||
|
|
@ -109,7 +110,7 @@ export default function SidebarDetail() {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="w-full mt-3">
|
<div className="w-full mt-3">
|
||||||
{article?.length < 1 ? (
|
{articlePolda?.length < 1 ? (
|
||||||
<Skeleton className="rounded-lg">
|
<Skeleton className="rounded-lg">
|
||||||
<div className="h-[320px] rounded-lg bg-default-300" />
|
<div className="h-[320px] rounded-lg bg-default-300" />
|
||||||
</Skeleton>
|
</Skeleton>
|
||||||
|
|
@ -129,7 +130,7 @@ export default function SidebarDetail() {
|
||||||
className="mySwiper"
|
className="mySwiper"
|
||||||
slidesPerView={1}
|
slidesPerView={1}
|
||||||
>
|
>
|
||||||
{article?.map((newsItem: any) => (
|
{articlePolda?.map((newsItem: any) => (
|
||||||
<SwiperSlide key={newsItem.id}>
|
<SwiperSlide key={newsItem.id}>
|
||||||
<div className=" h-[320px] flex flex-col gap-2 bg-gray-100 dark:bg-black p-4 rounded-lg">
|
<div className=" h-[320px] flex flex-col gap-2 bg-gray-100 dark:bg-black p-4 rounded-lg">
|
||||||
<Image
|
<Image
|
||||||
|
|
|
||||||
|
|
@ -24,12 +24,13 @@ export async function getListArticle(props: PaginationRequest) {
|
||||||
isBanner,
|
isBanner,
|
||||||
categoryIds,
|
categoryIds,
|
||||||
createdByIds,
|
createdByIds,
|
||||||
|
isPolda,
|
||||||
} = props;
|
} = props;
|
||||||
const headers = {
|
const headers = {
|
||||||
"content-type": "application/json",
|
"content-type": "application/json",
|
||||||
};
|
};
|
||||||
return await httpGet(
|
return await httpGet(
|
||||||
`/articles?limit=${limit}&page=${page}&isPublish=${
|
`/articles/public?limit=${limit}&page=${page}&isPublish=${
|
||||||
isPublish === undefined ? "" : isPublish
|
isPublish === undefined ? "" : isPublish
|
||||||
}&title=${search}&startDate=${startDate || ""}&endDate=${
|
}&title=${search}&startDate=${startDate || ""}&endDate=${
|
||||||
endDate || ""
|
endDate || ""
|
||||||
|
|
@ -37,7 +38,7 @@ export async function getListArticle(props: PaginationRequest) {
|
||||||
sort || "desc"
|
sort || "desc"
|
||||||
}&category=${categorySlug || ""}&isBanner=${isBanner || ""}&categoryIds=${
|
}&category=${categorySlug || ""}&isBanner=${isBanner || ""}&categoryIds=${
|
||||||
categoryIds || ""
|
categoryIds || ""
|
||||||
}&createdByIds=${createdByIds || ""}`,
|
}&createdByIds=${createdByIds || ""}&isPolda=${isPolda || ""}`,
|
||||||
headers
|
headers
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -69,4 +69,5 @@ export type PaginationRequest = {
|
||||||
isBanner?: boolean;
|
isBanner?: boolean;
|
||||||
categoryIds?: string;
|
categoryIds?: string;
|
||||||
createdByIds?: string;
|
createdByIds?: string;
|
||||||
|
isPolda?: boolean;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue