Skip to content

Commit

Permalink
Merge pull request #26 from InseeFr/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
BettyB979 authored Feb 21, 2023
2 parents 4e66bfd + 954dc42 commit 462541f
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 12,423 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
SKIP_PREFLIGHT_CHECK=true
ACCESS_API_URL=https://coleman-access-api.dev.insee.io
MY_SURVEYS_URL=https://mes-enquetes.dev.insee.io
AUTHENTICATION_MODE=anonymous
KC_URL=http://localhost:8180/auth
KC_REALM=insee-realm
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*
yarn.lock*
2 changes: 1 addition & 1 deletion .k8s/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ spec:
spec:
containers:
- name: coleman-access
image: inseefr/coleman-access:0.10.5
image: inseefr/coleman-access:0.10.10
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "colempub",
"version": "0.10.5",
"version": "0.10.10",
"dependencies": {
"axios": "^0.19.2",
"bootstrap": "^3.3.7",
Expand Down
1 change: 1 addition & 0 deletions public/configuration.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"urlColemanPromotionBack_commentaire": "access portal's api url",
"urlColemanPromotionBack": "${ACCESS_API_URL}",
"urlSurveys": "${MY_SURVEYS_URL}",
"authType": "${AUTHENTICATION_MODE}"
}
19 changes: 15 additions & 4 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ const apiConfigPath = `${window.location.origin}/configuration.json`;
class App extends Component {
constructor(props) {
super(props);
this.state = { urlBackEnd: null, isConfigLoaded: false, keycloakAuth: null };
this.state = {
urlBackEnd: null,
urlMySurveys: null,
isConfigLoaded: false,
keycloakAuth: null,
};
}

componentDidMount() {
Expand All @@ -19,14 +24,15 @@ class App extends Component {
.then(data =>
this.setState({
urlBackEnd: data.urlColemanPromotionBack,
urlMySurveys: data.urlSurveys,
isConfigLoaded: true,
keycloakAuth: data.authType === 'keycloak',
keycloakAuth: data.authType === 'OIDC',
})
);
}

render() {
const { isConfigLoaded, urlBackEnd, keycloakAuth } = this.state;
const { isConfigLoaded, urlBackEnd, urlMySurveys, keycloakAuth } = this.state;

return (
<>
Expand All @@ -45,7 +51,12 @@ class App extends Component {
<Route
path="/:id"
render={routeProps => (
<Main {...routeProps} urlBackEnd={urlBackEnd} keycloakAuth={keycloakAuth} />
<Main
{...routeProps}
urlBackEnd={urlBackEnd}
urlMySurveys={urlMySurveys}
keycloakAuth={keycloakAuth}
/>
)}
/>

Expand Down
18 changes: 6 additions & 12 deletions src/components/auth/component.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
// import React, { useCallback, useEffect, useState } from 'react';
import React, { useCallback, useEffect, useState } from 'react';
import PropTypes from 'prop-types';
import Loading from 'components/loading/loading';
import ErrorComponent from 'components/template/error-component';
/* import { extractQuestionnaireUrl } from 'utils/url-utils';
import { extractQuestionnaireUrl } from 'utils/url-utils';
import { getSurveyVerifMailById } from 'utils/read-content';
import { getQuestionnaireUrl } from 'utils/api'; */
import { getQuestionnaireUrl } from 'utils/api';
import useAuth from 'utils/hook/auth';
import NoSurveyPage from 'components/content/ineligible';

const Auth = ({ urlBackEnd, id, history, keycloakAuth }) => {
const { loading, authenticated, authError } = useAuth(keycloakAuth);
const [error, setError] = useState(null);
// const [ineligible, setIneligible] = useState(false);

const ineligible = false;
const [ineligible, setIneligible] = useState(false);

const redirectToUrl = url => {
window.location = url;
};

/* const redirectToQuestionnaire = useCallback(async () => {
const redirectToQuestionnaire = useCallback(async () => {
try {
const response = await getQuestionnaireUrl(urlBackEnd, keycloakAuth);
if (response.data && response.data.length) {
Expand All @@ -41,11 +38,7 @@ const Auth = ({ urlBackEnd, id, history, keycloakAuth }) => {
// including 410 status - no habilitation found
setError('technique');
}
}, [history, id, urlBackEnd, keycloakAuth]); */

const redirectToQuestionnaire = useCallback(() => {
redirectToUrl('https://mes-enquetes.dev.insee.io');
}, []);
}, [history, id, urlBackEnd, keycloakAuth]);

useEffect(() => {
if (authenticated && !loading) redirectToQuestionnaire();
Expand All @@ -63,6 +56,7 @@ const Auth = ({ urlBackEnd, id, history, keycloakAuth }) => {

Auth.propTypes = {
urlBackEnd: PropTypes.string.isRequired,
urlMySurveys: PropTypes.string.isRequired,
keycloakAuth: PropTypes.bool.isRequired,
id: PropTypes.string.isRequired,
history: PropTypes.shape({
Expand Down
5 changes: 4 additions & 1 deletion src/components/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ class Main extends React.Component {
};

/* return */ render() {
const { urlBackEnd, match, keycloakAuth } = this.props;
const { urlBackEnd, match, urlMySurveys, keycloakAuth } = this.props;

const { id, showMenu, showResponseButton, showMinimalFooter } = this.state;

return (
Expand Down Expand Up @@ -121,6 +122,7 @@ render={routeProps => <ChangePasswordForm {...routeProps} urlBackEnd={urlBackEnd
<Auth
{...routeProps}
urlBackEnd={urlBackEnd}
urlMySurveys={urlMySurveys}
id={id}
keycloakAuth={keycloakAuth}
/>
Expand Down Expand Up @@ -230,6 +232,7 @@ render={routeProps => <ChangePasswordForm {...routeProps} urlBackEnd={urlBackEnd

Main.propTypes = {
urlBackEnd: PropTypes.string.isRequired,
urlMySurveys: PropTypes.string.isRequired,
keycloakAuth: PropTypes.bool.isRequired,
match: PropTypes.shape({
params: PropTypes.shape({
Expand Down
Loading

0 comments on commit 462541f

Please sign in to comment.