Skip to content

Commit

Permalink
Merge pull request #56 from InseeFr/fix_develop
Browse files Browse the repository at this point in the history
Fix develop
  • Loading branch information
BettyB979 authored Jun 5, 2024
2 parents 18911f3 + 22dfbfc commit 39b25ce
Show file tree
Hide file tree
Showing 12 changed files with 65 additions and 271 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM nginx:stable-alpine
FROM nginx
COPY build /usr/share/nginx/html
RUN rm etc/nginx/conf.d/default.conf
COPY nginx-coleman-promotion.conf etc/nginx/conf.d/
Expand Down
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": "1.1.2",
"version": "1.0.2",
"dependencies": {
"axios": "^0.19.2",
"bootstrap": "^3.3.7",
Expand Down
45 changes: 6 additions & 39 deletions src/components/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import AssistanceForm from 'components/forms/assistance-form';
import AssistanceRouter from 'components/forms/assistance-router';
import ControlEmailForm from 'components/forms/mail-modif';
import DonneesPersonnelles from './content/donnees-personnelles';
import { isSurveyOnLine } from 'utils/api';

import {
idExists,
getSurveyTitleById,
Expand All @@ -40,9 +40,6 @@ class Main extends React.Component {
showResponseButton: true,
showMinimalFooter: false,
id: match.params.id,
isSurveyOnLine: undefined,
messageSurveyOffline: "",
messageInfoSurveyOffline: ""
};
}

Expand Down Expand Up @@ -73,31 +70,10 @@ class Main extends React.Component {
}
};

fetchData = async () => {
try {
const response = await isSurveyOnLine(this.props.urlBackEnd)(this.state.id);
if (response.data && response.data.opened === false) {
this.setState({isSurveyOnLine: false})
this.setState({messageSurveyOffline: response.data.messageSurveyOffline})
this.setState({messageInfoSurveyOffline: response.data.messageInfoSurveyOffline})
} else {
this.setState({isSurveyOnLine: true})
}
} catch (error) {
console.error('Error checking survey online:', error);
this.setState({isSurveyOnLine: false})
}
};

componentDidMount = () => {
this.fetchData();
}


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

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

return (
<>
Expand Down Expand Up @@ -129,7 +105,7 @@ class Main extends React.Component {
)}
/>

