diff --git a/src/components/pages/artist/Contests.tsx b/src/components/pages/artist/Contests.tsx index d31664e5..9943bb97 100644 --- a/src/components/pages/artist/Contests.tsx +++ b/src/components/pages/artist/Contests.tsx @@ -1,5 +1,6 @@ import { Pagination, Skeleton } from '@mui/material' import Mc from 'assets/images/mascot-empty.png' +import moment from 'moment' import Image from 'next/image' import Link from 'next/link' import { useRouter } from 'next/router' @@ -26,16 +27,16 @@ export default function Contests({ id }) { ) - console.log(data) + console.log(data) return (
- {data?.contest?.length ? ( -
- {data?.contest?.map((event, index) => ( - + {data?.contests?.length ? ( +
+ {data?.contests?.map((contest, index) => ( +
- - {event.isLive && ( + + {moment().isAfter(contest.start_date) && moment().isBefore(contest.end_date) && (
@@ -45,24 +46,32 @@ export default function Contests({ id }) { )}
-
{event[locale].title}
-
{event[locale].subtitle}
+
{contest[locale].title}
+
+ {locale == 'vn' + ? `${moment(contest.start_date).format('DD/MM/yyyy')} - ${moment(contest.end_date).format( + 'DD/MM/yyyy' + )}` + : `${moment(contest.start_date).format('MM/DD/yyyy')} - ${moment(contest.end_date).format( + 'MM/DD/yyyy' + )}`} +
- +
))}
) : (
-
{t('No artwork found')}
+
{t('No contest applied')}
)} - {!!data?.contest_aggregate?.aggregate?.count && ( -
+ {!!data?.count && ( +
, value: number) => { setPage(value) diff --git a/src/services/index.ts b/src/services/index.ts index 9fc6acc9..1d6c53c4 100644 --- a/src/services/index.ts +++ b/src/services/index.ts @@ -708,6 +708,20 @@ export const getArtistCollections = async (id: string) => { return { launchpads: launchpads as Launchpad[], count } } export const getContests = async (id: string) => { - const res = await axios.get(`${getConfig().API_URL}/api/rest/public/creators/${id}/contests`) - return res?.data + const {data} = await axios.get(`${getConfig().API_URL}/api/rest/public/creators/${id}/contests`) + const contestData = data.contest + const count = data.contest_aggregate.aggregate.count + const contests = contestData?.map((contest: any) => { + LANGUAGE.forEach((l) => { + const contestLanguage = + contest.contest_i18ns.find((ml) => ml.i18n_language.id == l.id) || + contest.contest_i18ns.find((ml) => ml.i18n_language.is_main) + contest[l.shortLang] = { + title: contestLanguage?.data?.title, + image: contestLanguage?.data?.image, + } + }) + return contest + }) + return { contests: contests, count } }