Skip to content

Commit

Permalink
Merge pull request #34 from InseeFr/v2-develop
Browse files Browse the repository at this point in the history
V2 develop
  • Loading branch information
bwerquin authored May 31, 2021
2 parents 06b2b4b + bba34ef commit 3a4b9a9
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "stromae",
"version": "2.0.5",
"version": "2.0.6",
"private": true,
"dependencies": {
"@axa-fr/react-oidc-context": "^3.1.6",
Expand Down
8 changes: 6 additions & 2 deletions src/components/genericPages/end.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ const EndPage = () => {
logoutAndClose,
metadata: { inseeContext, variables },
personalization,
stateData: { date },
} = useContext(OrchestratorContext);

const finalDate = date || 0;

const { pathname } = useLocation();

const { idQ, idSU } = useParams();
Expand All @@ -61,10 +65,10 @@ const EndPage = () => {
console.log(`${status} : ${error}`);
};

const validatedDate = `${formatDistance(new Date(), new Date(), {
const validatedDate = `${formatDistance(finalDate, new Date(), {
addSuffix: true,
locale: dateFnsLocal,
})} (${format(new Date(), formatLocal)})`;
})} (${format(finalDate, formatLocal)})`;

const getBodyWithVariables = myBody =>
interpret(['VTL'])({
Expand Down
9 changes: 7 additions & 2 deletions src/components/orchestrator/collector/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,12 @@ export const Orchestrator = ({
};

const [currentPage, setCurrentPage] = useState(() => {
if (!validated && stateData?.currentPage) return stateData?.currentPage;
if (!validated && stateData?.currentPage) {
if (isLunaticPage(stateData?.currentPage)) {
setPage(stateData?.currentPage);
}
return stateData?.currentPage;
}
if (validated) return END_PAGE;
return WELCOME_PAGE;
});
Expand Down Expand Up @@ -220,7 +225,7 @@ export const Orchestrator = ({
<WelcomeBack
open={!init && !validated && !!stateData?.currentPage}
setOpen={o => setInit(!o)}
goToFirstPage={() => setCurrentPage(0)}
goToFirstPage={() => setPage('1')}
/>
<SendingConfirmation
open={validationConfirmation}
Expand Down
8 changes: 7 additions & 1 deletion src/utils/hooks/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@ import { useContext } from 'react';
import { AppContext } from 'App';
import { useReactOidc } from '@axa-fr/react-oidc-context';
import { NONE, OIDC } from 'utils/constants';
import { useHistory } from 'react-router';

export const useAuth = () => {
const history = useHistory();
const { authenticationType } = useContext(AppContext);
if (authenticationType === NONE)
return { authenticationType, name: 'Fake User' };
return {
authenticationType,
name: 'Fake User',
logout: () => history.push('/'),
};
if (authenticationType === OIDC) {
/**
* Assume this conditional hook does not break anything
Expand Down

0 comments on commit 3a4b9a9

Please sign in to comment.