-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
50 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
import * as userAuthentication from './userAuthentication' | ||
import * as synchronizeData from './synchronizeData' | ||
import * as visualizeSurvey from './visualizeSurvey/visualizeSurvey' | ||
import * as surveyUnit from './surveyUnit' | ||
export const usecases = { | ||
userAuthentication, | ||
synchronizeData, | ||
visualizeSurvey, | ||
surveyUnit, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { assert } from 'tsafe/assert' | ||
import type { Thunks } from 'core/bootstrap' | ||
|
||
export const name = 'surveyUnit' | ||
|
||
export const reducer = null | ||
|
||
export const thunks = { | ||
getSurveyWithSurveyUnit: | ||
(params: { surveyUnitId: string }) => | ||
async (...args) => { | ||
const [, , { dataStore }] = args | ||
const { surveyUnitId } = params | ||
|
||
const surveyUnit = await dataStore.getSurveyUnit(surveyUnitId) | ||
return surveyUnit?.questionnaireId | ||
}, | ||
} satisfies Thunks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { prCore } from 'bootstrap' | ||
import { redirect, type LoaderFunctionArgs } from 'react-router-dom' | ||
import { assert } from 'tsafe' | ||
|
||
export async function surveyUnitLoader({ params }: LoaderFunctionArgs) { | ||
const { surveyUnit } = (await prCore).functions | ||
|
||
const surveyUnitId = params.surveyUnitId | ||
|
||
//surveyUnitId can't be undefined here (needed to match route) | ||
assert(surveyUnitId !== undefined) | ||
|
||
const questionnaireId = await surveyUnit.getSurveyWithSurveyUnit({ | ||
surveyUnitId, | ||
}) | ||
|
||
//TODO handle case when questionnaireId is undefined | ||
return redirect( | ||
`/questionnaire/${questionnaireId}/survey-unit/${surveyUnitId}` | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters