fix pagination

This commit is contained in:
Vlad 2024-10-12 19:08:24 +06:00
parent 40d8d21b3e
commit 59e7b48193
2 changed files with 3 additions and 3 deletions

View File

@ -21,7 +21,7 @@ const NewsList: React.FC<INewsListProps> = ({
useEffect(() => { useEffect(() => {
getNews(activePage); getNews(activePage);
}, []); }, [activePage]);
return ( return (
<div className="flex flex-col gap-4"> <div className="flex flex-col gap-4">
<ul className="flex gap-[30px] flex-wrap mb-[96px]"> <ul className="flex gap-[30px] flex-wrap mb-[96px]">
@ -46,7 +46,7 @@ const NewsList: React.FC<INewsListProps> = ({
next={news.next} next={news.next}
count={news.count as number} count={news.count as number}
current_count={news.results.length} current_count={news.results.length}
limit={20} limit={9}
/> />
</div> </div>
</div> </div>

View File

@ -22,7 +22,7 @@ export const useNewsStore = create<useNewsStore>((set) => ({
try { try {
set({ isLoading: true }); set({ isLoading: true });
const res = await apiInstance.get(`/news/`); const res = await apiInstance.get(`/news/?limit=9&offset=${(page - 1) * 9}`);
set({ data: res.data }); set({ data: res.data });
} catch (error: unknown) { } catch (error: unknown) {