From a046f78f0a49fb09ab85a63a09f13c61abd98410 Mon Sep 17 00:00:00 2001 From: Kishan Sambhi Date: Tue, 16 Jul 2024 16:30:44 +0100 Subject: [PATCH 1/2] chore: use updated mathpix token route --- src/api/routes.ts | 1 + .../Task/variants/HandwritingTask/live-updates.hook.ts | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/api/routes.ts b/src/api/routes.ts index ff49cb1..a630a5e 100644 --- a/src/api/routes.ts +++ b/src/api/routes.ts @@ -5,6 +5,7 @@ const routes = { studentMarks: (studentID: string) => `/${studentID}/marks`, question: (number: number) => `/questions/${number}`, questionAnswers: (number: number, username: string) => `/answers/${username}/question/${number}`, + getMathPixToken: '/proxy/mathpix-token', } export default routes diff --git a/src/components/questionStructure/Task/variants/HandwritingTask/live-updates.hook.ts b/src/components/questionStructure/Task/variants/HandwritingTask/live-updates.hook.ts index 86c710f..06e6f4e 100644 --- a/src/components/questionStructure/Task/variants/HandwritingTask/live-updates.hook.ts +++ b/src/components/questionStructure/Task/variants/HandwritingTask/live-updates.hook.ts @@ -8,6 +8,7 @@ import axios, { AxiosError } from 'axios' import { useCallback, useEffect, useRef, useState } from 'react' import axiosInstance from '../../../../../api/axiosInstance' +import routes from '../../../../../api/routes' // Constant /** Time to wait with user putting no stroks on the pages before API call */ @@ -91,10 +92,10 @@ const useLiveUpdates = (username: string, setLatex: (latex: string) => void): Li // Get a token for a mathpix session for this user const getToken = useCallback(() => { - axiosInstance.get(`/handwriting/${username}/mathpix-token`).then((res) => { + axiosInstance.get(routes.getMathPixToken).then((res) => { setToken(res.data) }) - }, [username]) + }, []) // Get token on startup (or username change) useEffect(getToken, [getToken]) From 07eae839f15dbdd1e98ee558cbda66135a7b689d Mon Sep 17 00:00:00 2001 From: Kishan Sambhi Date: Tue, 16 Jul 2024 16:36:20 +0100 Subject: [PATCH 2/2] refactor: rename MATHS_SINGLE_ANSWER to PROCESSD_HANDWRITING --- src/components/questionStructure/Task/constants.ts | 2 +- src/components/questionStructure/Task/index.tsx | 2 +- .../questionStructure/Task/variants/HandwritingTask/index.tsx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/questionStructure/Task/constants.ts b/src/components/questionStructure/Task/constants.ts index 819c019..3959a68 100644 --- a/src/components/questionStructure/Task/constants.ts +++ b/src/components/questionStructure/Task/constants.ts @@ -5,5 +5,5 @@ export enum TaskType { FLAG = 'FLAG', MULTIPLE_CHOICE_SELECT_ONE = 'MULTIPLE_CHOICE_SELECT_ONE', MULTIPLE_CHOICE_SELECT_SEVERAL = 'MULTIPLE_CHOICE_SELECT_SEVERAL', - MATHS_SINGLE_ANSWER = 'MATHS_SINGLE_ANSWER', + PROCESSED_HANDWRITING = 'PROCESSED_HANDWRITING', } diff --git a/src/components/questionStructure/Task/index.tsx b/src/components/questionStructure/Task/index.tsx index d23dda4..b96ee24 100644 --- a/src/components/questionStructure/Task/index.tsx +++ b/src/components/questionStructure/Task/index.tsx @@ -31,7 +31,7 @@ const taskComponentMap = { [TaskType.FLAG]: FlagTask, [TaskType.MULTIPLE_CHOICE_SELECT_ONE]: MCQOneTask, [TaskType.MULTIPLE_CHOICE_SELECT_SEVERAL]: MCQMultiTask, - [TaskType.MATHS_SINGLE_ANSWER]: HandwritingTask, + [TaskType.PROCESSED_HANDWRITING]: HandwritingTask, } as const type TaskComponent = FC diff --git a/src/components/questionStructure/Task/variants/HandwritingTask/index.tsx b/src/components/questionStructure/Task/variants/HandwritingTask/index.tsx index 38cdca3..ff3443d 100644 --- a/src/components/questionStructure/Task/variants/HandwritingTask/index.tsx +++ b/src/components/questionStructure/Task/variants/HandwritingTask/index.tsx @@ -12,7 +12,7 @@ import { ViewOnlyCanvas } from './ViewOnlyCanvas' import './index.scss' export interface HandwritingTaskProps extends TaskBaseProps { - type: TaskType.MATHS_SINGLE_ANSWER + type: TaskType.PROCESSED_HANDWRITING questionText: string }