From 2b9a8c0ce34962c3d8d83405a4081bad188ab342 Mon Sep 17 00:00:00 2001 From: Sunday Date: Mon, 2 Sep 2024 22:30:27 +0700 Subject: [PATCH] update mangas --- .../pages/event/kaia-island/Artwork.tsx | 2 +- .../pages/event/pudgy-asia-tour/Mangas.tsx | 102 ++++++++++++++++++ src/pages/events/pudgy-asia-tour/page.tsx | 2 + 3 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 src/components/pages/event/pudgy-asia-tour/Mangas.tsx diff --git a/src/components/pages/event/kaia-island/Artwork.tsx b/src/components/pages/event/kaia-island/Artwork.tsx index 265e0ba1..6d136619 100644 --- a/src/components/pages/event/kaia-island/Artwork.tsx +++ b/src/components/pages/event/kaia-island/Artwork.tsx @@ -129,7 +129,7 @@ export default function Artworks() { {latestComic.loading ? Array.apply(null, Array(10)).map((d, index) => ) : useableComic?.length - ? useableComic.map((data, index) => ) + ? useableComic?.slice((page - 1) * 10, page * 10)?.map((data, index) => ) : null} )} diff --git a/src/components/pages/event/pudgy-asia-tour/Mangas.tsx b/src/components/pages/event/pudgy-asia-tour/Mangas.tsx new file mode 100644 index 00000000..e9c52403 --- /dev/null +++ b/src/components/pages/event/pudgy-asia-tour/Mangas.tsx @@ -0,0 +1,102 @@ +import { Pagination } from '@mui/material' +import DummyComic from 'components/DummyComponent/comic' +import Image from 'next/image' +import Link from 'next/link' +import { useRouter } from 'next/router' +import { Fragment, useEffect, useState } from 'react' +import { isMobile } from 'react-device-detect' +import { useTranslation } from 'react-i18next' +import useApi from 'src/hooks/useApi' +import { IComic } from 'src/models/comic' +import { getLatestComic } from 'src/services' + +export default function Mangas() { + const { t } = useTranslation() + const latestComic = useApi(getLatestComic, true, []) + const [page, setPage] = useState(1) + const [useableComic, setUseableComic] = useState() + useEffect(() => { + const comic = latestComic.data?.filter( + (data: any) => + data.tags.some((lang: any) => lang.en.toLowerCase() === 'invent contest') && + data.tags.some((lang: any) => lang.en.toLowerCase() === 'pudgy asia tour') + ) + setUseableComic(comic) + }, [latestComic.data]) + if (!useableComic?.data?.length) return null + return ( +
+
+ {t('Mangas')} +
+
+
+ {latestComic.loading + ? null + : useableComic.data?.length + ? useableComic.slice((page - 1) * 12, page * 12).map((data, index) => ) + : null} +
+ {!!useableComic?.data?.length && ( + , value: number) => { + setPage(value) + }} + count={Math.ceil(useableComic.data?.length / 12)} + /> + )} +
+
+ ) +} +const Manga = (props) => { + const router = useRouter() + const { t } = useTranslation() + return ( + +
+
+ +
+
+
{props['en'].title}
+
+ by{' '} + + {props.authors.map((author, index) => ( + + , + + {author.slug ? ( +
{ + router.push(`/artist/${author.slug}`) + e.stopPropagation() + e.preventDefault() + }}> + {t(author.name)} +
+ ) : ( + t(author.name) + )} +
+
+ ))} +
+
+
+ + ) +} diff --git a/src/pages/events/pudgy-asia-tour/page.tsx b/src/pages/events/pudgy-asia-tour/page.tsx index 813553ea..63015cdb 100644 --- a/src/pages/events/pudgy-asia-tour/page.tsx +++ b/src/pages/events/pudgy-asia-tour/page.tsx @@ -20,6 +20,7 @@ import Rule1 from 'components/pages/event/pudgy-asia-tour/assets/rule1.png' import Rule1VN from 'components/pages/event/pudgy-asia-tour/assets/rule1vn.png' import Rule2 from 'components/pages/event/pudgy-asia-tour/assets/rule2.png' import Rule3 from 'components/pages/event/pudgy-asia-tour/assets/rule3.png' +import Mangas from 'components/pages/event/pudgy-asia-tour/Mangas' export default function Pudgy() { const { locale } = useRouter() const { t } = useTranslation() @@ -243,6 +244,7 @@ export default function Pudgy() { +