Skip to content

Commit

Permalink
Merge branch 'staging' of github.com:aura-nw/aura-punkga into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
imhson committed Aug 6, 2024
2 parents e7c0456 + 3484c07 commit f2d0a9e
Show file tree
Hide file tree
Showing 3 changed files with 145 additions and 2 deletions.
68 changes: 68 additions & 0 deletions src/components/pages/artist/Artworks.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { Pagination, Skeleton } from '@mui/material'
import Mc from 'assets/images/mascot-empty.png'
import Image from 'next/image'
import { useState } from 'react'
import { useTranslation } from 'react-i18next'
import { getArtistArtworks } from 'src/services'
import useSWR from 'swr'
import Manga from '../homepage/manga'
export default function ArtworkList({ id }) {
const [page, setPage] = useState(1)
const { data, isLoading } = useSWR(
{
key: 'fetch-artist-artworks',
id,
page,
},
({ id, page }) => (id ? getArtistArtworks(id, (page - 1) * 12) : null)
)

const { t } = useTranslation()
if (isLoading) {
return (
<div className='grid grid-cols-2 gap-4'>
{Array(6)
.fill(0)
?.map((c, index) => (
<div key={index}>
<Skeleton className='w-full aspect-square' />
</div>
))}
</div>
)
}
return (
<div>
{data?.artworks?.length ? (
<div className='grid grid-cols-2 gap-4'>
{data?.artworks?.map((comic, index) => (
<div key={index}>
<Manga {...comic} />
</div>
))}
<div></div>
<div></div>
<div></div>
<div></div>
</div>
) : (
<div className='flex flex-col items-center gap-4 py-8'>
<Image src={Mc} alt='' className='w-[160px] h-[160px]' />
<div className='font-medium'>{t('No artwork found')}</div>
</div>
)}
{!!data?.artworks_aggregate?.aggregate?.count && (
<div className='w-full flex justify-center -mt-8'>
<Pagination
shape='rounded'
count={Math.ceil(data?.artworks_aggregate?.aggregate?.count / 12)}
page={page}
onChange={(event: React.ChangeEvent<unknown>, value: number) => {
setPage(value)
}}
/>
</div>
)}
</div>
)
}
75 changes: 75 additions & 0 deletions src/components/pages/artist/Contests.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import { Pagination, Skeleton } from '@mui/material'
import Mc from 'assets/images/mascot-empty.png'
import Image from 'next/image'
import Link from 'next/link'
import { useRouter } from 'next/router'
import { useState } from 'react'
import { useTranslation } from 'react-i18next'
import { getContests } from 'src/services'
import useSWR from 'swr'
export const Contests = ({ id }) => {
const [page, setPage] = useState(1)
const { t } = useTranslation()
const { locale } = useRouter()
const { data, isLoading } = useSWR(
{
key: 'fetch-artist-contest',
id,
page,
},
({ id, page }) => (id ? getContests(id, (page - 1) * 4) : null)
)

if (isLoading)
return (
<div className='space-y-4'>
<Skeleton className='w-full aspect-[343/256]' />
<Skeleton className='w-full aspect-[343/256]' />
</div>
)
return (
<div>
{data?.contest?.length ? (
<div className='grid grid-cols-1 gap-4'>
{data?.contest?.map((event, index) => (
<Link key={event.url} href={event.url} className='rounded-mlg p-4 bg-white relative'>
<div className='relative'>
<Image src={event[locale].image} alt='' className='w-full aspect-[310/166] object-cover' />
{event.isLive && (
<div className='absolute top-2.5 right-2.5 text-xxs font-semibold leading-[15px] bg-error-100 text-text-error-primary-3 flex items-center gap-1 rounded px-2.5 py-0.5'>
<svg xmlns='http://www.w3.org/2000/svg' width='4' height='4' viewBox='0 0 4 4' fill='none'>
<circle cx='2' cy='2' r='2' fill='#F73B3B' />
</svg>
Live
</div>
)}
</div>
<div className='mt-4'>
<div className='text-sm font-medium'>{event[locale].title}</div>
<div className='mt-1 text-xs text-text-teriary font-medium'>{event[locale].subtitle}</div>
</div>
</Link>
))}
<div></div>
</div>
) : (
<div className='flex flex-col items-center gap-4 py-8'>
<Image src={Mc} alt='' className='w-[160px] h-[160px]' />
<div className='font-medium'>{t('No artwork found')}</div>
</div>
)}
{!!data?.contest_aggregate?.aggregate?.count && (
<div className='w-full flex justify-center -mt-8'>
<Pagination
shape='rounded'
count={Math.ceil(data?.contest_aggregate?.aggregate?.count / 4)}
page={page}
onChange={(event: React.ChangeEvent<unknown>, value: number) => {
setPage(value)
}}
/>
</div>
)}
</div>
)
}
4 changes: 2 additions & 2 deletions src/pages/collections/[slug]/collectionDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function CollectionDetail() {
}, [locale])

useEffect(() => {
console.log('hash result',result)
console.log('hash result', result)
if (result.data && hash) {
if (result.data?.status == 'success') {
setSuccessOpen(true)
Expand All @@ -84,7 +84,7 @@ function CollectionDetail() {
refetch()
setProcessingText('')
}
}, [result, hash])
}, [result.data?.status, hash])

if (!data || !onChainData) {
return null
Expand Down

0 comments on commit f2d0a9e

Please sign in to comment.