Skip to content

Commit

Permalink
update mangas
Browse files Browse the repository at this point in the history
  • Loading branch information
imhson committed Sep 2, 2024
1 parent bf9940f commit 2b9a8c0
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/components/pages/event/kaia-island/Artwork.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export default function Artworks() {
{latestComic.loading
? Array.apply(null, Array(10)).map((d, index) => <DummyComic key={index} />)
: useableComic?.length
? useableComic.map((data, index) => <Manga key={index} {...data} />)
? useableComic?.slice((page - 1) * 10, page * 10)?.map((data, index) => <Manga key={index} {...data} />)
: null}
</>
)}
Expand Down
102 changes: 102 additions & 0 deletions src/components/pages/event/pudgy-asia-tour/Mangas.tsx
Original file line number Diff line number Diff line change
@@ -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<IComic[]>(getLatestComic, true, [])
const [page, setPage] = useState(1)
const [useableComic, setUseableComic] = useState<any>()
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 (
<div className='pt-20 pk-container'>
<div className='uppercase text-white text-center w-full drop-shadow-[2px_2px_0px_#000] trailer-font text-[36px] md:text-[64px] leading-[47px] md:leading-[84px] font-black text-stroke'>
{t('Mangas')}
</div>
<div className='flex gap-8 md:gap-16 mt-8 md:mt-16 flex-col items-center'>
<div className='grid grid-cols-[repeat(auto-fill,minmax(150px,1fr))] lg:grid-cols-[repeat(auto-fill,minmax(270px,1fr))] gap-4 md:gap-8 w-full'>
{latestComic.loading
? null
: useableComic.data?.length
? useableComic.slice((page - 1) * 12, page * 12).map((data, index) => <Manga key={index} {...data} />)
: null}
</div>
{!!useableComic?.data?.length && (
<Pagination
shape='rounded'
page={page}
className='[&_.Mui-selected]:!bg-[#FABA77] [&_.Mui-selected]:!text-text-primary [&_.MuiPaginationItem-root:not(.Mui-selected)]:!text-text-quatenary'
onChange={(event: React.ChangeEvent<unknown>, value: number) => {
setPage(value)
}}
count={Math.ceil(useableComic.data?.length / 12)}
/>
)}
</div>
</div>
)
}
const Manga = (props) => {
const router = useRouter()
const { t } = useTranslation()
return (
<Link
href={isMobile ? `/comic/${props.slug}` : `/comic/${props.slug}/chapter/1`}
className='[&:hover_.shadow]:visible relative'>
<div className='relative'>
<div className='absolute w-full h-full -bottom-1.5 -right-1.5 bg-black rounded-xl invisible shadow'></div>
<Image
width={400}
height={600}
src={props.image}
alt=''
className=' relative w-full aspect-[164/230] object-cover rounded-xl border border-black'
/>
</div>
<div className='hidden lg:block mt-4'>
<div className='trailer-font font-black text-[32px] leading-[47px]'>{props['en'].title}</div>
<div className='estedad-font text-[24px] leading-[35px] font-semibold flex gap-1'>
by{' '}
<span>
{props.authors.map((author, index) => (
<Fragment key={index}>
<span className=' first:hidden'>, </span>
<span className=''>
{author.slug ? (
<div
className='author'
onClick={(e) => {
router.push(`/artist/${author.slug}`)
e.stopPropagation()
e.preventDefault()
}}>
{t(author.name)}
</div>
) : (
t(author.name)
)}
</span>
</Fragment>
))}
</span>
</div>
</div>
</Link>
)
}
2 changes: 2 additions & 0 deletions src/pages/events/pudgy-asia-tour/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -243,6 +244,7 @@ export default function Pudgy() {
</div>
<TimeLine />
<PudgyList />
<Mangas/>
<div className='mt-28 -mb-14 flex justify-center overflow-hidden'>
<FooterAnimationSection />
</div>
Expand Down

0 comments on commit 2b9a8c0

Please sign in to comment.