style(error-code): prettier auto-format

pull/73/head
Clement G 4 years ago
parent 429c0f755b
commit 4e7665e2f5

@ -1,45 +1,41 @@
import React from 'react';
import {
Container,
Row,
Col,
} from "reactstrap";
import React from "react";
import { Container, Row, Col } from "reactstrap";
export const UNKNOWN_ELECTION_ERROR = 'E1';
export const ONGOING_ELECTION_ERROR = 'E2';
export const NO_VOTE_ERROR = 'E3';
export const ELECTION_NOT_STARTED_ERROR = 'E4';
export const ELECTION_FINISHED_ERROR = 'E5';
export const INVITATION_ONLY_ERROR = 'E6';
export const UNKNOWN_TOKEN_ERROR = 'E7';
export const USED_TOKEN_ERROR = 'E8';
export const WRONG_ELECTION_ERROR = 'E9';
export const UNKNOWN_ELECTION_ERROR = "E1";
export const ONGOING_ELECTION_ERROR = "E2";
export const NO_VOTE_ERROR = "E3";
export const ELECTION_NOT_STARTED_ERROR = "E4";
export const ELECTION_FINISHED_ERROR = "E5";
export const INVITATION_ONLY_ERROR = "E6";
export const UNKNOWN_TOKEN_ERROR = "E7";
export const USED_TOKEN_ERROR = "E8";
export const WRONG_ELECTION_ERROR = "E9";
export const redirectError = (errorMsg, history) => {};
export const errorMessage = (error, t) => {
if (error.startsWith(UNKNOWN_ELECTION_ERROR)) {
return t('Oops... The election is unknown.');
return t("Oops... The election is unknown.");
} else if (error.startsWith(ONGOING_ELECTION_ERROR)) {
return t(
"The election is still going on. You can't access now to the results.",
"The election is still going on. You can't access now to the results."
);
} else if (error.startsWith(NO_VOTE_ERROR)) {
return t('No votes have been recorded yet. Come back later.');
return t("No votes have been recorded yet. Come back later.");
} else if (error.startsWith(ELECTION_NOT_STARTED_ERROR)) {
return t('The election has not started yet.');
return t("The election has not started yet.");
} else if (error.startsWith(ELECTION_FINISHED_ERROR)) {
return t('The election is over. You can\'t vote anymore');
return t("The election is over. You can't vote anymore");
} else if (error.startsWith(INVITATION_ONLY_ERROR)) {
return t('You need a token to vote in this election');
return t("You need a token to vote in this election");
} else if (error.startsWith(USED_TOKEN_ERROR)) {
return t('You seem to have already voted.');
return t("You seem to have already voted.");
} else if (error.startsWith(WRONG_ELECTION_ERROR)) {
return t('The parameters of the election are incorrect.');
return t("The parameters of the election are incorrect.");
}
};
export const Error = (props) => (
export const Error = props => (
<Container>
<Row>
<Col xs="12">

@ -1,35 +1,35 @@
import React from 'react';
import React from "react";
export const UNKNOWN_ELECTION_ERROR = 'E1';
export const ONGOING_ELECTION_ERROR = 'E2';
export const NO_VOTE_ERROR = 'E3';
export const ELECTION_NOT_STARTED_ERROR = 'E4';
export const ELECTION_FINISHED_ERROR = 'E5';
export const INVITATION_ONLY_ERROR = 'E6';
export const UNKNOWN_TOKEN_ERROR = 'E7';
export const USED_TOKEN_ERROR = 'E8';
export const WRONG_ELECTION_ERROR = 'E9';
export const UNKNOWN_ELECTION_ERROR = "E1";
export const ONGOING_ELECTION_ERROR = "E2";
export const NO_VOTE_ERROR = "E3";
export const ELECTION_NOT_STARTED_ERROR = "E4";
export const ELECTION_FINISHED_ERROR = "E5";
export const INVITATION_ONLY_ERROR = "E6";
export const UNKNOWN_TOKEN_ERROR = "E7";
export const USED_TOKEN_ERROR = "E8";
export const WRONG_ELECTION_ERROR = "E9";
export const redirectError = (errorMsg, history) => {};
export const errorMessage = (error, t) => {
if (error.startsWith(UNKNOWN_ELECTION_ERROR)) {
return t('Oops... The election is unknown.');
return t("Oops... The election is unknown.");
} else if (error.startsWith(ONGOING_ELECTION_ERROR)) {
return t(
"The election is still going on. You can't access now to the results.",
"The election is still going on. You can't access now to the results."
);
} else if (error.startsWith(NO_VOTE_ERROR)) {
return t('No votes have been recorded yet. Come back later.');
return t("No votes have been recorded yet. Come back later.");
} else if (error.startsWith(ELECTION_NOT_STARTED_ERROR)) {
return t('The election has not started yet.');
return t("The election has not started yet.");
} else if (error.startsWith(ELECTION_FINISHED_ERROR)) {
return t('The election is over. You can\'t vote anymore');
return t("The election is over. You can't vote anymore");
} else if (error.startsWith(INVITATION_ONLY_ERROR)) {
return t('You need a token to vote in this election');
return t("You need a token to vote in this election");
} else if (error.startsWith(USED_TOKEN_ERROR)) {
return t('You seem to have already voted.');
return t("You seem to have already voted.");
} else if (error.startsWith(WRONG_ELECTION_ERROR)) {
return t('The parameters of the election are incorrect.');
return t("The parameters of the election are incorrect.");
}
};

Loading…
Cancel
Save