mirror of
https://github.com/MetaFam/TheGame.git
synced 2026-02-11 06:24:56 -05:00
* squash frontend changes * Style quest explorer * Style quest page * Dates * Dates * Typecheck * Prettier * Fix create page layout * Update only OPEN quests * Repetition info * Fix create quest errors * Quest form Textarea * Quest form Textarea * Truncate texts * Redirect if user not logged in * Tooltips * Factorize skills tags * fix username in completions * Metafam as default guild on creation * Layouts * Remove todo * cooldown * Rename to "claim quest" * squash frontend changes * Style quest explorer * Style quest page * Dates * Dates * Typecheck * Prettier * Fix create page layout * Update only OPEN quests * Repetition info * Fix create quest errors * Quest form Textarea * Quest form Textarea * Truncate texts * Redirect if user not logged in * Tooltips * Factorize skills tags * fix username in completions * Metafam as default guild on creation * Layouts * Remove todo * cooldown * Rename to "claim quest" * Move ConfirmModal in ds * Extract pSeed balance * Fix "created by me" switch * Reword complete quest * Style quest form * prettier * lint
69 lines
1.5 KiB
TypeScript
69 lines
1.5 KiB
TypeScript
import gql from 'fake-tag';
|
|
import { Client } from 'urql';
|
|
|
|
import {
|
|
GetQuestDocument,
|
|
GetQuestQuery,
|
|
GetQuestQueryVariables,
|
|
GetQuestWithCompletionsDocument,
|
|
GetQuestWithCompletionsQuery,
|
|
GetQuestWithCompletionsQueryVariables,
|
|
} from './autogen/types';
|
|
import { client as defaultClient } from './client';
|
|
import {
|
|
PlayerFragment,
|
|
QuestFragment,
|
|
QuestWithCompletionFragment,
|
|
} from './fragments';
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
gql`
|
|
query GetQuest($id: uuid!) {
|
|
quest_by_pk(id: $id) {
|
|
...QuestFragment
|
|
}
|
|
}
|
|
${QuestFragment}
|
|
`;
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
gql`
|
|
query GetQuestWithCompletions($id: uuid!) {
|
|
quest_by_pk(id: $id) {
|
|
...QuestWithCompletionFragment
|
|
player {
|
|
...PlayerFragment
|
|
}
|
|
}
|
|
}
|
|
${QuestWithCompletionFragment}
|
|
${PlayerFragment}
|
|
`;
|
|
|
|
export const getQuest = async (
|
|
id: string | undefined,
|
|
client: Client = defaultClient,
|
|
) => {
|
|
if (!id) return null;
|
|
const { data } = await client
|
|
.query<GetQuestQuery, GetQuestQueryVariables>(GetQuestDocument, { id })
|
|
.toPromise();
|
|
|
|
return data?.quest_by_pk;
|
|
};
|
|
|
|
export const getQuestWithCompletions = async (
|
|
id: string | undefined,
|
|
client: Client = defaultClient,
|
|
) => {
|
|
if (!id) return null;
|
|
const { data } = await client
|
|
.query<GetQuestWithCompletionsQuery, GetQuestWithCompletionsQueryVariables>(
|
|
GetQuestWithCompletionsDocument,
|
|
{ id },
|
|
)
|
|
.toPromise();
|
|
|
|
return data?.quest_by_pk;
|
|
};
|