Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: typo with accessToken -> access_token my bad 👼 #59

Merged
merged 1 commit into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "drama-queen-container",
"private": true,
"version": "1.3.9",
"version": "1.3.10",
"workspaces": [
"drama-queen",
"queen-v2",
Expand Down
2 changes: 1 addition & 1 deletion queen-v2/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "queen-v2",
"version": "1.0.11",
"version": "1.0.12",
"description": "Web application for the management of questionnaires powered by Lunatic",
"repository": {
"type": "git",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ export const OrchestratorManager = () => {
[idQ, idSU, readonly]
);

const { surveyUnit, questionnaire, nomenclatures, loadingMessage, errorMessage } =
useAPIRemoteData(idSU, idQ);
const { surveyUnit, questionnaire, loadingMessage, errorMessage } = useAPIRemoteData(idSU, idQ);

const stateData = surveyUnit?.stateData;
const initialData = surveyUnit?.data;
Expand Down Expand Up @@ -73,7 +72,7 @@ export const OrchestratorManager = () => {
setError(questionnaireError);
}
}
}, [questionnaire, surveyUnit, nomenclatures, apiUrl, LOGGER, init]);
}, [questionnaire, surveyUnit, apiUrl, LOGGER, init]);

useEffect(() => {
if (errorMessage) setError(errorMessage);
Expand Down
14 changes: 5 additions & 9 deletions queen-v2/src/utils/hook/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const useGetReferentiel = nomenclatures => {
const getReferentiel = useCallback(
refName => {
const finalUrl = `${apiUrl}/api/nomenclature/${refName}`;
return getFetcherForLunatic(oidcUser?.accessToken)(finalUrl);
return getFetcherForLunatic(oidcUser?.access_token)(finalUrl);
},
[apiUrl, oidcUser]
);
Expand All @@ -48,7 +48,7 @@ export const useGetReferentiel = nomenclatures => {
refName => {
if (nomenclatures && Object.keys(nomenclatures).includes(refName)) {
const finalUrl = nomenclatures[refName];
return getFetcherForLunatic(oidcUser?.accessToken)(finalUrl);
return getFetcherForLunatic(oidcUser?.access_token)(finalUrl);
}
// No nomenclature, return empty array to lunatic
return Promise.resolve([]);
Expand Down Expand Up @@ -169,31 +169,27 @@ export const useGetSurveyUnit = () => {
export const useAPIRemoteData = (surveyUnitID, questionnaireID) => {
const { standalone } = useContext(AppContext);
const [questionnaire, setQuestionnaire] = useState(null);
const [nomenclatures, setNomenclatures] = useState(null);
const [surveyUnit, setSurveyUnit] = useState(null);

const [loadingMessage, setLoadingMessage] = useState('');
const [errorMessage, setErrorMessage] = useState(null);

const { getQuestionnaire, getRequiredNomenclatures } = useAPI();
const { getQuestionnaire } = useAPI();
const getSurveyUnit = useGetSurveyUnit();

useEffect(() => {
if (questionnaireID && surveyUnitID && !questionnaire && !surveyUnit) {
setErrorMessage(null);
setQuestionnaire(null);
setNomenclatures(null);
setSurveyUnit(null);
const load = async () => {
setLoadingMessage(Dictionary.waitingCleaning);
const { error } = await clean(standalone);
if (!error) {
setLoadingMessage(Dictionary.waitingQuestionnaire);
const qR = await getQuestionnaire(questionnaireID);
const nR = await getRequiredNomenclatures(questionnaireID);
if (!qR.error && !nR.error && qR.status !== 404) {
if (!qR.error && qR.status !== 404) {
setQuestionnaire(qR.data.value);
setNomenclatures(nR.data);
setLoadingMessage(Dictionary.waitingDataSU);
const suR = await getSurveyUnit(surveyUnitID, standalone);
if (!suR.error && suR.surveyUnit) {
Expand All @@ -212,7 +208,7 @@ export const useAPIRemoteData = (surveyUnitID, questionnaireID) => {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [surveyUnitID, questionnaireID]);

return { loadingMessage, errorMessage, surveyUnit, questionnaire, nomenclatures };
return { loadingMessage, errorMessage, surveyUnit, questionnaire };
};

export const useRemoteData = (questionnaireUrl, dataUrl) => {
Expand Down
Loading