diff --git a/api/functions/graphql/nexus-typegen.ts b/api/functions/graphql/nexus-typegen.ts index b5d78da..44f453f 100644 --- a/api/functions/graphql/nexus-typegen.ts +++ b/api/functions/graphql/nexus-typegen.ts @@ -69,6 +69,7 @@ export interface NexusGenInputs { export interface NexusGenEnums { POST_TYPE: "Bounty" | "Question" | "Story" RoleLevelEnum: 3 | 0 | 1 | 2 | 4 + TournamentEventTypeEnum: 2 | 0 | 1 VOTE_ITEM_TYPE: "Bounty" | "PostComment" | "Project" | "Question" | "Story" | "User" } @@ -261,7 +262,7 @@ export interface NexusGenObjects { links: string[]; // [String!]! location: string; // String! title: string; // String! - type: string; // String! + type: NexusGenEnums['TournamentEventTypeEnum']; // TournamentEventTypeEnum! website: string; // String! } TournamentFAQ: { // root type @@ -562,7 +563,7 @@ export interface NexusGenFieldTypes { links: string[]; // [String!]! location: string; // String! title: string; // String! - type: string; // String! + type: NexusGenEnums['TournamentEventTypeEnum']; // TournamentEventTypeEnum! website: string; // String! } TournamentFAQ: { // field return type @@ -886,7 +887,7 @@ export interface NexusGenFieldTypeNames { links: 'String' location: 'String' title: 'String' - type: 'String' + type: 'TournamentEventTypeEnum' website: 'String' } TournamentFAQ: { // field return type name diff --git a/api/functions/graphql/schema.graphql b/api/functions/graphql/schema.graphql index 0a8c099..2944fcc 100644 --- a/api/functions/graphql/schema.graphql +++ b/api/functions/graphql/schema.graphql @@ -351,10 +351,16 @@ type TournamentEvent { links: [String!]! location: String! title: String! - type: String! + type: TournamentEventTypeEnum! website: String! } +enum TournamentEventTypeEnum { + IRLMeetup + TwitterSpace + Workshop +} + type TournamentFAQ { answer: String! question: String! diff --git a/api/functions/graphql/types/tournament.js b/api/functions/graphql/types/tournament.js index c60de12..6952ff8 100644 --- a/api/functions/graphql/types/tournament.js +++ b/api/functions/graphql/types/tournament.js @@ -4,6 +4,7 @@ const { stringArg, extendType, nonNull, + enumType, } = require('nexus'); const { prisma } = require('../../../prisma'); @@ -35,6 +36,18 @@ const TournamentFAQ = objectType({ } }) + + +const TournamentEventTypeEnum = enumType({ + name: 'TournamentEventTypeEnum', + members: { + TwitterSpace: 0, + Workshop: 1, + IRLMeetup: 2, + }, +}); + + const TournamentEvent = objectType({ name: 'TournamentEvent', definition(t) { @@ -45,7 +58,7 @@ const TournamentEvent = objectType({ t.nonNull.date('date'); t.nonNull.string('location'); t.nonNull.string('website'); - t.nonNull.string('type'); + t.nonNull.field('type', { type: TournamentEventTypeEnum }) t.nonNull.list.nonNull.string('links'); } }) diff --git a/src/features/Tournaments/pages/EventsPage/EventCard/EventCard.tsx b/src/features/Tournaments/pages/EventsPage/EventCard/EventCard.tsx index 54c478f..07f74de 100644 --- a/src/features/Tournaments/pages/EventsPage/EventCard/EventCard.tsx +++ b/src/features/Tournaments/pages/EventsPage/EventCard/EventCard.tsx @@ -4,8 +4,10 @@ import dayjs from "dayjs"; import advancedFormat from 'dayjs/plugin/advancedFormat' import { trimText } from "src/utils/helperFunctions"; import { Override } from "src/utils/interfaces"; -import { Tag, Tournament } from "src/graphql"; -dayjs.extend(advancedFormat) +import { Tag, Tournament, TournamentEventTypeEnum } from "src/graphql"; +import { UnionToObjectKeys } from 'src/utils/types/utils'; +import { useAppDispatch, } from "src/utils/hooks"; +import { openModal } from "src/redux/features/modals.slice"; interface Props { @@ -22,8 +24,25 @@ interface Props { } export default function EventCard({ event }: Props) { + + const dispatch = useAppDispatch() + + const openEventModal = () => { + dispatch(openModal({ + Modal: "EventModal", + isPageModal: true, + props: { + event + } + })) + } + return ( -
-
{trimText(event.description, 90)}
+ + {mapTypeToBadge[event.type].text} ++ {event.date} +
+
+
+
+ {event.description} +
+