Skip to content

Commit

Permalink
feat(vil-612): add save for the step 3 of creation game
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanJuz committed Nov 4, 2024
1 parent 95cbbb3 commit 0524cf7
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
1 change: 1 addition & 0 deletions server/controllers/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ gameController.post({ path: '/standardGame', userType: UserType.TEACHER }, async
activityId = activity.id;
createGame(data.game as GameData, activity);
}
// step 2 & 3
} else {
const activity = await getActivityById(data.activityId);
if (activity) {
Expand Down
35 changes: 34 additions & 1 deletion src/pages/creer-un-jeu/mimique/3.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,49 @@
import { useRouter } from 'next/router';
import React from 'react';

import { postGameDataMonneyOrExpression } from 'src/api/game/game.post';
import { Base } from 'src/components/Base';
import { PageLayout } from 'src/components/PageLayout';
import { Steps } from 'src/components/Steps';
import { StepsButton } from 'src/components/StepsButtons';
import CreateGame from 'src/components/game/CreateGame';
import { ActivityContext } from 'src/contexts/activityContext';
import { GameContext } from 'src/contexts/gameContext';
import { UserContext } from 'src/contexts/userContext';
import { VillageContext } from 'src/contexts/villageContext';
import { ActivityStatus, ActivityType } from 'types/activity.type';
import type { GameDataMonneyOrExpression } from 'types/game.type';
import { GameType } from 'types/game.type';

const MimiqueStep3 = () => {
const router = useRouter();
const { selectedPhase } = React.useContext(VillageContext);
const { user } = React.useContext(UserContext);
const { village } = React.useContext(VillageContext);
const { gameConfig } = React.useContext(GameContext);
const { activityId } = React.useContext(ActivityContext);

const onNext = () => {
const onNext = async () => {
const data: GameDataMonneyOrExpression = {
userId: user?.id || 0,
villageId: village?.id || 0,
type: ActivityType.GAME,
subType: GameType.MIMIC,
game: {
type: GameType.MIMIC,
origine: gameConfig?.[2]?.[0]?.inputs?.[2]?.selectedValue,
signification: gameConfig?.[2]?.[0]?.inputs?.[1]?.selectedValue,
fakeSignification1: gameConfig?.[2]?.[1]?.inputs?.[0]?.selectedValue,
fakeSignification2: gameConfig?.[2]?.[1]?.inputs?.[1]?.selectedValue,
video: gameConfig?.[2]?.[0]?.inputs?.[0]?.selectedValue,
},
selectedPhase: selectedPhase,
status: ActivityStatus.DRAFT,
draftUrl: window.location.pathname,
activityId: activityId,
};

await postGameDataMonneyOrExpression(data);
router.push('/creer-un-jeu/mimique/4');
};

Expand Down

0 comments on commit 0524cf7

Please sign in to comment.