feat: add hacking_status to api, update maker card, halt registration if already registered

This commit is contained in:
MTG2000
2022-09-09 09:46:18 +03:00
parent a0f09aaa33
commit 64d8263ae6
17 changed files with 301 additions and 109 deletions

View File

@@ -192,6 +192,10 @@ export interface NexusGenObjects {
twitter?: string | null; // String
website?: string | null; // String
}
ParticipationInfo: { // root type
createdAt: NexusGenScalars['Date']; // Date!
hacking_status: NexusGenEnums['TournamentMakerHackingStatusEnum']; // TournamentMakerHackingStatusEnum!
}
PostComment: { // root type
author: NexusGenRootTypes['Author']; // Author!
body: string; // String!
@@ -275,7 +279,12 @@ export interface NexusGenObjects {
TournamentMakersResponse: { // root type
hasNext?: boolean | null; // Boolean
hasPrev?: boolean | null; // Boolean
makers: NexusGenRootTypes['User'][]; // [User!]!
makers: NexusGenRootTypes['TournamentParticipant'][]; // [TournamentParticipant!]!
}
TournamentParticipant: { // root type
hacking_status: NexusGenEnums['TournamentMakerHackingStatusEnum']; // TournamentMakerHackingStatusEnum!
is_registered?: boolean | null; // Boolean
user: NexusGenRootTypes['User']; // User!
}
TournamentPrize: { // root type
amount: string; // String!
@@ -464,6 +473,10 @@ export interface NexusGenFieldTypes {
walletsKeys: NexusGenRootTypes['WalletKey'][]; // [WalletKey!]!
website: string | null; // String
}
ParticipationInfo: { // field return type
createdAt: NexusGenScalars['Date']; // Date!
hacking_status: NexusGenEnums['TournamentMakerHackingStatusEnum']; // TournamentMakerHackingStatusEnum!
}
PostComment: { // field return type
author: NexusGenRootTypes['Author']; // Author!
body: string; // String!
@@ -514,6 +527,7 @@ export interface NexusGenFieldTypes {
projectsByCategory: NexusGenRootTypes['Project'][]; // [Project!]!
searchProjects: NexusGenRootTypes['Project'][]; // [Project!]!
similarMakers: NexusGenRootTypes['User'][]; // [User!]!
tournamentParticipationInfo: NexusGenRootTypes['ParticipationInfo'] | null; // ParticipationInfo
}
Question: { // field return type
author: NexusGenRootTypes['Author']; // Author!
@@ -593,7 +607,12 @@ export interface NexusGenFieldTypes {
TournamentMakersResponse: { // field return type
hasNext: boolean | null; // Boolean
hasPrev: boolean | null; // Boolean
makers: NexusGenRootTypes['User'][]; // [User!]!
makers: NexusGenRootTypes['TournamentParticipant'][]; // [TournamentParticipant!]!
}
TournamentParticipant: { // field return type
hacking_status: NexusGenEnums['TournamentMakerHackingStatusEnum']; // TournamentMakerHackingStatusEnum!
is_registered: boolean | null; // Boolean
user: NexusGenRootTypes['User']; // User!
}
TournamentPrize: { // field return type
amount: string; // String!
@@ -807,6 +826,10 @@ export interface NexusGenFieldTypeNames {
walletsKeys: 'WalletKey'
website: 'String'
}
ParticipationInfo: { // field return type name
createdAt: 'Date'
hacking_status: 'TournamentMakerHackingStatusEnum'
}
PostComment: { // field return type name
author: 'Author'
body: 'String'
@@ -857,6 +880,7 @@ export interface NexusGenFieldTypeNames {
projectsByCategory: 'Project'
searchProjects: 'Project'
similarMakers: 'User'
tournamentParticipationInfo: 'ParticipationInfo'
}
Question: { // field return type name
author: 'Author'
@@ -936,7 +960,12 @@ export interface NexusGenFieldTypeNames {
TournamentMakersResponse: { // field return type name
hasNext: 'Boolean'
hasPrev: 'Boolean'
makers: 'User'
makers: 'TournamentParticipant'
}
TournamentParticipant: { // field return type name
hacking_status: 'TournamentMakerHackingStatusEnum'
is_registered: 'Boolean'
user: 'User'
}
TournamentPrize: { // field return type name
amount: 'String'
@@ -1133,6 +1162,9 @@ export interface NexusGenArgTypes {
similarMakers: { // args
id: number; // Int!
}
tournamentParticipationInfo: { // args
tournamentId: number; // Int!
}
}
User: {
in_tournament: { // args

View File

@@ -188,6 +188,11 @@ enum POST_TYPE {
Story
}
type ParticipationInfo {
createdAt: Date!
hacking_status: TournamentMakerHackingStatusEnum!
}
union Post = Bounty | Question | Story
interface PostBase {
@@ -272,6 +277,7 @@ type Query {
projectsByCategory(category_id: Int!, skip: Int = 0, take: Int = 10): [Project!]!
searchProjects(search: String!, skip: Int = 0, take: Int = 50): [Project!]!
similarMakers(id: Int!): [User!]!
tournamentParticipationInfo(tournamentId: Int!): ParticipationInfo
}
type Question implements PostBase {
@@ -393,7 +399,13 @@ enum TournamentMakerHackingStatusEnum {
type TournamentMakersResponse {
hasNext: Boolean
hasPrev: Boolean
makers: [User!]!
makers: [TournamentParticipant!]!
}
type TournamentParticipant {
hacking_status: TournamentMakerHackingStatusEnum!
is_registered: Boolean
user: User!
}
type TournamentPrize {

View File

@@ -39,7 +39,14 @@ const TournamentFAQ = objectType({
}
})
const TournamentParticipant = objectType({
name: "TournamentParticipant",
definition(t) {
t.nonNull.field('hacking_status', { type: TournamentMakerHackingStatusEnum });
t.boolean('is_registered')
t.nonNull.field('user', { type: "User" })
}
})
const TournamentEventTypeEnum = enumType({
name: 'TournamentEventTypeEnum',
@@ -152,7 +159,7 @@ const TournamentMakersResponse = objectType({
t.boolean('hasNext');
t.boolean('hasPrev');
t.nonNull.list.nonNull.field('makers', { type: "User" })
t.nonNull.list.nonNull.field('makers', { type: TournamentParticipant })
}
}
)
@@ -185,7 +192,40 @@ const getTournamentById = extendType({
}
})
const ParticipationInfo = objectType({
name: "ParticipationInfo",
definition(t) {
t.nonNull.date('createdAt')
t.nonNull.field('hacking_status', { type: TournamentMakerHackingStatusEnum });
}
})
const tournamentParticipationInfo = extendType({
type: "Query",
definition(t) {
t.field('tournamentParticipationInfo', {
type: ParticipationInfo,
args: {
tournamentId: nonNull(intArg()),
},
async resolve(_, args, ctx) {
const user = await getUserByPubKey(ctx.userPubKey);
if (!user)
return null
return prisma.tournamentParticipant.findFirst({
where: {
user_id: user.id,
tournament_id: args.tournamentId
}
})
}
})
}
})
const getMakersInTournament = extendType({
type: "Query",
@@ -198,7 +238,9 @@ const getMakersInTournament = extendType({
search: stringArg(),
roleId: intArg(),
},
async resolve(_, args) {
async resolve(_, args, ctx) {
const user = await getUserByPubKey(ctx.userPubKey);
let filters = [];
@@ -229,6 +271,12 @@ const getMakersInTournament = extendType({
}
})
if (user?.id) filters.push({
id: {
not: user.id
}
})
const makers = (await prisma.tournamentParticipant.findMany({
where: {
tournament_id: args.tournamentId,
@@ -238,12 +286,19 @@ const getMakersInTournament = extendType({
}
})
},
orderBy: {
createdAt: 'desc'
},
include: {
user: true,
},
skip: args.skip,
take: args.take + 1,
})).map(item => item.user)
}))
.map(item => ({
hacking_status: item.hacking_status,
user: item.user
}))
@@ -381,6 +436,7 @@ const registerInTournament = extendType({
module.exports = {
// Types
Tournament,
// Enums
TournamentEventTypeEnum,
@@ -388,8 +444,9 @@ module.exports = {
getTournamentById,
getMakersInTournament,
getProjectsInTournament,
tournamentParticipationInfo,
// Mutations
registerInTournament,
}
}

View File

@@ -16,22 +16,22 @@ export default function LinkingAccountModal({ onClose, direction, maker, ...prop
const links = [
{
hasValue: maker.twitter,
text: maker.twitter,
hasValue: maker.user.twitter,
text: maker.user.twitter,
icon: FiTwitter,
url: `https://twitter.com/${maker.twitter}`
url: `https://twitter.com/${maker.user.twitter}`
},
{
hasValue: maker.github,
text: maker.github,
hasValue: maker.user.github,
text: maker.user.github,
icon: FiGithub,
url: `https://github.com/${maker.github}`
url: `https://github.com/${maker.user.github}`
},
{
hasValue: maker.linkedin,
hasValue: maker.user.linkedin,
text: "LinkedIn",
icon: FiLinkedin,
url: maker.linkedin && withHttp(maker.linkedin),
url: maker.user.linkedin && withHttp(maker.user.linkedin),
}
];
@@ -51,10 +51,10 @@ export default function LinkingAccountModal({ onClose, direction, maker, ...prop
</div>
<hr className="bg-gray-200" />
<div className='flex flex-col justify-center gap-24 items-center text-center p-24'>
<Avatar src={maker.avatar} width={80} />
<Avatar src={maker.user.avatar} width={80} />
<div className="flex flex-col gap-4">
<p className="text-body3 text-gray-900">{maker.name}</p>
<p className="text-body4 text-gray-600">{maker.jobTitle}</p>
<p className="text-body3 text-gray-900">{maker.user.name}</p>
<p className="text-body4 text-gray-600">{maker.user.jobTitle}</p>
</div>
<p className="text-gray-600">Team up with this maker by sending them a message on one of the following platforms.</p>

View File

@@ -1,11 +1,13 @@
import Button from "src/Components/Button/Button"
import { GetMakersInTournamentQuery, } from "src/graphql";
import { GetMakersInTournamentQuery, TournamentMakerHackingStatusEnum, } from "src/graphql";
import { useAppDispatch, } from "src/utils/hooks";
import Card from 'src/Components/Card/Card';
import Avatar from 'src/features/Profiles/Components/Avatar/Avatar';
import Badge from 'src/Components/Badge/Badge';
import { createRoute } from 'src/utils/routing';
import { openModal } from "src/redux/features/modals.slice";
import InfoCard from "src/Components/InfoCard/InfoCard";
import { Link } from "react-router-dom";
type MakerType = GetMakersInTournamentQuery['getMakersInTournament']['makers'][number]
@@ -18,27 +20,33 @@ export default function MakerCard({ maker, isMe }: Props) {
const dispatch = useAppDispatch();
const contactLinksAvailable = maker.github || maker.email || maker.linkedin || maker.twitter;
const contactLinksAvailable = maker.user.github || maker.user.linkedin || maker.user.twitter;
let actionBtn = <Button fullWidth color='white' disabled size='sm' className='ml-auto'>Hacking solo</Button>
let actionBtn = <></>
if (isMe) actionBtn = <Button fullWidth color='white' href={createRoute({ type: 'edit-profile' })} size='sm' className='ml-auto'>Edit Profile</Button>;
else if (contactLinksAvailable) actionBtn = <Button fullWidth color='white' size='sm' className='ml-auto' onClick={() => dispatch(openModal({ Modal: "ConnectToMakerModal", props: { maker } }))}>🤝 Team Up</Button>
if (isMe)
actionBtn = <Button fullWidth color='white' href={createRoute({ type: 'edit-profile' })} size='sm' className='ml-auto'>Edit Profile</Button>;
else if (maker.hacking_status === TournamentMakerHackingStatusEnum.OpenToConnect && contactLinksAvailable)
actionBtn = <Button fullWidth color='white' size='sm' className='ml-auto' onClick={() => dispatch(openModal({ Modal: "ConnectToMakerModal", props: { maker } }))}>🤝 Team Up</Button>
else if (maker.hacking_status === TournamentMakerHackingStatusEnum.Solo)
actionBtn = <Button fullWidth color='white' disabled size='sm' className='ml-auto'>Hacking solo</Button>
const missingFields = isMe && getMissingFields(maker)
return (
<Card>
<div className="flex flex-wrap gap-24 items-start">
<div className="shrink-0 w-64 md:w-80">
<Avatar src={maker.avatar} width={'100%'}></Avatar>
<Avatar src={maker.user.avatar} width={'100%'}></Avatar>
</div>
<div className="flex flex-col gap-4 flex-1 overflow-hidden">
<p className="text-body2 text-gray-900 font-bold overflow-hidden text-ellipsis">{maker.name}</p>
{maker.jobTitle ? <p className="text-body4 text-gray-600 font-medium">{maker.jobTitle}</p>
<p className="text-body2 text-gray-900 font-bold overflow-hidden text-ellipsis">{maker.user.name}</p>
{maker.user.jobTitle ? <p className="text-body4 text-gray-600 font-medium">{maker.user.jobTitle}</p>
:
<p className="text-body4 text-gray-400 font-medium">No job title</p>}
{maker.roles.length ? <ul className="hidden md:flex flex-wrap gap-8 mt-4">
{maker.roles.map(role => <li key={role.id}><Badge size='sm' className='!text-body5'>{role.icon} {role.title}</Badge> </li>)}
{maker.user.roles.length ? <ul className="hidden md:flex flex-wrap gap-8 mt-4">
{maker.user.roles.map(role => <li key={role.id}><Badge size='sm' className='!text-body5'>{role.icon} {role.title}</Badge> </li>)}
</ul>
:
<p className="hidden md:block text-body4 text-gray-400">No roles added</p>
@@ -51,8 +59,8 @@ export default function MakerCard({ maker, isMe }: Props) {
<div className="md:hidden mt-24">
<p className="text-body5 text-gray-900 font-medium mb-12">🌈 Roles</p>
{maker.roles.length ? <ul className="flex flex-wrap gap-8">
{maker.roles.map(role => <li key={role.id}><Badge size='sm' className='!text-body5'>{role.icon} {role.title}</Badge> </li>)}
{maker.user.roles.length ? <ul className="flex flex-wrap gap-8">
{maker.user.roles.map(role => <li key={role.id}><Badge size='sm' className='!text-body5'>{role.icon} {role.title}</Badge> </li>)}
</ul>
:
<p className="text-body4 text-gray-400">No roles added</p>
@@ -61,14 +69,33 @@ export default function MakerCard({ maker, isMe }: Props) {
<div className="mt-24">
<p className="text-body5 text-gray-900 font-medium mb-12">🛠 Skills</p>
{maker.skills.length ? <ul className="flex flex-wrap gap-8">
{maker.skills.map(skill => <li key={skill.id}><Badge size='sm' className='!text-body5'>{skill.title}</Badge> </li>)}
{maker.user.skills.length ? <ul className="flex flex-wrap gap-8">
{maker.user.skills.map(skill => <li key={skill.id}><Badge size='sm' className='!text-body5'>{skill.title}</Badge> </li>)}
</ul>
:
<p className="text-body4 text-gray-400">No skills added</p>
}
</div>
<div className="md:hidden w-full mt-24">{actionBtn}</div>
{missingFields && <InfoCard className="!bg-warning-50 !border-warning-200 mt-24">
<span className="font-bold">👾 Complete your profile:</span> make it easy for other makers to find you by adding your <span className="font-bold">{missingFields}</span>. You can add this information in your profiles <Link to={createRoute({ type: "edit-profile" })} className='underline text-blue-500'>Settings menu.</Link>
</InfoCard>}
</Card>
)
}
function getMissingFields(maker: Props['maker']) {
let res: string[] = [];
if (!maker.user.jobTitle) res.push("job title")
if (maker.user.roles.length === 0) res.push('roles')
if (maker.user.skills.length === 0) res.push('skills')
if (!maker.user.linkedin && !maker.user.twitter) res.push('contacts')
return res.join(', ');
}

View File

@@ -1,4 +1,4 @@
import { Tournament, useMeTournamentQuery, User } from 'src/graphql'
import { Tournament, useMeTournamentQuery, User, } from 'src/graphql'
import MakerCard from './MakerCard/MakerCard';
import MakerCardSkeleton from './MakerCard/MakerCard.Skeleton';
import ParticipantsSection from './ParticipantsSection/ParticipantsSection';
@@ -12,7 +12,7 @@ interface Props {
export default function MakersPage({ data: { id } }: Props) {
const query = useMeTournamentQuery({
variables: { inTournamentId: id }
variables: { id: id }
});
return (
@@ -21,8 +21,8 @@ export default function MakersPage({ data: { id } }: Props) {
{query.loading ?
<MakerCardSkeleton />
:
query.data?.me?.in_tournament ?
<MakerCard isMe maker={query.data.me as User} />
query.data?.me ?
<MakerCard isMe maker={{ user: query.data.me as User, hacking_status: query.data.tournamentParticipationInfo?.hacking_status! }} />
: null
}
<ParticipantsSection tournamentId={id} />

View File

@@ -87,7 +87,7 @@ export default function MakersList(props: Props) {
</>
:
(itemsCount !== 0 ?
query.data?.getMakersInTournament.makers.map(maker => <MakerCard key={maker.id} maker={maker} />) :
query.data?.getMakersInTournament.makers.map(maker => <MakerCard key={maker.user.id} maker={maker} />) :
<div className="py-80 text-center text-body2">
<p className="text-gray-400">No makers found here...</p>
</div>)

View File

@@ -64,7 +64,7 @@ export default function ParticipantsSection({ tournamentId }: Props) {
>
Makers looking for a team
</button>
<button
{/* <button
className={`
min-w-max rounded-48 px-16 py-8 cursor-pointer font-medium text-body5
active:scale-95 transition-transform
@@ -73,7 +73,7 @@ export default function ParticipantsSection({ tournamentId }: Props) {
onClick={() => setCurTab('projects')}
>
Projects looking for makers
</button>
</button> */}
</div>
</div>
{curTab === 'projects' && <ProjectsList searchFilter={debouncedsearchFilter} roleFilter={roleFilter?.id ?? null} tournamentId={tournamentId} />}

View File

@@ -23,22 +23,24 @@ query GetMakersInTournament(
hasNext
hasPrev
makers {
id
name
avatar
jobTitle
email
twitter
linkedin
github
roles {
hacking_status
user {
id
icon
title
}
skills {
id
title
name
avatar
jobTitle
twitter
linkedin
github
roles {
id
icon
title
}
skills {
id
title
}
}
}
}

View File

@@ -12,6 +12,7 @@ import useCopyToClipboard from 'src/utils/hooks/useCopyToClipboard';
import { useLnurlQuery } from 'src/features/Auth/pages/LoginPage/LoginPage';
import { useAppDispatch } from 'src/utils/hooks';
import { Direction, replaceModal } from 'src/redux/features/modals.slice';
import { NotificationsService } from 'src/services';
interface Props extends ModalCard {
@@ -34,13 +35,15 @@ export default function LinkingAccountModal({ onClose, direction, tournamentId,
const meQuery = useMeTournamentQuery({
variables: {
inTournamentId: tournamentId
id: tournamentId
},
onCompleted: (data) => {
if (data.me) {
const already_registerd = data.me.in_tournament;
if (already_registerd)
const already_registerd = !!data.tournamentParticipationInfo;
if (already_registerd) {
onClose?.();
NotificationsService.info("You are already registered")
}
else dispatch(replaceModal({
Modal: "RegisterTournamet_RegistrationDetails",
direction: Direction.NEXT,

View File

@@ -28,20 +28,21 @@ export default function Navigation({ data }: Props) {
path: "makers",
},
{
text: `Projects (${data.projects_count})`,
text: `Projects 🔒`,
path: "projects",
},
{
text: "???? 🚧",
path: "ideas",
isDisabled: true,
},
{
text: "?????????? 🚧",
path: "resources",
isDisabled: true,
},
], [data.events_count, data.makers_count, data.projects_count])
// {
// text: "???? 🚧",
// path: "ideas",
// isDisabled: true,
// },
// {
// text: "?????????? 🚧",
// path: "resources",
// isDisabled: true,
// },
], [data.events_count, data.makers_count])
return (
<div className="w-full bg-white py-16 border-b border-gray-200 sticky-top-element z-10">

View File

@@ -44,7 +44,7 @@ export default function TournamentDetailsPage() {
<div className="content-container !mt-24">
<Routes >
<Route index element={<Navigate to='overview' />} />
<Route path='overview' element={<OverviewPage data={tournaemntQuery.data.getTournamentById} avatars={tournaemntQuery.data.getMakersInTournament.makers.map(m => m.avatar)} isRegistered={!!tournaemntQuery.data.me?.in_tournament} />} />
<Route path='overview' element={<OverviewPage data={tournaemntQuery.data.getTournamentById} avatars={tournaemntQuery.data.getMakersInTournament.makers.map(m => m.user.avatar)} isRegistered={!!tournaemntQuery.data.tournamentParticipationInfo} />} />
<Route path='events' element={<EventsPage data={tournaemntQuery.data.getTournamentById} />} />
<Route path='makers' element={<MakersPage data={tournaemntQuery.data.getTournamentById} />} />
<Route path='projects' element={<ProjectsPage data={tournaemntQuery.data.getTournamentById} />} />

View File

@@ -1,11 +1,16 @@
query MeTournament($inTournamentId: Int!) {
query MeTournament($id: Int!) {
tournamentParticipationInfo(tournamentId: $id) {
createdAt
hacking_status
}
me {
id
name
avatar
jobTitle
in_tournament(id: $inTournamentId)
twitter
linkedin
github
...UserRolesSkills
}

View File

@@ -44,18 +44,25 @@ query GetTournamentById($id: Int!) {
getMakersInTournament(tournamentId: $id, take: 4) {
makers {
id
avatar
user {
id
avatar
}
}
}
tournamentParticipationInfo(tournamentId: $id) {
createdAt
hacking_status
}
me {
id
name
avatar
jobTitle
in_tournament(id: $id)
twitter
linkedin
github
...UserRolesSkills
}

View File

@@ -279,6 +279,12 @@ export enum Post_Type {
Story = 'Story'
}
export type ParticipationInfo = {
__typename?: 'ParticipationInfo';
createdAt: Scalars['Date'];
hacking_status: TournamentMakerHackingStatusEnum;
};
export type Post = Bounty | Question | Story;
export type PostBase = {
@@ -366,6 +372,7 @@ export type Query = {
projectsByCategory: Array<Project>;
searchProjects: Array<Project>;
similarMakers: Array<User>;
tournamentParticipationInfo: Maybe<ParticipationInfo>;
};
@@ -473,6 +480,11 @@ export type QuerySimilarMakersArgs = {
id: Scalars['Int'];
};
export type QueryTournamentParticipationInfoArgs = {
tournamentId: Scalars['Int'];
};
export type Question = PostBase & {
__typename?: 'Question';
author: Author;
@@ -600,7 +612,14 @@ export type TournamentMakersResponse = {
__typename?: 'TournamentMakersResponse';
hasNext: Maybe<Scalars['Boolean']>;
hasPrev: Maybe<Scalars['Boolean']>;
makers: Array<User>;
makers: Array<TournamentParticipant>;
};
export type TournamentParticipant = {
__typename?: 'TournamentParticipant';
hacking_status: TournamentMakerHackingStatusEnum;
is_registered: Maybe<Scalars['Boolean']>;
user: User;
};
export type TournamentPrize = {
@@ -875,7 +894,7 @@ export type GetMakersInTournamentQueryVariables = Exact<{
}>;
export type GetMakersInTournamentQuery = { __typename?: 'Query', getMakersInTournament: { __typename?: 'TournamentMakersResponse', hasNext: boolean | null, hasPrev: boolean | null, makers: Array<{ __typename?: 'User', id: number, name: string, avatar: string, jobTitle: string | null, email: string | null, twitter: string | null, linkedin: string | null, github: string | null, roles: Array<{ __typename?: 'MakerRole', id: number, icon: string, title: string }>, skills: Array<{ __typename?: 'MakerSkill', id: number, title: string }> }> } };
export type GetMakersInTournamentQuery = { __typename?: 'Query', getMakersInTournament: { __typename?: 'TournamentMakersResponse', hasNext: boolean | null, hasPrev: boolean | null, makers: Array<{ __typename?: 'TournamentParticipant', hacking_status: TournamentMakerHackingStatusEnum, user: { __typename?: 'User', id: number, name: string, avatar: string, jobTitle: string | null, twitter: string | null, linkedin: string | null, github: string | null, roles: Array<{ __typename?: 'MakerRole', id: number, icon: string, title: string }>, skills: Array<{ __typename?: 'MakerSkill', id: number, title: string }> } }> } };
export type GetProjectsInTournamentQueryVariables = Exact<{
tournamentId: Scalars['Int'];
@@ -897,18 +916,18 @@ export type RegisterInTournamentMutationVariables = Exact<{
export type RegisterInTournamentMutation = { __typename?: 'Mutation', registerInTournament: { __typename?: 'User', id: number, in_tournament: boolean } | null };
export type MeTournamentQueryVariables = Exact<{
inTournamentId: Scalars['Int'];
id: Scalars['Int'];
}>;
export type MeTournamentQuery = { __typename?: 'Query', me: { __typename?: 'MyProfile', id: number, name: string, avatar: string, jobTitle: string | null, in_tournament: boolean, skills: Array<{ __typename?: 'MakerSkill', id: number, title: string }>, roles: Array<{ __typename?: 'MakerRole', id: number, title: string, icon: string, level: RoleLevelEnum }> } | null };
export type MeTournamentQuery = { __typename?: 'Query', tournamentParticipationInfo: { __typename?: 'ParticipationInfo', createdAt: any, hacking_status: TournamentMakerHackingStatusEnum } | null, me: { __typename?: 'MyProfile', id: number, name: string, avatar: string, jobTitle: string | null, twitter: string | null, linkedin: string | null, github: string | null, skills: Array<{ __typename?: 'MakerSkill', id: number, title: string }>, roles: Array<{ __typename?: 'MakerRole', id: number, title: string, icon: string, level: RoleLevelEnum }> } | null };
export type GetTournamentByIdQueryVariables = Exact<{
id: Scalars['Int'];
}>;
export type GetTournamentByIdQuery = { __typename?: 'Query', getTournamentById: { __typename?: 'Tournament', id: number, title: string, description: string, thumbnail_image: string, cover_image: string, start_date: any, end_date: any, location: string, website: string, events_count: number, makers_count: number, projects_count: number, prizes: Array<{ __typename?: 'TournamentPrize', title: string, amount: string, image: string }>, judges: Array<{ __typename?: 'TournamentJudge', name: string, company: string, avatar: string }>, events: Array<{ __typename?: 'TournamentEvent', id: number, title: string, image: string, description: string, starts_at: any, ends_at: any, location: string, website: string, type: TournamentEventTypeEnum, links: Array<string> }>, faqs: Array<{ __typename?: 'TournamentFAQ', question: string, answer: string }> }, getMakersInTournament: { __typename?: 'TournamentMakersResponse', makers: Array<{ __typename?: 'User', id: number, avatar: string }> }, me: { __typename?: 'MyProfile', id: number, name: string, avatar: string, jobTitle: string | null, in_tournament: boolean, skills: Array<{ __typename?: 'MakerSkill', id: number, title: string }>, roles: Array<{ __typename?: 'MakerRole', id: number, title: string, icon: string, level: RoleLevelEnum }> } | null };
export type GetTournamentByIdQuery = { __typename?: 'Query', getTournamentById: { __typename?: 'Tournament', id: number, title: string, description: string, thumbnail_image: string, cover_image: string, start_date: any, end_date: any, location: string, website: string, events_count: number, makers_count: number, projects_count: number, prizes: Array<{ __typename?: 'TournamentPrize', title: string, amount: string, image: string }>, judges: Array<{ __typename?: 'TournamentJudge', name: string, company: string, avatar: string }>, events: Array<{ __typename?: 'TournamentEvent', id: number, title: string, image: string, description: string, starts_at: any, ends_at: any, location: string, website: string, type: TournamentEventTypeEnum, links: Array<string> }>, faqs: Array<{ __typename?: 'TournamentFAQ', question: string, answer: string }> }, getMakersInTournament: { __typename?: 'TournamentMakersResponse', makers: Array<{ __typename?: 'TournamentParticipant', user: { __typename?: 'User', id: number, avatar: string } }> }, tournamentParticipationInfo: { __typename?: 'ParticipationInfo', createdAt: any, hacking_status: TournamentMakerHackingStatusEnum } | null, me: { __typename?: 'MyProfile', id: number, name: string, avatar: string, jobTitle: string | null, twitter: string | null, linkedin: string | null, github: string | null, skills: Array<{ __typename?: 'MakerSkill', id: number, title: string }>, roles: Array<{ __typename?: 'MakerRole', id: number, title: string, icon: string, level: RoleLevelEnum }> } | null };
export type VoteMutationVariables = Exact<{
itemType: Vote_Item_Type;
@@ -2281,22 +2300,24 @@ export const GetMakersInTournamentDocument = gql`
hasNext
hasPrev
makers {
id
name
avatar
jobTitle
email
twitter
linkedin
github
roles {
hacking_status
user {
id
icon
title
}
skills {
id
title
name
avatar
jobTitle
twitter
linkedin
github
roles {
id
icon
title
}
skills {
id
title
}
}
}
}
@@ -2433,13 +2454,19 @@ export type RegisterInTournamentMutationHookResult = ReturnType<typeof useRegist
export type RegisterInTournamentMutationResult = Apollo.MutationResult<RegisterInTournamentMutation>;
export type RegisterInTournamentMutationOptions = Apollo.BaseMutationOptions<RegisterInTournamentMutation, RegisterInTournamentMutationVariables>;
export const MeTournamentDocument = gql`
query MeTournament($inTournamentId: Int!) {
query MeTournament($id: Int!) {
tournamentParticipationInfo(tournamentId: $id) {
createdAt
hacking_status
}
me {
id
name
avatar
jobTitle
in_tournament(id: $inTournamentId)
twitter
linkedin
github
...UserRolesSkills
}
}
@@ -2457,7 +2484,7 @@ export const MeTournamentDocument = gql`
* @example
* const { data, loading, error } = useMeTournamentQuery({
* variables: {
* inTournamentId: // value for 'inTournamentId'
* id: // value for 'id'
* },
* });
*/
@@ -2516,16 +2543,24 @@ export const GetTournamentByIdDocument = gql`
}
getMakersInTournament(tournamentId: $id, take: 4) {
makers {
id
avatar
user {
id
avatar
}
}
}
tournamentParticipationInfo(tournamentId: $id) {
createdAt
hacking_status
}
me {
id
name
avatar
jobTitle
in_tournament(id: $id)
twitter
linkedin
github
...UserRolesSkills
}
}

View File

@@ -37,6 +37,7 @@ import {
GetMakersInTournamentQuery,
GetMakersInTournamentQueryVariables,
MeTournamentQuery,
TournamentMakerHackingStatusEnum,
} from 'src/graphql'
const delay = (ms = 1000) => new Promise((res) => setTimeout(res, ms + Math.random() * 1000))
@@ -284,7 +285,12 @@ export const handlers = [
ctx.data({
getTournamentById: getTournamentById(12),
getMakersInTournament: getMakersInTournament({ roleId: null, search: null, skip: null, take: 4, tournamentId: 12 }),
me: { ...me() }
me: { ...me() },
tournamentParticipationInfo: {
hacking_status: TournamentMakerHackingStatusEnum.OpenToConnect,
createdAt: new Date()
}
})
)
}),
@@ -294,7 +300,11 @@ export const handlers = [
return res(
ctx.data({
me: { ...me() }
me: { ...me() },
tournamentParticipationInfo: {
hacking_status: TournamentMakerHackingStatusEnum.OpenToConnect,
createdAt: new Date()
}
})
)
}),
@@ -304,7 +314,7 @@ export const handlers = [
return res(
ctx.data({
getMakersInTournament: getMakersInTournament(req.variables)
getMakersInTournament: getMakersInTournament(req.variables),
})
)
}),

View File

@@ -1,5 +1,5 @@
import { MOCK_DATA } from "./data";
import { GetMakersInTournamentQueryVariables, MyProfile, Query, QueryGetFeedArgs, QueryGetPostByIdArgs, User } from 'src/graphql'
import { GetMakersInTournamentQueryVariables, MyProfile, Query, QueryGetFeedArgs, QueryGetPostByIdArgs, TournamentMakerHackingStatusEnum, User } from 'src/graphql'
import { Chance } from "chance";
import { tags } from "./data/tags";
import { hackathons } from "./data/hackathon";
@@ -114,7 +114,8 @@ export function getMakersInTournament(vars: GetMakersInTournamentQueryVariables)
if (!vars.roleId) return true;
return u.roles.some(r => r.id === vars.roleId)
})
.slice(offsetStart, offsetEnd + 1) as User[]
.slice(offsetStart, offsetEnd + 1)
.map(u => ({ user: u as User, hacking_status: TournamentMakerHackingStatusEnum.OpenToConnect }))
;
return {