diff --git a/client/public/json/checkpoints.json b/client/public/json/checkpoints.json index c0ed35a..ace60f3 100644 --- a/client/public/json/checkpoints.json +++ b/client/public/json/checkpoints.json @@ -9,8 +9,7 @@ { "option": "Yes", "explain_risk": true, - "risk_level": "red", - "explain_text": "" + "risk_level": "red" }, { "option": "No", diff --git a/client/src/checkpointsSlice.js b/client/src/checkpointsSlice.js index 388770d..7d59cf5 100644 --- a/client/src/checkpointsSlice.js +++ b/client/src/checkpointsSlice.js @@ -1,5 +1,6 @@ import { createAsyncThunk, createSlice } from '@reduxjs/toolkit'; import axiosInstance from './axiosInstance'; +import Login from './Login'; // Thunk to get checkpoints export const getCheckpoints = createAsyncThunk( @@ -49,15 +50,16 @@ export const startAssessmentThunk = createAsyncThunk( if (id) { assessment = state.assessmentsList.find(assessment => assessment._id === id); found = true; - } - - if (id && found) { dispatch(startAssessment(id)); - navigate(id); } else { - const response = await dispatch(createAssessment(assessment)).unwrap(); - navigate(response._id); + try { + const response = await dispatch(createAssessment(assessment)).unwrap(); + id = response._id; + } catch (err) { + navigate(Login); + } } + navigate(id); } );