Skip to content

Commit

Permalink
Fixing login issue for creating new assessments
Browse files Browse the repository at this point in the history
  • Loading branch information
davetaz committed Nov 21, 2024
1 parent 9c6375c commit 24a6a8d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
3 changes: 1 addition & 2 deletions client/public/json/checkpoints.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
{
"option": "Yes",
"explain_risk": true,
"risk_level": "red",
"explain_text": ""
"risk_level": "red"
},
{
"option": "No",
Expand Down
14 changes: 8 additions & 6 deletions client/src/checkpointsSlice.js
Original file line number Diff line number Diff line change
@@ -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(
Expand Down Expand Up @@ -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);
}
);

Expand Down

0 comments on commit 24a6a8d

Please sign in to comment.