From f314b0dfc73699e8b5bc7039311fa319ab7921df Mon Sep 17 00:00:00 2001 From: steel <mael.acier@ensiie.fr> Date: Sun, 8 Sep 2024 23:35:59 +0200 Subject: [PATCH] 1/0A --- README.md | 19 +++++++++++++++++++ src/lib/graphql/queries.ts | 8 ++++++++ src/routes/quiz/new/+page.server.ts | 13 +++++++++++-- 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5ce6766..243302f 100644 --- a/README.md +++ b/README.md @@ -36,3 +36,22 @@ npm run build You can preview the production build with `npm run preview`. > To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment. + +```graphql +mutation createToken { + createToken( + token: { + id: "quiestce" + description: "Qui est-ce | photos & pseudos" + claims: [ + { claim: "users.id", access: READ } + { claim: "users.nickname", access: READ } + { claim: "users.photo", access: READ } + ] + allowedIps: ["0.0.0.0/0"] + } + ) { + base64 + } +} +``` diff --git a/src/lib/graphql/queries.ts b/src/lib/graphql/queries.ts index 105febf..68a07b4 100644 --- a/src/lib/graphql/queries.ts +++ b/src/lib/graphql/queries.ts @@ -36,3 +36,11 @@ export const USER_DETAILS_QUERY = graphql(` } } `); + +export const INTE_QUERY = graphql(` + query Inte { + globalsValues { + integration + } + } +`); diff --git a/src/routes/quiz/new/+page.server.ts b/src/routes/quiz/new/+page.server.ts index dcb8a77..4ceb1dc 100644 --- a/src/routes/quiz/new/+page.server.ts +++ b/src/routes/quiz/new/+page.server.ts @@ -6,6 +6,9 @@ import { Game, GameStage } from "$lib/game"; import { getPromotion } from "$lib/data"; import images from "./images"; import { sum } from "$lib/utils"; +import { client } from "$lib/graphql"; +import { INTE_QUERY } from "$lib/graphql/queries"; +import { handleGqlError } from "$lib/graphql/error"; type BaseLevel = { year: number; @@ -28,10 +31,16 @@ export async function load(event) { if (game.state.stage !== GameStage.NEW) redirect(303, "/quiz"); + const globals = await client.query(INTE_QUERY, {}); + handleGqlError(globals); + + const { integration } = globals.data!.globalsValues; + const zeroA = integration ? 0 : 1; + const baseLevels: BaseLevel[] = [ { - year: 1, - name: "1A", + year: zeroA, + name: `${zeroA}A`, image: images.stroller, }, { -- GitLab