-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #103 from cs3216-a3-group-4/seeleng/paginate-categ…
…ories feat: paginate categories page
- Loading branch information
Showing
13 changed files
with
474 additions
and
67 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
frontend/app/(authenticated)/categories/[id]/articles-list.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
"use client"; | ||
|
||
import { MiniEventDTO } from "@/client"; | ||
import ArticleLoading from "@/components/news/article-loading"; | ||
import NewsArticle from "@/components/news/news-article"; | ||
|
||
interface Props { | ||
eventData: MiniEventDTO[] | undefined; | ||
isEventsLoaded: boolean; | ||
} | ||
|
||
const Articles = ({ eventData, isEventsLoaded }: Props) => { | ||
if (!isEventsLoaded) { | ||
return ( | ||
<> | ||
<ArticleLoading /> | ||
<ArticleLoading /> | ||
<ArticleLoading /> | ||
</> | ||
); | ||
} | ||
|
||
if (eventData!.length == 0) { | ||
return ( | ||
<div className="flex w-full justify-center"> | ||
<p className="text-sm text-offblack"> | ||
No recent events. Try refreshing the page. | ||
</p> | ||
</div> | ||
); | ||
} | ||
|
||
return eventData!.map((newsEvent: MiniEventDTO, index: number) => ( | ||
<NewsArticle key={index} newsEvent={newsEvent} /> | ||
)); | ||
}; | ||
|
||
export default Articles; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
frontend/app/(authenticated)/events/[id]/page-component.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
"use client"; | ||
|
||
import { useEffect } from "react"; | ||
import Image from "next/image"; | ||
import { useQuery } from "@tanstack/react-query"; | ||
|
||
import { LoadingSpinner } from "@/components/ui/loading-spinner"; | ||
import { Separator } from "@/components/ui/separator"; | ||
import { getEvent } from "@/queries/event"; | ||
|
||
import EventAnalysis from "./event-analysis"; | ||
import EventDetails from "./event-details"; | ||
import EventSource from "./event-source"; | ||
import EventSummary from "./event-summary"; | ||
|
||
const Page = ({ params }: { params: { id: string } }) => { | ||
const id = parseInt(params.id); | ||
const { data, isLoading } = useQuery(getEvent(id)); | ||
|
||
console.log({ data, isLoading }); | ||
|
||
useEffect(() => { | ||
console.log(`Client-side hydration ${id}`); | ||
}, [id]); | ||
|
||
if (isLoading) { | ||
return ( | ||
<div className="flex justify-center items-center w-full"> | ||
<LoadingSpinner className="w-24 h-24" /> | ||
</div> | ||
); | ||
} | ||
|
||
return ( | ||
data && ( | ||
<div className="flex flex-col mx-8 md:mx-16 xl:mx-56 py-8 w-full h-fit"> | ||
<div className="flex flex-col gap-y-10"> | ||
<div className="flex w-full max-h-52 overflow-y-clip items-center rounded-t-2xl rounded-b-sm border"> | ||
<Image | ||
alt={data?.title} | ||
height={154} | ||
src={data.original_article.image_url} | ||
style={{ | ||
width: "100%", | ||
height: "fit-content", | ||
}} | ||
unoptimized | ||
width={273} | ||
/> | ||
</div> | ||
<h1 className="text-4xl font-bold px-6">{data.title}</h1> | ||
<EventDetails event={data} /> | ||
<EventSummary summary={data.description} /> | ||
</div> | ||
<Separator className="my-10" /> | ||
<EventAnalysis event={data} /> | ||
<Separator className="my-10" /> | ||
<EventSource originalSource={data.original_article} /> | ||
</div> | ||
) | ||
); | ||
}; | ||
|
||
export default Page; |
Oops, something went wrong.