{showMenu && <Menu id={id} link={urlBackEnd} isSurveyOnLine={isSurveyOnLine} />}
{showMenu && <Menu id={id} link={urlBackEnd} />}
<div className="row">
<div className="col-md-8 text-justify">
{/* <Route
Expand Down Expand Up @@ -239,22 +215,13 @@ render={routeProps => <ChangePasswordForm {...routeProps} urlBackEnd={urlBackEnd
component={routeProps => <Faq {...routeProps} enquete={id} />}
/>
{!showMinimalFooter ? (
<FooterMenu home={false} path={match.url} id={id} isSurveyOnLine={isSurveyOnLine} />
<FooterMenu home={false} path={match.url} id={id} />
) : (
<FooterMenu home path={match.url} id={id} isSurveyOnLine={isSurveyOnLine}/>
<FooterMenu home path={match.url} id={id} />
)}
</div>
</div>
<div className="col-md-4">
{showResponseButton &&
<ResponseButton
id={id}
isSurveyOnLine={isSurveyOnLine}
messageSurveyOffline={messageSurveyOffline}
messageInfoSurveyOffline={messageInfoSurveyOffline}
/>
}
</div>
<div className="col-md-4">{showResponseButton && <ResponseButton id={id} />}</div>
</div>
</>
)}
Expand Down
5 changes: 3 additions & 2 deletions src/components/template/footer-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import { Navbar, Nav, NavItem } from 'react-bootstrap';
import { LinkContainer } from 'react-router-bootstrap';
import logoTwitter from 'img/common/logo-twitter.png';
import { urlInseeFr } from 'utils/properties';
import { getIsSurveyOnlineById } from 'utils/read-content';

function FooterMenu({ path, home, id, isSurveyOnLine }) {
function FooterMenu({ path, home, id }) {
const [isDesktop, setIsDesktop] = useState(window.innerWidth > 767);
const updateFooterMenu = () => {
if (window.innerWidth <= 767) {
Expand Down Expand Up @@ -43,7 +44,7 @@ function FooterMenu({ path, home, id, isSurveyOnLine }) {
<LinkContainer to={`/${id}/faq`}>
<NavItem eventKey={1}>{`Questions/réponses`}</NavItem>
</LinkContainer>
{isSurveyOnLine && (
{getIsSurveyOnlineById(id) && (
<LinkContainer to={`/${id}/contacter-assistance`}>
<NavItem eventKey={2}>{`Contacter l'assistance`}</NavItem>
</LinkContainer>
Expand Down
31 changes: 13 additions & 18 deletions src/components/template/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { Link } from 'react-router-dom';
import { urlInseeFr } from 'utils/properties';
import logoTwitter from 'img/common/logo-twitter.png';
import { getResultsMenuTitle, getSurveyDetailLink } from 'utils/read-content';
import ReactLoading from 'react-loading';
import { getIsSurveyOnlineById } from '../../utils/read-content';

function Menu({ id, isSurveyOnLine }) {
function Menu({ id }) {
const [isDesktop, setIsDesktop] = useState(window.innerWidth > 767);
const updateFooterMenu = () => {
if (window.innerWidth <= 767) {
Expand All @@ -35,21 +35,16 @@ function Menu({ id, isSurveyOnLine }) {
</Navbar.Header>
<Navbar.Collapse>
<Nav>
{isSurveyOnLine === undefined ?
<NavItem style={{display: "flex", flexDirection: "column", alignItems: "center" }}>
<ReactLoading type="spin" color={`#0f417a`} width={"30px"} />
</NavItem>
:
<NavItem
href={`/${id}/login`}
to={`/${id}/login`}
eventKey={1}
id="menuItemRepondre"
disabled={!isSurveyOnLine}
>
{`Accéder au questionnaire`}
</NavItem>
}
<NavItem
href={`/${id}/login`}
to={`/${id}/login`}
eventKey={1}
id="menuItemRepondre"
disabled={!getIsSurveyOnlineById(id)}
>
{`Accéder au questionnaire`}
</NavItem>

<LinkContainer to={`/${id}/donnees-personnelles`}>
<NavItem eventKey={2}>{`Données personnelles`}</NavItem>
</LinkContainer>
Expand All @@ -71,7 +66,7 @@ function Menu({ id, isSurveyOnLine }) {
<NavItem eventKey={7} href={`/${id}/faq`}>
{`Questions/réponses`}
</NavItem>
{isSurveyOnLine && (
{getIsSurveyOnlineById(id) && (
<NavItem eventKey={8} href={`/${id}/contacter-assistance`}>
{`Contacter l'assistance`}
</NavItem>
Expand Down
63 changes: 29 additions & 34 deletions src/components/template/response-button.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,34 @@
import React from 'react';
import { Link } from 'react-router-dom';
import ReactLoading from 'react-loading';
import {
getIsSurveyOnlineById,
getSurveyOfflineMessageById,
getSurveyOfflineMessageInfoById,
} from '../../utils/read-content';

const ResponseButton = ({ id, isSurveyOnLine, messageSurveyOffline,messageInfoSurveyOffline}) => {

if(isSurveyOnLine === undefined) {
return (
<div className="center-block text-center">
<section style={{display: "flex", flexDirection: "column", alignItems: "center" }}>
<h3>{`Veuillez patienter`}</h3>
<ReactLoading type="spin" color={`#0f417a`} width="50px" />
</section>
</div>
)
}

return (
<div className="center-block text-center">
<section>
<h2>{`Répondre à l'enquête`}</h2>
<Link to={`/${id}/login`} tabIndex="-1">
<button type="button" className="btn btn-lg" id="accessButton" disabled={!isSurveyOnLine}>
{'Accéder au questionnaire'}
</button>
</Link>
<p />
{!isSurveyOnLine && (
<>
{messageSurveyOffline && <div className="surveyOver">{messageSurveyOffline}</div>}
{messageInfoSurveyOffline && <p>{messageInfoSurveyOffline}</p>}
</>
)}
</section>
</div>
);
};
const ResponseButton = ({ id }) => (
<div className="center-block text-center">
<section>
<h2>{`Répondre à l'enquête`}</h2>
<Link to={`/${id}/login`} tabIndex="-1">
<button
type="button"
className="btn btn-lg"
id="boutonRepondre"
disabled={!getIsSurveyOnlineById(id)}
>
{'Accéder au questionnaire'}
</button>
</Link>
<p />
{!getIsSurveyOnlineById(id) && (
<>
<div className="surveyOver">{getSurveyOfflineMessageById(id)}</div>
<p>{getSurveyOfflineMessageInfoById(id)}</p>
</>
)}
</section>
</div>
);

export default ResponseButton;
4 changes: 2 additions & 2 deletions src/components/template/survey-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { Link } from 'react-router-dom';

const SurveyItem = ({ survey }) => (
<div className="survey-item">
<Link to={`/${survey.id}`} tabIndex="-1" className='survey-item-link'>
<button type="button" className="btn " id="boutonRepondre">
<Link to={`/${survey.id}`} tabIndex="-1">
<button type="button" className="btn btn-lg" id="boutonRepondre">
<span>{survey.titleShort}</span>
<br />
{`${window.location.host}/${survey.id}`}
Expand Down
35 changes: 6 additions & 29 deletions src/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -94,26 +94,8 @@ h2 {
.btn-md {
margin-right: 10px;
}

#survey-item-link {
display: inline-block;
width: 100%;
height: 100%;
}

#boutonRepondre {
display: flex;
flex-direction: column;
white-space: inherit;
width: 100%;
height: 100%;
justify-content: center;
align-items: center;
word-wrap: break-word;
}
#menuItemRepondre,
#boutonRepondre,
#accessButton,
#boutonMailConfirm,
#boutonMailModif,
#formSend,
Expand All @@ -123,11 +105,9 @@ h2 {
}
#menuItemRepondre:hover,
#boutonRepondre:hover,
#accessButton:hover,
#boutonMailConfirm:hover,
#boutonMailModif:hover,
#menuItemRepondre:focus,
#accessButton:focus,
#boutonRepondre:focus,
#boutonMailConfirm:focus,
#boutonMailModif:focus,
Expand Down Expand Up @@ -341,17 +321,14 @@ div.banner-top h1 {

/* survey item */
.surveys-list {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: center;
gap: 10px;
margin-top:2rem;
text-align: center;
}
.survey-item {
width: 30%;
min-width: 300px;
text-align: center;
margin: 5px;
display: inline-block;
border-radius: 7px;
width: auto;
background-color: $blue-insee;
color: $yellow-insee;

Expand All @@ -363,7 +340,7 @@ div.banner-top h1 {
text-decoration: none;
}
span {
font-size: 1.5em;
font-size: 2em;
}
}

Expand Down
Loading

0 comments on commit 39b25ce

Please sign in to comment.