mirror of
https://github.com/Radiquum/AniX.git
synced 2025-04-30 01:49:40 +05:00
feat: add Show Releases Pages. fix: hover handling on touchscreens
This commit is contained in:
parent
b0246aa4e5
commit
7f2b4f17a4
9 changed files with 168 additions and 43 deletions
50
app/home/[slug]/page.js
Normal file
50
app/home/[slug]/page.js
Normal file
|
@ -0,0 +1,50 @@
|
|||
"use client";
|
||||
import useSWR from "swr";
|
||||
import { ReleaseSection } from "../../components/ReleaseSection/ReleaseSection";
|
||||
import { Spinner } from "../../components/Spinner/Spinner";
|
||||
|
||||
const fetcher = async (...args) => {
|
||||
const res = await fetch(...args);
|
||||
|
||||
if (!res.ok) {
|
||||
const error = new Error("An error occurred while fetching the data.");
|
||||
error.info = await res.json();
|
||||
error.status = res.status;
|
||||
throw error;
|
||||
}
|
||||
|
||||
return res.json();
|
||||
};
|
||||
|
||||
const SectionTitleMapping = {
|
||||
last: "Последние релизы",
|
||||
finished: "Завершенные релизы",
|
||||
ongoing: "В эфире",
|
||||
announce: "Анонсированные релизы",
|
||||
};
|
||||
|
||||
export default function HomeStatus({ params }) {
|
||||
const { data, error, isLoading } = useSWR(
|
||||
`/api/home?status=${params.slug}`,
|
||||
fetcher
|
||||
);
|
||||
|
||||
if (error) return <div>failed to load</div>;
|
||||
if (isLoading)
|
||||
return (
|
||||
<main className="flex flex-col items-center justify-center min-w-full min-h-screen">
|
||||
<Spinner />
|
||||
</main>
|
||||
);
|
||||
|
||||
return (
|
||||
<main className="flex flex-col pt-2 pb-16 sm:pt-4 sm:pb-0">
|
||||
{data && (
|
||||
<ReleaseSection
|
||||
sectionTitle={SectionTitleMapping[params.slug]}
|
||||
content={data.content}
|
||||
/>
|
||||
)}
|
||||
</main>
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue