Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
imhson committed Aug 30, 2024
1 parent 0d74fea commit f9e4933
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 79 deletions.
30 changes: 15 additions & 15 deletions public/config.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
{
"REDIRECT_URL": "https://staging.punkga.me",
"CHAIN_ID": "aura_6321-3",
"REDIRECT_URL": "https://punkga.me",
"CHAIN_ID": "aura_6322-2",
"CHAIN_INFO": {
"chainId": "aura_6321-3",
"evmChainId": 6321,
"chainName": "Aura Euphoria TestNet",
"rpc": ["https://rpc.euphoria.aura.network", "https://jsonrpc.euphoria.aura.network"],
"indexerV2": "https://indexer-v2.staging.aurascan.io/api/v2/graphql",
"chainId": "aura_6322-2",
"chainName": "Aura Mainnet",
"evmChainId": 6322,
"rpc": ["https://rpc.aura.network", "https://jsonrpc.aura.network"],
"indexerV2": "https://horoscope.aura.network/api/v2/graphql",
"nativeCurrency": {
"name": "Aura",
"symbol": "EAURA",
"symbol": "AURA",
"decimals": 18
},
"explorer": "https://euphoria.aurascan.io"
"explorer": "https://aurascan.io/"
},
"API_URL": "https://hasura.staging.punkga.me",
"AUTHORIZER_URL": "https://auth.staging.punkga.me",
"API_URL": "https://hasura.punkga.me",
"AUTHORIZER_URL": "https://auth.punkga.me",
"AUTHORIZER_CLIENT_ID": "06c9c437-15cd-4240-b435-5d16206b46c6",
"ADMIN_URL": "https://admin.staging.punkga.me",
"REST_API_URL": "https://api.staging.punkga.me",
"ADMIN_URL": "https://admin.punkga.me",
"REST_API_URL": "https://api.punkga.me",
"IN_MAINTENANCE_MODE": false,
"GTM_ID": "GTM-MMT4K22K",
"SEEKHYPE_URL": "https://staging.seekhype.io/",
"GTM_ID": "GTM-5N2X4HSN",
"SEEKHYPE_URL": "https://seekhype.io/",
"WALLET_CONNECT_PROJECT_ID": "ec40291093ad80fa0def54b1fb44c8ef"
}
72 changes: 56 additions & 16 deletions src/components/pages/artist/Contests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default function Contests({ id }) {
const [index, setIndex] = useState(1)
const [open, setOpen] = useState(false)
const [artworkPage, setArtworkPage] = useState(1)
const [selectedArtwork, setSelectedArtwork] = useState<any>(null)
const { t } = useTranslation()
const { locale } = useRouter()
const [selectedContest, setSelectedContest] = useState<any>()
Expand All @@ -34,14 +35,25 @@ export default function Contests({ id }) {
},
({ id, selectedContestId }) => (id && selectedContestId ? getContestMangaAndArtwork(id, selectedContestId) : null)
)
console.log(contestData)
if (isLoading)
return (
<div className='space-y-4'>
<Skeleton className='w-full aspect-[343/256]' />
<Skeleton className='w-full aspect-[343/256]' />
</div>
)
const prevHandler = () => {
const idx = contestData?.artworks?.artworks?.findIndex((artwork) => artwork.url == selectedArtwork.url)
if (contestData?.artworks?.artworks[idx - 1]) {
setSelectedArtwork(contestData?.artworks?.artworks[idx - 1])
}
}
const nextHandler = () => {
const idx = contestData?.artworks?.artworks?.findIndex((artwork) => artwork.url == selectedArtwork.url)
if (contestData?.artworks?.artworks[idx + 1]) {
setSelectedArtwork(contestData?.artworks?.artworks[idx + 1])
}
}
if (contestData) {
return (
<div className='-mt-4 lg:mt-0'>
Expand Down Expand Up @@ -79,7 +91,7 @@ export default function Contests({ id }) {
<div
key={index}
onClick={() => {
setIndex(index)
setSelectedArtwork(artwork)
setOpen(true)
}}>
<Image
Expand All @@ -104,20 +116,48 @@ export default function Contests({ id }) {
/>
</div>
)}
<Modal open={open} setOpen={setOpen} preventClickOutsideToClose={false}>
<Swiper slidesPerView={1} autoHeight initialSlide={index}>
{contestData?.artworks?.artworks?.map((artwork, index) => (
<SwiperSlide key={index}>
<Image
width={300}
height={300}
src={artwork.url}
alt=''
className='w-full h-auto rounded-md object-cover lg:max-w-[40vw]'
/>
</SwiperSlide>
))}
</Swiper>
<Modal
open={open}
setOpen={setOpen}
preventClickOutsideToClose={false}
className='[&_.static]:!overflow-visible'>
<div className='relative'>
<Image
width={300}
height={300}
src={selectedArtwork?.url}
alt=''
className='w-auto h-full max-h-[80vh] rounded-md object-cover'
/>
<div>
<div
onClick={prevHandler}
className='absolute -bottom-14 lg:top-1/2 -scale-x-100 left-[calc(50%-20px)] lg:-left-[98px] -translate-x-1/2 lg:translate-x-0 -translate-y-1/2 cursor-pointer bg-[#FFFFFF] rounded-full text-[#B0B0B0] hover:text-border-brand-hover active:text-border-brand-focus w-8 lg:w-16 h-8 lg:h-16 grid place-items-center shadow-[0px_4px_4px_rgba(0,0,0,0.25)]'>
<svg xmlns='http://www.w3.org/2000/svg' width='7' height='12' viewBox='0 0 7 12' fill='none'>
<path
d='M1 1L6 6L1 11'
stroke='currentColor'
strokeWidth='2'
strokeLinecap='round'
strokeLinejoin='round'
/>
</svg>
</div>
<div
onClick={nextHandler}
className='absolute -bottom-14 lg:top-1/2 right-[calc(50%-20px)] lg:-right-[98px] translate-x-1/2 lg:translate-x-0 -translate-y-1/2 cursor-pointer bg-[#FFFFFF] rounded-full text-[#B0B0B0] hover:text-border-brand-hover active:text-border-brand-focus w-8 lg:w-16 h-8 lg:h-16 grid place-items-center shadow-[0px_4px_4px_rgba(0,0,0,0.25)]'>
<svg xmlns='http://www.w3.org/2000/svg' width='7' height='12' viewBox='0 0 7 12' fill='none'>
<path
d='M1 1L6 6L1 11'
stroke='currentColor'
strokeWidth='2'
strokeLinecap='round'
strokeLinejoin='round'
/>
</svg>
</div>
</div>
</div>
</Modal>
</div>
)
Expand Down
102 changes: 54 additions & 48 deletions src/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -726,54 +726,60 @@ export const getContests = async (id: string) => {
return { contests: contests, count }
}
export const getContestMangaAndArtwork = async (id: string, contestId: string) => {
const { data: mangaData } = await axios.get(
`${getConfig().API_URL}/api/rest/public/creators/${id}/contests/${contestId}/manga`
)
const { data: artworksData } = await axios.get(
`${getConfig().API_URL}/api/rest/public/creators/${id}/contests/${contestId}/artworks`
)
return {
mangas: mangaData.manga?.map((m: any) => {
const response = {
id: m.id,
slug: m.slug,
image: m.poster,
status: {
type: COMIC_STATUS[formatStatus(m.status)],
text: formatStatus(m.status),
},
authors: m.manga_creators?.map((c: any) => ({
id: c.creator?.isActive ? c.creator?.id : undefined,
slug: c.creator?.isActive ? c.creator?.slug : undefined,
name: c.creator?.isActive ? c.creator?.pen_name || c.creator?.name : 'Unknown creator',
})),
views: m.manga_total_views?.views || 0,
likes: m.manga_total_likes?.likes || 0,
subscriptions: m.manga_subscribers_aggregate?.aggregate?.count || 0,
latestChap: {
number: m.chapters?.[0]?.chapter_number,
id: m.chapters?.[0]?.id,
},
tags: m.manga_tags.map(({ tag }: any) => {
const r = {}
LANGUAGE.forEach((l) => {
const tagLanguage = tag.tag_languages.find((tl) => tl.language_id == l.id) || tag.tag_languages[0]
r[l.shortLang] = tagLanguage.value
})
return r
}),
}
LANGUAGE.forEach((language) => {
const l =
m.manga_languages.find((ml) => ml.language_id == language.id) ||
m.manga_languages.find((ml) => ml.is_main_language)
response[language.shortLang] = {
title: l ? l?.title : 'Unknown title',
description: l ? l?.description : 'Unknown description',
try {
const { data: mangaData } = await axios.get(
`${getConfig().API_URL}/api/rest/public/creators/${id}/contests/${contestId}/manga`
)
const { data: artworksData } = await axios.get(
`${getConfig().API_URL}/api/rest/public/creators/${id}/contests/${contestId}/artworks`
)
const result = {
mangas: mangaData.manga?.map((m: any) => {
const response = {
id: m.id,
slug: m.slug,
image: m.poster,
status: {
type: COMIC_STATUS[formatStatus(m.status)],
text: formatStatus(m.status),
},
authors: m.manga_creators?.map((c: any) => ({
id: c.creator?.isActive ? c.creator?.id : undefined,
slug: c.creator?.isActive ? c.creator?.slug : undefined,
name: c.creator?.isActive ? c.creator?.pen_name || c.creator?.name : 'Unknown creator',
})),
views: m.manga_total_views?.views || 0,
likes: m.manga_total_likes?.likes || 0,
subscriptions: m.manga_subscribers_aggregate?.aggregate?.count || 0,
latestChap: {
number: m.chapters?.[0]?.chapter_number,
id: m.chapters?.[0]?.id,
},
tags: m.manga_tags.map(({ tag }: any) => {
const r = {}
LANGUAGE.forEach((l) => {
const tagLanguage = tag.tag_languages.find((tl) => tl.language_id == l.id) || tag.tag_languages[0]
r[l.shortLang] = tagLanguage.value
})
return r
}),
}
})
return response
}),
artworks: artworksData,
LANGUAGE.forEach((language) => {
const l =
m.manga_languages.find((ml) => ml.language_id == language.id) ||
m.manga_languages.find((ml) => ml.is_main_language)
response[language.shortLang] = {
title: l ? l?.title : 'Unknown title',
description: l ? l?.description : 'Unknown description',
}
})
return response
}),
artworks: artworksData,
}
console.log(result)
return result
} catch (error) {
console.error(error)
}
}

0 comments on commit f9e4933

Please sign in to comment.