@ -1,19 +1,65 @@
|
||||
version: 2.1
|
||||
workflows:
|
||||
workflow:
|
||||
jobs:
|
||||
- test:
|
||||
name: test
|
||||
|
||||
- deploy:
|
||||
name: deploy
|
||||
filters:
|
||||
branches:
|
||||
only:
|
||||
- next
|
||||
requires:
|
||||
- test
|
||||
|
||||
jobs:
|
||||
build:
|
||||
test:
|
||||
docker:
|
||||
- image: cimg/node:lts
|
||||
steps:
|
||||
- checkout
|
||||
- restore_cache:
|
||||
name: Restore Yarn Package Cache
|
||||
keys:
|
||||
- node_modules-{{ checksum "yarn.lock" }}
|
||||
- run:
|
||||
name: update-yarn
|
||||
command: 'curl --compressed -o- -L https://yarnpkg.com/install.sh | bash'
|
||||
- run:
|
||||
name: install-dependencies
|
||||
command: yarn install
|
||||
- run:
|
||||
name: compile-translations
|
||||
command: yarn translate
|
||||
name: Install Dependencies
|
||||
command: yarn install --frozen-lockfile
|
||||
- save_cache:
|
||||
name: Save Yarn Package Cache
|
||||
key: node_modules-{{ checksum "yarn.lock" }}
|
||||
paths:
|
||||
- node_modules
|
||||
- ~/.cache
|
||||
background: true
|
||||
- run:
|
||||
name: test
|
||||
command: yarn test
|
||||
|
||||
deploy:
|
||||
docker:
|
||||
- image: cimg/node:lts
|
||||
steps:
|
||||
- checkout
|
||||
- restore_cache:
|
||||
name: Restore Yarn Package Cache
|
||||
keys:
|
||||
- node_modules-{{ checksum "yarn.lock" }}
|
||||
- run:
|
||||
name: Install Dependencies
|
||||
command: yarn install --frozen-lockfile
|
||||
- save_cache:
|
||||
name: Save Yarn Package Cache
|
||||
key: node_modules-{{ checksum "yarn.lock" }}
|
||||
paths:
|
||||
- node_modules
|
||||
- ~/.cache
|
||||
background: true
|
||||
- run:
|
||||
name: build
|
||||
command: yarn build
|
||||
- run:
|
||||
name: deploy
|
||||
command: yarn deploy
|
||||
|
@ -1,35 +0,0 @@
|
||||
{
|
||||
"env": {
|
||||
"browser": true,
|
||||
"es6": true,
|
||||
"node": true,
|
||||
"commonjs": true
|
||||
},
|
||||
"parser": "babel-eslint",
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:react/recommended"
|
||||
],
|
||||
"globals": {
|
||||
"Atomics": "readonly",
|
||||
"SharedArrayBuffer": "readonly"
|
||||
},
|
||||
"parserOptions": {
|
||||
"ecmaFeatures": {
|
||||
"jsx": true
|
||||
},
|
||||
"ecmaVersion": 2018,
|
||||
"sourceType": "module"
|
||||
},
|
||||
"plugins": [
|
||||
"react"
|
||||
],
|
||||
"settings": {
|
||||
"react": {
|
||||
"version": "detect"
|
||||
}
|
||||
},
|
||||
"rules": {
|
||||
"no-console": "off"
|
||||
}
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
# Usage: $ make
|
||||
|
||||
NPM := $(shell eval command -v npm)
|
||||
APT := $(shell eval command -v apt)
|
||||
|
||||
|
||||
.PHONY: help
|
||||
|
||||
help: ## Usage: make <concept>, eg: make install
|
||||
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|
||||
|
||||
|
||||
install: ## Install required javascript dependencies
|
||||
ifndef NPM
|
||||
ifdef APT
|
||||
@echo "Installing NPM debian package…"
|
||||
sudo apt install -y npm
|
||||
endif
|
||||
endif
|
||||
npm install
|
||||
|
||||
|
||||
demo: ## Run locally at http://localhost:3000
|
||||
npm run dev
|
||||
|
||||
|
||||
love: ## Fund development of Majority Judgment
|
||||
firefox https://www.paypal.com/donate/?hosted_button_id=QD6U4D323WV4S
|
@ -1,69 +0,0 @@
|
||||
/* eslint react/prop-types: 0 */
|
||||
import React from "react";
|
||||
import { Button } from "reactstrap";
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
import {
|
||||
faCopy,
|
||||
faVoteYea,
|
||||
faExclamationTriangle,
|
||||
faExternalLinkAlt,
|
||||
} from "@fortawesome/free-solid-svg-icons";
|
||||
|
||||
const CopyField = (props) => {
|
||||
const ref = React.createRef();
|
||||
const handleClickOnField = (event) => {
|
||||
event.target.focus();
|
||||
event.target.select();
|
||||
};
|
||||
const handleClickOnButton = () => {
|
||||
const input = ref.current;
|
||||
input.focus();
|
||||
input.select();
|
||||
document.execCommand("copy");
|
||||
};
|
||||
|
||||
const { t, value, iconCopy, iconOpen } = props;
|
||||
|
||||
return (
|
||||
<div className="input-group ">
|
||||
<input
|
||||
type="text"
|
||||
className="form-control"
|
||||
ref={ref}
|
||||
value={value}
|
||||
readOnly
|
||||
onClick={handleClickOnField}
|
||||
/>
|
||||
|
||||
<div className="input-group-append">
|
||||
{/*
|
||||
<Button
|
||||
href={value}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
className="btn btn-success"
|
||||
type="button"
|
||||
>
|
||||
<FontAwesomeIcon icon={iconOpen} className="mr-2" />
|
||||
{t("Go")}
|
||||
</Button>
|
||||
*/}
|
||||
<Button
|
||||
className="btn btn-secondary"
|
||||
onClick={handleClickOnButton}
|
||||
type="button"
|
||||
>
|
||||
<FontAwesomeIcon icon={iconCopy} className="mr-2" />
|
||||
{t("Copy")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
CopyField.defaultProps = {
|
||||
iconCopy: faCopy,
|
||||
iconOpen: faExternalLinkAlt,
|
||||
};
|
||||
|
||||
export default CopyField;
|
@ -1,40 +0,0 @@
|
||||
import Link from "next/link";
|
||||
import { Container, Row, Col } from "reactstrap";
|
||||
import { useTranslation } from "next-i18next";
|
||||
|
||||
const Error = (props) => {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<Container>
|
||||
<Row>
|
||||
<Link href="/">
|
||||
<a className="d-block ml-auto mr-auto mb-4">
|
||||
<img src="/logos/logo-line-white.svg" alt="logo" height="128" />
|
||||
</a>
|
||||
</Link>
|
||||
</Row>
|
||||
<Row className="mt-4">
|
||||
<Col className="text-center">
|
||||
<h4>{props.value}</h4>
|
||||
</Col>
|
||||
</Row>
|
||||
<Row className="mt-4">
|
||||
<Col className="text-right mr-4">
|
||||
<Link href="/">
|
||||
<a className="btn btn-secondary">{t("common.backHomepage")}</a>
|
||||
</Link>
|
||||
</Col>
|
||||
<Col className="text-left ml-4">
|
||||
<a
|
||||
href="mailto:app@mieuxvoter.fr?subject=[HELP]"
|
||||
className="btn btn-success"
|
||||
>
|
||||
{t("resource.help")}
|
||||
</a>
|
||||
</Col>
|
||||
</Row>
|
||||
</Container>
|
||||
);
|
||||
};
|
||||
|
||||
export default Error;
|
@ -1,29 +0,0 @@
|
||||
/* eslint react/prop-types: 0 */
|
||||
import React from "react";
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
import { faFacebookSquare } from "@fortawesome/free-brands-svg-icons";
|
||||
|
||||
const Facebook = props => {
|
||||
const handleClick = () => {
|
||||
const url =
|
||||
"https://www.facebook.com/sharer.php?u=" +
|
||||
props.url +
|
||||
"&t=" +
|
||||
props.title;
|
||||
window.open(
|
||||
url,
|
||||
"",
|
||||
"menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=500,width=700"
|
||||
);
|
||||
};
|
||||
return (
|
||||
<button className={props.className} onClick={handleClick} type="button">
|
||||
<FontAwesomeIcon icon={faFacebookSquare} className="mr-2" />
|
||||
{props.text}
|
||||
</button>
|
||||
);
|
||||
};
|
||||
|
||||
export default Facebook;
|
||||
|
||||
//i
|
@ -1,25 +0,0 @@
|
||||
import PropTypes from 'prop-types';
|
||||
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
|
||||
import {faCommentAlt} from "@fortawesome/free-solid-svg-icons";
|
||||
import {api} from "@services/api"
|
||||
|
||||
|
||||
const Gform = (props) => {
|
||||
return (
|
||||
<a
|
||||
className={props.className}
|
||||
href={api.feedbackForm}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<FontAwesomeIcon icon={faCommentAlt} className="mr-2" />
|
||||
Votre avis nous intéresse !
|
||||
</a>
|
||||
);
|
||||
}
|
||||
|
||||
Gform.propTypes = {
|
||||
className: PropTypes.string,
|
||||
};
|
||||
|
||||
export default Gform;
|
@ -1,24 +0,0 @@
|
||||
/* eslint react/prop-types: 0 */
|
||||
import React from "react";
|
||||
import i18n from "../../i18n";
|
||||
|
||||
const Helloasso = props => {
|
||||
const locale =
|
||||
i18n.language.substring(0, 2).toLowerCase() === "fr" ? "fr" : "en";
|
||||
const linkHelloAssoBanner =
|
||||
locale === "fr"
|
||||
? "https://www.helloasso.com/associations/mieux-voter/formulaires/1/widget"
|
||||
: "https://www.helloasso.com/associations/mieux-voter/formulaires/1/widget/en";
|
||||
|
||||
return (
|
||||
<a href={linkHelloAssoBanner} target="_blank" rel="noopener noreferrer">
|
||||
<img
|
||||
src={"/banner/" + locale + "/helloasso.png"}
|
||||
alt="support us on helloasso"
|
||||
style={{ width: props.width }}
|
||||
/>
|
||||
</a>
|
||||
);
|
||||
};
|
||||
|
||||
export default Helloasso;
|
@ -1,44 +0,0 @@
|
||||
import {useTranslation} from "next-i18next";
|
||||
import {useRouter} from "next/router"
|
||||
import {faPaypal} from "@fortawesome/free-brands-svg-icons";
|
||||
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
|
||||
|
||||
const Paypal = () => {
|
||||
const {t} = useTranslation();
|
||||
|
||||
// FIXME generate a xx_XX string for locale version
|
||||
const {locale} = useRouter();
|
||||
let localeShort = locale.substring(0, 2);
|
||||
let localeComplete =
|
||||
localeShort.toLowerCase() + "_" + localeShort.toUpperCase();
|
||||
if (localeComplete === "en_EN") {
|
||||
localeComplete = "en_US";
|
||||
}
|
||||
const pixelLink =
|
||||
`https://www.paypal.com/${localeComplete}/i/scr/pixel.gif`;
|
||||
|
||||
return (
|
||||
<div className="d-inline-block m-auto">
|
||||
<form
|
||||
action="https://www.paypal.com/cgi-bin/webscr"
|
||||
method="post"
|
||||
target="_top"
|
||||
>
|
||||
<button
|
||||
type="submit"
|
||||
className="btn btn-primary"
|
||||
title={t("PayPal - The safer, easier way to pay online!")}
|
||||
>
|
||||
{" "}
|
||||
<FontAwesomeIcon icon={faPaypal} className="mr-2" />
|
||||
{t("Support us !")}
|
||||
</button>
|
||||
<input type="hidden" name="cmd" value="_s-xclick" />
|
||||
<input type="hidden" name="hosted_button_id" value="KB2Z7L9KARS7C" />
|
||||
<img alt="" border="0" src={pixelLink} width="1" height="1" />
|
||||
</form>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Paypal;
|
@ -1,4 +0,0 @@
|
||||
import * as React from "react";
|
||||
import FlagIconFactory from "react-flag-icon-css";
|
||||
|
||||
export const FlagIcon = FlagIconFactory(React, { useCssModules: false });
|
@ -1,57 +0,0 @@
|
||||
import {useState} from "react";
|
||||
import {
|
||||
faTrashAlt,
|
||||
} from "@fortawesome/free-solid-svg-icons";
|
||||
import {Button, Modal, ModalHeader, ModalBody, ModalFooter} from "reactstrap";
|
||||
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
|
||||
import {useTranslation} from "next-i18next";
|
||||
|
||||
const ButtonWithConfirm = ({className, label, onDelete}) => {
|
||||
const [visibled, setVisibility] = useState(false);
|
||||
const {t} = useTranslation();
|
||||
|
||||
const toggle = () => setVisibility(!visibled)
|
||||
|
||||
return (
|
||||
<div className="input-group-append">
|
||||
<button
|
||||
type="button"
|
||||
className={className}
|
||||
onClick={toggle}
|
||||
>
|
||||
<FontAwesomeIcon icon={faTrashAlt} />
|
||||
</button>
|
||||
<Modal
|
||||
isOpen={visibled}
|
||||
toggle={toggle}
|
||||
className="modal-dialog-centered"
|
||||
>
|
||||
<ModalHeader toggle={toggle}>{t("Delete?")}</ModalHeader>
|
||||
<ModalBody>
|
||||
{t("Are you sure to delete")}{" "}
|
||||
{label && label !== "" ? (
|
||||
<b>"{label}"</b>
|
||||
) : (
|
||||
<>{t("the row")}</>
|
||||
)}{" "}
|
||||
?
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<Button
|
||||
color="primary-outline"
|
||||
className="text-primary border-primary"
|
||||
onClick={toggle}>
|
||||
{t("No")}
|
||||
</Button>
|
||||
<Button color="primary"
|
||||
onClick={() => {toggle(); onDelete();}}
|
||||
>
|
||||
{t("Yes")}
|
||||
</Button>
|
||||
</ModalFooter>
|
||||
</Modal>
|
||||
</div >
|
||||
);
|
||||
}
|
||||
|
||||
export default ButtonWithConfirm;
|
@ -1,55 +0,0 @@
|
||||
import {useState} from 'react'
|
||||
import ButtonWithConfirm from "./ButtonWithConfirm";
|
||||
import {
|
||||
Row,
|
||||
Col,
|
||||
Input,
|
||||
InputGroup,
|
||||
InputGroupAddon,
|
||||
} from "reactstrap";
|
||||
import {useTranslation} from "react-i18next";
|
||||
import {
|
||||
sortableHandle
|
||||
} from "react-sortable-hoc";
|
||||
import HelpButton from "@components/form/HelpButton";
|
||||
|
||||
const DragHandle = sortableHandle(({children}) => (
|
||||
<span className="input-group-text indexNumber">{children}</span>
|
||||
));
|
||||
const CandidateField = ({label, candIndex, onDelete, ...inputProps}) => {
|
||||
const {t} = useTranslation();
|
||||
|
||||
return (
|
||||
<Row>
|
||||
<Col>
|
||||
<InputGroup>
|
||||
<InputGroupAddon addonType="prepend">
|
||||
<DragHandle>
|
||||
<span>{candIndex + 1}</span>
|
||||
</DragHandle>
|
||||
</InputGroupAddon>
|
||||
<Input
|
||||
type="text"
|
||||
value={label}
|
||||
{...inputProps}
|
||||
placeholder={t("resource.candidatePlaceholder")}
|
||||
tabIndex={candIndex + 1}
|
||||
maxLength="250"
|
||||
autoFocus
|
||||
/>
|
||||
<ButtonWithConfirm className="btn btn-primary border-light" label={label} onDelete={onDelete}>
|
||||
</ButtonWithConfirm>
|
||||
</InputGroup>
|
||||
</Col>
|
||||
<Col xs="auto" className="align-self-center pl-0">
|
||||
<HelpButton>
|
||||
{t(
|
||||
"Enter the name of your candidate or proposal here (250 characters max.)"
|
||||
)}
|
||||
</HelpButton>
|
||||
</Col>
|
||||
</Row>
|
||||
);
|
||||
}
|
||||
|
||||
export default CandidateField
|
@ -1,128 +0,0 @@
|
||||
import {useState, useEffect, createRef} from 'react'
|
||||
import {useTranslation} from "react-i18next";
|
||||
import {
|
||||
Button,
|
||||
Card,
|
||||
CardBody
|
||||
} from "reactstrap";
|
||||
import {
|
||||
faPlus,
|
||||
} from "@fortawesome/free-solid-svg-icons";
|
||||
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
|
||||
import {
|
||||
sortableContainer,
|
||||
sortableElement,
|
||||
sortableHandle
|
||||
} from "react-sortable-hoc";
|
||||
import arrayMove from "array-move"
|
||||
import CandidateField from './CandidateField'
|
||||
|
||||
// const SortableItem = sortableElement(({className, ...childProps}) => <li className={className}><CandidateField {...childProps} /></li>);
|
||||
//
|
||||
// const SortableContainer = sortableContainer(({children}) => {
|
||||
// return <ul className="sortable">{children}</ul>;
|
||||
// });
|
||||
|
||||
const SortableItem = ({className, ...childProps}) => <li className={className}><CandidateField {...childProps} /></li>;
|
||||
|
||||
const SortableContainer = ({children}) => {
|
||||
return <ul className="sortable">{children}</ul>;
|
||||
};
|
||||
|
||||
|
||||
const CandidatesField = ({onChange}) => {
|
||||
const {t} = useTranslation();
|
||||
const [candidates, setCandidates] = useState([])
|
||||
|
||||
const addCandidate = () => {
|
||||
if (candidates.length < 1000) {
|
||||
candidates.push({label: "", fieldRef: createRef()});
|
||||
setCandidates([...candidates]);
|
||||
onChange(candidates)
|
||||
} else {
|
||||
console.error("Too many candidates")
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
addCandidate();
|
||||
addCandidate();
|
||||
}, [])
|
||||
|
||||
|
||||
const removeCandidate = index => {
|
||||
if (candidates.length === 1) {
|
||||
const newCandidates = []
|
||||
newCandidates.push({label: "", fieldRef: createRef()});
|
||||
newCandidates.push({label: "", fieldRef: createRef()});
|
||||
setCandidates(newCandidates);
|
||||
onChange(newCandidates)
|
||||
}
|
||||
else {
|
||||
const newCandidates = candidates.filter((c, i) => i != index)
|
||||
setCandidates(newCandidates);
|
||||
onChange(newCandidates);
|
||||
}
|
||||
};
|
||||
|
||||
const editCandidate = (index, label) => {
|
||||
candidates[index].label = label
|
||||
setCandidates([...candidates]);
|
||||
onChange(candidates);
|
||||
};
|
||||
|
||||
const handleKeyPress = (e, index) => {
|
||||
if (e.key === "Enter") {
|
||||
e.preventDefault();
|
||||
if (index + 1 === candidates.length) {
|
||||
addCandidate();
|
||||
}
|
||||
else {
|
||||
candidates[index + 1].fieldRef.current.focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const onSortEnd = ({oldIndex, newIndex}) => {
|
||||
setCandidates(arrayMove(candidates, oldIndex, newIndex));
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<SortableContainer onSortEnd={onSortEnd}>
|
||||
{candidates.map((candidate, index) => {
|
||||
const className = "sortable"
|
||||
return (
|
||||
<SortableItem
|
||||
className={className}
|
||||
key={`item-${index}`}
|
||||
index={index}
|
||||
candIndex={index}
|
||||
label={candidate.label}
|
||||
onDelete={() => removeCandidate(index)}
|
||||
onChange={(e) => editCandidate(index, e.target.value)}
|
||||
onKeyPress={(e) => handleKeyPress(e, index)}
|
||||
innerRef={candidate.fieldRef}
|
||||
/>
|
||||
)
|
||||
})}
|
||||
</SortableContainer>
|
||||
|
||||
<Button
|
||||
color="secondary"
|
||||
className="btn-block mt-2"
|
||||
tabIndex={candidates.length + 2}
|
||||
type="button"
|
||||
onClick={addCandidate}
|
||||
>
|
||||
<FontAwesomeIcon icon={faPlus} className="mr-2" />
|
||||
{t("Add a proposal")}
|
||||
</Button>
|
||||
</>
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
export default CandidatesField
|
||||
|
@ -1,164 +0,0 @@
|
||||
import {useTranslation} from "next-i18next";
|
||||
import {useState} from "react";
|
||||
import {
|
||||
faExclamationTriangle,
|
||||
faCheck,
|
||||
} from "@fortawesome/free-solid-svg-icons";
|
||||
import {Button, Modal, ModalHeader, ModalBody, ModalFooter} from "reactstrap";
|
||||
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
|
||||
|
||||
const ConfirmModal = ({tabIndex, title, candidates, grades, isTimeLimited, start, finish, emails, restrictResult, className, confirmCallback}) => {
|
||||
const [visibled, setVisibility] = useState(false);
|
||||
const {t} = useTranslation();
|
||||
const toggle = () => setVisibility(!visibled)
|
||||
|
||||
return (
|
||||
<div className="input-group-append">
|
||||
<button
|
||||
type="button"
|
||||
className={className}
|
||||
onClick={toggle}
|
||||
tabIndex={tabIndex}
|
||||
>
|
||||
<FontAwesomeIcon icon={faCheck} className="mr-2" />
|
||||
{t("Validate")}
|
||||
</button>
|
||||
<Modal
|
||||
isOpen={visibled}
|
||||
toggle={toggle}
|
||||
className="modal-dialog-centered"
|
||||
>
|
||||
<ModalHeader toggle={toggle}>
|
||||
{t("Confirm your vote")}
|
||||
</ModalHeader>
|
||||
<ModalBody>
|
||||
<div className="mt-1 mb-1">
|
||||
<div className="text-white bg-primary p-2 pl-3 pr-3 rounded">
|
||||
{t("Question of the election")}
|
||||
</div>
|
||||
<div className="p-2 pl-3 pr-3 bg-light mb-3">{title}</div>
|
||||
<div className="text-white bg-primary p-2 pl-3 pr-3 rounded">
|
||||
{t("Candidates/Proposals")}
|
||||
</div>
|
||||
<div className="p-2 pl-3 pr-3 bg-light mb-3">
|
||||
<ul className="m-0 pl-4">
|
||||
{candidates.map((candidate, i) => {
|
||||
if (candidate.label !== "") {
|
||||
return (
|
||||
<li key={i} className="m-0">
|
||||
{candidate.label}
|
||||
</li>
|
||||
);
|
||||
} else {
|
||||
return <li key={i} className="d-none" />;
|
||||
}
|
||||
})}
|
||||
</ul>
|
||||
</div>
|
||||
<div className={(isTimeLimited ? "d-block " : "d-none")} >
|
||||
<div className="text-white bg-primary p-2 pl-3 pr-3 rounded">
|
||||
{t("Dates")}
|
||||
</div>
|
||||
<div className="p-2 pl-3 pr-3 bg-light mb-3">
|
||||
{t("The election will take place from")}{" "}
|
||||
<b>
|
||||
{start.toLocaleDateString()}, {t("at")}{" "}
|
||||
{start.toLocaleTimeString()}
|
||||
</b>{" "}
|
||||
{t("to")}{" "}
|
||||
<b>
|
||||
{finish.toLocaleDateString()}, {t("at")}{" "}
|
||||
{finish.toLocaleTimeString()}
|
||||
</b>
|
||||
</div>
|
||||
</div>
|
||||
<div className="text-white bg-primary p-2 pl-3 pr-3 rounded">
|
||||
{t("Grades")}
|
||||
</div>
|
||||
<div className="p-2 pl-3 pr-3 bg-light mb-3">
|
||||
{grades.map((mention, i) => {
|
||||
return i < grades.length ? (
|
||||
<span
|
||||
key={i}
|
||||
className="badge badge-light mr-2 mt-2"
|
||||
style={{
|
||||
backgroundColor: mention.color,
|
||||
color: "#fff"
|
||||
}}
|
||||
>
|
||||
{mention.label}
|
||||
</span>
|
||||
) : (
|
||||
<span key={i} />
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
<div className="text-white bg-primary p-2 pl-3 pr-3 rounded">
|
||||
{t("Voters' list")}
|
||||
</div>
|
||||
<div className="p-2 pl-3 pr-3 bg-light mb-3">
|
||||
{emails.length > 0 ? (
|
||||
emails.join(", ")
|
||||
) : (
|
||||
<p>
|
||||
{t("The form contains no address.")}
|
||||
<br />
|
||||
<em>
|
||||
{t(
|
||||
"The election will be opened to anyone with the link"
|
||||
)}
|
||||
</em>
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
{restrictResult ? (
|
||||
<div>
|
||||
<div className="small bg-primary text-white p-3 mt-2 rounded">
|
||||
<h6 className="m-0 p-0">
|
||||
<FontAwesomeIcon
|
||||
icon={faExclamationTriangle}
|
||||
className="mr-2"
|
||||
/>
|
||||
<u>{t("Results available at the close of the vote")}</u>
|
||||
</h6>
|
||||
<p className="m-2 p-0">
|
||||
<span>
|
||||
{t(
|
||||
"The results page will not be accessible until the end date is reached."
|
||||
)}{" "}
|
||||
({finish.toLocaleDateString()} {t("at")}{" "}
|
||||
{finish.toLocaleTimeString()})
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<div>
|
||||
<div className="small bg-primary text-white p-3 mt-2 rounded">
|
||||
<h6 className="m-0 p-0">
|
||||
{t("Results available at any time")}
|
||||
</h6>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<Button
|
||||
color="primary-outline"
|
||||
className="text-primary border-primary"
|
||||
onClick={toggle}>
|
||||
{t("Cancel")}
|
||||
</Button>
|
||||
<Button color="primary"
|
||||
onClick={() => {toggle(); confirmCallback();}}
|
||||
>
|
||||
{t("Start the election")}
|
||||
</Button>
|
||||
</ModalFooter>
|
||||
</Modal>
|
||||
</div >
|
||||
)
|
||||
}
|
||||
|
||||
export default ConfirmModal
|
@ -1,75 +0,0 @@
|
||||
/* eslint react/prop-types: 0 */
|
||||
import React, { Component } from "react";
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
import { faQuestionCircle } from "@fortawesome/free-solid-svg-icons";
|
||||
|
||||
class HelpButton extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
tooltipOpen: false
|
||||
};
|
||||
}
|
||||
|
||||
showTooltip = () => {
|
||||
this.setState({
|
||||
tooltipOpen: true
|
||||
});
|
||||
};
|
||||
|
||||
hideTooltip = () => {
|
||||
this.setState({
|
||||
tooltipOpen: false
|
||||
});
|
||||
};
|
||||
|
||||
render() {
|
||||
return (
|
||||
<span className={this.props.className}>
|
||||
<span>
|
||||
{this.state.tooltipOpen ? (
|
||||
<span
|
||||
style={{
|
||||
position: "absolute",
|
||||
zIndex: 10,
|
||||
fontSize: "12px",
|
||||
color: "#000",
|
||||
backgroundColor: "#fff",
|
||||
display: "inline-block",
|
||||
borderRadius: "0.25rem",
|
||||
boxShadow: "-5px 0 5px rgba(0,0,0,0.5)",
|
||||
maxWidth: "200px",
|
||||
padding: "10px",
|
||||
marginLeft: "-215px",
|
||||
marginTop: "-25px"
|
||||
}}
|
||||
>
|
||||
<span
|
||||
style={{
|
||||
position: "absolute",
|
||||
width: 0,
|
||||
height: 0,
|
||||
borderTop: "10px solid transparent",
|
||||
borderBottom: "10px solid transparent",
|
||||
borderLeft: "10px solid #fff",
|
||||
marginLeft: "190px",
|
||||
marginTop: "15px"
|
||||
}}
|
||||
></span>
|
||||
{this.props.children}
|
||||
</span>
|
||||
) : (
|
||||
<span />
|
||||
)}
|
||||
</span>
|
||||
<FontAwesomeIcon
|
||||
icon={faQuestionCircle}
|
||||
onMouseOver={this.showTooltip}
|
||||
onMouseOut={this.hideTooltip}
|
||||
/>
|
||||
</span>
|
||||
);
|
||||
}
|
||||
}
|
||||
export default HelpButton;
|
@ -1,94 +0,0 @@
|
||||
import Link from "next/link";
|
||||
import { useTranslation } from "next-i18next";
|
||||
import Paypal from "../banner/Paypal";
|
||||
import { useBbox } from "./useBbox";
|
||||
|
||||
const Footer = () => {
|
||||
const linkStyle = { whiteSpace: "nowrap" };
|
||||
const { t } = useTranslation();
|
||||
|
||||
const [bboxLink1, link1] = useBbox();
|
||||
const [bboxLink2, link2] = useBbox();
|
||||
const [bboxLink3, link3] = useBbox();
|
||||
const [bboxLink4, link4] = useBbox();
|
||||
const [bboxLink5, link5] = useBbox();
|
||||
const [bboxLink6, link6] = useBbox();
|
||||
const [bboxLink7, link7] = useBbox();
|
||||
|
||||
return (
|
||||
<footer className="text-center">
|
||||
<div>
|
||||
<ul className="tacky">
|
||||
<li
|
||||
ref={link1}
|
||||
className={bboxLink1.top === bboxLink2.top ? "" : "no-tack"}
|
||||
>
|
||||
<Link href="/" style={linkStyle}>
|
||||
{t("Homepage")}
|
||||
</Link>
|
||||
</li>
|
||||
<li
|
||||
ref={link2}
|
||||
className={bboxLink2.top === bboxLink3.top ? "" : "no-tack"}
|
||||
>
|
||||
<Link href="/faq" style={linkStyle}>
|
||||
{t("FAQ")}
|
||||
</Link>
|
||||
</li>
|
||||
<li
|
||||
ref={link3}
|
||||
className={bboxLink3.top === bboxLink4.top ? "" : "no-tack"}
|
||||
>
|
||||
<a href="mailto:app@mieuxvoter.fr?subject=[HELP]" style={linkStyle}>
|
||||
{t("resource.help")}
|
||||
</a>
|
||||
</li>
|
||||
<li
|
||||
ref={link4}
|
||||
className={bboxLink4.top === bboxLink5.top ? "" : "no-tack"}
|
||||
>
|
||||
<a
|
||||
href="https://mieuxvoter.fr/"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
style={linkStyle}
|
||||
>
|
||||
{t("Who are we?")}
|
||||
</a>
|
||||
</li>
|
||||
<li
|
||||
ref={link5}
|
||||
className={bboxLink5.top === bboxLink6.top ? "" : "no-tack"}
|
||||
>
|
||||
<Link href="/privacy-policy" style={linkStyle}>
|
||||
{t("Privacy policy")}
|
||||
</Link>
|
||||
</li>
|
||||
<li
|
||||
ref={link6}
|
||||
className={bboxLink6.top === bboxLink7.top ? "" : "no-tack"}
|
||||
>
|
||||
<Link href="/legal-notices" style={linkStyle}>
|
||||
{t("resource.legalNotices")}
|
||||
</Link>
|
||||
</li>
|
||||
<li ref={link7}>
|
||||
{" "}
|
||||
<a
|
||||
href="https://github.com/MieuxVoter"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
style={linkStyle}
|
||||
>
|
||||
{t("Source code")}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div className="mt-3">
|
||||
<Paypal btnColor="btn-primary" />
|
||||
</div>
|
||||
</footer>
|
||||
);
|
||||
};
|
||||
export default Footer;
|
@ -1,61 +0,0 @@
|
||||
/* eslint react/prop-types: 0 */
|
||||
import {useState} from "react";
|
||||
import {Collapse, Navbar, NavbarToggler, Nav, NavItem} from "reactstrap";
|
||||
import Link from "next/link";
|
||||
import Head from "next/head";
|
||||
import {useTranslation} from 'next-i18next'
|
||||
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
|
||||
import {faRocket} from "@fortawesome/free-solid-svg-icons";
|
||||
import LanguageSelector from "./LanguageSelector";
|
||||
|
||||
|
||||
const Header = () => {
|
||||
const [isOpen, setOpen] = useState(false)
|
||||
|
||||
const toggle = () => setOpen(!isOpen);
|
||||
|
||||
const {t} = useTranslation()
|
||||
return (
|
||||
<>
|
||||
<Head><title>{t("title")}</title></Head>
|
||||
<header>
|
||||
<Navbar color="light" light expand="md">
|
||||
<Link href="/">
|
||||
<a className="navbar-brand">
|
||||
<div className="d-flex flex-row">
|
||||
<div className="align-self-center">
|
||||
<img src="/logos/logo-color.svg" alt="logo" height="32" />
|
||||
</div>
|
||||
<div className="align-self-center ml-2">
|
||||
<div className="logo-text">
|
||||
<h1>
|
||||
{t("Voting platform")}
|
||||
<small>{t("Majority Judgment")}</small>
|
||||
</h1>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
</Link>
|
||||
<NavbarToggler onClick={toggle} />
|
||||
<Collapse isOpen={isOpen} navbar>
|
||||
<Nav className="ml-auto" navbar>
|
||||
<NavItem>
|
||||
<Link href="/new/">
|
||||
<a className="text-primary nav-link"> <FontAwesomeIcon icon={faRocket} className="mr-2" />
|
||||
{t("Start an election")}
|
||||
</a>
|
||||
</Link>
|
||||
</NavItem>
|
||||
<NavItem style={{width: "80px"}}>
|
||||
<LanguageSelector />
|
||||
</NavItem>
|
||||
</Nav>
|
||||
</Collapse>
|
||||
</Navbar>
|
||||
</header>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default Header;
|
@ -1,32 +0,0 @@
|
||||
import {useRouter} from 'next/router'
|
||||
import ReactFlagsSelect from 'react-flags-select';
|
||||
|
||||
const LanguageSelector = () => {
|
||||
|
||||
const router = useRouter();
|
||||
let localeShort = router.locale.substring(0, 2).toUpperCase();
|
||||
if (localeShort === "EN") localeShort = "GB";
|
||||
|
||||
const selectHandler = e => {
|
||||
let locale = e.toLowerCase();
|
||||
if (locale === "gb") locale = "en";
|
||||
router.push("", "", {locale})
|
||||
};
|
||||
return (
|
||||
<ReactFlagsSelect
|
||||
onSelect={selectHandler}
|
||||
countries={
|
||||
// ["GB", "FR", "ES", "DE", "RU"]
|
||||
["GB", "FR"]
|
||||
}
|
||||
showOptionLabel={false}
|
||||
selected={localeShort}
|
||||
selectedSize={15}
|
||||
optionsSize={22}
|
||||
showSelectedLabel={false}
|
||||
showSecondaryOptionLabel={false}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export default LanguageSelector;
|
@ -1,20 +0,0 @@
|
||||
/* eslint react/prop-types: 0 */
|
||||
import { useState } from 'react';
|
||||
import { useRef } from 'react';
|
||||
import { useEffect } from 'react';
|
||||
|
||||
export const useBbox = () => {
|
||||
const ref = useRef();
|
||||
const [bbox, setBbox] = useState({});
|
||||
|
||||
const set = () =>
|
||||
setBbox(ref && ref.current ? ref.current.getBoundingClientRect() : {});
|
||||
|
||||
useEffect(() => {
|
||||
set();
|
||||
window.addEventListener('resize', set);
|
||||
return () => window.removeEventListener('resize', set);
|
||||
}, []);
|
||||
|
||||
return [bbox, ref];
|
||||
};
|
@ -1,14 +0,0 @@
|
||||
import React from "react";
|
||||
import Image from 'next/image'
|
||||
|
||||
const Loader = () => {
|
||||
return (
|
||||
<div className="loader bg-primary">
|
||||
<img src="/loader-pulse-2.gif" alt="Loading..." />
|
||||
|
||||
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Loader;
|
@ -1,8 +0,0 @@
|
||||
import React from "react";
|
||||
import Loader from "../loader";
|
||||
|
||||
const Wait = () => {
|
||||
return <Loader />;
|
||||
};
|
||||
|
||||
export default Wait;
|
Before Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 32 KiB |
@ -1,14 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
// This is a custom Jest transformer turning style imports into empty objects.
|
||||
// http://facebook.github.io/jest/docs/en/webpack.html
|
||||
|
||||
module.exports = {
|
||||
process() {
|
||||
return 'module.exports = {};';
|
||||
},
|
||||
getCacheKey() {
|
||||
// The output is always the same.
|
||||
return 'cssTransform';
|
||||
},
|
||||
};
|
@ -1,40 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const path = require('path');
|
||||
const camelcase = require('camelcase');
|
||||
|
||||
// This is a custom Jest transformer turning file imports into filenames.
|
||||
// http://facebook.github.io/jest/docs/en/webpack.html
|
||||
|
||||
module.exports = {
|
||||
process(src, filename) {
|
||||
const assetFilename = JSON.stringify(path.basename(filename));
|
||||
|
||||
if (filename.match(/\.svg$/)) {
|
||||
// Based on how SVGR generates a component name:
|
||||
// https://github.com/smooth-code/svgr/blob/01b194cf967347d43d4cbe6b434404731b87cf27/packages/core/src/state.js#L6
|
||||
const pascalCaseFileName = camelcase(path.parse(filename).name, {
|
||||
pascalCase: true,
|
||||
});
|
||||
const componentName = `Svg${pascalCaseFileName}`;
|
||||
return `const React = require('react');
|
||||
module.exports = {
|
||||
__esModule: true,
|
||||
default: ${assetFilename},
|
||||
ReactComponent: React.forwardRef(function ${componentName}(props, ref) {
|
||||
return {
|
||||
$$typeof: Symbol.for('react.element'),
|
||||
type: 'svg',
|
||||
ref: ref,
|
||||
key: null,
|
||||
props: Object.assign({}, props, {
|
||||
children: ${assetFilename}
|
||||
})
|
||||
};
|
||||
}),
|
||||
};`;
|
||||
}
|
||||
|
||||
return `module.exports = ${assetFilename};`;
|
||||
},
|
||||
};
|
@ -1,84 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const paths = require('./paths');
|
||||
const chalk = require('react-dev-utils/chalk');
|
||||
|
||||
/**
|
||||
* Get the baseUrl of a compilerOptions object.
|
||||
*
|
||||
* @param {Object} options
|
||||
*/
|
||||
function getAdditionalModulePaths(options = {}) {
|
||||
const baseUrl = options.baseUrl;
|
||||
|
||||
// We need to explicitly check for null and undefined (and not a falsy value) because
|
||||
// TypeScript treats an empty string as `.`.
|
||||
if (baseUrl == null) {
|
||||
// If there's no baseUrl set we respect NODE_PATH
|
||||
// Note that NODE_PATH is deprecated and will be removed
|
||||
// in the next major release of create-react-app.
|
||||
|
||||
const nodePath = process.env.NODE_PATH || '';
|
||||
return nodePath.split(path.delimiter).filter(Boolean);
|
||||
}
|
||||
|
||||
const baseUrlResolved = path.resolve(paths.appPath, baseUrl);
|
||||
|
||||
// We don't need to do anything if `baseUrl` is set to `node_modules`. This is
|
||||
// the default behavior.
|
||||
if (path.relative(paths.appNodeModules, baseUrlResolved) === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Allow the user set the `baseUrl` to `appSrc`.
|
||||
if (path.relative(paths.appSrc, baseUrlResolved) === '') {
|
||||
return [paths.appSrc];
|
||||
}
|
||||
|
||||
// Otherwise, throw an error.
|
||||
throw new Error(
|
||||
chalk.red.bold(
|
||||
"Your project's `baseUrl` can only be set to `src` or `node_modules`." +
|
||||
' Create React App does not support other values at this time.'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function getModules() {
|
||||
// Check if TypeScript is setup
|
||||
const hasTsConfig = fs.existsSync(paths.appTsConfig);
|
||||
const hasJsConfig = fs.existsSync(paths.appJsConfig);
|
||||
|
||||
if (hasTsConfig && hasJsConfig) {
|
||||
throw new Error(
|
||||
'You have both a tsconfig.json and a jsconfig.json. If you are using TypeScript please remove your jsconfig.json file.'
|
||||
);
|
||||
}
|
||||
|
||||
let config;
|
||||
|
||||
// If there's a tsconfig.json we assume it's a
|
||||
// TypeScript project and set up the config
|
||||
// based on tsconfig.json
|
||||
if (hasTsConfig) {
|
||||
config = require(paths.appTsConfig);
|
||||
// Otherwise we'll check if there is jsconfig.json
|
||||
// for non TS projects.
|
||||
} else if (hasJsConfig) {
|
||||
config = require(paths.appJsConfig);
|
||||
}
|
||||
|
||||
config = config || {};
|
||||
const options = config.compilerOptions || {};
|
||||
|
||||
const additionalModulePaths = getAdditionalModulePaths(options);
|
||||
|
||||
return {
|
||||
additionalModulePaths: additionalModulePaths,
|
||||
hasTsConfig,
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = getModules();
|
@ -1,90 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const url = require('url');
|
||||
|
||||
// Make sure any symlinks in the project folder are resolved:
|
||||
// https://github.com/facebook/create-react-app/issues/637
|
||||
const appDirectory = fs.realpathSync(process.cwd());
|
||||
const resolveApp = relativePath => path.resolve(appDirectory, relativePath);
|
||||
|
||||
const envPublicUrl = process.env.PUBLIC_URL;
|
||||
|
||||
function ensureSlash(inputPath, needsSlash) {
|
||||
const hasSlash = inputPath.endsWith('/');
|
||||
if (hasSlash && !needsSlash) {
|
||||
return inputPath.substr(0, inputPath.length - 1);
|
||||
} else if (!hasSlash && needsSlash) {
|
||||
return `${inputPath}/`;
|
||||
} else {
|
||||
return inputPath;
|
||||
}
|
||||
}
|
||||
|
||||
const getPublicUrl = appPackageJson =>
|
||||
envPublicUrl || require(appPackageJson).homepage;
|
||||
|
||||
// We use `PUBLIC_URL` environment variable or "homepage" field to infer
|
||||
// "public path" at which the app is served.
|
||||
// Webpack needs to know it to put the right <script> hrefs into HTML even in
|
||||
// single-page apps that may serve index.html for nested URLs like /todos/42.
|
||||
// We can't use a relative path in HTML because we don't want to load something
|
||||
// like /todos/42/static/js/bundle.7289d.js. We have to know the root.
|
||||
function getServedPath(appPackageJson) {
|
||||
const publicUrl = getPublicUrl(appPackageJson);
|
||||
const servedUrl =
|
||||
envPublicUrl || (publicUrl ? url.parse(publicUrl).pathname : '/');
|
||||
return ensureSlash(servedUrl, true);
|
||||
}
|
||||
|
||||
const moduleFileExtensions = [
|
||||
'web.mjs',
|
||||
'mjs',
|
||||
'web.js',
|
||||
'js',
|
||||
'web.ts',
|
||||
'ts',
|
||||
'web.tsx',
|
||||
'tsx',
|
||||
'json',
|
||||
'web.jsx',
|
||||
'jsx',
|
||||
];
|
||||
|
||||
// Resolve file paths in the same order as webpack
|
||||
const resolveModule = (resolveFn, filePath) => {
|
||||
const extension = moduleFileExtensions.find(extension =>
|
||||
fs.existsSync(resolveFn(`${filePath}.${extension}`))
|
||||
);
|
||||
|
||||
if (extension) {
|
||||
return resolveFn(`${filePath}.${extension}`);
|
||||
}
|
||||
|
||||
return resolveFn(`${filePath}.js`);
|
||||
};
|
||||
|
||||
// config after eject: we're in ./config/
|
||||
module.exports = {
|
||||
dotenv: resolveApp('.env'),
|
||||
appPath: resolveApp('.'),
|
||||
appBuild: resolveApp('build'),
|
||||
appPublic: resolveApp('public'),
|
||||
appHtml: resolveApp('public/index.html'),
|
||||
appIndexJs: resolveModule(resolveApp, 'src/index'),
|
||||
appPackageJson: resolveApp('package.json'),
|
||||
appSrc: resolveApp('src'),
|
||||
appTsConfig: resolveApp('tsconfig.json'),
|
||||
appJsConfig: resolveApp('jsconfig.json'),
|
||||
yarnLockFile: resolveApp('yarn.lock'),
|
||||
testsSetup: resolveModule(resolveApp, 'src/setupTests'),
|
||||
proxySetup: resolveApp('src/setupProxy.js'),
|
||||
appNodeModules: resolveApp('node_modules'),
|
||||
publicUrl: getPublicUrl(resolveApp('package.json')),
|
||||
servedPath: getServedPath(resolveApp('package.json')),
|
||||
};
|
||||
|
||||
|
||||
|
||||
module.exports.moduleFileExtensions = moduleFileExtensions;
|
@ -1,35 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const { resolveModuleName } = require('ts-pnp');
|
||||
|
||||
exports.resolveModuleName = (
|
||||
typescript,
|
||||
moduleName,
|
||||
containingFile,
|
||||
compilerOptions,
|
||||
resolutionHost
|
||||
) => {
|
||||
return resolveModuleName(
|
||||
moduleName,
|
||||
containingFile,
|
||||
compilerOptions,
|
||||
resolutionHost,
|
||||
typescript.resolveModuleName
|
||||
);
|
||||
};
|
||||
|
||||
exports.resolveTypeReferenceDirective = (
|
||||
typescript,
|
||||
moduleName,
|
||||
containingFile,
|
||||
compilerOptions,
|
||||
resolutionHost
|
||||
) => {
|
||||
return resolveModuleName(
|
||||
moduleName,
|
||||
containingFile,
|
||||
compilerOptions,
|
||||
resolutionHost,
|
||||
typescript.resolveTypeReferenceDirective
|
||||
);
|
||||
};
|
@ -1,628 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
const isWsl = require('is-wsl');
|
||||
const path = require('path');
|
||||
const webpack = require('webpack');
|
||||
const resolve = require('resolve');
|
||||
const PnpWebpackPlugin = require('pnp-webpack-plugin');
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
|
||||
const InlineChunkHtmlPlugin = require('react-dev-utils/InlineChunkHtmlPlugin');
|
||||
const TerserPlugin = require('terser-webpack-plugin');
|
||||
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
||||
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
|
||||
const safePostCssParser = require('postcss-safe-parser');
|
||||
const ManifestPlugin = require('webpack-manifest-plugin');
|
||||
const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
|
||||
const WorkboxWebpackPlugin = require('workbox-webpack-plugin');
|
||||
const WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin');
|
||||
const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
|
||||
const getCSSModuleLocalIdent = require('react-dev-utils/getCSSModuleLocalIdent');
|
||||
const paths = require('./paths');
|
||||
const modules = require('./modules');
|
||||
const getClientEnvironment = require('./env');
|
||||
const ModuleNotFoundPlugin = require('react-dev-utils/ModuleNotFoundPlugin');
|
||||
const ForkTsCheckerWebpackPlugin = require('react-dev-utils/ForkTsCheckerWebpackPlugin');
|
||||
const typescriptFormatter = require('react-dev-utils/typescriptFormatter');
|
||||
|
||||
const postcssNormalize = require('postcss-normalize');
|
||||
|
||||
// Source maps are resource heavy and can cause out of memory issue for large source files.
|
||||
const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== 'false';
|
||||
// Some apps do not need the benefits of saving a web request, so not inlining the chunk
|
||||
// makes for a smoother build process.
|
||||
const shouldInlineRuntimeChunk = process.env.INLINE_RUNTIME_CHUNK !== 'false';
|
||||
|
||||
// Check if TypeScript is setup
|
||||
const useTypeScript = fs.existsSync(paths.appTsConfig);
|
||||
|
||||
// style files regexes
|
||||
const cssRegex = /\.css$/;
|
||||
const cssModuleRegex = /\.module\.css$/;
|
||||
const sassRegex = /\.(scss|sass)$/;
|
||||
const sassModuleRegex = /\.module\.(scss|sass)$/;
|
||||
|
||||
// This is the production and development configuration.
|
||||
// It is focused on developer experience, fast rebuilds, and a minimal bundle.
|
||||
module.exports = function(webpackEnv) {
|
||||
const isEnvDevelopment = webpackEnv === 'development';
|
||||
const isEnvProduction = webpackEnv === 'production';
|
||||
|
||||
// Webpack uses `publicPath` to determine where the app is being served from.
|
||||
// It requires a trailing slash, or the file assets will get an incorrect path.
|
||||
// In development, we always serve from the root. This makes config easier.
|
||||
const publicPath = isEnvProduction
|
||||
? paths.servedPath
|
||||
: isEnvDevelopment && '/';
|
||||
// Some apps do not use client-side routing with pushState.
|
||||
// For these, "homepage" can be set to "." to enable relative asset paths.
|
||||
const shouldUseRelativeAssetPaths = publicPath === './';
|
||||
|
||||
// `publicUrl` is just like `publicPath`, but we will provide it to our app
|
||||
// as %PUBLIC_URL% in `index.html` and `process.env.PUBLIC_URL` in JavaScript.
|
||||
// Omit trailing slash as %PUBLIC_URL%/xyz looks better than %PUBLIC_URL%xyz.
|
||||
const publicUrl = isEnvProduction
|
||||
? publicPath.slice(0, -1)
|
||||
: isEnvDevelopment && '';
|
||||
// Get environment variables to inject into our app.
|
||||
const env = getClientEnvironment(publicUrl);
|
||||
|
||||
// common function to get style loaders
|
||||
const getStyleLoaders = (cssOptions, preProcessor) => {
|
||||
const loaders = [
|
||||
isEnvDevelopment && require.resolve('style-loader'),
|
||||
isEnvProduction && {
|
||||
loader: MiniCssExtractPlugin.loader,
|
||||
options: shouldUseRelativeAssetPaths ? { publicPath: '../../' } : {},
|
||||
},
|
||||
{
|
||||
loader: require.resolve('css-loader'),
|
||||
options: cssOptions,
|
||||
},
|
||||
{
|
||||
// Options for PostCSS as we reference these options twice
|
||||
// Adds vendor prefixing based on your specified browser support in
|
||||
// package.json
|
||||
loader: require.resolve('postcss-loader'),
|
||||
options: {
|
||||
// Necessary for external CSS imports to work
|
||||
// https://github.com/facebook/create-react-app/issues/2677
|
||||
ident: 'postcss',
|
||||
plugins: () => [
|
||||
require('postcss-flexbugs-fixes'),
|
||||
require('postcss-preset-env')({
|
||||
autoprefixer: {
|
||||
flexbox: 'no-2009',
|
||||
},
|
||||
stage: 3,
|
||||
}),
|
||||
// Adds PostCSS Normalize as the reset css with default options,
|
||||
// so that it honors browserslist config in package.json
|
||||
// which in turn let's users customize the target behavior as per their needs.
|
||||
postcssNormalize(),
|
||||
],
|
||||
sourceMap: isEnvProduction && shouldUseSourceMap,
|
||||
},
|
||||
},
|
||||
].filter(Boolean);
|
||||
if (preProcessor) {
|
||||
loaders.push({
|
||||
loader: require.resolve(preProcessor),
|
||||
options: {
|
||||
sourceMap: isEnvProduction && shouldUseSourceMap,
|
||||
},
|
||||
});
|
||||
}
|
||||
return loaders;
|
||||
};
|
||||
|
||||
return {
|
||||
mode: isEnvProduction ? 'production' : isEnvDevelopment && 'development',
|
||||
// Stop compilation early in production
|
||||
bail: isEnvProduction,
|
||||
devtool: isEnvProduction
|
||||
? shouldUseSourceMap
|
||||
? 'source-map'
|
||||
: false
|
||||
: isEnvDevelopment && 'cheap-module-source-map',
|
||||
// These are the "entry points" to our application.
|
||||
// This means they will be the "root" imports that are included in JS bundle.
|
||||
entry: [
|
||||
// Include an alternative client for WebpackDevServer. A client's job is to
|
||||
// connect to WebpackDevServer by a socket and get notified about changes.
|
||||
// When you save a file, the client will either apply hot updates (in case
|
||||
// of CSS changes), or refresh the page (in case of JS changes). When you
|
||||
// make a syntax error, this client will display a syntax error overlay.
|
||||
// Note: instead of the default WebpackDevServer client, we use a custom one
|
||||
// to bring better experience for Create React App users. You can replace
|
||||
// the line below with these two lines if you prefer the stock client:
|
||||
// require.resolve('webpack-dev-server/client') + '?/',
|
||||
// require.resolve('webpack/hot/dev-server'),
|
||||
isEnvDevelopment &&
|
||||
require.resolve('react-dev-utils/webpackHotDevClient'),
|
||||
// Finally, this is your app's code:
|
||||
paths.appIndexJs,
|
||||
// We include the app code last so that if there is a runtime error during
|
||||
// initialization, it doesn't blow up the WebpackDevServer client, and
|
||||
// changing JS code would still trigger a refresh.
|
||||
].filter(Boolean),
|
||||
output: {
|
||||
// The build folder.
|
||||
path: isEnvProduction ? paths.appBuild : undefined,
|
||||
// Add /* filename */ comments to generated require()s in the output.
|
||||
pathinfo: isEnvDevelopment,
|
||||
// There will be one main bundle, and one file per asynchronous chunk.
|
||||
// In development, it does not produce real files.
|
||||
filename: isEnvProduction
|
||||
? 'static/js/[name].[contenthash:8].js'
|
||||
: isEnvDevelopment && 'static/js/bundle.js',
|
||||
// TODO: remove this when upgrading to webpack 5
|
||||
futureEmitAssets: true,
|
||||
// There are also additional JS chunk files if you use code splitting.
|
||||
chunkFilename: isEnvProduction
|
||||
? 'static/js/[name].[contenthash:8].chunk.js'
|
||||
: isEnvDevelopment && 'static/js/[name].chunk.js',
|
||||
// We inferred the "public path" (such as / or /my-project) from homepage.
|
||||
// We use "/" in development.
|
||||
publicPath: publicPath,
|
||||
// Point sourcemap entries to original disk location (format as URL on Windows)
|
||||
devtoolModuleFilenameTemplate: isEnvProduction
|
||||
? info =>
|
||||
path
|
||||
.relative(paths.appSrc, info.absoluteResourcePath)
|
||||
.replace(/\\/g, '/')
|
||||
: isEnvDevelopment &&
|
||||
(info => path.resolve(info.absoluteResourcePath).replace(/\\/g, '/')),
|
||||
},
|
||||
optimization: {
|
||||
minimize: isEnvProduction,
|
||||
minimizer: [
|
||||
// This is only used in production mode
|
||||
new TerserPlugin({
|
||||
terserOptions: {
|
||||
parse: {
|
||||
// we want terser to parse ecma 8 code. However, we don't want it
|
||||
// to apply any minfication steps that turns valid ecma 5 code
|
||||
// into invalid ecma 5 code. This is why the 'compress' and 'output'
|
||||
// sections only apply transformations that are ecma 5 safe
|
||||
// https://github.com/facebook/create-react-app/pull/4234
|
||||
ecma: 8,
|
||||
},
|
||||
compress: {
|
||||
ecma: 5,
|
||||
warnings: false,
|
||||
// Disabled because of an issue with Uglify breaking seemingly valid code:
|
||||
// https://github.com/facebook/create-react-app/issues/2376
|
||||
// Pending further investigation:
|
||||
// https://github.com/mishoo/UglifyJS2/issues/2011
|
||||
comparisons: false,
|
||||
// Disabled because of an issue with Terser breaking valid code:
|
||||
// https://github.com/facebook/create-react-app/issues/5250
|
||||
// Pending futher investigation:
|
||||
// https://github.com/terser-js/terser/issues/120
|
||||
inline: 2,
|
||||
},
|
||||
mangle: {
|
||||
safari10: true,
|
||||
},
|
||||
output: {
|
||||
ecma: 5,
|
||||
comments: false,
|
||||
// Turned on because emoji and regex is not minified properly using default
|
||||
// https://github.com/facebook/create-react-app/issues/2488
|
||||
ascii_only: true,
|
||||
},
|
||||
},
|
||||
// Use multi-process parallel running to improve the build speed
|
||||
// Default number of concurrent runs: os.cpus().length - 1
|
||||
// Disabled on WSL (Windows Subsystem for Linux) due to an issue with Terser
|
||||
// https://github.com/webpack-contrib/terser-webpack-plugin/issues/21
|
||||
parallel: !isWsl,
|
||||
// Enable file caching
|
||||
cache: true,
|
||||
sourceMap: shouldUseSourceMap,
|
||||
}),
|
||||
// This is only used in production mode
|
||||
new OptimizeCSSAssetsPlugin({
|
||||
cssProcessorOptions: {
|
||||
parser: safePostCssParser,
|
||||
map: shouldUseSourceMap
|
||||
? {
|
||||
// `inline: false` forces the sourcemap to be output into a
|
||||
// separate file
|
||||
inline: false,
|
||||
// `annotation: true` appends the sourceMappingURL to the end of
|
||||
// the css file, helping the browser find the sourcemap
|
||||
annotation: true,
|
||||
}
|
||||
: false,
|
||||
},
|
||||
}),
|
||||
],
|
||||
// Automatically split vendor and commons
|
||||
// https://twitter.com/wSokra/status/969633336732905474
|
||||
// https://medium.com/webpack/webpack-4-code-splitting-chunk-graph-and-the-splitchunks-optimization-be739a861366
|
||||
splitChunks: {
|
||||
chunks: 'all',
|
||||
name: false,
|
||||
},
|
||||
// Keep the runtime chunk separated to enable long term caching
|
||||
// https://twitter.com/wSokra/status/969679223278505985
|
||||
runtimeChunk: true,
|
||||
},
|
||||
resolve: {
|
||||
// This allows you to set a fallback for where Webpack should look for modules.
|
||||
// We placed these paths second because we want `node_modules` to "win"
|
||||
// if there are any conflicts. This matches Node resolution mechanism.
|
||||
// https://github.com/facebook/create-react-app/issues/253
|
||||
modules: ['node_modules', paths.appNodeModules].concat(
|
||||
modules.additionalModulePaths || []
|
||||
),
|
||||
// These are the reasonable defaults supported by the Node ecosystem.
|
||||
// We also include JSX as a common component filename extension to support
|
||||
// some tools, although we do not recommend using it, see:
|
||||
// https://github.com/facebook/create-react-app/issues/290
|
||||
// `web` extension prefixes have been added for better support
|
||||
// for React Native Web.
|
||||
extensions: paths.moduleFileExtensions
|
||||
.map(ext => `.${ext}`)
|
||||
.filter(ext => useTypeScript || !ext.includes('ts')),
|
||||
alias: {
|
||||
// Support React Native Web
|
||||
// https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
|
||||
'react-native': 'react-native-web',
|
||||
},
|
||||
plugins: [
|
||||
// Adds support for installing with Plug'n'Play, leading to faster installs and adding
|
||||
// guards against forgotten dependencies and such.
|
||||
PnpWebpackPlugin,
|
||||
// Prevents users from importing files from outside of src/ (or node_modules/).
|
||||
// This often causes confusion because we only process files within src/ with babel.
|
||||
// To fix this, we prevent you from importing files out of src/ -- if you'd like to,
|
||||
// please link the files into your node_modules/ and let module-resolution kick in.
|
||||
// Make sure your source files are compiled, as they will not be processed in any way.
|
||||
new ModuleScopePlugin(paths.appSrc, [paths.appPackageJson]),
|
||||
],
|
||||
},
|
||||
resolveLoader: {
|
||||
plugins: [
|
||||
// Also related to Plug'n'Play, but this time it tells Webpack to load its loaders
|
||||
// from the current package.
|
||||
PnpWebpackPlugin.moduleLoader(module),
|
||||
],
|
||||
},
|
||||
module: {
|
||||
strictExportPresence: true,
|
||||
rules: [
|
||||
// Disable require.ensure as it's not a standard language feature.
|
||||
{ parser: { requireEnsure: false } },
|
||||
|
||||
// First, run the linter.
|
||||
// It's important to do this before Babel processes the JS.
|
||||
{
|
||||
test: /\.(js|mjs|jsx|ts|tsx)$/,
|
||||
enforce: 'pre',
|
||||
use: [
|
||||
{
|
||||
options: {
|
||||
formatter: require.resolve('react-dev-utils/eslintFormatter'),
|
||||
eslintPath: require.resolve('eslint'),
|
||||
|
||||
},
|
||||
loader: require.resolve('eslint-loader'),
|
||||
},
|
||||
],
|
||||
include: paths.appSrc,
|
||||
},
|
||||
{
|
||||
// "oneOf" will traverse all following loaders until one will
|
||||
// match the requirements. When no loader matches it will fall
|
||||
// back to the "file" loader at the end of the loader list.
|
||||
oneOf: [
|
||||
// "url" loader works like "file" loader except that it embeds assets
|
||||
// smaller than specified limit in bytes as data URLs to avoid requests.
|
||||
// A missing `test` is equivalent to a match.
|
||||
{
|
||||
test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
|
||||
loader: require.resolve('url-loader'),
|
||||
options: {
|
||||
limit: 10000,
|
||||
name: 'static/media/[name].[hash:8].[ext]',
|
||||
},
|
||||
},
|
||||
// Process application JS with Babel.
|
||||
// The preset includes JSX, Flow, TypeScript, and some ESnext features.
|
||||
{
|
||||
test: /\.(js|mjs|jsx|ts|tsx)$/,
|
||||
include: paths.appSrc,
|
||||
loader: require.resolve('babel-loader'),
|
||||
options: {
|
||||
customize: require.resolve(
|
||||
'babel-preset-react-app/webpack-overrides'
|
||||
),
|
||||
|
||||
plugins: [
|
||||
[
|
||||
require.resolve('babel-plugin-named-asset-import'),
|
||||
{
|
||||
loaderMap: {
|
||||
svg: {
|
||||
ReactComponent: '@svgr/webpack?-svgo,+ref![path]',
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
// This is a feature of `babel-loader` for webpack (not Babel itself).
|
||||
// It enables caching results in ./node_modules/.cache/babel-loader/
|
||||
// directory for faster rebuilds.
|
||||
cacheDirectory: true,
|
||||
cacheCompression: isEnvProduction,
|
||||
compact: isEnvProduction,
|
||||
},
|
||||
},
|
||||
// Process any JS outside of the app with Babel.
|
||||
// Unlike the application JS, we only compile the standard ES features.
|
||||
{
|
||||
test: /\.(js|mjs)$/,
|
||||
exclude: /@babel(?:\/|\\{1,2})runtime/,
|
||||
loader: require.resolve('babel-loader'),
|
||||
options: {
|
||||
babelrc: false,
|
||||
configFile: false,
|
||||
compact: false,
|
||||
presets: [
|
||||
[
|
||||
require.resolve('babel-preset-react-app/dependencies'),
|
||||
{ helpers: true },
|
||||
],
|
||||
],
|
||||
cacheDirectory: true,
|
||||
cacheCompression: isEnvProduction,
|
||||
|
||||
// If an error happens in a package, it's possible to be
|
||||
// because it was compiled. Thus, we don't want the browser
|
||||
// debugger to show the original code. Instead, the code
|
||||
// being evaluated would be much more helpful.
|
||||
sourceMaps: false,
|
||||
},
|
||||
},
|
||||
// "postcss" loader applies autoprefixer to our CSS.
|
||||
// "css" loader resolves paths in CSS and adds assets as dependencies.
|
||||
// "style" loader turns CSS into JS modules that inject <style> tags.
|
||||
// In production, we use MiniCSSExtractPlugin to extract that CSS
|
||||
// to a file, but in development "style" loader enables hot editing
|
||||
// of CSS.
|
||||
// By default we support CSS Modules with the extension .module.css
|
||||
{
|
||||
test: cssRegex,
|
||||
exclude: cssModuleRegex,
|
||||
use: getStyleLoaders({
|
||||
importLoaders: 1,
|
||||
sourceMap: isEnvProduction && shouldUseSourceMap,
|
||||
}),
|
||||
// Don't consider CSS imports dead code even if the
|
||||
// containing package claims to have no side effects.
|
||||
// Remove this when webpack adds a warning or an error for this.
|
||||
// See https://github.com/webpack/webpack/issues/6571
|
||||
sideEffects: true,
|
||||
},
|
||||
// Adds support for CSS Modules (https://github.com/css-modules/css-modules)
|
||||
// using the extension .module.css
|
||||
{
|
||||
test: cssModuleRegex,
|
||||
use: getStyleLoaders({
|
||||
importLoaders: 1,
|
||||
sourceMap: isEnvProduction && shouldUseSourceMap,
|
||||
modules: true,
|
||||
getLocalIdent: getCSSModuleLocalIdent,
|
||||
}),
|
||||
},
|
||||
// Opt-in support for SASS (using .scss or .sass extensions).
|
||||
// By default we support SASS Modules with the
|
||||
// extensions .module.scss or .module.sass
|
||||
{
|
||||
test: sassRegex,
|
||||
exclude: sassModuleRegex,
|
||||
use: getStyleLoaders(
|
||||
{
|
||||
importLoaders: 2,
|
||||
sourceMap: isEnvProduction && shouldUseSourceMap,
|
||||
},
|
||||
'sass-loader'
|
||||
),
|
||||
// Don't consider CSS imports dead code even if the
|
||||
// containing package claims to have no side effects.
|
||||
// Remove this when webpack adds a warning or an error for this.
|
||||
// See https://github.com/webpack/webpack/issues/6571
|
||||
sideEffects: true,
|
||||
},
|
||||
// Adds support for CSS Modules, but using SASS
|
||||
// using the extension .module.scss or .module.sass
|
||||
{
|
||||
test: sassModuleRegex,
|
||||
use: getStyleLoaders(
|
||||
{
|
||||
importLoaders: 2,
|
||||
sourceMap: isEnvProduction && shouldUseSourceMap,
|
||||
modules: true,
|
||||
getLocalIdent: getCSSModuleLocalIdent,
|
||||
},
|
||||
'sass-loader'
|
||||
),
|
||||
},
|
||||
// "file" loader makes sure those assets get served by WebpackDevServer.
|
||||
// When you `import` an asset, you get its (virtual) filename.
|
||||
// In production, they would get copied to the `build` folder.
|
||||
// This loader doesn't use a "test" so it will catch all modules
|
||||
// that fall through the other loaders.
|
||||
{
|
||||
loader: require.resolve('file-loader'),
|
||||
// Exclude `js` files to keep "css" loader working as it injects
|
||||
// its runtime that would otherwise be processed through "file" loader.
|
||||
// Also exclude `html` and `json` extensions so they get processed
|
||||
// by webpacks internal loaders.
|
||||
exclude: [/\.(js|mjs|jsx|ts|tsx)$/, /\.html$/, /\.json$/],
|
||||
options: {
|
||||
name: 'static/media/[name].[hash:8].[ext]',
|
||||
},
|
||||
},
|
||||
// ** STOP ** Are you adding a new loader?
|
||||
// Make sure to add the new loader(s) before the "file" loader.
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
plugins: [
|
||||
// Generates an `index.html` file with the <script> injected.
|
||||
new HtmlWebpackPlugin(
|
||||
Object.assign(
|
||||
{},
|
||||
{
|
||||
inject: true,
|
||||
template: paths.appHtml,
|
||||
},
|
||||
isEnvProduction
|
||||
? {
|
||||
minify: {
|
||||
removeComments: true,
|
||||
collapseWhitespace: true,
|
||||
removeRedundantAttributes: true,
|
||||
useShortDoctype: true,
|
||||
removeEmptyAttributes: true,
|
||||
removeStyleLinkTypeAttributes: true,
|
||||
keepClosingSlash: true,
|
||||
minifyJS: true,
|
||||
minifyCSS: true,
|
||||
minifyURLs: true,
|
||||
},
|
||||
}
|
||||
: undefined
|
||||
)
|
||||
),
|
||||
// Inlines the webpack runtime script. This script is too small to warrant
|
||||
// a network request.
|
||||
isEnvProduction &&
|
||||
shouldInlineRuntimeChunk &&
|
||||
new InlineChunkHtmlPlugin(HtmlWebpackPlugin, [/runtime~.+[.]js/]),
|
||||
// Makes some environment variables available in index.html.
|
||||
// The public URL is available as %PUBLIC_URL% in index.html, e.g.:
|
||||
// <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
|
||||
// In production, it will be an empty string unless you specify "homepage"
|
||||
// in `package.json`, in which case it will be the pathname of that URL.
|
||||
// In development, this will be an empty string.
|
||||
new InterpolateHtmlPlugin(HtmlWebpackPlugin, env.raw),
|
||||
// This gives some necessary context to module not found errors, such as
|
||||
// the requesting resource.
|
||||
new ModuleNotFoundPlugin(paths.appPath),
|
||||
// Makes some environment variables available to the JS code, for example:
|
||||
// if (process.env.NODE_ENV === 'production') { ... }. See `./env.js`.
|
||||
// It is absolutely essential that NODE_ENV is set to production
|
||||
// during a production build.
|
||||
// Otherwise React will be compiled in the very slow development mode.
|
||||
new webpack.DefinePlugin(env.stringified),
|
||||
// This is necessary to emit hot updates (currently CSS only):
|
||||
isEnvDevelopment && new webpack.HotModuleReplacementPlugin(),
|
||||
// Watcher doesn't work well if you mistype casing in a path so we use
|
||||
// a plugin that prints an error when you attempt to do this.
|
||||
// See https://github.com/facebook/create-react-app/issues/240
|
||||
isEnvDevelopment && new CaseSensitivePathsPlugin(),
|
||||
// If you require a missing module and then `npm install` it, you still have
|
||||
// to restart the development server for Webpack to discover it. This plugin
|
||||
// makes the discovery automatic so you don't have to restart.
|
||||
// See https://github.com/facebook/create-react-app/issues/186
|
||||
isEnvDevelopment &&
|
||||
new WatchMissingNodeModulesPlugin(paths.appNodeModules),
|
||||
isEnvProduction &&
|
||||
new MiniCssExtractPlugin({
|
||||
// Options similar to the same options in webpackOptions.output
|
||||
// both options are optional
|
||||
filename: 'static/css/[name].[contenthash:8].css',
|
||||
chunkFilename: 'static/css/[name].[contenthash:8].chunk.css',
|
||||
}),
|
||||
// Generate a manifest file which contains a mapping of all asset filenames
|
||||
// to their corresponding output file so that tools can pick it up without
|
||||
// having to parse `index.html`.
|
||||
new ManifestPlugin({
|
||||
fileName: 'asset-manifest.json',
|
||||
publicPath: publicPath,
|
||||
generate: (seed, files) => {
|
||||
const manifestFiles = files.reduce(function(manifest, file) {
|
||||
manifest[file.name] = file.path;
|
||||
return manifest;
|
||||
}, seed);
|
||||
|
||||
return {
|
||||
files: manifestFiles,
|
||||
};
|
||||
},
|
||||
}),
|
||||
// Moment.js is an extremely popular library that bundles large locale files
|
||||
// by default due to how Webpack interprets its code. This is a practical
|
||||
// solution that requires the user to opt into importing specific locales.
|
||||
// https://github.com/jmblog/how-to-optimize-momentjs-with-webpack
|
||||
// You can remove this if you don't use Moment.js:
|
||||
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
|
||||
// Generate a service worker script that will precache, and keep up to date,
|
||||
// the HTML & assets that are part of the Webpack build.
|
||||
isEnvProduction &&
|
||||
new WorkboxWebpackPlugin.GenerateSW({
|
||||
clientsClaim: true,
|
||||
exclude: [/\.map$/, /asset-manifest\.json$/],
|
||||
importWorkboxFrom: 'cdn',
|
||||
navigateFallback: publicUrl + '/index.html',
|
||||
navigateFallbackBlacklist: [
|
||||
// Exclude URLs starting with /_, as they're likely an API call
|
||||
new RegExp('^/_'),
|
||||
// Exclude URLs containing a dot, as they're likely a resource in
|
||||
// public/ and not a SPA route
|
||||
new RegExp('/[^/]+\\.[^/]+$'),
|
||||
],
|
||||
}),
|
||||
// TypeScript type checking
|
||||
useTypeScript &&
|
||||
new ForkTsCheckerWebpackPlugin({
|
||||
typescript: resolve.sync('typescript', {
|
||||
basedir: paths.appNodeModules,
|
||||
}),
|
||||
async: isEnvDevelopment,
|
||||
useTypescriptIncrementalApi: true,
|
||||
checkSyntacticErrors: true,
|
||||
resolveModuleNameModule: process.versions.pnp
|
||||
? `${__dirname}/pnpTs.js`
|
||||
: undefined,
|
||||
resolveTypeReferenceDirectiveModule: process.versions.pnp
|
||||
? `${__dirname}/pnpTs.js`
|
||||
: undefined,
|
||||
tsconfig: paths.appTsConfig,
|
||||
reportFiles: [
|
||||
'**',
|
||||
'!**/__tests__/**',
|
||||
'!**/?(*.)(spec|test).*',
|
||||
'!**/src/setupProxy.*',
|
||||
'!**/src/setupTests.*',
|
||||
],
|
||||
watch: paths.appSrc,
|
||||
silent: true,
|
||||
// The formatter is invoked directly in WebpackDevServerUtils during development
|
||||
formatter: isEnvProduction ? typescriptFormatter : undefined,
|
||||
}),
|
||||
].filter(Boolean),
|
||||
// Some libraries import Node modules but don't use them in the browser.
|
||||
// Tell Webpack to provide empty mocks for them so importing them works.
|
||||
node: {
|
||||
module: 'empty',
|
||||
dgram: 'empty',
|
||||
dns: 'mock',
|
||||
fs: 'empty',
|
||||
http2: 'empty',
|
||||
net: 'empty',
|
||||
tls: 'empty',
|
||||
child_process: 'empty',
|
||||
},
|
||||
// Turn off performance processing because we utilize
|
||||
// our own hints via the FileSizeReporter
|
||||
performance: false,
|
||||
};
|
||||
};
|
@ -1,218 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title></title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<style type="text/css">
|
||||
/* FONTS */
|
||||
@media screen {
|
||||
@font-face {
|
||||
font-family: 'Lato';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Lato Regular'), local('Lato-Regular'), url(https://fonts.gstatic.com/s/lato/v11/qIIYRU-oROkIk8vfvxw6QvesZW2xOQ-xsNqO47m55DA.woff) format('woff');
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Lato';
|
||||
font-style: normal;
|
||||
font-weight: 700;
|
||||
src: local('Lato Bold'), local('Lato-Bold'), url(https://fonts.gstatic.com/s/lato/v11/qdgUG4U09HnJwhYI-uK18wLUuEpTyoUstqEm5AMlJo4.woff) format('woff');
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Lato';
|
||||
font-style: italic;
|
||||
font-weight: 400;
|
||||
src: local('Lato Italic'), local('Lato-Italic'), url(https://fonts.gstatic.com/s/lato/v11/RYyZNoeFgb0l7W3Vu1aSWOvvDin1pK8aKteLpeZ5c0A.woff) format('woff');
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Lato';
|
||||
font-style: italic;
|
||||
font-weight: 700;
|
||||
src: local('Lato Bold Italic'), local('Lato-BoldItalic'), url(https://fonts.gstatic.com/s/lato/v11/HkF_qI1x_noxlxhrhMQYELO3LdcAZYWl9Si6vvxL-qU.woff) format('woff');
|
||||
}
|
||||
}
|
||||
|
||||
/* CLIENT-SPECIFIC STYLES */
|
||||
body, table, th, a { -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; }
|
||||
img { -ms-interpolation-mode: bicubic; border: 0; height: auto; line-height: 100%; outline: none; text-decoration: none;}
|
||||
|
||||
/* RESET STYLES */
|
||||
table { border-collapse: collapse !important; padding: 0 !important;}
|
||||
body { height: 100% !important; margin: 0 !important; padding: 0 !important; width: 100% !important; }
|
||||
|
||||
/* iOS BLUE LINKS */
|
||||
a[x-apple-data-detectors] {
|
||||
color: inherit !important;
|
||||
text-decoration: none !important;
|
||||
font-size: inherit !important;
|
||||
font-family: inherit !important;
|
||||
font-weight: inherit !important;
|
||||
line-height: inherit !important;
|
||||
}
|
||||
|
||||
/* MOBILE STYLES */
|
||||
@media screen and (max-width:600px){
|
||||
h1 {
|
||||
font-size: 32px !important;
|
||||
line-height: 32px !important;
|
||||
}
|
||||
}
|
||||
|
||||
/* ANDROID CENTER FIX */
|
||||
div[style*="margin: 16px 0;"] { margin: 0 !important; }
|
||||
</style>
|
||||
</head>
|
||||
<body style="background-color: #f4f4f4; margin: 0 !important; padding: 0 !important;">
|
||||
|
||||
<!-- HIDDEN PREHEADER TEXT -->
|
||||
<div style="display: none; font-size: 1px; color: #fefefe; line-height: 1px; font-family: 'Lato', Helvetica, Arial, sans-serif; max-height: 0px; max-width: 0px; opacity: 0; overflow: hidden;">
|
||||
{{#i18n 'email.happy' }}We are happy to send you this email! You will be able to vote using majority judgment.{{/i18n}}
|
||||
</div>
|
||||
<table border="0" style="margin: 0px auto 0px auto; width: 100%;" aria-describedby="Email">
|
||||
<!-- LOGO -->
|
||||
<tr>
|
||||
<th scope="col" style="background-color:#efefff ;">
|
||||
<table border="0" style="margin: 0px auto 0px auto; width: 100%; max-width: 600px;" aria-describedby="Logo picture">
|
||||
<tr>
|
||||
<th scope="col" style="vertical-align: top; padding: 40px 10px 40px 10px;">
|
||||
<a href="https://mieuxvoter.fr/" target="_blank" rel="noopener noreferrer">
|
||||
<img alt="Logo" src="https://mieuxvoter.fr/wp-content/uploads/2019/10/mieuxvoter_logo.png" width="40" height="40" style="display: block; margin: 0px auto 0px auto; width: 50%; max-width: 250px; min-width: 40px; height: auto; font-family: 'Lato', Helvetica, Arial, sans-serif; color: #ffffff; font-size: 18px;" border="0">
|
||||
</a>
|
||||
</th>
|
||||
</tr>
|
||||
</table>
|
||||
</th>
|
||||
</tr>
|
||||
<!-- TITLE -->
|
||||
<tr>
|
||||
<th scope="col" style="background-color: #efefff; padding: 0px 10px 0px 10px;">
|
||||
<table border="0" style="margin: 0px auto 0px auto; width: 100%; max-width: 600px;" aria-describedby="email title">
|
||||
<tr>
|
||||
<th scope="col" style="vertical-align: top; background-color: #ffffff; padding: 40px 20px 20px 20px; border-radius: 4px 4px 0px 0px; color: #111111; font-family: 'Lato', Helvetica, Arial, sans-serif; font-size: 48px; font-weight: 400; letter-spacing: 4px; line-height: 48px;">
|
||||
<h1 style="font-size: 48px; font-weight: 400; margin: 0;">{{#i18n 'email.hello'}}Hi, there! 🙂{{/i18n}}</h1>
|
||||
</th>
|
||||
</tr>
|
||||
</table>
|
||||
</th>
|
||||
</tr>
|
||||
<!-- BLOCKS -->
|
||||
<tr>
|
||||
<th scope="col" style="background-color: #2a43a0; padding: 0px 10px 0px 10px;">
|
||||
<table border="0" style="margin: 0px auto 0px auto; width: 100%; max-width: 600px;" aria-describedby="email body">
|
||||
<!-- BLOCK SUBTITLE-->
|
||||
<tr>
|
||||
<th scope="col" style="background-color: #ffffff; padding: 20px 30px 40px 30px; color: #666666; font-family: 'Lato', Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;" >
|
||||
<p style="margin: 0; text-align: left;">
|
||||
{{#i18n 'email.happy'}}We are happy to send you this email! You will be able to vote using majority judgment.{{/i18n}}
|
||||
</p>
|
||||
</th>
|
||||
</tr>
|
||||
<!-- BLOCK EXPLANATION-->
|
||||
<tr>
|
||||
<th scope="col" style="background-color: #ffffff; padding: 20px 30px 40px 30px; color: #666666; font-family: 'Lato', Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;" >
|
||||
<p style="margin: 0; text-align: left;">
|
||||
{{#i18n 'email.why'}}This email was sent to you because your email address was entered to participate in the vote on the subject:{{/i18n}}
|
||||
|
||||
<strong>{{title}}</strong>
|
||||
</p>
|
||||
</th>
|
||||
</tr>
|
||||
<!-- BULLETPROOF BUTTON BLUE-->
|
||||
<tr>
|
||||
<th scope="col" style="background-color: #ffffff;">
|
||||
<table border="0" style="margin: 0px auto 0px auto; width: 100%;" aria-describedby="Blue bulletproof button">
|
||||
<tr>
|
||||
<th scope="col" style="background-color: #ffffff; padding: 20px 30px 60px 30px;">
|
||||
<table border="0" style="margin: 0px auto 0px auto; border-collapse: collapse;" aria-describedby="invitation url">
|
||||
<tr>
|
||||
<th scope="col" style="border-radius: 3px; background-color: #2a43a0;">
|
||||
<a href="%recipient.urlVote%" target="_blank" style="font-size: 20px; font-family: Helvetica, Arial, sans-serif; color: #ffffff; text-decoration: none; padding: 15px 25px; border-radius: 2px; border: 1px solid #2a43a0; display: inline-block;">
|
||||
{{#i18n 'common.vote' }}Vote!{{/i18n}}</a></th>
|
||||
</tr>
|
||||
</table>
|
||||
</th>
|
||||
</tr>
|
||||
</table>
|
||||
</th>
|
||||
</tr>
|
||||
<!-- BLOCK DOES NOT WORK -->
|
||||
<tr>
|
||||
<th scope="col" style="background-color: #ffffff; padding: 20px 30px 40px 30px; color: #666666; font-family: 'Lato', Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;" >
|
||||
<p style="margin: 0; text-align: left;">
|
||||
{{#i18n 'email.copyLink' }}If that doesn't work, copy and paste the following link into your browser:{{/i18n}}
|
||||
|
||||
<a target="_blank" style="color: #2a43a0;">%recipient.urlVote%</a>
|
||||
</p>
|
||||
</th>
|
||||
</tr>
|
||||
<!-- BLOCK TEXT RESULT -->
|
||||
<tr>
|
||||
<th scope="col" style="background-color: #ffffff; padding: 20px 30px 20px 30px; color: #666666; font-family: 'Lato', Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;" >
|
||||
<p style="margin: 0; text-align: left;">
|
||||
{{#i18n 'email.linkResult' }}The results will be available with the following link when the vote is finished:{{/i18n}}
|
||||
|
||||
<a target="_blank" style="color: #2a43a0;">%recipient.urlResult%</a>
|
||||
</p>
|
||||
</th>
|
||||
</tr>
|
||||
<!-- BLOCK THANKS -->
|
||||
<tr>
|
||||
<th scope="col" style="background-color: #ffffff; padding: 0px 30px 40px 30px; border-radius: 0px 0px 4px 4px; color: #666666; font-family: 'Lato', Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;" >
|
||||
<p style="margin: 0; text-align: left;">{{#i18n 'email.bye'}}Good vote{{/i18n}},<br>{{#i18n 'common.mieuxvoter'}}Mieux Voter{{/i18n}}</p>
|
||||
</th>
|
||||
</tr>
|
||||
</table>
|
||||
</th>
|
||||
</tr>
|
||||
<!-- SUPPORT CALLOUT -->
|
||||
<tr>
|
||||
<th scope="col" style="background-color: #f4f4f4; padding: 30px 10px 0px 10px;">
|
||||
<table border="0" style="margin: 0px auto 0px auto; width: 100%; max-width: 600px;" aria-describedby="support callout">
|
||||
<!-- HEADLINE -->
|
||||
<tr>
|
||||
<th scope="col" style="background-color: #7d8ecf; padding: 30px 30px 30px 30px; border-radius: 4px 4px 4px 4px; color: #666666; font-family: 'Lato', Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;" >
|
||||
<p style="margin: 0;"><strong>
|
||||
<a href="https://mieuxvoter.fr/index.php/decouvrir/" target="_blank" style="color: #FFFFFF;" rel="noopener noreferrer">
|
||||
{{#i18n 'email.aboutjm'}}Need any further information?{{/i18n}}
|
||||
</a></strong>
|
||||
</p>
|
||||
<p style="margin: 0;"> <strong>
|
||||
<a href="https://mieuxvoter.fr/index.php/decouvrir/" target="_blank" style="color: #111111;" rel="noopener noreferrer">
|
||||
{{#i18n 'common.helpus'}}Do you want to help us?{{/i18n}}
|
||||
</a></strong>
|
||||
</p>
|
||||
</th>
|
||||
</tr>
|
||||
</table>
|
||||
</th>
|
||||
</tr>
|
||||
<!-- FOOTER -->
|
||||
<tr>
|
||||
<th scope="col" style="background-color: #f4f4f4; padding: 0px 10px 0px 10px;">
|
||||
<table border="0" style="margin: 0px auto 0px auto; width: 100%; max-width: 600px;" aria-describedby="footer informations">
|
||||
<!-- EXPLAIN WHY -->
|
||||
</br>
|
||||
<tr>
|
||||
<th scope="col" style="background-color: #f4f4f4; padding: 0px 30px 30px 30px; color: #666666; font-family: 'Lato', Helvetica, Arial, sans-serif; font-size: 14px; font-weight: 400; line-height: 18px;" >
|
||||
<p style="margin: 0;">
|
||||
{{#i18n email.why }}You received this email because someone invited you to vote.{{/i18n}}
|
||||
</p>
|
||||
</th>
|
||||
</tr>
|
||||
<!-- ADDRESS -->
|
||||
<tr>
|
||||
<th scope="col" style="background-color: #f4f4f4; padding: 0px 30px 30px 30px; color: #666666; font-family: 'Lato', Helvetica, Arial, sans-serif; font-size: 14px; font-weight: 400; line-height: 18px;" >
|
||||
<p style="margin: 0;">{{#i18n mieuxvoter }}Mieux Voter{{/i18n}} - <a "mailto:app@mieuxvoter.fr">app@mieuxvoter.fr</a></p>
|
||||
</th>
|
||||
</tr>
|
||||
</table>
|
||||
</th>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
@ -1,19 +0,0 @@
|
||||
{{i18n 'email.hello'}}Hi there! 🙂{{i18n}}
|
||||
|
||||
{{i18n 'email.happy'}}We are happy to send you this email! You will be able to vote using majority judgment.{{i18n}}
|
||||
|
||||
{{i18n 'email.why'}}This email was sent to you because your email was filled out to participate in the vote on the subject:{{i18n}}
|
||||
|
||||
{{ title }}
|
||||
|
||||
{{i18n 'email.linkVote' }}The link for the vote is as follows:{{i18n}}
|
||||
|
||||
%recipient.urlVote%
|
||||
|
||||
{{i18n 'email.linkResult' }}The link that will give you the results when they are available is as follows:{{i18n}}
|
||||
|
||||
%recipient.urlResult%
|
||||
|
||||
{{i18n 'email.bye'}}Good vote{{i18n}}
|
||||
|
||||
{{i18n 'common.mieuxvoter'}}Mieux Voter{{i18n}}
|
@ -1,203 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title></title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<style type="text/css">
|
||||
/* FONTS */
|
||||
@media screen {
|
||||
@font-face {
|
||||
font-family: 'Lato';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Lato Regular'), local('Lato-Regular'), url(https://fonts.gstatic.com/s/lato/v11/qIIYRU-oROkIk8vfvxw6QvesZW2xOQ-xsNqO47m55DA.woff) format('woff');
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Lato';
|
||||
font-style: normal;
|
||||
font-weight: 700;
|
||||
src: local('Lato Bold'), local('Lato-Bold'), url(https://fonts.gstatic.com/s/lato/v11/qdgUG4U09HnJwhYI-uK18wLUuEpTyoUstqEm5AMlJo4.woff) format('woff');
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Lato';
|
||||
font-style: italic;
|
||||
font-weight: 400;
|
||||
src: local('Lato Italic'), local('Lato-Italic'), url(https://fonts.gstatic.com/s/lato/v11/RYyZNoeFgb0l7W3Vu1aSWOvvDin1pK8aKteLpeZ5c0A.woff) format('woff');
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Lato';
|
||||
font-style: italic;
|
||||
font-weight: 700;
|
||||
src: local('Lato Bold Italic'), local('Lato-BoldItalic'), url(https://fonts.gstatic.com/s/lato/v11/HkF_qI1x_noxlxhrhMQYELO3LdcAZYWl9Si6vvxL-qU.woff) format('woff');
|
||||
}
|
||||
}
|
||||
|
||||
/* CLIENT-SPECIFIC STYLES */
|
||||
body, table, th, a { -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; }
|
||||
img { -ms-interpolation-mode: bicubic; border: 0; height: auto; line-height: 100%; outline: none; text-decoration: none;}
|
||||
|
||||
/* RESET STYLES */
|
||||
table { border-collapse: collapse !important; padding: 0 !important;}
|
||||
body { height: 100% !important; margin: 0 !important; padding: 0 !important; width: 100% !important; }
|
||||
|
||||
/* iOS BLUE LINKS */
|
||||
a[x-apple-data-detectors] {
|
||||
color: inherit !important;
|
||||
text-decoration: none !important;
|
||||
font-size: inherit !important;
|
||||
font-family: inherit !important;
|
||||
font-weight: inherit !important;
|
||||
line-height: inherit !important;
|
||||
}
|
||||
|
||||
/* MOBILE STYLES */
|
||||
@media screen and (max-width:600px){
|
||||
h1 {
|
||||
font-size: 32px !important;
|
||||
line-height: 32px !important;
|
||||
}
|
||||
}
|
||||
|
||||
/* ANDROID CENTER FIX */
|
||||
div[style*="margin: 16px 0;"] { margin: 0 !important; }
|
||||
</style>
|
||||
</head>
|
||||
<body style="background-color: #f4f4f4; margin: 0 !important; padding: 0 !important;">
|
||||
|
||||
<!-- HIDDEN PREHEADER TEXT -->
|
||||
<div style="display: none; font-size: 1px; color: #fefefe; line-height: 1px; font-family: 'Lato', Helvetica, Arial, sans-serif; max-height: 0px; max-width: 0px; opacity: 0; overflow: hidden;">Nous sommes très heureux de vous partager ce lien de vote ! Vous allez pouvoir voter avec le jugement majoritaire.</div>
|
||||
<table border="0" style="margin: 0px auto 0px auto; width: 100%;" aria-describedby="Email">
|
||||
<!-- LOGO -->
|
||||
<tr>
|
||||
<th scope="col" style="background-color:#efefff ;">
|
||||
<table border="0" style="margin: 0px auto 0px auto; width: 100%; max-width: 600px;" aria-describedby="Logo picture">
|
||||
<tr>
|
||||
<th scope="col" style="vertical-align: top; padding: 40px 10px 40px 10px;">
|
||||
<a href="https://mieuxvoter.fr/" target="_blank" rel="noopener noreferrer">
|
||||
<img alt="Logo" src="https://mieuxvoter.fr/wp-content/uploads/2019/10/mieuxvoter_logo.png" width="40" height="40" style="display: block; margin: 0px auto 0px auto; width: 50%; max-width: 250px; min-width: 40px; height: auto; font-family: 'Lato', Helvetica, Arial, sans-serif; color: #ffffff; font-size: 18px;" border="0">
|
||||
</a>
|
||||
</th>
|
||||
</tr>
|
||||
</table>
|
||||
</th>
|
||||
</tr>
|
||||
<!-- TITLE -->
|
||||
<tr>
|
||||
<th scope="col" style="background-color: #efefff; padding: 0px 10px 0px 10px;">
|
||||
<table border="0" style="margin: 0px auto 0px auto; width: 100%; max-width: 600px;" aria-describedby="email title">
|
||||
<tr>
|
||||
<th scope="col" style="vertical-align: top; background-color: #ffffff; padding: 40px 20px 20px 20px; border-radius: 4px 4px 0px 0px; color: #111111; font-family: 'Lato', Helvetica, Arial, sans-serif; font-size: 48px; font-weight: 400; letter-spacing: 4px; line-height: 48px;">
|
||||
<h1 style="font-size: 48px; font-weight: 400; margin: 0;">Bonjour ! 🙂</h1>
|
||||
</th>
|
||||
</tr>
|
||||
</table>
|
||||
</th>
|
||||
</tr>
|
||||
<!-- BLOCKS -->
|
||||
<tr>
|
||||
<th scope="col" style="background-color: #2a43a0; padding: 0px 10px 0px 10px;">
|
||||
<table border="0" style="margin: 0px auto 0px auto; width: 100%; max-width: 600px;" aria-describedby="email body">
|
||||
<!-- BLOCK SUBTITLE-->
|
||||
<tr>
|
||||
<th scope="col" style="background-color: #ffffff; padding: 20px 30px 40px 30px; color: #666666; font-family: 'Lato', Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;" >
|
||||
<p style="margin: 0; text-align: left;">Nous sommes très heureux de vous partager ce lien de vote ! Vous allez pouvoir voter avec le jugement majoritaire.</p>
|
||||
</th>
|
||||
</tr>
|
||||
<!-- BLOCK EXPLANATION-->
|
||||
<tr>
|
||||
<th scope="col" style="background-color: #ffffff; padding: 20px 30px 40px 30px; color: #666666; font-family: 'Lato', Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;" >
|
||||
<p style="margin: 0; text-align: left;">Vous avez été invité·e à participer à l'élection suivante : </p>
|
||||
</th>
|
||||
</tr>
|
||||
<!-- BULLETPROOF BUTTON BLUE-->
|
||||
<tr>
|
||||
<th scope="col" style="background-color: #ffffff;">
|
||||
<table border="0" style="margin: 0px auto 0px auto; width: 100%;" aria-describedby="Blue bulletproof button">
|
||||
<tr>
|
||||
<th scope="col" style="background-color: #ffffff; padding: 20px 30px 60px 30px;">
|
||||
<table border="0" style="margin: 0px auto 0px auto; border-collapse: collapse;" aria-describedby="invitation url">
|
||||
<tr>
|
||||
<th scope="col" style="border-radius: 3px; background-color: #2a43a0;">
|
||||
<a href="%recipient.urlVote%" target="_blank" style="font-size: 20px; font-family: Helvetica, Arial, sans-serif; color: #ffffff; text-decoration: none; padding: 15px 25px; border-radius: 2px; border: 1px solid #2a43a0; display: inline-block;">Voter !</a></th>
|
||||
</tr>
|
||||
</table>
|
||||
</th>
|
||||
</tr>
|
||||
</table>
|
||||
</th>
|
||||
</tr>
|
||||
<!-- BLOCK DOES NOT WORK -->
|
||||
<tr>
|
||||
<th scope="col" style="background-color: #ffffff; padding: 20px 30px 40px 30px; color: #666666; font-family: 'Lato', Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;" >
|
||||
<p style="margin: 0; text-align: left;">
|
||||
Si le lien ne fonctionne pas, vous pouvez le copier et le coller dans la barre de navigation de votre navigateur.
|
||||
|
||||
<a target="_blank" style="color: #2a43a0;">%recipient.urlVote%</a>
|
||||
</p>
|
||||
</th>
|
||||
</tr>
|
||||
<!-- BLOCK TEXT RESULT -->
|
||||
<tr>
|
||||
<th scope="col" style="background-color: #ffffff; padding: 20px 30px 20px 30px; color: #666666; font-family: 'Lato', Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;" >
|
||||
<p style="margin: 0; text-align: left;">
|
||||
A la fin de l'élection, vous pourrez accéder aux résultats en cliquant sur ce lien :
|
||||
|
||||
<a target="_blank" style="color: #2a43a0;">%recipient.urlResult%</a>
|
||||
</p>
|
||||
</th>
|
||||
</tr>
|
||||
<!-- BLOCK THANKS -->
|
||||
<tr>
|
||||
<th scope="col" style="background-color: #ffffff; padding: 0px 30px 40px 30px; border-radius: 0px 0px 4px 4px; color: #666666; font-family: 'Lato', Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;" >
|
||||
<p style="margin: 0; text-align: left;">Bon vote,<br>Mieux Voter</p>
|
||||
</th>
|
||||
</tr>
|
||||
</table>
|
||||
</th>
|
||||
</tr>
|
||||
<!-- SUPPORT CALLOUT -->
|
||||
<tr>
|
||||
<th scope="col" style="background-color: #f4f4f4; padding: 30px 10px 0px 10px;">
|
||||
<table border="0" style="margin: 0px auto 0px auto; width: 100%; max-width: 600px;" aria-describedby="support callout">
|
||||
<!-- HEADLINE -->
|
||||
<tr>
|
||||
<th scope="col" style="background-color: #7d8ecf; padding: 30px 30px 30px 30px; border-radius: 4px 4px 4px 4px; color: #666666; font-family: 'Lato', Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;" >
|
||||
<p style="margin: 0;"><strong>
|
||||
<a href="https://mieuxvoter.fr/index.php/decouvrir/" target="_blank" style="color: #FFFFFF;" rel="noopener noreferrer">Besoin de plus d'information</a></strong>
|
||||
</p>
|
||||
<p style="margin: 0;"> <strong>
|
||||
<a href="https://mieuxvoter.fr/index.php/decouvrir/" target="_blank" style="color: #111111;" rel="noopener noreferrer">Vous souhaitez nous aider ?</a></strong>
|
||||
</p>
|
||||
</th>
|
||||
</tr>
|
||||
</table>
|
||||
</th>
|
||||
</tr>
|
||||
<!-- FOOTER -->
|
||||
<tr>
|
||||
<th scope="col" style="background-color: #f4f4f4; padding: 0px 10px 0px 10px;">
|
||||
<table border="0" style="margin: 0px auto 0px auto; width: 100%; max-width: 600px;" aria-describedby="footer informations">
|
||||
<!-- EXPLAIN WHY -->
|
||||
</br>
|
||||
<tr>
|
||||
<th scope="col" style="background-color: #f4f4f4; padding: 0px 30px 30px 30px; color: #666666; font-family: 'Lato', Helvetica, Arial, sans-serif; font-size: 14px; font-weight: 400; line-height: 18px;" >
|
||||
<p style="margin: 0;">Vous avez été invité·e à participer à l'élection suivante</p>
|
||||
</th>
|
||||
</tr>
|
||||
<!-- ADDRESS -->
|
||||
<tr>
|
||||
<th scope="col" style="background-color: #f4f4f4; padding: 0px 30px 30px 30px; color: #666666; font-family: 'Lato', Helvetica, Arial, sans-serif; font-size: 14px; font-weight: 400; line-height: 18px;" >
|
||||
<p style="margin: 0;">Mieux Voter - <a "mailto:app@mieuxvoter.fr">app@mieuxvoter.fr</a></p>
|
||||
</th>
|
||||
</tr>
|
||||
</table>
|
||||
</th>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
@ -1,17 +0,0 @@
|
||||
Bonjour ! 🙂
|
||||
|
||||
Vous avez été invité·e à participer à l'élection suivante :
|
||||
|
||||
{{ title }}
|
||||
|
||||
Le lien pour voter est le suivant :
|
||||
|
||||
%recipient.urlVote%
|
||||
|
||||
A la fin de l'élection, vous pourrez accéder aux résultats en cliquant sur ce lien :
|
||||
|
||||
%recipient.urlResult%
|
||||
|
||||
Bon vote ! 🤗
|
||||
|
||||
Mieux Voter
|
@ -1,218 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title></title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<style type="text/css">
|
||||
/* FONTS */
|
||||
@media screen {
|
||||
@font-face {
|
||||
font-family: 'Lato';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: local('Lato Regular'), local('Lato-Regular'), url(https://fonts.gstatic.com/s/lato/v11/qIIYRU-oROkIk8vfvxw6QvesZW2xOQ-xsNqO47m55DA.woff) format('woff');
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Lato';
|
||||
font-style: normal;
|
||||
font-weight: 700;
|
||||
src: local('Lato Bold'), local('Lato-Bold'), url(https://fonts.gstatic.com/s/lato/v11/qdgUG4U09HnJwhYI-uK18wLUuEpTyoUstqEm5AMlJo4.woff) format('woff');
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Lato';
|
||||
font-style: italic;
|
||||
font-weight: 400;
|
||||
src: local('Lato Italic'), local('Lato-Italic'), url(https://fonts.gstatic.com/s/lato/v11/RYyZNoeFgb0l7W3Vu1aSWOvvDin1pK8aKteLpeZ5c0A.woff) format('woff');
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Lato';
|
||||
font-style: italic;
|
||||
font-weight: 700;
|
||||
src: local('Lato Bold Italic'), local('Lato-BoldItalic'), url(https://fonts.gstatic.com/s/lato/v11/HkF_qI1x_noxlxhrhMQYELO3LdcAZYWl9Si6vvxL-qU.woff) format('woff');
|
||||
}
|
||||
}
|
||||
|
||||
/* CLIENT-SPECIFIC STYLES */
|
||||
body, table, th, a { -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; }
|
||||
img { -ms-interpolation-mode: bicubic; border: 0; height: auto; line-height: 100%; outline: none; text-decoration: none;}
|
||||
|
||||
/* RESET STYLES */
|
||||
table { border-collapse: collapse !important; padding: 0 !important;}
|
||||
body { height: 100% !important; margin: 0 !important; padding: 0 !important; width: 100% !important; }
|
||||
|
||||
/* iOS BLUE LINKS */
|
||||
a[x-apple-data-detectors] {
|
||||
color: inherit !important;
|
||||
text-decoration: none !important;
|
||||
font-size: inherit !important;
|
||||
font-family: inherit !important;
|
||||
font-weight: inherit !important;
|
||||
line-height: inherit !important;
|
||||
}
|
||||
|
||||
/* MOBILE STYLES */
|
||||
@media screen and (max-width:600px){
|
||||
h1 {
|
||||
font-size: 32px !important;
|
||||
line-height: 32px !important;
|
||||
}
|
||||
}
|
||||
|
||||
/* ANDROID CENTER FIX */
|
||||
div[style*="margin: 16px 0;"] { margin: 0 !important; }
|
||||
</style>
|
||||
</head>
|
||||
<body style="background-color: #f4f4f4; margin: 0 !important; padding: 0 !important;">
|
||||
|
||||
<!-- HIDDEN PREHEADER TEXT -->
|
||||
<div style="display: none; font-size: 1px; color: #fefefe; line-height: 1px; font-family: 'Lato', Helvetica, Arial, sans-serif; max-height: 0px; max-width: 0px; opacity: 0; overflow: hidden;">
|
||||
{{#i18n 'email.happy' }}We are happy to send you this email! You will be able to vote using majority judgment.{{/i18n}}
|
||||
</div>
|
||||
<table border="0" style="margin: 0px auto 0px auto; width: 100%;" aria-describedby="Email">
|
||||
<!-- LOGO -->
|
||||
<tr>
|
||||
<th scope="col" style="background-color:#efefff ;">
|
||||
<table border="0" style="margin: 0px auto 0px auto; width: 100%; max-width: 600px;" aria-describedby="Logo picture">
|
||||
<tr>
|
||||
<th scope="col" style="vertical-align: top; padding: 40px 10px 40px 10px;">
|
||||
<a href="https://mieuxvoter.fr/" target="_blank" rel="noopener noreferrer">
|
||||
<img alt="Logo" src="https://mieuxvoter.fr/wp-content/uploads/2019/10/mieuxvoter_logo.png" width="40" height="40" style="display: block; margin: 0px auto 0px auto; width: 50%; max-width: 250px; min-width: 40px; height: auto; font-family: 'Lato', Helvetica, Arial, sans-serif; color: #ffffff; font-size: 18px;" border="0">
|
||||
</a>
|
||||
</th>
|
||||
</tr>
|
||||
</table>
|
||||
</th>
|
||||
</tr>
|
||||
<!-- TITLE -->
|
||||
<tr>
|
||||
<th scope="col" style="background-color: #efefff; padding: 0px 10px 0px 10px;">
|
||||
<table border="0" style="margin: 0px auto 0px auto; width: 100%; max-width: 600px;" aria-describedby="email title">
|
||||
<tr>
|
||||
<th scope="col" style="vertical-align: top; background-color: #ffffff; padding: 40px 20px 20px 20px; border-radius: 4px 4px 0px 0px; color: #111111; font-family: 'Lato', Helvetica, Arial, sans-serif; font-size: 48px; font-weight: 400; letter-spacing: 4px; line-height: 48px;">
|
||||
<h1 style="font-size: 48px; font-weight: 400; margin: 0;">{{#i18n 'email.hello'}}Hi, there! 🙂{{/i18n}}</h1>
|
||||
</th>
|
||||
</tr>
|
||||
</table>
|
||||
</th>
|
||||
</tr>
|
||||
<!-- BLOCKS -->
|
||||
<tr>
|
||||
<th scope="col" style="background-color: #2a43a0; padding: 0px 10px 0px 10px;">
|
||||
<table border="0" style="margin: 0px auto 0px auto; width: 100%; max-width: 600px;" aria-describedby="email body">
|
||||
<!-- BLOCK SUBTITLE-->
|
||||
<tr>
|
||||
<th scope="col" style="background-color: #ffffff; padding: 20px 30px 40px 30px; color: #666666; font-family: 'Lato', Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;" >
|
||||
<p style="margin: 0; text-align: left;">
|
||||
{{#i18n 'email.happy'}}We are happy to send you this email! You will be able to vote using majority judgment.{{/i18n}}
|
||||
</p>
|
||||
</th>
|
||||
</tr>
|
||||
<!-- BLOCK EXPLANATION-->
|
||||
<tr>
|
||||
<th scope="col" style="background-color: #ffffff; padding: 20px 30px 40px 30px; color: #666666; font-family: 'Lato', Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;" >
|
||||
<p style="margin: 0; text-align: left;">
|
||||
{{#i18n 'email.why'}}This email was sent to you because your email address was entered to participate in the vote on the subject:{{/i18n}}
|
||||
|
||||
<strong>{{title}}</strong>
|
||||
</p>
|
||||
</th>
|
||||
</tr>
|
||||
<!-- BULLETPROOF BUTTON BLUE-->
|
||||
<tr>
|
||||
<th scope="col" style="background-color: #ffffff;">
|
||||
<table border="0" style="margin: 0px auto 0px auto; width: 100%;" aria-describedby="Blue bulletproof button">
|
||||
<tr>
|
||||
<th scope="col" style="background-color: #ffffff; padding: 20px 30px 60px 30px;">
|
||||
<table border="0" style="margin: 0px auto 0px auto; border-collapse: collapse;" aria-describedby="invitation url">
|
||||
<tr>
|
||||
<th scope="col" style="border-radius: 3px; background-color: #2a43a0;">
|
||||
<a href="%recipient.urlVote%" target="_blank" style="font-size: 20px; font-family: Helvetica, Arial, sans-serif; color: #ffffff; text-decoration: none; padding: 15px 25px; border-radius: 2px; border: 1px solid #2a43a0; display: inline-block;">
|
||||
{{#i18n 'common.vote' }}Vote!{{/i18n}}</a></th>
|
||||
</tr>
|
||||
</table>
|
||||
</th>
|
||||
</tr>
|
||||
</table>
|
||||
</th>
|
||||
</tr>
|
||||
<!-- BLOCK DOES NOT WORK -->
|
||||
<tr>
|
||||
<th scope="col" style="background-color: #ffffff; padding: 20px 30px 40px 30px; color: #666666; font-family: 'Lato', Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;" >
|
||||
<p style="margin: 0; text-align: left;">
|
||||
{{#i18n 'email.copyLink' }}If that doesn't work, copy and paste the following link into your browser:{{/i18n}}
|
||||
|
||||
<a target="_blank" style="color: #2a43a0;">%recipient.urlVote%</a>
|
||||
</p>
|
||||
</th>
|
||||
</tr>
|
||||
<!-- BLOCK TEXT RESULT -->
|
||||
<tr>
|
||||
<th scope="col" style="background-color: #ffffff; padding: 20px 30px 20px 30px; color: #666666; font-family: 'Lato', Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;" >
|
||||
<p style="margin: 0; text-align: left;">
|
||||
{{#i18n 'email.linkResult' }}The results will be available with the following link when the vote is finished:{{/i18n}}
|
||||
|
||||
<a target="_blank" style="color: #2a43a0;">%recipient.urlResult%</a>
|
||||
</p>
|
||||
</th>
|
||||
</tr>
|
||||
<!-- BLOCK THANKS -->
|
||||
<tr>
|
||||
<th scope="col" style="background-color: #ffffff; padding: 0px 30px 40px 30px; border-radius: 0px 0px 4px 4px; color: #666666; font-family: 'Lato', Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;" >
|
||||
<p style="margin: 0; text-align: left;">{{#i18n 'email.bye'}}Good vote{{/i18n}},<br>{{#i18n 'common.mieuxvoter'}}Mieux Voter{{/i18n}}</p>
|
||||
</th>
|
||||
</tr>
|
||||
</table>
|
||||
</th>
|
||||
</tr>
|
||||
<!-- SUPPORT CALLOUT -->
|
||||
<tr>
|
||||
<th scope="col" style="background-color: #f4f4f4; padding: 30px 10px 0px 10px;">
|
||||
<table border="0" style="margin: 0px auto 0px auto; width: 100%; max-width: 600px;" aria-describedby="support callout">
|
||||
<!-- HEADLINE -->
|
||||
<tr>
|
||||
<th scope="col" style="background-color: #7d8ecf; padding: 30px 30px 30px 30px; border-radius: 4px 4px 4px 4px; color: #666666; font-family: 'Lato', Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;" >
|
||||
<p style="margin: 0;"><strong>
|
||||
<a href="https://mieuxvoter.fr/index.php/decouvrir/" target="_blank" style="color: #FFFFFF;" rel="noopener noreferrer">
|
||||
{{#i18n 'email.aboutjm'}}Need any further information?{{/i18n}}
|
||||
</a></strong>
|
||||
</p>
|
||||
<p style="margin: 0;"> <strong>
|
||||
<a href="https://mieuxvoter.fr/index.php/decouvrir/" target="_blank" style="color: #111111;" rel="noopener noreferrer">
|
||||
{{#i18n 'common.helpus'}}Do you want to help us?{{/i18n}}
|
||||
</a></strong>
|
||||
</p>
|
||||
</th>
|
||||
</tr>
|
||||
</table>
|
||||
</th>
|
||||
</tr>
|
||||
<!-- FOOTER -->
|
||||
<tr>
|
||||
<th scope="col" style="background-color: #f4f4f4; padding: 0px 10px 0px 10px;">
|
||||
<table border="0" style="margin: 0px auto 0px auto; width: 100%; max-width: 600px;" aria-describedby="footer informations">
|
||||
<!-- EXPLAIN WHY -->
|
||||
</br>
|
||||
<tr>
|
||||
<th scope="col" style="background-color: #f4f4f4; padding: 0px 30px 30px 30px; color: #666666; font-family: 'Lato', Helvetica, Arial, sans-serif; font-size: 14px; font-weight: 400; line-height: 18px;" >
|
||||
<p style="margin: 0;">
|
||||
{{#i18n email.why }}You received this email because someone invited you to vote.{{/i18n}}
|
||||
</p>
|
||||
</th>
|
||||
</tr>
|
||||
<!-- ADDRESS -->
|
||||
<tr>
|
||||
<th scope="col" style="background-color: #f4f4f4; padding: 0px 30px 30px 30px; color: #666666; font-family: 'Lato', Helvetica, Arial, sans-serif; font-size: 14px; font-weight: 400; line-height: 18px;" >
|
||||
<p style="margin: 0;">{{#i18n mieuxvoter }}Mieux Voter{{/i18n}} - <a "mailto:app@mieuxvoter.fr">app@mieuxvoter.fr</a></p>
|
||||
</th>
|
||||
</tr>
|
||||
</table>
|
||||
</th>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
@ -1,19 +0,0 @@
|
||||
{{#i18n 'email.hello'}}Hi there! 🙂{{/i18n}}
|
||||
|
||||
{{#i18n 'email.happy'}}We are happy to send you this email! You will be able to vote using majority judgment.{{/i18n}}
|
||||
|
||||
{{#i18n 'email.why'}}This email was sent to you because your email was filled out to participate in the vote on the subject:{{/i18n}}
|
||||
|
||||
{{ title }}
|
||||
|
||||
{{#i18n 'email.linkVote' }}The link for the vote is as follows:{{/i18n}}
|
||||
|
||||
%recipient.urlVote%
|
||||
|
||||
{{#i18n 'email.linkResult' }}The link that will give you the results when they are available is as follows:{{/i18n}}
|
||||
|
||||
%recipient.urlResult%
|
||||
|
||||
{{#i18n 'email.bye'}}Good vote{{/i18n}}
|
||||
|
||||
{{#i18n 'common.mieuxvoter'}}Mieux Voter{{/i18n}}
|
@ -1,150 +0,0 @@
|
||||
const fs = require("fs");
|
||||
const Mailgun = require("mailgun.js");
|
||||
const formData = require("form-data");
|
||||
const dotenv = require("dotenv");
|
||||
const i18next = require("i18next");
|
||||
const Backend = require("i18next-chained-backend");
|
||||
const FSBackend = require("i18next-fs-backend");
|
||||
const HttpApi = require("i18next-http-backend");
|
||||
const Handlebars = require("handlebars");
|
||||
|
||||
dotenv.config();
|
||||
const {
|
||||
MAILGUN_API_KEY,
|
||||
MAILGUN_DOMAIN,
|
||||
MAILGUN_URL,
|
||||
FROM_EMAIL_ADDRESS,
|
||||
CONTACT_TO_EMAIL_ADDRESS,
|
||||
} = process.env;
|
||||
|
||||
const mailgun = new Mailgun(formData);
|
||||
const mg = mailgun.client({
|
||||
username: "api",
|
||||
key: MAILGUN_API_KEY,
|
||||
url: "https://api.eu.mailgun.net",
|
||||
});
|
||||
|
||||
const success = {
|
||||
statusCode: 200,
|
||||
body: "Your message was sent successfully! We'll be in touch.",
|
||||
};
|
||||
const err = {
|
||||
statusCode: 422,
|
||||
body: "Can't send message",
|
||||
};
|
||||
|
||||
// setup i18n
|
||||
// i18next.use(Backend).init({
|
||||
// lng: "fr",
|
||||
// ns: ["emailInvite", "common"],
|
||||
// defaultNS: "emailInvite",
|
||||
// fallbackNS: "common",
|
||||
// debug: false,
|
||||
// fallbackLng: ["fr"],
|
||||
// backend: {
|
||||
// backends: [FSBackend, HttpApi],
|
||||
// backendOptions: [{ loadPath: "/public/locales/{{lng}}/{{ns}}.json" }, {}],
|
||||
// },
|
||||
// });
|
||||
|
||||
// setup the template engine
|
||||
// See https://github.com/UUDigitalHumanitieslab/handlebars-i18next
|
||||
// function extend(target, ...sources) {
|
||||
// sources.forEach((source) => {
|
||||
// if (source)
|
||||
// for (let key in source) {
|
||||
// target[key] = source[key];
|
||||
// }
|
||||
// });
|
||||
// return target;
|
||||
// }
|
||||
// Handlebars.registerHelper("i18n", function (key, { hash, data, fn }) {
|
||||
// let parsed = {};
|
||||
// const jsonKeys = [
|
||||
// "lngs",
|
||||
// "fallbackLng",
|
||||
// "ns",
|
||||
// "postProcess",
|
||||
// "interpolation",
|
||||
// ];
|
||||
// jsonKeys.forEach((key) => {
|
||||
// if (hash[key]) {
|
||||
// parsed[key] = JSON.parse(hash[key]);
|
||||
// delete hash[key];
|
||||
// }
|
||||
// });
|
||||
// let options = extend({}, data.root.i18next, hash, parsed, {
|
||||
// returnObjects: false,
|
||||
// });
|
||||
// let replace = (options.replace = extend({}, this, options.replace, hash));
|
||||
// delete replace.i18next; // may creep in if this === data.root
|
||||
// if (fn) options.defaultValue = fn(replace);
|
||||
// return new Handlebars.SafeString(i18next.t(key, options));
|
||||
// });
|
||||
// const txtStr = fs.readFileSync(__dirname + "/invite.txt").toString();
|
||||
const txtStr = {
|
||||
en: fs.readFileSync(__dirname + "/invite-en.txt").toString(),
|
||||
fr: fs.readFileSync(__dirname + "/invite-fr.txt").toString(),
|
||||
};
|
||||
const txtTemplate = {
|
||||
en: Handlebars.compile(txtStr.en),
|
||||
fr: Handlebars.compile(txtStr.fr),
|
||||
};
|
||||
const htmlStr = {
|
||||
en: fs.readFileSync(__dirname + "/invite-en.html").toString(),
|
||||
fr: fs.readFileSync(__dirname + "/invite-fr.html").toString(),
|
||||
};
|
||||
const htmlTemplate = {
|
||||
en: Handlebars.compile(htmlStr.en),
|
||||
fr: Handlebars.compile(htmlStr.fr),
|
||||
};
|
||||
|
||||
const test = Handlebars.compile("test");
|
||||
|
||||
const sendMail = async (event) => {
|
||||
if (event.httpMethod !== "POST") {
|
||||
return {
|
||||
statusCode: 405,
|
||||
body: "Method Not Allowed",
|
||||
headers: { Allow: "POST" },
|
||||
};
|
||||
}
|
||||
|
||||
const data = JSON.parse(event.body);
|
||||
if (!data.recipientVariables || !data.title || !data.locale) {
|
||||
return {
|
||||
statusCode: 422,
|
||||
body: "Recipient variables and title are required.",
|
||||
};
|
||||
}
|
||||
|
||||
// i18next.changeLanguage(data.locale);
|
||||
const templateData = {
|
||||
title: data.title,
|
||||
};
|
||||
|
||||
const mailgunData = {
|
||||
// from: `${i18next.t("Mieux Voter")} <mailgun@mg.app.mieuxvoter.fr>`,
|
||||
from: '"Mieux Voter" <postmaster@mg.app.mieuxvoter.fr>',
|
||||
to: Object.keys(data.recipientVariables),
|
||||
text: txtTemplate.fr(templateData),
|
||||
html: htmlTemplate.fr(templateData),
|
||||
subject: data.title,
|
||||
"h:Reply-To": "app@mieuxvoter.fr",
|
||||
"recipient-variables": JSON.stringify(data.recipientVariables),
|
||||
};
|
||||
|
||||
const res = mg.messages
|
||||
.create("mg.app.mieuxvoter.fr", mailgunData)
|
||||
.then((msg) => {
|
||||
return success;
|
||||
}) // logs response data
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
return success;
|
||||
}); // logs any error
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
exports.handler = sendMail;
|
@ -1,82 +0,0 @@
|
||||
const fs = require("fs");
|
||||
const chalk = require("chalk");
|
||||
|
||||
module.exports = {
|
||||
input: [
|
||||
"app/**/*.{js,jsx}",
|
||||
// Use ! to filter out files or directories
|
||||
"!app/**/*.spec.{js,jsx}",
|
||||
"!app/i18n/**",
|
||||
"!**/node_modules/**"
|
||||
],
|
||||
output: ".",
|
||||
options: {
|
||||
debug: true,
|
||||
func: {
|
||||
list: ["i18next.t", "i18n.t", "t"],
|
||||
extensions: [".js", ".jsx"]
|
||||
},
|
||||
trans: {
|
||||
component: "Trans",
|
||||
i18nKey: "i18nKey",
|
||||
defaultsKey: "defaults",
|
||||
extensions: [".js", ".jsx"],
|
||||
fallbackKey: function(ns, value) {
|
||||
return value;
|
||||
},
|
||||
acorn: {
|
||||
ecmaVersion: 10, // defaults to 10
|
||||
sourceType: "module" // defaults to 'module'
|
||||
// Check out https://github.com/acornjs/acorn/tree/master/acorn#interface for additional options
|
||||
}
|
||||
},
|
||||
lngs: ["en", "fr", "es", "de", "ru"],
|
||||
ns: ["resource", "common"],
|
||||
defaultLng: "en",
|
||||
defaultNs: "resource",
|
||||
defaultValue: "__STRING_NOT_TRANSLATED__",
|
||||
resource: {
|
||||
loadPath: "./public/locale/i18n/{{lng}}/{{ns}}.json",
|
||||
savePath: "./public/locale/i18n/{{lng}}/{{ns}}.json",
|
||||
jsonIndent: 2,
|
||||
lineEnding: "\n"
|
||||
},
|
||||
nsSeparator: false, // namespace separator
|
||||
keySeparator: false, // key separator
|
||||
interpolation: {
|
||||
prefix: "{{",
|
||||
suffix: "}}"
|
||||
}
|
||||
},
|
||||
transform: function customTransform(file, enc, done) {
|
||||
"use strict";
|
||||
const parser = this.parser;
|
||||
const content = fs.readFileSync(file.path, enc);
|
||||
let count = 0;
|
||||
|
||||
parser.parseFuncFromString(
|
||||
content,
|
||||
{ list: ["i18next._", "i18next.__"] },
|
||||
(key, options) => {
|
||||
parser.set(
|
||||
key,
|
||||
Object.assign({}, options, {
|
||||
nsSeparator: false,
|
||||
keySeparator: false
|
||||
})
|
||||
);
|
||||
++count;
|
||||
}
|
||||
);
|
||||
|
||||
if (count > 0) {
|
||||
/* console.log(
|
||||
`i18next-scanner: count=${chalk.cyan(count)}, file=${chalk.yellow(
|
||||
JSON.stringify(file.relative)
|
||||
)}`
|
||||
);*/
|
||||
}
|
||||
|
||||
done();
|
||||
}
|
||||
};
|
@ -1,10 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"baseUrl": "./",
|
||||
"paths": {
|
||||
"@components/*": ["components/*"],
|
||||
"@styles/*": ["styles/*"],
|
||||
"@services/*": ["services/*"]
|
||||
}
|
||||
}
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
[build]
|
||||
command = "npm run build"
|
||||
publish = "out"
|
||||
functions = "functions"
|
||||
|
||||
[dev]
|
||||
command = "npm run dev"
|
@ -1,9 +0,0 @@
|
||||
module.exports = {
|
||||
i18n: {
|
||||
defaultLocale: "fr",
|
||||
locales: ["en", "fr", "de", "es", "ru"],
|
||||
ns: ["resource", "common", "error"],
|
||||
defaultNS: "resource",
|
||||
fallbackNS: ["common", "error"],
|
||||
},
|
||||
};
|
@ -1,45 +0,0 @@
|
||||
const { i18n } = require("./next-i18next.config");
|
||||
|
||||
module.exports = {
|
||||
i18n,
|
||||
// See https://github.com/netlify/netlify-plugin-nextjs/issues/223
|
||||
unstableNetlifyFunctionsSupport: {
|
||||
"pages/index.jsx": {
|
||||
includeDirs: ["public"],
|
||||
},
|
||||
"pages/faq.jsx": {
|
||||
includeDirs: ["public"],
|
||||
},
|
||||
"pages/legal-notices.jsx": {
|
||||
includeDirs: ["public"],
|
||||
},
|
||||
"pages/new/confirm/[pid].jsx": {
|
||||
includeDirs: ["public"],
|
||||
},
|
||||
"pages/new.jsx": {
|
||||
includeDirs: ["public"],
|
||||
},
|
||||
"pages/result/[pid]/[[...tid]].jsx": {
|
||||
includeDirs: ["public"],
|
||||
},
|
||||
"pages/vote/[pid]/[[...tid]].jsx": {
|
||||
includeDirs: ["public"],
|
||||
},
|
||||
"pages/vote/[pid]/confirm.jsx": {
|
||||
includeDirs: ["public"],
|
||||
},
|
||||
"pages/privacy-policy.jsx": {
|
||||
includeDirs: ["public"],
|
||||
},
|
||||
},
|
||||
pageExtensions: ["mdx", "jsx", "js", "ts", "tsx"],
|
||||
webpack(config) {
|
||||
config.module.rules.push({
|
||||
test: /\.svg$/,
|
||||
use: ["@svgr/webpack"],
|
||||
});
|
||||
|
||||
return config;
|
||||
},
|
||||
target: "experimental-serverless-trace",
|
||||
};
|
@ -1,46 +1,46 @@
|
||||
{
|
||||
"name": "mv-front-react",
|
||||
"version": "1.1.0",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
"build": "next build",
|
||||
"start": "next start",
|
||||
"export": "next export"
|
||||
},
|
||||
"dependencies": {
|
||||
"@fortawesome/fontawesome-free": "^5.15.3",
|
||||
"@fortawesome/fontawesome-svg-core": "^1.2.35",
|
||||
"@fortawesome/free-brands-svg-icons": "^5.15.3",
|
||||
"@fortawesome/free-solid-svg-icons": "^5.15.3",
|
||||
"@fortawesome/react-fontawesome": "^0.1.14",
|
||||
"@svgr/webpack": "^5.5.0",
|
||||
"array-move": "^3.0.1",
|
||||
"bootstrap": "^4.6.0",
|
||||
"bootstrap-scss": "^4.6.0",
|
||||
"domexception": "^2.0.1",
|
||||
"dotenv": "^8.6.0",
|
||||
"form-data": "^4.0.0",
|
||||
"handlebars": "^4.7.7",
|
||||
"handlebars-i18next": "^1.0.1",
|
||||
"i18next": "^20.2.2",
|
||||
"i18next-chained-backend": "^2.1.0",
|
||||
"i18next-fs-backend": "^1.1.1",
|
||||
"i18next-http-backend": "^1.2.4",
|
||||
"i18next-localstorage-backend": "^3.1.2",
|
||||
"i18next-text": "^0.5.6",
|
||||
"mailgun.js": "^3.3.2",
|
||||
"next": "^10.2.0",
|
||||
"next-i18next": "^8.2.0",
|
||||
"query-string": "^7.0.0",
|
||||
"@testing-library/jest-dom": "^5.16.2",
|
||||
"@testing-library/react": "^12.1.2",
|
||||
"@testing-library/user-event": "^13.5.0",
|
||||
"@types/jest": "^27.4.0",
|
||||
"@types/node": "^16.11.22",
|
||||
"@types/react": "^17.0.39",
|
||||
"@types/react-dom": "^17.0.11",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2",
|
||||
"react-flags-select": "^2.1.2",
|
||||
"react-i18next": "^11.8.15",
|
||||
"react-multi-email": "^0.5.3",
|
||||
"react-sortable-hoc": "^2.0.0",
|
||||
"react-toastify": "^7.0.4",
|
||||
"reactstrap": "^8.9.0",
|
||||
"sass": "^1.32.13"
|
||||
"react-scripts": "5.0.0",
|
||||
"typescript": "^4.5.5",
|
||||
"web-vitals": "^2.1.4"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "react-scripts start",
|
||||
"build": "react-scripts build",
|
||||
"test": "react-scripts test",
|
||||
"deploy": "gh-pages -d build"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": [
|
||||
"react-app",
|
||||
"react-app/jest"
|
||||
]
|
||||
},
|
||||
"browserslist": {
|
||||
"production": [
|
||||
">0.2%",
|
||||
"not dead",
|
||||
"not op_mini all"
|
||||
],
|
||||
"development": [
|
||||
"last 1 chrome version",
|
||||
"last 1 firefox version",
|
||||
"last 1 safari version"
|
||||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"gh-pages": "^3.2.3"
|
||||
}
|
||||
}
|
||||
|
@ -1,34 +0,0 @@
|
||||
import Head from 'next/head'
|
||||
import '@styles/globals.css'
|
||||
import '@styles/footer.css'
|
||||
import '@styles/loader.css'
|
||||
import "@styles/scss/config.scss";
|
||||
import '@fortawesome/fontawesome-svg-core/styles.css'
|
||||
import {appWithTranslation} from 'next-i18next'
|
||||
import {AppProvider} from '@services/context.js'
|
||||
import Header from '@components/layouts/Header'
|
||||
import Footer from '@components/layouts/Footer'
|
||||
|
||||
|
||||
function Application({Component, pageProps}) {
|
||||
const origin = typeof window !== 'undefined' && window.location.origin ? window.location.origin : 'http://localhost';
|
||||
return (<AppProvider>
|
||||
<Head>
|
||||
<link rel="icon" key="favicon" href="/favicon.ico" />
|
||||
<meta property="og:url" content={origin} key="og:url" />
|
||||
<meta property="og:type" content="website" key="og:type" />
|
||||
<meta
|
||||
property="og:image"
|
||||
content="https://app.mieuxvoter.fr/app-mieux-voter.png"
|
||||
key="og:image"
|
||||
/>
|
||||
</Head>
|
||||
<Header />
|
||||
<main className="d-flex flex-column justify-content-center">
|
||||
<Component {...pageProps} />
|
||||
</main>
|
||||
<Footer />
|
||||
</AppProvider>);
|
||||
}
|
||||
|
||||
export default appWithTranslation(Application)
|
@ -1,71 +0,0 @@
|
||||
import { useState } from "react";
|
||||
import Head from "next/head";
|
||||
import Link from "next/link";
|
||||
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
|
||||
import { useTranslation } from "next-i18next";
|
||||
import { Container, Row, Col, Button, Input } from "reactstrap";
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
import { faRocket } from "@fortawesome/free-solid-svg-icons";
|
||||
import config from "../next-i18next.config.js";
|
||||
|
||||
export const getStaticProps = async ({ locale }) => ({
|
||||
props: {
|
||||
...(await serverSideTranslations(locale, [], config)),
|
||||
},
|
||||
});
|
||||
|
||||
const Home = () => {
|
||||
const [title, setTitle] = useState(null);
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<Container>
|
||||
<form autoComplete="off">
|
||||
<Row>
|
||||
<img
|
||||
src="logos/logo-line-white.svg"
|
||||
alt="logo of Mieux Voter"
|
||||
height="128"
|
||||
className="d-block ml-auto mr-auto mb-4"
|
||||
/>
|
||||
</Row>
|
||||
<Row>
|
||||
<Col className="text-center">
|
||||
<h3>{t("common.valueProp")}</h3>
|
||||
</Col>
|
||||
</Row>
|
||||
<Row className="mt-2">
|
||||
<Col xs="12" md="9" xl="6" className="offset-xl-2">
|
||||
<Input
|
||||
placeholder={t("resource.writeQuestion")}
|
||||
autoFocus
|
||||
required
|
||||
className="mt-2"
|
||||
name="title"
|
||||
value={title ? title : ""}
|
||||
onChange={(e) => setTitle(e.target.value)}
|
||||
maxLength="250"
|
||||
/>
|
||||
</Col>
|
||||
<Col xs="12" md="3" xl="2">
|
||||
<Link href={{ pathname: "/new/", query: { title: title } }}>
|
||||
<Button
|
||||
type="submit"
|
||||
className="btn btn-block btn-secondary mt-2"
|
||||
>
|
||||
<FontAwesomeIcon icon={faRocket} className="mr-2" />
|
||||
{t("resource.start")}
|
||||
</Button>
|
||||
</Link>
|
||||
</Col>
|
||||
</Row>
|
||||
<Row className="mt-4">
|
||||
<Col className="text-center">
|
||||
<p>{t("resource.noAds")}</p>
|
||||
</Col>
|
||||
</Row>
|
||||
</form>
|
||||
</Container>
|
||||
);
|
||||
};
|
||||
|
||||
export default Home;
|
@ -1,171 +0,0 @@
|
||||
import { createRef } from "react";
|
||||
import Head from "next/head";
|
||||
import { useRouter } from "next/router";
|
||||
import { useTranslation } from "next-i18next";
|
||||
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
|
||||
import {
|
||||
getDetails,
|
||||
apiErrors,
|
||||
ELECTION_NOT_STARTED_ERROR,
|
||||
} from "@services/api";
|
||||
import { Col, Container, Row } from "reactstrap";
|
||||
import Link from "next/link";
|
||||
import {
|
||||
faCopy,
|
||||
faVoteYea,
|
||||
faExclamationTriangle,
|
||||
faExternalLinkAlt,
|
||||
faPollH,
|
||||
} from "@fortawesome/free-solid-svg-icons";
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
import CopyField from "@components/CopyField";
|
||||
import Error from "@components/Error";
|
||||
import Facebook from "@components/banner/Facebook";
|
||||
import config from "../../../next-i18next.config.js";
|
||||
|
||||
export async function getServerSideProps({ query: { pid }, locale }) {
|
||||
let [details, translations] = await Promise.all([
|
||||
getDetails(pid),
|
||||
serverSideTranslations(locale, [], config),
|
||||
]);
|
||||
|
||||
if (details.includes(ELECTION_NOT_STARTED_ERROR)) {
|
||||
details = { title: "", on_invitation_only: true, restrict_results: true };
|
||||
} else {
|
||||
if (typeof details === "string" || details instanceof String) {
|
||||
return { props: { err: details, ...translations } };
|
||||
}
|
||||
|
||||
if (!details.title) {
|
||||
return { props: { err: "Unknown error", ...translations } };
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
props: {
|
||||
invitationOnly: details.on_invitation_only,
|
||||
restrictResults: details.restrict_results,
|
||||
title: details.title,
|
||||
pid: pid,
|
||||
...translations,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
const ConfirmElection = ({
|
||||
title,
|
||||
restrictResults,
|
||||
invitationOnly,
|
||||
pid,
|
||||
err,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
if (err) {
|
||||
return <Error value={apiErrors(err, t)} />;
|
||||
}
|
||||
|
||||
const origin =
|
||||
typeof window !== "undefined" && window.location.origin
|
||||
? window.location.origin
|
||||
: "http://localhost";
|
||||
const urlVote = new URL(`/vote/${pid}`, origin);
|
||||
const urlResult = new URL(`/result/${pid}`, origin);
|
||||
|
||||
const electionLink = invitationOnly ? (
|
||||
<>
|
||||
<p className="mb-1">
|
||||
{t(
|
||||
"Voters received a link to vote by email. Each link can be used only once!"
|
||||
)}
|
||||
</p>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<p className="mb-1">{t("Voting address")}</p>
|
||||
<CopyField
|
||||
value={urlVote.href}
|
||||
iconCopy={faCopy}
|
||||
iconOpen={faExternalLinkAlt}
|
||||
t={t}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
const fb = invitationOnly ? null : (
|
||||
<Facebook
|
||||
className="btn btn-sm btn-outline-light m-2"
|
||||
text={t("Share election on Facebook")}
|
||||
url={urlVote}
|
||||
title={"app.mieuxvoter.fr"}
|
||||
/>
|
||||
);
|
||||
|
||||
const participate = invitationOnly ? null : (
|
||||
<>
|
||||
<Col className="col-lg-3 text-center mr-10">
|
||||
<Link href={`/vote/${pid}`}>
|
||||
<a target="_blank" rel="noreferrer" className="btn btn-success">
|
||||
<FontAwesomeIcon icon={faVoteYea} className="mr-2" />
|
||||
{t("resource.participateBtn")}
|
||||
</a>
|
||||
</Link>
|
||||
</Col>
|
||||
</>
|
||||
);
|
||||
|
||||
return (
|
||||
<Container>
|
||||
<Head>
|
||||
<title>{t("Successful election creation!")}</title>
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
<meta key="og:title" property="og:title" content={title} />
|
||||
<meta
|
||||
property="og:description"
|
||||
key="og:description"
|
||||
content={t("common.application")}
|
||||
/>
|
||||
</Head>
|
||||
|
||||
<Row className="mt-5">
|
||||
<Col className="text-center offset-lg-3" lg="6">
|
||||
<h2>{t("Successful election creation!")}</h2>
|
||||
{fb}
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
<Row className="mt-5 mb-4">
|
||||
<Col className="offset-lg-3" lg="6">
|
||||
<h3 className="mb-3 text-center">{title}</h3>
|
||||
<h5 className="mb-3 text-center">
|
||||
<FontAwesomeIcon icon={faExclamationTriangle} className="mr-2" />
|
||||
{t("Keep these links carefully")}
|
||||
</h5>
|
||||
<div className="border rounded p-4 pb-5">
|
||||
{electionLink}
|
||||
|
||||
<p className="mt-4 mb-1">{t("Results address")}</p>
|
||||
<CopyField
|
||||
value={urlResult}
|
||||
iconCopy={faCopy}
|
||||
iconOpen={faExternalLinkAlt}
|
||||
t={t}
|
||||
/>
|
||||
</div>
|
||||
</Col>
|
||||
</Row>
|
||||
<Row className="mt-4 mb-4 justify-content-md-center">
|
||||
{participate}
|
||||
<Col className="text-center col-lg-3">
|
||||
<Link href={`/result/${pid}`}>
|
||||
<a target="_blank" rel="noreferrer" className="btn btn-secondary">
|
||||
<FontAwesomeIcon icon={faPollH} className="mr-2" />
|
||||
{t("resource.resultsBtn")}
|
||||
</a>
|
||||
</Link>
|
||||
</Col>
|
||||
</Row>
|
||||
</Container>
|
||||
);
|
||||
};
|
||||
|
||||
export default ConfirmElection;
|
@ -1,333 +0,0 @@
|
||||
import { useState } from "react";
|
||||
import Head from "next/head";
|
||||
import { useTranslation } from "next-i18next";
|
||||
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
|
||||
import { useRouter } from "next/router";
|
||||
import {
|
||||
Container,
|
||||
Row,
|
||||
Col,
|
||||
Collapse,
|
||||
Card,
|
||||
CardHeader,
|
||||
CardBody,
|
||||
Table,
|
||||
} from "reactstrap";
|
||||
import { getResults, getDetails, apiErrors } from "@services/api";
|
||||
import { grades } from "@services/grades";
|
||||
import { translateGrades } from "@services/grades";
|
||||
import Facebook from "@components/banner/Facebook";
|
||||
import Error from "@components/Error";
|
||||
import config from "../../../next-i18next.config.js";
|
||||
|
||||
export async function getServerSideProps({ query, locale }) {
|
||||
const { pid, tid } = query;
|
||||
|
||||
const [res, details, translations] = await Promise.all([
|
||||
getResults(pid),
|
||||
getDetails(pid),
|
||||
serverSideTranslations(locale, [], config),
|
||||
]);
|
||||
|
||||
if (typeof res === "string" || res instanceof String) {
|
||||
return { props: { err: res.slice(1, -1), ...translations } };
|
||||
}
|
||||
|
||||
if (typeof details === "string" || details instanceof String) {
|
||||
return { props: { err: res.slice(1, -1), ...translations } };
|
||||
}
|
||||
|
||||
if (!details.candidates || !Array.isArray(details.candidates)) {
|
||||
return { props: { err: "Unknown error", ...translations } };
|
||||
}
|
||||
|
||||
return {
|
||||
props: {
|
||||
title: details.title,
|
||||
numGrades: details.num_grades,
|
||||
candidates: res,
|
||||
pid: pid,
|
||||
...translations,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
const Result = ({ candidates, numGrades, title, pid, err }) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
if (err && err !== "") {
|
||||
return <Error value={apiErrors(err, t)} />;
|
||||
}
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
const allGrades = translateGrades(t);
|
||||
const grades = allGrades.filter(
|
||||
(grade) => grade.value >= allGrades.length - numGrades
|
||||
);
|
||||
const offsetGrade = grades.length - numGrades;
|
||||
|
||||
const colSizeCandidateLg = 4;
|
||||
const colSizeCandidateMd = 6;
|
||||
const colSizeCandidateXs = 12;
|
||||
const colSizeGradeLg = 1;
|
||||
const colSizeGradeMd = 1;
|
||||
const colSizeGradeXs = 1;
|
||||
|
||||
const origin =
|
||||
typeof window !== "undefined" && window.location.origin
|
||||
? window.location.origin
|
||||
: "http://localhost";
|
||||
console.log("origin", origin);
|
||||
const urlVote = new URL(`/vote/${pid}`, origin);
|
||||
|
||||
const [collapseProfiles, setCollapseProfiles] = useState(false);
|
||||
const [collapseGraphics, setCollapseGraphics] = useState(false);
|
||||
|
||||
const sum = (seq) => Object.values(seq).reduce((a, b) => a + b, 0);
|
||||
const numVotes =
|
||||
candidates && candidates.length > 0 ? sum(candidates[0].profile) : 1;
|
||||
const gradeIds =
|
||||
candidates && candidates.length > 0
|
||||
? Object.keys(candidates[0].profile)
|
||||
: [];
|
||||
|
||||
return (
|
||||
<Container>
|
||||
<Head>
|
||||
<title>{title}</title>
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
<meta property="og:title" content={title} />
|
||||
</Head>
|
||||
<Row>
|
||||
<Col xs="12">
|
||||
<h3>{title}</h3>
|
||||
</Col>
|
||||
</Row>
|
||||
<Row className="mt-5">
|
||||
<Col>
|
||||
<ol className="result">
|
||||
{candidates.map((candidate, i) => {
|
||||
const gradeValue = candidate.grade + offsetGrade;
|
||||
return (
|
||||
<li key={i} className="mt-2">
|
||||
<span className="mt-2 ml-2">{candidate.name}</span>
|
||||
<span
|
||||
className="badge badge-light ml-2 mt-2"
|
||||
style={{
|
||||
backgroundColor: grades.slice(0).reverse()[
|
||||
candidate.grade
|
||||
].color,
|
||||
color: "#fff",
|
||||
}}
|
||||
>
|
||||
{allGrades.slice(0).reverse()[gradeValue].label}
|
||||
</span>
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ol>
|
||||
<h5>
|
||||
<small>
|
||||
{t("resource.numVotes")}
|
||||
{" " + numVotes}
|
||||
</small>
|
||||
</h5>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
<Row className="mt-5">
|
||||
<Col>
|
||||
<Card className="bg-light text-primary">
|
||||
<CardHeader
|
||||
className="pointer"
|
||||
onClick={() => setCollapseGraphics(!collapseGraphics)}
|
||||
>
|
||||
<h4
|
||||
className={
|
||||
"m-0 panel-title " + (collapseGraphics ? "collapsed" : "")
|
||||
}
|
||||
>
|
||||
{t("Graph")}
|
||||
</h4>
|
||||
</CardHeader>
|
||||
<Collapse isOpen={collapseGraphics}>
|
||||
<CardBody className="pt-5">
|
||||
<div>
|
||||
<div
|
||||
className="median"
|
||||
style={{ height: candidates.length * 28 + 30 }}
|
||||
/>
|
||||
<table style={{ width: "100%" }}>
|
||||
<tbody>
|
||||
{candidates.map((candidate, i) => {
|
||||
return (
|
||||
<tr key={i}>
|
||||
<td style={{ width: "30px" }}>{i + 1}</td>
|
||||
{/*candidate.label*/}
|
||||
<td>
|
||||
<table style={{ width: "100%" }}>
|
||||
<tbody>
|
||||
<tr>
|
||||
{gradeIds
|
||||
.slice(0)
|
||||
.reverse()
|
||||
.map((id, i) => {
|
||||
const value = candidate.profile[id];
|
||||
if (value > 0) {
|
||||
let percent =
|
||||
(value * 100) / numVotes + "%";
|
||||
if (i === 0) {
|
||||
percent = "auto";
|
||||
}
|
||||
return (
|
||||
<td
|
||||
key={i}
|
||||
style={{
|
||||
width: percent,
|
||||
backgroundColor:
|
||||
grades[i].color,
|
||||
}}
|
||||
>
|
||||
|
||||
</td>
|
||||
);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
})}
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
})}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div className="mt-4">
|
||||
<small>
|
||||
{candidates.map((candidate, i) => {
|
||||
return (
|
||||
<span key={i}>
|
||||
{i > 0 ? ", " : ""}
|
||||
<b>{i + 1}</b>: {candidate.name}
|
||||
</span>
|
||||
);
|
||||
})}
|
||||
</small>
|
||||
</div>
|
||||
<div className="mt-2">
|
||||
<small>
|
||||
{grades.map((grade, i) => {
|
||||
return (
|
||||
<span
|
||||
key={i}
|
||||
className="badge badge-light mr-2 mt-2"
|
||||
style={{
|
||||
backgroundColor: grade.color,
|
||||
color: "#fff",
|
||||
}}
|
||||
>
|
||||
{grade.label}
|
||||
</span>
|
||||
);
|
||||
})}
|
||||
</small>
|
||||
</div>
|
||||
</CardBody>
|
||||
</Collapse>
|
||||
</Card>
|
||||
</Col>
|
||||
</Row>
|
||||
<Row className="mt-3">
|
||||
<Col>
|
||||
<Card className="bg-light text-primary">
|
||||
<CardHeader
|
||||
className="pointer"
|
||||
onClick={() => setCollapseProfiles(!collapseProfiles)}
|
||||
>
|
||||
<h4
|
||||
className={
|
||||
"m-0 panel-title " + (collapseProfiles ? "collapsed" : "")
|
||||
}
|
||||
>
|
||||
{t("Preference profile")}
|
||||
</h4>
|
||||
</CardHeader>
|
||||
<Collapse isOpen={collapseProfiles}>
|
||||
<CardBody>
|
||||
<div className="table-responsive">
|
||||
<Table className="profiles">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
{grades.map((grade, i) => {
|
||||
return (
|
||||
<th key={i}>
|
||||
<span
|
||||
className="badge badge-light"
|
||||
style={{
|
||||
backgroundColor: grade.color,
|
||||
color: "#fff",
|
||||
}}
|
||||
>
|
||||
{grade.label}{" "}
|
||||
</span>
|
||||
</th>
|
||||
);
|
||||
})}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{candidates.map((candidate, i) => {
|
||||
return (
|
||||
<tr key={i}>
|
||||
<td>{i + 1}</td>
|
||||
{gradeIds
|
||||
.slice(0)
|
||||
.reverse()
|
||||
.map((id, i) => {
|
||||
const value = candidate.profile[id];
|
||||
const percent = (
|
||||
(value / numVotes) *
|
||||
100
|
||||
).toFixed(1);
|
||||
return <td key={i}>{percent} %</td>;
|
||||
})}
|
||||
</tr>
|
||||
);
|
||||
})}
|
||||
</tbody>
|
||||
</Table>
|
||||
</div>
|
||||
<small>
|
||||
{candidates.map((candidate, i) => {
|
||||
return (
|
||||
<span key={i}>
|
||||
{i > 0 ? ", " : ""}
|
||||
<b>{i + 1}</b>: {candidate.name}
|
||||
</span>
|
||||
);
|
||||
})}
|
||||
</small>
|
||||
</CardBody>
|
||||
</Collapse>
|
||||
</Card>
|
||||
</Col>
|
||||
</Row>
|
||||
<Row>
|
||||
<Col xs="12" className="text-center pt-2 pb-5">
|
||||
<Facebook
|
||||
className="btn btn-outline-light m-2"
|
||||
text={t("Share results on Facebook")}
|
||||
url={urlVote}
|
||||
title={title}
|
||||
/>
|
||||
</Col>
|
||||
</Row>
|
||||
</Container>
|
||||
);
|
||||
};
|
||||
export default Result;
|
@ -1,271 +0,0 @@
|
||||
import { useState } from "react";
|
||||
import Head from "next/head";
|
||||
import { useRouter } from "next/router";
|
||||
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
|
||||
import { useTranslation } from "next-i18next";
|
||||
import { Button, Col, Container, Row } from "reactstrap";
|
||||
import { toast, ToastContainer } from "react-toastify";
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
import { faCheck } from "@fortawesome/free-solid-svg-icons";
|
||||
import { getDetails, castBallot, apiErrors } from "@services/api";
|
||||
import Error from "@components/Error";
|
||||
import { translateGrades } from "@services/grades";
|
||||
import config from "../../../next-i18next.config.js";
|
||||
|
||||
const shuffle = (array) => array.sort(() => Math.random() - 0.5);
|
||||
|
||||
export async function getServerSideProps({ query: { pid, tid }, locale }) {
|
||||
const [details, translations] = await Promise.all([
|
||||
getDetails(pid),
|
||||
serverSideTranslations(locale, [], config),
|
||||
]);
|
||||
|
||||
if (typeof details === "string" || details instanceof String) {
|
||||
return { props: { err: details, ...translations } };
|
||||
}
|
||||
|
||||
if (!details.candidates || !Array.isArray(details.candidates)) {
|
||||
return { props: { err: "Unknown error", ...translations } };
|
||||
}
|
||||
|
||||
shuffle(details.candidates);
|
||||
|
||||
return {
|
||||
props: {
|
||||
...translations,
|
||||
invitationOnly: details.on_invitation_only,
|
||||
restrictResults: details.restrict_results,
|
||||
candidates: details.candidates.map((name, i) => ({ id: i, label: name })),
|
||||
title: details.title,
|
||||
numGrades: details.num_grades,
|
||||
pid: pid,
|
||||
token: tid || null,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
const VoteBallot = ({ candidates, title, numGrades, pid, err, token }) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
if (err) {
|
||||
return <Error value={apiErrors(err, t)}></Error>;
|
||||
}
|
||||
|
||||
const [judgments, setJudgments] = useState([]);
|
||||
const colSizeCandidateLg = 4;
|
||||
const colSizeCandidateMd = 6;
|
||||
const colSizeCandidateXs = 12;
|
||||
const colSizeGradeLg = Math.floor((12 - colSizeCandidateLg) / numGrades);
|
||||
const colSizeGradeMd = Math.floor((12 - colSizeCandidateMd) / numGrades);
|
||||
const colSizeGradeXs = Math.floor((12 - colSizeCandidateXs) / numGrades);
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
const allGrades = translateGrades(t);
|
||||
const grades = allGrades.filter(
|
||||
(grade) => grade.value >= allGrades.length - numGrades
|
||||
);
|
||||
|
||||
const handleGradeClick = (event) => {
|
||||
let data = {
|
||||
id: parseInt(event.currentTarget.getAttribute("data-id")),
|
||||
value: parseInt(event.currentTarget.value),
|
||||
};
|
||||
//remove candidate
|
||||
const newJudgments = judgments.filter(
|
||||
(judgment) => judgment.id !== data.id
|
||||
);
|
||||
newJudgments.push(data);
|
||||
setJudgments(newJudgments);
|
||||
};
|
||||
|
||||
const handleSubmitWithoutAllRate = () => {
|
||||
toast.error(t("You have to judge every candidate/proposal!"), {
|
||||
position: toast.POSITION.TOP_CENTER,
|
||||
});
|
||||
};
|
||||
|
||||
const handleSubmit = (event) => {
|
||||
event.preventDefault();
|
||||
|
||||
const gradesById = {};
|
||||
judgments.forEach((c) => {
|
||||
gradesById[c.id] = c.value;
|
||||
});
|
||||
const gradesByCandidate = [];
|
||||
Object.keys(gradesById).forEach((id) => {
|
||||
gradesByCandidate.push(gradesById[id]);
|
||||
});
|
||||
|
||||
castBallot(gradesByCandidate, pid, token, () => {
|
||||
router.push(`/vote/${pid}/confirm`);
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<Container>
|
||||
<Head>
|
||||
<title>{title}</title>
|
||||
|
||||
<title>{title}</title>
|
||||
<meta key="og:title" property="og:title" content={title} />
|
||||
<meta
|
||||
property="og:description"
|
||||
key="og:description"
|
||||
content={t("common.application")}
|
||||
/>
|
||||
</Head>
|
||||
<ToastContainer />
|
||||
<form onSubmit={handleSubmit} autoComplete="off">
|
||||
<Row>
|
||||
<Col>
|
||||
<h3>{title}</h3>
|
||||
</Col>
|
||||
</Row>
|
||||
<Row className="cardVote d-none d-lg-flex">
|
||||
<Col
|
||||
xs={colSizeCandidateXs}
|
||||
md={colSizeCandidateMd}
|
||||
lg={colSizeCandidateLg}
|
||||
>
|
||||
<h5> </h5>
|
||||
</Col>
|
||||
{grades.map((grade, gradeId) => {
|
||||
return gradeId < numGrades ? (
|
||||
<Col
|
||||
xs={colSizeGradeXs}
|
||||
md={colSizeGradeMd}
|
||||
lg={colSizeGradeLg}
|
||||
key={gradeId}
|
||||
className="text-center p-0"
|
||||
style={{ lineHeight: 2 }}
|
||||
>
|
||||
<small
|
||||
className="nowrap bold badge"
|
||||
style={{ backgroundColor: grade.color, color: "#fff" }}
|
||||
>
|
||||
{grade.label}
|
||||
</small>
|
||||
</Col>
|
||||
) : null;
|
||||
})}
|
||||
</Row>
|
||||
|
||||
{candidates.map((candidate, candidateId) => {
|
||||
return (
|
||||
<Row key={candidateId} className="cardVote">
|
||||
<Col
|
||||
xs={colSizeCandidateXs}
|
||||
md={colSizeCandidateMd}
|
||||
lg={colSizeCandidateLg}
|
||||
>
|
||||
<h5 className="m-0">{candidate.label}</h5>
|
||||
<hr className="d-lg-none" />
|
||||
</Col>
|
||||
{grades.map((grade, gradeId) => {
|
||||
console.assert(gradeId < numGrades);
|
||||
const gradeValue = grade.value;
|
||||
return (
|
||||
<Col
|
||||
xs={colSizeGradeXs}
|
||||
md={colSizeGradeMd}
|
||||
lg={colSizeGradeLg}
|
||||
key={gradeId}
|
||||
className="text-lg-center"
|
||||
>
|
||||
<label
|
||||
htmlFor={
|
||||
"candidateGrade" + candidateId + "-" + gradeValue
|
||||
}
|
||||
className="check"
|
||||
>
|
||||
<small
|
||||
className="nowrap d-lg-none ml-2 bold badge"
|
||||
style={
|
||||
judgments.find((judgment) => {
|
||||
return (
|
||||
JSON.stringify(judgment) ===
|
||||
JSON.stringify({
|
||||
id: candidate.id,
|
||||
value: gradeValue,
|
||||
})
|
||||
);
|
||||
})
|
||||
? { backgroundColor: grade.color, color: "#fff" }
|
||||
: {
|
||||
backgroundColor: "transparent",
|
||||
color: "#000",
|
||||
}
|
||||
}
|
||||
>
|
||||
{grade.label}
|
||||
</small>
|
||||
<input
|
||||
type="radio"
|
||||
name={"candidate" + candidateId}
|
||||
id={"candidateGrade" + candidateId + "-" + gradeValue}
|
||||
data-index={candidateId}
|
||||
data-id={candidate.id}
|
||||
value={grade.value}
|
||||
onClick={handleGradeClick}
|
||||
defaultChecked={judgments.find((element) => {
|
||||
return (
|
||||
JSON.stringify(element) ===
|
||||
JSON.stringify({
|
||||
id: candidate.id,
|
||||
value: gradeValue,
|
||||
})
|
||||
);
|
||||
})}
|
||||
/>
|
||||
<span
|
||||
className="checkmark"
|
||||
style={
|
||||
judgments.find(function (judgment) {
|
||||
return (
|
||||
JSON.stringify(judgment) ===
|
||||
JSON.stringify({
|
||||
id: candidate.id,
|
||||
value: gradeValue,
|
||||
})
|
||||
);
|
||||
})
|
||||
? { backgroundColor: grade.color, color: "#fff" }
|
||||
: {
|
||||
backgroundColor: "transparent",
|
||||
color: "#000",
|
||||
}
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
</Col>
|
||||
);
|
||||
})}
|
||||
</Row>
|
||||
);
|
||||
})}
|
||||
|
||||
<Row>
|
||||
<Col className="text-center">
|
||||
{judgments.length !== candidates.length ? (
|
||||
<Button
|
||||
type="button"
|
||||
onClick={handleSubmitWithoutAllRate}
|
||||
className="btn btn-dark "
|
||||
>
|
||||
<FontAwesomeIcon icon={faCheck} className="mr-2" />
|
||||
{t("Submit my vote")}
|
||||
</Button>
|
||||
) : (
|
||||
<Button type="submit" className="btn btn-success ">
|
||||
<FontAwesomeIcon icon={faCheck} className="mr-2" />
|
||||
{t("Submit my vote")}
|
||||
</Button>
|
||||
)}
|
||||
</Col>
|
||||
</Row>
|
||||
</form>
|
||||
</Container>
|
||||
);
|
||||
};
|
||||
export default VoteBallot;
|
@ -1,79 +0,0 @@
|
||||
import Head from "next/head";
|
||||
import { Col, Container, Row } from "reactstrap";
|
||||
import Link from "next/link";
|
||||
import { useTranslation } from "next-i18next";
|
||||
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
|
||||
import Paypal from "@components/banner/Paypal";
|
||||
import Gform from "@components/banner/Gform";
|
||||
import Error from "@components/Error";
|
||||
import { getDetails, apiErrors } from "@services/api";
|
||||
import config from "../../../next-i18next.config.js";
|
||||
|
||||
export async function getServerSideProps({ query: { pid }, locale }) {
|
||||
const [details, translations] = await Promise.all([
|
||||
getDetails(pid),
|
||||
serverSideTranslations(locale, [], config),
|
||||
]);
|
||||
|
||||
if (typeof details === "string" || details instanceof String) {
|
||||
return { props: { err: res.slice(1, -1), ...translations } };
|
||||
}
|
||||
|
||||
if (!details.candidates || !Array.isArray(details.candidates)) {
|
||||
return { props: { err: "Unknown error", ...translations } };
|
||||
}
|
||||
|
||||
return {
|
||||
props: {
|
||||
...translations,
|
||||
invitationOnly: details.on_invitation_only,
|
||||
restrictResults: details.restrict_results,
|
||||
candidates: details.candidates.map((name, i) => ({ id: i, label: name })),
|
||||
title: details.title,
|
||||
numGrades: details.num_grades,
|
||||
pid: pid,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
const VoteSuccess = ({ title, invitationOnly, pid, err }) => {
|
||||
const { t } = useTranslation();
|
||||
if (err && err !== "") {
|
||||
return <Error value={apiErrors(err, t)} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<Container>
|
||||
<Head>
|
||||
<title>{t("resource.voteSuccess")}</title>
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
<meta key="og:title" property="og:title" content={title} />
|
||||
<meta
|
||||
property="og:description"
|
||||
key="og:description"
|
||||
content={t("common.application")}
|
||||
/>
|
||||
</Head>
|
||||
<Row>
|
||||
<Link href="/">
|
||||
<a className="d-block ml-auto mr-auto mb-4">
|
||||
<img src="/logos/logo-line-white.svg" alt="logo" height="128" />
|
||||
</a>
|
||||
</Link>
|
||||
</Row>
|
||||
<Row className="mt-4">
|
||||
<Col className="text-center offset-lg-3" lg="6">
|
||||
<h2>{t("resource.voteSuccess")}</h2>
|
||||
<p>{t("resource.thanks")}</p>
|
||||
<div className="mt-3">
|
||||
<Gform className="btn btn-secondary" />
|
||||
</div>
|
||||
<div className="mt-5">
|
||||
<Paypal btnColor="btn-success" />
|
||||
</div>
|
||||
</Col>
|
||||
</Row>
|
||||
</Container>
|
||||
);
|
||||
};
|
||||
export default VoteSuccess;
|
Before Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 32 KiB |
@ -0,0 +1,43 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="theme-color" content="#000000" />
|
||||
<meta
|
||||
name="description"
|
||||
content="Web site created using create-react-app"
|
||||
/>
|
||||
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
|
||||
<!--
|
||||
manifest.json provides metadata used when your web app is installed on a
|
||||
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
||||
-->
|
||||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
||||
<!--
|
||||
Notice the use of %PUBLIC_URL% in the tags above.
|
||||
It will be replaced with the URL of the `public` folder during the build.
|
||||
Only files inside the `public` folder can be referenced from the HTML.
|
||||
|
||||
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
||||
work correctly both with client-side routing and a non-root public URL.
|
||||
Learn how to configure a non-root public URL by running `npm run build`.
|
||||
-->
|
||||
<title>React App</title>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
<div id="root"></div>
|
||||
<!--
|
||||
This HTML file is a template.
|
||||
If you open it directly in the browser, you will see an empty page.
|
||||
|
||||
You can add webfonts, meta tags, or analytics to this file.
|
||||
The build step will place the bundled scripts into the <body> tag.
|
||||
|
||||
To begin the development, run `npm start` or `yarn start`.
|
||||
To create a production bundle, use `npm run build` or `yarn build`.
|
||||
-->
|
||||
</body>
|
||||
</html>
|
Before Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 32 KiB |
@ -1 +0,0 @@
|
||||
{}
|
@ -1,100 +0,0 @@
|
||||
{
|
||||
"title": "Plattform mit Mehrheitswahl",
|
||||
"Homepage": "Homepage",
|
||||
"Source code": "Quellcode",
|
||||
"Who are we?": "Wer wir sind?",
|
||||
"Privacy policy": "Datenschutzerklärung",
|
||||
"resource.legalNotices": "Rechtliche Hinweise",
|
||||
"FAQ": "FAQ",
|
||||
"resource.help": "Brauchen Sie Hilfe?",
|
||||
"BetterVote": " BetterVote",
|
||||
"Voting platform": "Wahlplattform",
|
||||
"Majority Judgment": " Mehrheitswahl ",
|
||||
"Start an election": "Eine Wahl beginnen",
|
||||
"resource.candidatePlaceholder": "Name des Kandidaten/Abstimmungsvorschlags",
|
||||
"Delete?": "Löschen?",
|
||||
"Are you sure to delete": "Sind Sie sich sicher, dass Sie dies löschen möchten?",
|
||||
"the row": "die Zeile",
|
||||
"Write here your question or introduce simple your election (250 characters max.)": "Schreiben Sie hier Ihre Frage oder erklären Sie kurz ihre Wahl (bis 250 Zeichen)",
|
||||
"Enter the name of your candidate or proposal here (250 characters max.)": "Geben Sie hier den Namen Ihres Kandidaten oder Antrags ein (max. 250 Zeichen)",
|
||||
"Please add at least 2 candidates.": "Bitte geben Sie mindestens zwei Kandidaten vor. ",
|
||||
"Question of the election": "Zur Wahl stehende Frage",
|
||||
"Write here the question of your election": "Schreiben Sie hier die zur Wahl stehenden Frage",
|
||||
"For example:": "Zum Beispiel",
|
||||
"For the role of my representative, I judge this candidate...": "Meine Einschätzung des Kandidaten als meinen Repräsentanten ist …",
|
||||
"Candidates/Proposals": "Kandidaten/Abstimmungsvorschlag ",
|
||||
"Add a proposal": "Weiteren hinzufügen",
|
||||
"Advanced options": "Weitere Optionen",
|
||||
"Starting date": "Anfangsdatum",
|
||||
"Ending date": "Enddatum",
|
||||
"Defined period" : "Definierte Periode",
|
||||
"Unlimited" : "Unbegrenzt",
|
||||
"Voting time" : "Abstimmungszeit",
|
||||
"Grades": "Note",
|
||||
"You can select here the number of grades for your election": " Sie können hier die Anzahl der Noten für Ihre Wahl auswählen ",
|
||||
"5 = Excellent, Very good, Good, Fair, Passable": "5 = hervorragend, sehr gut, gut, befriedigend, ausreichend",
|
||||
"Participants": "Teilnehmer",
|
||||
"Add here participants' emails": "Fügen Sie hier die Email Adressen der Teilnehmer hinzu.",
|
||||
"List voters' emails in case the election is not opened": "Falls die Wahl noch nicht sofort geöffnet werden soll, fügen Sie die Email Adressen der Teilnehmer hier zu.",
|
||||
"Validate": "Ok",
|
||||
"Submit my vote": "Ok",
|
||||
"Confirm your vote": "Bestätigen Sie Ihre Wahl",
|
||||
"The form contains no address.": "Keine Email Adresse wurde hinzugefügt.",
|
||||
"The election will be opened to anyone with the link": "Die Wahl ist offen afür jeden, der diesen Link hat.",
|
||||
"Start the election": "Mit der Wahl beginnen.",
|
||||
"Cancel": "Abbrechen",
|
||||
"Confirm": "Ok",
|
||||
"Successful election creation!": "Die Wahl wurde erfolgreich erstellt!",
|
||||
"You can now share the election link to participants:": "Sie können nun den Teilnehmern den Link zukommen lassen.",
|
||||
"Copy": "Kopieren",
|
||||
"Here is the link for the results in real time:": " Hier ist der Link für die Ergebnisse in Echtzeit:",
|
||||
"Keep these links carefully": "Speichern Sie diesen Link an einem sicheren Ort.",
|
||||
"resource.participateBtn": "Machen Sie jetzt mit!",
|
||||
"t": "<0>Achtung</0> : Sie werden zu einem späteren Zeitpunkt keine Möglichkeit haben, diese Links abzurufen, auch wir haben keinen Zugriff darauf. Sie können aber beispielsweise diese Seite in Ihrem Browser als Lesezeichen speichern.",
|
||||
"Simple and free: organize an election with Majority Judgment.": "Einfach und kostenlos: Organisation von Mehrheitswahlen.",
|
||||
"Start": "Start",
|
||||
"No advertising or ad cookies": "Keine Werbung und auch keine Cookies zu Werbezwecken.",
|
||||
"Oops! This election does not exist or it is not available anymore.": "Ups! Diese Wahl existiert nicht oder ist nicht mehr verfügbar. ",
|
||||
"You can start another election.": "Sie können eine neue Umfrage starten.",
|
||||
"Go back to homepage": "Zurück zur Hompage",
|
||||
"You have to judge every candidate/proposal!": "Sie müssen jeden Kandidaten/Abstimmungsvorschlag bewerten!",
|
||||
"resource.voteSuccess": " Ihre Teilnahme wurde gespeichert!",
|
||||
"resource.thanks": " Vielen Dank für Ihre Teilnahme.",
|
||||
"Support us !": "Unterstützen Sie uns!",
|
||||
"PayPal - The safer, easier way to pay online!": "PayPal - Die sicherere und einfachere Art, online zu bezahlen!",
|
||||
"resource.numVotes": "Anzahl der Stimmen:",
|
||||
"Unknown error. Try again please.": "Unbekannter Fehler. Bitte versuchen Sie es erneut.",
|
||||
"Ending date:": "Enddatum:",
|
||||
"If you list voters' emails, only them will be able to access the election": "Wenn Sie die E-Mails der Wähler auflisten, haben nur diese Zugriff auf die Wahl",
|
||||
"Dates": "Datum",
|
||||
"The election will take place from": "Die Wahl findet von",
|
||||
"at": "um",
|
||||
"to": "bis",
|
||||
"Voters' list": "Wählerliste",
|
||||
"Voters received a link to vote by email. Each link can be used only once!": "Die Wähler erhielten per E-Mail einen Link zur Stimmabgabe. Jeder Link kann nur einmal verwendet werden!",
|
||||
"Results of the election:": "Ergebnisse der Wahl",
|
||||
"Graph": "Grafik",
|
||||
"Preference profile": "Präferenz-Profil",
|
||||
"Oops... The election is unknown.": "Hoppla... Die Wahl ist unbekannt.",
|
||||
"The election is still going on. You can't access now to the results.": "Die Wahl dauert noch an. Sie können jetzt nicht auf die Ergebnisse zugreifen.",
|
||||
"No votes have been recorded yet. Come back later.": "Es wurden noch keine Abstimmungen registriert. Kommen Sie später wieder.",
|
||||
"The election has not started yet.": "Die Wahlen haben noch nicht begonnen.",
|
||||
"The election is over. You can't vote anymore": "Die Wahl ist vorbei. Sie können nicht mehr wählen",
|
||||
"You need a token to vote in this election": "Sie brauchen eine Wertmarke, um an dieser Wahl teilzunehmen",
|
||||
"You seem to have already voted.": "Sie scheinen bereits abgestimmt zu haben.",
|
||||
"The parameters of the election are incorrect.": "Die Parameter der Wahl sind falsch.",
|
||||
"Access to results" : "Zugang zu den Ergebnissen",
|
||||
"Immediately": "Sofort",
|
||||
"At the end of the election": "Am Ende der Wahl",
|
||||
"Results available at the close of the vote": "Ergebnisse am Ende der Abstimmung verfügbar",
|
||||
"The results page will not be accessible until all participants have voted.":"Die Ergebnisseite wird nicht zugänglich sein, bis alle Teilnehmer abgestimmt haben.",
|
||||
"The results page will not be accessible until the end date is reached.": "Die Ergebnisseite wird nicht zugänglich sein, bis das Enddatum erreicht ist.",
|
||||
"No one will be able to see the result until the end date is reached or until all participants have voted.": "Niemand wird das Ergebnis sehen können, bis das Enddatum erreicht ist oder bis alle Teilnehmer abgestimmt haben.",
|
||||
"Send me this link" : "Senden Sie mir diesen Link",
|
||||
"Send me these links" : "Schicken Sie mir diesen Link",
|
||||
"Open" : "Öffnen Sie",
|
||||
"Voting address" : "Abstimmungs-URL",
|
||||
"Results address" : "Ergebnis-URL",
|
||||
"Share election on Facebook" : "Wahl auf Facebook teilen",
|
||||
"Share results on Facebook" : "Ergebnisse auf Facebook teilen"
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
{
|
||||
"common.vote": "Vote!",
|
||||
"common.mieuxvoter": "Better Vote",
|
||||
"common.helpus": "Do you want to help us?",
|
||||
"common.valueProp": "Simple and free: organise a vote with Majority Judgment.",
|
||||
"common.candidates": "Candidates/Proposals",
|
||||
"common.backHomepage": "Back to home page"
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
{
|
||||
"email.hello": "Hi, there! 🙂",
|
||||
"email.why": "This email was sent to you because your email was filled out to participate in the vote on the subject:",
|
||||
"email.linkVote": "The link for the vote is as follows:",
|
||||
"email.linkResult": "The link that will give you the results when they are available is as follows:",
|
||||
"email.happy": "We are happy to send you this email! You will be able to vote using majority judgment.",
|
||||
"email.copyLink": "If that doesn't work, copy and paste the following link into your browser:",
|
||||
"email.aboutjm": "If you require any further information, please visit our site.",
|
||||
"email.bye": "Good vote! 🤗"
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
{
|
||||
"error.e1": "Oops... The election is unknown",
|
||||
"error.e2": "The election is still going on. You can't access now to the results.",
|
||||
"error.e3": "No votes have been recorded yet. Come back later.",
|
||||
"error.e4": "The election has not started yet.",
|
||||
"error.e5": "The election is over. You can't vote anymore",
|
||||
"error.e6": "You need a token to vote in this election",
|
||||
"error.e7": "You seem to have already voted.",
|
||||
"error.e8": "The parameters of the election are incorrect.",
|
||||
"error.catch22": "Unknown error"
|
||||
}
|
@ -1 +0,0 @@
|
||||
{}
|
@ -1,107 +0,0 @@
|
||||
{
|
||||
"title": "Application for Majority Judgment",
|
||||
"Homepage": "Homepage",
|
||||
"Source code": "Source code",
|
||||
"Who are we?": "Who are we?",
|
||||
"Privacy policy": "Privacy policy",
|
||||
"resource.legalNotices": "Legal notices",
|
||||
"FAQ": "FAQ",
|
||||
"resource.help": "Need help?",
|
||||
"BetterVote": "BetterVote",
|
||||
"Voting platform": "Voting platform",
|
||||
"Majority Judgment": "Majority Judgment",
|
||||
"Start an election": "Start a vote",
|
||||
"Candidate/proposal ...": "Candidate/proposal...",
|
||||
"Delete?": "Confirm deletion",
|
||||
"Are you sure to delete": "Are you sure you want to delete",
|
||||
"the row": "the row",
|
||||
"resource.candidatePlaceholder": "Candidates or proposal's name",
|
||||
"resource.writeQuestionHere": "Write here your question or describe your vote (max. 250 characters)",
|
||||
"Enter the name of your candidate or proposal here (250 characters max.)": "Enter your proposal or the name of your candidate (max. 250 characters)",
|
||||
"Please add at least 2 candidates.": "Please add at least 2 candidates.",
|
||||
"resource.questionLabel": "Question of the vote",
|
||||
"resource.writeQuestion": "Write here your question or describe your vote",
|
||||
"resource.eg": "For example:",
|
||||
"resource.exampleQuestion": "For the role of my representative, I think this candidate is...",
|
||||
"Add a proposal": "Add a candidate/proposal",
|
||||
"resource.advancedOptions": "Advanced options",
|
||||
"Starting date": "Start date",
|
||||
"Ending date": "End date",
|
||||
"Defined period": "Defined period",
|
||||
"Unlimited": "Unlimited",
|
||||
"Voting time": "Voting time",
|
||||
"Grades": "Mentions",
|
||||
"You can select here the number of grades for your election": "Select here the number of mentions of your vote",
|
||||
"5 = Excellent, Very good, Good, Fair, Passable": "5 = Excellent, Very good, Good, Fair, Poor",
|
||||
"Participants": "Participants",
|
||||
"Add here participants' emails": "Add here participants' emails",
|
||||
"List voters' emails in case the election is not opened": "List participants' emails in case the election is not open",
|
||||
"Validate": "Confirm",
|
||||
"Submit my vote": "Submit my vote",
|
||||
"Confirm your vote": "Confirm your vote",
|
||||
"The form contains no address.": "The form contains no email addresses.",
|
||||
"The election will be opened to anyone with the link": "The vote will be open to anyone with the link",
|
||||
"resource.startVote": "Start the vote",
|
||||
"Cancel": "Cancel",
|
||||
"Confirm": "Confirm",
|
||||
"Successful election creation!": "Vote successfully created!",
|
||||
"You can now share the election link to participants:": "You can now share the voting link to participants:",
|
||||
"Copy": "Copy",
|
||||
"Here is the link for the results in real time:": "Here is the link for real-time results:",
|
||||
"Keep these links carefully": "Keep these links carefully",
|
||||
"resource.participateBtn": "Participate now!",
|
||||
"resource.resultsBtn": "Go to results",
|
||||
"t": "<0>Warning</0>: you will have no possibility to recover these links, and we will not be able to share them with you. For safekeeping, you can bookmark them in your browser.",
|
||||
"resource.start": "Start",
|
||||
"resource.noAds": "No advertising or ad cookies",
|
||||
"Oops! This election does not exist or it is not available anymore.": "Oops! This vote does not exist or is no longer available.",
|
||||
"You can start another election.": "You can start another vote.",
|
||||
"Go back to homepage": "Go back to homepage",
|
||||
"You have to judge every candidate/proposal!": "Please assess every candidate/proposal.",
|
||||
"resource.voteSuccess": "Your participation was successfully recorded!",
|
||||
"resource.thanks": "Thank your for your participation.",
|
||||
"Ending date:": "Ending date:",
|
||||
"Excellent": "Excellent",
|
||||
"Very good": "Very good",
|
||||
"Good": "Good",
|
||||
"Fair": "Fair",
|
||||
"Passable": "Poor",
|
||||
"Insufficient": "Insufficient",
|
||||
"To reject": "To be rejected",
|
||||
"Dates": "Dates",
|
||||
"The election will take place from": "The vote will take place from",
|
||||
"at": "at",
|
||||
"to": "to",
|
||||
"Voters' list": "List of participants' emails",
|
||||
"Graph": "Graph",
|
||||
"Preference profile": "Detailed results",
|
||||
"Results of the election:": "Results of the vote:",
|
||||
"Unknown error. Try again please.": "Unknown error. Please try again.",
|
||||
"If you list voters' emails, only them will be able to access the election": "If you list participants' emails, only they will be able to access the election",
|
||||
"Voters received a link to vote by email. Each link can be used only once!": "Participants have received a link to vote by email. Each link can be used only once.",
|
||||
"Oops... The election is unknown.": "Oops... The vote is unknown.",
|
||||
"The election is still going on. You can't access now to the results.": "The vote is on-going. You cannot access the results at this time.",
|
||||
"No votes have been recorded yet. Come back later.": "No votes have been recorded yet. Please check in later.",
|
||||
"The election has not started yet.": "The vote has not started yet.",
|
||||
"The election is over. You can't vote anymore": "The vote is over. You can no longer participate",
|
||||
"You need a token to vote in this election": "You need a valid token to participate in this vote",
|
||||
"You seem to have already voted.": "You seem to have already voted.",
|
||||
"The parameters of the election are incorrect.": "The parameters of the vote are incorrect.",
|
||||
"Support us !": "Support us!",
|
||||
"PayPal - The safer, easier way to pay online!": "PayPal - The safer, easier way to pay online!",
|
||||
"resource.numVotes": "Number of votes:",
|
||||
"Access to results": "Results availability",
|
||||
"Immediately": "Immediately",
|
||||
"At the end of the election": "At the end of the vote",
|
||||
"Results available at the close of the vote": "Results available at the close of the vote",
|
||||
"The results page will not be accessible until all participants have voted.": "The results page will not be accessible until all participants have voted.",
|
||||
"The results page will not be accessible until the end date is reached.": "The results page will not be accessible until the end date is reached.",
|
||||
"No one will be able to see the result until the end date is reached or until all participants have voted.": "No one will be able to see the results until the end date is reached or until all participants have voted.",
|
||||
"Send me this link": "Send me this link",
|
||||
"Send me these links": "Send me these links",
|
||||
"Open": "Open",
|
||||
"Voting address": "Link to the vote",
|
||||
"Results address": "Link to the results",
|
||||
"Share election on Facebook": "Share vote on Facebook",
|
||||
"Share results on Facebook": "Share results on Facebook"
|
||||
}
|
@ -1 +0,0 @@
|
||||
{}
|
@ -1 +0,0 @@
|
||||
{}
|
@ -1,108 +0,0 @@
|
||||
{
|
||||
"title": "Plataforma de Juicio Mayoritario",
|
||||
"Homepage": "Página de inicio",
|
||||
"Source code": "Código fuente",
|
||||
"Who are we": "Quiénes somos",
|
||||
"Privacy policy": "Política de privacidad",
|
||||
"resource.legalNotices": "Avisos legales",
|
||||
"FAQ": "FAQ",
|
||||
"resource.help": "¿Necesitas ayuda?",
|
||||
"BetterVote": "VotarMejor",
|
||||
"Voting platform": "Plataforma de votación",
|
||||
"Majority Judgment": "Juicio Mayoritario",
|
||||
"Start an election": "Iniciar una elección",
|
||||
"resource.candidatePlaceholder": "Nombre del(la) candidato(a)/propuesta...",
|
||||
"Delete?": "Borrar?",
|
||||
"Are you sure to delete": "Estás seguro de querer borrar",
|
||||
"the row": "la fila",
|
||||
"Write here your question or introduce simple your election (250 characters max.)": "Escriba aquí su pregunta o introduzca simplemente su elección (250 caracteres máx.)",
|
||||
"Enter the name of your candidate or proposal here (250 characters max.)": "Escriba aquí el nombre de su candidato o propuesta (250 caracteres como máximo)",
|
||||
"Please add at least 2 candidates.": "Por favor, añada al menos dos canidatos(as).",
|
||||
"Question of the election": "Pregunta de su elección",
|
||||
"Write here the question of your election": "Escriba aquí la pregunta de su elección",
|
||||
"For example:": "Por ejemplo:",
|
||||
"For the role of my representative, I judge this candidate...": "Para ser mi representante, yo elijo a este(a) candidato(a)....",
|
||||
"Candidates/Proposals": "Candidatos(as)/Propuestas",
|
||||
"Add a proposal": "Añadir una propuesta",
|
||||
"Advanced options": "Opciones avanzadas",
|
||||
"Starting date": "Fecha de inicio",
|
||||
"Ending date": "Fecha de finalización",
|
||||
"Defined period" : "Período definido",
|
||||
"Unlimited" : "Ilimitado",
|
||||
"Voting time" : "Hora de la votación",
|
||||
"Grades": "Escala",
|
||||
"You can select here the number of grades for your election": "Puede seleccionar aquí el número de niveles de la escala para su elección",
|
||||
"5 = Excellent, Very good, Good, Fair, Passable": "5 == Excelente, Muy bien, Bien, Regular, Pasable",
|
||||
"Participants:": "Participantes",
|
||||
"Add here participants' emails": "Añadir aquí los correos electrónicos de los(as) participantes",
|
||||
"List voters' emails in case the election is not opened": "Enumere los correos electrónicos de los(as) votantes en caso de que la elección no se abra",
|
||||
"Validate": "Validar",
|
||||
"Submit my vote": "Validar",
|
||||
"Confirm your vote": "Confirme su voto",
|
||||
"The form contains no address.": "El formulario no contiene ningún correo electrónico",
|
||||
"The election will be opened to anyone with the link": "La elección se abrirá a cualquiera que tenga el enlace",
|
||||
"Start the election": "Iniciar la elección",
|
||||
"Cancel": "Cancelar",
|
||||
"Confirm": "Confirmar",
|
||||
"Successful election creation!": "La elección ha sido creada con éxito!",
|
||||
"You can now share the election link to participants:": "Ahora puede compartir el enlace de la elección con los(as) participantes",
|
||||
"Copy": "Copiar",
|
||||
"Here is the link for the results in real time:": "En este enlace puedes revisar los resultados en tiempo real",
|
||||
"Keep these links carefully": "Guarda cuidadosamente estos enlaces",
|
||||
"resource.participateBtn": "¡Participa ahora!",
|
||||
"t": "<0>Advertencia</0>: No tendrás otras opciones para recuperar los enlaces, y no podremos compartirlos contigo. Por ejemplo, puedes agregarlos a favoritos de tu buscador.",
|
||||
"Simple and free: organize an election with Majority Judgment.": "Simple y gratuito: organiza una elección con Juicio Mayoritario",
|
||||
"Start": "Comenzar",
|
||||
"No advertising or ad cookies": "No contiene publicidad ni cookies publicitarias",
|
||||
"Oops! This election does not exist or it is not available anymore.": "¡Uy! Esta elección no existe o ya no está disponible",
|
||||
"You can start another election.": "Puedes empezar otra elección",
|
||||
"Go back to homepage": "Vuelve a la página de inicio",
|
||||
"You have to judge every candidate/proposal!": "¡Tienes que evaluar a todos(as) los(as) candidatos(as)/propuestas",
|
||||
"resource.voteSuccess": "¡Su participación fue registrada con éxito!",
|
||||
"resource.thanks": "Muchas gracias por participar",
|
||||
"Ending date:": "Fecha de finalización:",
|
||||
"Excellent": "Excelente",
|
||||
"Very good": "Muy bien",
|
||||
"Good": "Bien",
|
||||
"Fair": "Regular",
|
||||
"Passable": "Pasable",
|
||||
"Insufficient": "Insuficiente",
|
||||
"To reject": "Rechazar",
|
||||
"Dates": "Fechas",
|
||||
"The election will take place from": "La elección tendrá lugar desde",
|
||||
"at": "a las",
|
||||
"to": "hasta",
|
||||
"Voters' list": "Lista de votantes",
|
||||
"Graph": "Gráfico",
|
||||
"Preference profile": "Perfil de preferencia",
|
||||
"Results of the election:": "Resultados de la elección",
|
||||
"PayPal - The safer, easier way to pay online!": "PayPal la forma más segura y fácil de pagar en linea!",
|
||||
"Support us !": "¡apórtanos!",
|
||||
"Who are we?": "¿Quiénes somos?",
|
||||
"Unknown error. Try again please.": "Error desconocido. Inténtelo de nuevo, por favor.",
|
||||
"If you list voters' emails, only them will be able to access the election": "Si enumera los correos electrónicos de los votantes, sólo ellos podrán acceder a la elección",
|
||||
"Voters received a link to vote by email. Each link can be used only once!": "Los votantes recibieron un enlace para votar por correo electrónico. ¡Cada enlace puede ser usado sólo una vez!",
|
||||
"resource.numVotes": "Número de votos:",
|
||||
"Oops... The election is unknown.": "Oops... La elección es desconocida",
|
||||
"The election is still going on. You can't access now to the results.": "La elección sigue en marcha. No puedes acceder ahora a los resultados.",
|
||||
"No votes have been recorded yet. Come back later.": "Aún no se han registrado votos. Vuelva más tarde.",
|
||||
"The election has not started yet.": "Las elecciones aún no han comenzado.",
|
||||
"The election is over. You can't vote anymore": "La elección ha terminado. Ya no puedes votar.",
|
||||
"You need a token to vote in this election": "Necesitas una ficha para votar en esta elección",
|
||||
"You seem to have already voted.": "Parece que ya has votado.",
|
||||
"The parameters of the election are incorrect.": "Los parámetros de la elección son incorrectos.",
|
||||
"Access to results" : "Acceso a los resultados",
|
||||
"Immediately": "Inmediatamente",
|
||||
"At the end of the election": "Al final de la elección",
|
||||
"Results available at the close of the vote": "Resultados disponibles al cierre de la votación",
|
||||
"The results page will not be accessible until all participants have voted.":"La página de resultados no será accesible hasta que todos los participantes hayan votado.",
|
||||
"The results page will not be accessible until the end date is reached.": "No se podrá acceder a la página de resultados hasta que se alcance la fecha de finalización.",
|
||||
"No one will be able to see the result until the end date is reached or until all participants have voted.": "Nadie podrá ver el resultado hasta que se alcance la fecha final o hasta que todos los participantes hayan votado.",
|
||||
"Send me this link" : "Envíame este enlace",
|
||||
"Send me these links" : "Envíame estos enlaces",
|
||||
"Open" : "Abrir",
|
||||
"Voting address" : "URL de la votación",
|
||||
"Results address" : "URL de los resultados",
|
||||
"Share election on Facebook" : "Compartir la elección en Facebook",
|
||||
"Share results on Facebook" : "Comparte los resultados en Facebook"
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
{
|
||||
"common.vote": "Votez !",
|
||||
"common.mieuxvoter": "Mieux Voter",
|
||||
"common.helpus": "Vous souhaitez nous soutenir ?",
|
||||
"common.candidates": "Candidats/Propositions",
|
||||
"common.valueProp": "Simple et gratuit : organisez un vote avec le Jugement Majoritaire",
|
||||
"common.backHomepage": "Retour à la page d'accueil"
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
{
|
||||
"email.hello": "Bonjour ! 🙂",
|
||||
"email.why": "Vous avez été invité·e à participer à l'élection suivante : ",
|
||||
"email.linkVote": "Le lien pour voter est le suivant :",
|
||||
"email.linkResult": "A la fin de l'élection, vous pourrez accéder aux résultats en cliquant sur ce lien :",
|
||||
"email.happy": "Nous sommes très heureux de vous partager ce lien de vote ! Vous allez pouvoir voter avec le jugement majoritaire.",
|
||||
"email.copyLink": "Si le lien ne fonctionne pas, vous pouvez le copier et le coller dans la barre de navigation de votre navigateur.",
|
||||
"email.bye": "Bon vote ! 🤗",
|
||||
"email.aboutjm": "If you require any further information, please visit our site."
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
{
|
||||
"error.e1": "Impossible de retrouver le vote en question",
|
||||
"error.e2": "L'élection est encore en cours. Revenez plus tard.",
|
||||
"error.e3": "Aucun vote n'a encore été enregistré. Revenez plus tard.",
|
||||
"error.e4": "L'élection n'a pas encore démarrée.",
|
||||
"error.e5": "L'élection est terminée. Vous ne pouvez plus voter.",
|
||||
"error.e6": "Vous avez besoin d'un jeton pour participer à cette élection.",
|
||||
"error.e7": "Vous avez déjà voté pour cette élection.",
|
||||
"error.e8": "Les paramètres de l'élection sont inconnues.",
|
||||
"error.catch22": "Erreur inconnue."
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
{
|
||||
"Homepage": "Accueil",
|
||||
"Source code": "Code source",
|
||||
"Who are we": "Qui sommes-nous",
|
||||
"BetterVote": "MieuxVoter",
|
||||
"Voting platform": "Plateforme de vote",
|
||||
"Majority Judgment": "Jugement Majoritaire",
|
||||
"Start an election": "Lancer une élection",
|
||||
"resource.candidatePlaceholder": "Name du candidat/proposition",
|
||||
"Delete?": "Supprimer ?",
|
||||
"Are you sure to delete": "Êtes-vous sûr(e) de supprimer",
|
||||
"the row": "la ligne",
|
||||
"Write here your question or introduce simple your election (250 characters max.)": "Décrire ici votre question ou introduire simplement votre élection (250 caractères max.)",
|
||||
"Please add at least 2 candidates.": "Merci d'ajouter au moins 2 candidats.",
|
||||
"Question of the election": "Question de votre élection",
|
||||
"Write here the question of your election": "Ecrire ici la question de votre élection",
|
||||
"For example:": "Par exemple",
|
||||
"For the role of my representative, I judge this candidate...": "Pour être mon représentant, je juge ce candidat...",
|
||||
"Candidates/Proposals": "Candidats/Propositions",
|
||||
"Add a proposal": "Ajouter une proposition",
|
||||
"Advanced options": "Options avancées",
|
||||
"Starting date:": "Date de début :",
|
||||
"Ending date: ": "Date de fin : ",
|
||||
"Grades:": "Mentions",
|
||||
"You can select here the number of grades for your election": "You pouvez choisir ici le nombre de mentions de votre élection",
|
||||
"5 = Excellent, Very good, Good, Fair, Passable": "5 = Excellent, Très bien, Bien, Assez bien, Passable",
|
||||
"Participants:": "Participants :",
|
||||
"Add here participants' emails": "Ajouter ici les emails des participants",
|
||||
"List voters' emails in case the election is not opened": "Lister ici les emails des électeurs dans le cas où l'élection n'est pas ouverte.",
|
||||
"Validate": "Valider",
|
||||
"Confirm your vote": "Confirmer votre vote",
|
||||
"The form contains no address.": "Aucune adresse email n'a été ajoutée.",
|
||||
"The election will be opened to anyone with the link": "L'élection sera accessible à tous ceux qui disposent de ce lien",
|
||||
"Start the election": "Démarrer l'élection",
|
||||
"Cancel": "Annuler",
|
||||
"Confirm": "Valider",
|
||||
"Successful election creation!": "L'élection a été créée avec succès !",
|
||||
"You can now share the election link to participants:": "Vous pouvez maintenant partager ce lien à tous les participants",
|
||||
"Copy": "Copier",
|
||||
"Here is the link for the results in real time:": "Voici le lien pour afficher les résultats en temps réel :",
|
||||
"Keep these links carefully": "Gardez ces liens précieusement",
|
||||
"resource.participateBtn": "Participez maintenant !",
|
||||
"t": "<0>Attention</0> : vous n'aurez pas d'autres moyens pour récupérer ces liens par la suite, et nous ne serons pas capables de les partager avec vous. Vous pouvez, par exemple, ajouter ces liens à vos favoris dans votre navigateur.",
|
||||
"Simple and free: organize an election with Majority Judgment.": "Simple et grauit: organiser une élection avec le Jugement Majoritaire.",
|
||||
"Start": "Démarrer",
|
||||
"No advertising or ad cookies": "Pas de publictés, ni de cookies publicitaires",
|
||||
"Oops! This election does not exist or it is not available anymore.": "Oups ! L'élection n'existe pas ou n'est plus disponible.",
|
||||
"You can start another election.": "Vous pouvez démarrer une autre élection.",
|
||||
"Go back to homepage": "Revenir à la page d'accueil",
|
||||
"You have to judge every candidate/proposal!": "Vous devez évaluer tous les candidats/propositions !",
|
||||
"resource.voteSuccess": "Votre participation a été enregistrée avec succès !",
|
||||
"resource.thanks": "Merci de votre participation."
|
||||
}
|
@ -1,105 +0,0 @@
|
||||
{
|
||||
"title": "Application au Jugement Majoritaire",
|
||||
"Homepage": "Accueil",
|
||||
"Source code": "Code source",
|
||||
"Who are we?": "Qui sommes-nous ?",
|
||||
"Privacy policy": "Politique de confidentialité",
|
||||
"resource.legalNotices": "Mentions légales",
|
||||
"FAQ": "FAQ",
|
||||
"resource.help": "Besoin d'aide ?",
|
||||
"BetterVote": "MieuxVoter",
|
||||
"Voting platform": "Plateforme de vote",
|
||||
"Majority Judgment": "Jugement Majoritaire",
|
||||
"Start an election": "Lancer un vote",
|
||||
"resource.candidatePlaceholder": "Nom du candidat/proposition",
|
||||
"Delete?": "Supprimer ?",
|
||||
"Are you sure to delete": "Êtes-vous sûr(e) de supprimer",
|
||||
"the row": "la ligne",
|
||||
"resource.writeQuestionHere": "Décrire ici votre question ou introduire simplement votre vote (250 caractères max.)",
|
||||
"Enter the name of your candidate or proposal here (250 characters max.)": "Saisissez ici le nom de votre candidat ou de votre proposition (250 caractères max.)",
|
||||
"Please add at least 2 candidates.": "Merci d'ajouter au moins 2 candidats.",
|
||||
"resource.questionLabel": "Question de votre vote",
|
||||
"resource.writeQuestion": "Ecrire ici la question de votre vote",
|
||||
"resource.eg": "Par exemple",
|
||||
"resource.exampleQuestion": "Pour être mon représentant, je juge ce candidat...",
|
||||
"Add a proposal": "Ajouter une proposition",
|
||||
"resource.advancedOptions": "Options avancées",
|
||||
"Starting date": "Date de début",
|
||||
"Ending date": "Date de fin ",
|
||||
"Defined period": "Période définie",
|
||||
"Unlimited": "Illimitée",
|
||||
"Voting time": "Durée du vote",
|
||||
"Grades": "Mentions",
|
||||
"You can select here the number of grades for your election": "You pouvez choisir ici le nombre de mentions de votre vote",
|
||||
"5 = Excellent, Very good, Good, Fair, Passable": "5 = Excellent, Très bien, Bien, Assez bien, Passable",
|
||||
"Participants": "Participants",
|
||||
"Add here participants' emails": "Ajouter ici les emails des participants",
|
||||
"List voters' emails in case the election is not opened": "Lister ici les emails des électeurs dans le cas où le vote n'est pas ouverte.",
|
||||
"Validate": "Valider",
|
||||
"Submit my vote": "Enregistrer mon vote",
|
||||
"Confirm your vote": "Confirmer votre vote",
|
||||
"The form contains no address.": "Aucune adresse email n'a été ajoutée.",
|
||||
"The election will be opened to anyone with the link": "Le vote sera accessible à tous ceux qui disposent du lien",
|
||||
"resource.startVote": "Démarrer le vote",
|
||||
"Cancel": "Annuler",
|
||||
"Confirm": "Valider",
|
||||
"Successful election creation!": "Le vote a été créé avec succès !",
|
||||
"You can now share the election link to participants:": "Vous pouvez maintenant partager ce lien à tous les participants",
|
||||
"Copy": "Copier",
|
||||
"Here is the link for the results in real time:": "Voici le lien pour afficher les résultats en temps réel :",
|
||||
"Keep these links carefully": "Gardez ces liens précieusement",
|
||||
"resource.participateBtn": "Participez maintenant !",
|
||||
"resource.resultsBtn": "Résultats",
|
||||
"t": "<0>Attention</0> : vous n'aurez pas d'autres moyens pour récupérer ces liens par la suite, et nous ne serons pas capables de les partager avec vous. Vous pouvez, par exemple, ajouter ces liens à vos favoris dans votre navigateur.",
|
||||
"resource.start": "Démarrer",
|
||||
"resource.noAds": "Pas de publicités, ni de cookies publicitaires",
|
||||
"Oops! This election does not exist or it is not available anymore.": "Oups ! Le vote n'existe pas ou n'est plus disponible.",
|
||||
"You can start another election.": "Vous pouvez démarrer une autre vote.",
|
||||
"Go back to homepage": "Revenir à la page d'accueil",
|
||||
"You have to judge every candidate/proposal!": "Vous devez évaluer tous les candidats/propositions !",
|
||||
"resource.voteSuccess": "Votre participation a été enregistrée avec succès !",
|
||||
"resource.thanks": "Merci de votre participation.",
|
||||
"Excellent": "Excellent",
|
||||
"Very good": "Très bien",
|
||||
"Good": "Bien",
|
||||
"Fair": "Assez bien",
|
||||
"Passable": "Passable",
|
||||
"Insufficient": "Insuffisant",
|
||||
"To reject": "A rejeter",
|
||||
"Dates": "Dates",
|
||||
"The election will take place from": "Le vote se déroulera du",
|
||||
"at": "à",
|
||||
"to": "au",
|
||||
"Voters' list": "Listes des électeurs",
|
||||
"Graph": "Graphique",
|
||||
"Preference profile": "Profil de mérites",
|
||||
"Results of the election:": "Résultats du vote",
|
||||
"Unknown error. Try again please.": "Erreur inconnue. Merci de ré-essayer plus tard.",
|
||||
"If you list voters' emails, only them will be able to access the election": "Si vous ajoutez des emails, seulement ceux-là seront capables d'accéder au vote",
|
||||
"Voters received a link to vote by email. Each link can be used only once!": "Les électeurs ont reçu un lien par courriel pour voter. Chaque lien ne peut être utilisé qu'une seule fois.",
|
||||
"Oops... The election is unknown.": "Oups... Le serveur ne retrouve pas le vote.",
|
||||
"The election is still going on. You can't access now to the results.": "le vote est encore en cours. Vous ne pouvez pas encore accéder aux résultats.",
|
||||
"No votes have been recorded yet. Come back later.": "Aucun vote n'a été enregistré. Merci de revenir plus tard.",
|
||||
"The election has not started yet.": "le vote n'a pas encore commencé.",
|
||||
"The election is over. You can't vote anymore": "le vote est terminée. Vous ne pouvez plus voter.",
|
||||
"You need a token to vote in this election": "Vous avez besoin d'un jeton pour participer à ce vote",
|
||||
"You seem to have already voted.": "Il semble que vous ayez déjà voté.",
|
||||
"The parameters of the election are incorrect.": "Les paramètres de vote sont incorrects.",
|
||||
"Support us !": "Soutenez-nous !",
|
||||
"PayPal - The safer, easier way to pay online!": "PayPal - Le moyen le plus sûr et le plus simple de payer en ligne !",
|
||||
"resource.numVotes": "Nombre de votes :",
|
||||
"Access to results": "Accès aux résultats",
|
||||
"Immediately": "Immédiatement",
|
||||
"At the end of the election": "A la clôture du vote",
|
||||
"Results available at the close of the vote": "Résultats disponibles à la clôture du vote",
|
||||
"The results page will not be accessible until all participants have voted.": "La page de résultats ne sera pas accessible tant que tous les participants n'auront pas voté.",
|
||||
"The results page will not be accessible until the end date is reached.": "La page de résultats ne sera pas accessible tant que la date de fin ne sera pas atteinte.",
|
||||
"No one will be able to see the result until the end date is reached or until all participants have voted.": "Personne ne pourra voir le résultat tant que la date de fin n'est pas atteinte ou que tous les participants n'ont pas voté.",
|
||||
"Send me this link": "Envoyez-moi ce lien",
|
||||
"Send me these links": "Envoyez-moi ces liens",
|
||||
"Open": "Ouvrir",
|
||||
"Voting address": "Adresse du vote",
|
||||
"Results address": "Adresse des résultats",
|
||||
"Share election on Facebook": "Partager le vote sur Facebook",
|
||||
"Share results on Facebook": "Partager ces résultats sur Facebook"
|
||||
}
|
@ -1 +0,0 @@
|
||||
{}
|
@ -1 +0,0 @@
|
||||
{}
|
After Width: | Height: | Size: 5.2 KiB |
After Width: | Height: | Size: 9.4 KiB |
Before Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 4.7 KiB |
Before Width: | Height: | Size: 4.7 KiB |
Before Width: | Height: | Size: 4.7 KiB |
Before Width: | Height: | Size: 1.9 KiB |
@ -0,0 +1,25 @@
|
||||
{
|
||||
"short_name": "React App",
|
||||
"name": "Create React App Sample",
|
||||
"icons": [
|
||||
{
|
||||
"src": "favicon.ico",
|
||||
"sizes": "64x64 32x32 24x24 16x16",
|
||||
"type": "image/x-icon"
|
||||
},
|
||||
{
|
||||
"src": "logo192.png",
|
||||
"type": "image/png",
|
||||
"sizes": "192x192"
|
||||
},
|
||||
{
|
||||
"src": "logo512.png",
|
||||
"type": "image/png",
|
||||
"sizes": "512x512"
|
||||
}
|
||||
],
|
||||
"start_url": ".",
|
||||
"display": "standalone",
|
||||
"theme_color": "#000000",
|
||||
"background_color": "#ffffff"
|
||||
}
|
Before Width: | Height: | Size: 2.9 KiB |
@ -0,0 +1,3 @@
|
||||
# https://www.robotstxt.org/robotstxt.html
|
||||
User-agent: *
|
||||
Disallow:
|
@ -1,191 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
// Do this as the first thing so that any code reading it knows the right env.
|
||||
process.env.BABEL_ENV = 'production';
|
||||
process.env.NODE_ENV = 'production';
|
||||
|
||||
// Makes the script crash on unhandled rejections instead of silently
|
||||
// ignoring them. In the future, promise rejections that are not handled will
|
||||
// terminate the Node.js process with a non-zero exit code.
|
||||
process.on('unhandledRejection', err => {
|
||||
throw err;
|
||||
});
|
||||
|
||||
// Ensure environment variables are read.
|
||||
require('../config/env');
|
||||
|
||||
|
||||
const path = require('path');
|
||||
const chalk = require('react-dev-utils/chalk');
|
||||
const fs = require('fs-extra');
|
||||
const webpack = require('webpack');
|
||||
const configFactory = require('../config/webpack.config');
|
||||
const paths = require('../config/paths');
|
||||
const checkRequiredFiles = require('react-dev-utils/checkRequiredFiles');
|
||||
const formatWebpackMessages = require('react-dev-utils/formatWebpackMessages');
|
||||
const printHostingInstructions = require('react-dev-utils/printHostingInstructions');
|
||||
const FileSizeReporter = require('react-dev-utils/FileSizeReporter');
|
||||
const printBuildError = require('react-dev-utils/printBuildError');
|
||||
|
||||
const measureFileSizesBeforeBuild =
|
||||
FileSizeReporter.measureFileSizesBeforeBuild;
|
||||
const printFileSizesAfterBuild = FileSizeReporter.printFileSizesAfterBuild;
|
||||
const useYarn = fs.existsSync(paths.yarnLockFile);
|
||||
|
||||
// These sizes are pretty large. We'll warn for bundles exceeding them.
|
||||
const WARN_AFTER_BUNDLE_GZIP_SIZE = 512 * 1024;
|
||||
const WARN_AFTER_CHUNK_GZIP_SIZE = 1024 * 1024;
|
||||
|
||||
const isInteractive = process.stdout.isTTY;
|
||||
|
||||
// Warn and crash if required files are missing
|
||||
if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Generate configuration
|
||||
const config = configFactory('production');
|
||||
|
||||
// We require that you explicitly set browsers and do not fall back to
|
||||
// browserslist defaults.
|
||||
const { checkBrowsers } = require('react-dev-utils/browsersHelper');
|
||||
checkBrowsers(paths.appPath, isInteractive)
|
||||
.then(() => {
|
||||
// First, read the current file sizes in build directory.
|
||||
// This lets us display how much they changed later.
|
||||
return measureFileSizesBeforeBuild(paths.appBuild);
|
||||
})
|
||||
.then(previousFileSizes => {
|
||||
// Remove all content but keep the directory so that
|
||||
// if you're in it, you don't end up in Trash
|
||||
fs.emptyDirSync(paths.appBuild);
|
||||
// Merge with the public folder
|
||||
copyPublicFolder();
|
||||
// Start the webpack build
|
||||
return build(previousFileSizes);
|
||||
})
|
||||
.then(
|
||||
({ stats, previousFileSizes, warnings }) => {
|
||||
if (warnings.length) {
|
||||
console.log(chalk.yellow('Compiled with warnings.\n'));
|
||||
console.log(warnings.join('\n\n'));
|
||||
console.log(
|
||||
'\nSearch for the ' +
|
||||
chalk.underline(chalk.yellow('keywords')) +
|
||||
' to learn more about each warning.'
|
||||
);
|
||||
console.log(
|
||||
'To ignore, add ' +
|
||||
chalk.cyan('// eslint-disable-next-line') +
|
||||
' to the line before.\n'
|
||||
);
|
||||
} else {
|
||||
console.log(chalk.green('Compiled successfully.\n'));
|
||||
}
|
||||
|
||||
console.log('File sizes after gzip:\n');
|
||||
printFileSizesAfterBuild(
|
||||
stats,
|
||||
previousFileSizes,
|
||||
paths.appBuild,
|
||||
WARN_AFTER_BUNDLE_GZIP_SIZE,
|
||||
WARN_AFTER_CHUNK_GZIP_SIZE
|
||||
);
|
||||
console.log();
|
||||
|
||||
const appPackage = require(paths.appPackageJson);
|
||||
const publicUrl = paths.publicUrl;
|
||||
const publicPath = config.output.publicPath;
|
||||
const buildFolder = path.relative(process.cwd(), paths.appBuild);
|
||||
printHostingInstructions(
|
||||
appPackage,
|
||||
publicUrl,
|
||||
publicPath,
|
||||
buildFolder,
|
||||
useYarn
|
||||
);
|
||||
},
|
||||
err => {
|
||||
console.log(chalk.red('Failed to compile.\n'));
|
||||
printBuildError(err);
|
||||
process.exit(1);
|
||||
}
|
||||
)
|
||||
.catch(err => {
|
||||
if (err && err.message) {
|
||||
console.log(err.message);
|
||||
}
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
// Create the production build and print the deployment instructions.
|
||||
function build(previousFileSizes) {
|
||||
// We used to support resolving modules according to `NODE_PATH`.
|
||||
// This now has been deprecated in favor of jsconfig/tsconfig.json
|
||||
// This lets you use absolute paths in imports inside large monorepos:
|
||||
if (process.env.NODE_PATH) {
|
||||
console.log(
|
||||
chalk.yellow(
|
||||
'Setting NODE_PATH to resolve modules absolutely has been deprecated in favor of setting baseUrl in jsconfig.json (or tsconfig.json if you are using TypeScript) and will be removed in a future major release of create-react-app.'
|
||||
)
|
||||
);
|
||||
console.log();
|
||||
}
|
||||
|
||||
console.log('Creating an optimized production build...');
|
||||
|
||||
const compiler = webpack(config);
|
||||
return new Promise((resolve, reject) => {
|
||||
compiler.run((err, stats) => {
|
||||
let messages;
|
||||
if (err) {
|
||||
if (!err.message) {
|
||||
return reject(err);
|
||||
}
|
||||
messages = formatWebpackMessages({
|
||||
errors: [err.message],
|
||||
warnings: [],
|
||||
});
|
||||
} else {
|
||||
messages = formatWebpackMessages(
|
||||
stats.toJson({ all: false, warnings: true, errors: true })
|
||||
);
|
||||
}
|
||||
if (messages.errors.length) {
|
||||
// Only keep the first error. Others are often indicative
|
||||
// of the same problem, but confuse the reader with noise.
|
||||
if (messages.errors.length > 1) {
|
||||
messages.errors.length = 1;
|
||||
}
|
||||
return reject(new Error(messages.errors.join('\n\n')));
|
||||
}
|
||||
if (
|
||||
process.env.CI &&
|
||||
(typeof process.env.CI !== 'string' ||
|
||||
process.env.CI.toLowerCase() !== 'false') &&
|
||||
messages.warnings.length
|
||||
) {
|
||||
console.log(
|
||||
chalk.yellow(
|
||||
'\nTreating warnings as errors because process.env.CI = true.\n' +
|
||||
'Most CI servers set it automatically.\n'
|
||||
)
|
||||
);
|
||||
return reject(new Error(messages.warnings.join('\n\n')));
|
||||
}
|
||||
|
||||
return resolve({
|
||||
stats,
|
||||
previousFileSizes,
|
||||
warnings: messages.warnings,
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function copyPublicFolder() {
|
||||
fs.copySync(paths.appPublic, paths.appBuild, {
|
||||
dereference: true,
|
||||
filter: file => file !== paths.appHtml,
|
||||
});
|
||||
}
|
@ -1,145 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
// Do this as the first thing so that any code reading it knows the right env.
|
||||
process.env.BABEL_ENV = 'development';
|
||||
process.env.NODE_ENV = 'development';
|
||||
|
||||
// Makes the script crash on unhandled rejections instead of silently
|
||||
// ignoring them. In the future, promise rejections that are not handled will
|
||||
// terminate the Node.js process with a non-zero exit code.
|
||||
process.on('unhandledRejection', err => {
|
||||
throw err;
|
||||
});
|
||||
|
||||
// Ensure environment variables are read.
|
||||
require('../config/env');
|
||||
|
||||
|
||||
const fs = require('fs');
|
||||
const chalk = require('react-dev-utils/chalk');
|
||||
const webpack = require('webpack');
|
||||
const WebpackDevServer = require('webpack-dev-server');
|
||||
const clearConsole = require('react-dev-utils/clearConsole');
|
||||
const checkRequiredFiles = require('react-dev-utils/checkRequiredFiles');
|
||||
const {
|
||||
choosePort,
|
||||
createCompiler,
|
||||
prepareProxy,
|
||||
prepareUrls,
|
||||
} = require('react-dev-utils/WebpackDevServerUtils');
|
||||
const openBrowser = require('react-dev-utils/openBrowser');
|
||||
const paths = require('../config/paths');
|
||||
const configFactory = require('../config/webpack.config');
|
||||
const createDevServerConfig = require('../config/webpackDevServer.config');
|
||||
|
||||
const useYarn = fs.existsSync(paths.yarnLockFile);
|
||||
const isInteractive = process.stdout.isTTY;
|
||||
|
||||
// Warn and crash if required files are missing
|
||||
if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Tools like Cloud9 rely on this.
|
||||
const DEFAULT_PORT = parseInt(process.env.PORT, 10) || 3000;
|
||||
const HOST = process.env.HOST || '0.0.0.0';
|
||||
|
||||
if (process.env.HOST) {
|
||||
console.log(
|
||||
chalk.cyan(
|
||||
`Attempting to bind to HOST environment variable: ${chalk.yellow(
|
||||
chalk.bold(process.env.HOST)
|
||||
)}`
|
||||
)
|
||||
);
|
||||
console.log(
|
||||
`If this was unintentional, check that you haven't mistakenly set it in your shell.`
|
||||
);
|
||||
console.log(
|
||||
`Learn more here: ${chalk.yellow('https://bit.ly/CRA-advanced-config')}`
|
||||
);
|
||||
console.log();
|
||||
}
|
||||
|
||||
// We require that you explicitly set browsers and do not fall back to
|
||||
// browserslist defaults.
|
||||
const { checkBrowsers } = require('react-dev-utils/browsersHelper');
|
||||
checkBrowsers(paths.appPath, isInteractive)
|
||||
.then(() => {
|
||||
// We attempt to use the default port but if it is busy, we offer the user to
|
||||
// run on a different port. `choosePort()` Promise resolves to the next free port.
|
||||
return choosePort(HOST, DEFAULT_PORT);
|
||||
})
|
||||
.then(port => {
|
||||
if (port == null) {
|
||||
// We have not found a port.
|
||||
return;
|
||||
}
|
||||
const config = configFactory('development');
|
||||
const protocol = process.env.HTTPS === 'true' ? 'https' : 'http';
|
||||
const appName = require(paths.appPackageJson).name;
|
||||
const useTypeScript = fs.existsSync(paths.appTsConfig);
|
||||
const urls = prepareUrls(protocol, HOST, port);
|
||||
const devSocket = {
|
||||
warnings: warnings =>
|
||||
devServer.sockWrite(devServer.sockets, 'warnings', warnings),
|
||||
errors: errors =>
|
||||
devServer.sockWrite(devServer.sockets, 'errors', errors),
|
||||
};
|
||||
// Create a webpack compiler that is configured with custom messages.
|
||||
const compiler = createCompiler({
|
||||
appName,
|
||||
config,
|
||||
devSocket,
|
||||
urls,
|
||||
useYarn,
|
||||
useTypeScript,
|
||||
webpack,
|
||||
});
|
||||
// Load proxy config
|
||||
const proxySetting = require(paths.appPackageJson).proxy;
|
||||
const proxyConfig = prepareProxy(proxySetting, paths.appPublic);
|
||||
// Serve webpack assets generated by the compiler over a web server.
|
||||
const serverConfig = createDevServerConfig(
|
||||
proxyConfig,
|
||||
urls.lanUrlForConfig
|
||||
);
|
||||
const devServer = new WebpackDevServer(compiler, serverConfig);
|
||||
// Launch WebpackDevServer.
|
||||
devServer.listen(port, HOST, err => {
|
||||
if (err) {
|
||||
return console.log(err);
|
||||
}
|
||||
if (isInteractive) {
|
||||
clearConsole();
|
||||
}
|
||||
|
||||
// We used to support resolving modules according to `NODE_PATH`.
|
||||
// This now has been deprecated in favor of jsconfig/tsconfig.json
|
||||
// This lets you use absolute paths in imports inside large monorepos:
|
||||
if (process.env.NODE_PATH) {
|
||||
console.log(
|
||||
chalk.yellow(
|
||||
'Setting NODE_PATH to resolve modules absolutely has been deprecated in favor of setting baseUrl in jsconfig.json (or tsconfig.json if you are using TypeScript) and will be removed in a future major release of create-react-app.'
|
||||
)
|
||||
);
|
||||
console.log();
|
||||
}
|
||||
|
||||
console.log(chalk.cyan('Starting the development server...\n'));
|
||||
openBrowser(urls.localUrlForBrowser);
|
||||
});
|
||||
|
||||
['SIGINT', 'SIGTERM'].forEach(function(sig) {
|
||||
process.on(sig, function() {
|
||||
devServer.close();
|
||||
process.exit();
|
||||
});
|
||||
});
|
||||
})
|
||||
.catch(err => {
|
||||
if (err && err.message) {
|
||||
console.log(err.message);
|
||||
}
|
||||
process.exit(1);
|
||||
});
|
@ -1,52 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
// Do this as the first thing so that any code reading it knows the right env.
|
||||
process.env.BABEL_ENV = 'test';
|
||||
process.env.NODE_ENV = 'test';
|
||||
process.env.PUBLIC_URL = '';
|
||||
|
||||
// Makes the script crash on unhandled rejections instead of silently
|
||||
// ignoring them. In the future, promise rejections that are not handled will
|
||||
// terminate the Node.js process with a non-zero exit code.
|
||||
process.on('unhandledRejection', err => {
|
||||
throw err;
|
||||
});
|
||||
|
||||
// Ensure environment variables are read.
|
||||
require('../config/env');
|
||||
|
||||
|
||||
const jest = require('jest');
|
||||
const execSync = require('child_process').execSync;
|
||||
let argv = process.argv.slice(2);
|
||||
|
||||
function isInGitRepository() {
|
||||
try {
|
||||
execSync('git rev-parse --is-inside-work-tree', { stdio: 'ignore' });
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function isInMercurialRepository() {
|
||||
try {
|
||||
execSync('hg --cwd . root', { stdio: 'ignore' });
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Watch unless on CI or explicitly running all tests
|
||||
if (
|
||||
!process.env.CI &&
|
||||
argv.indexOf('--watchAll') === -1
|
||||
) {
|
||||
// https://github.com/facebook/create-react-app/issues/5210
|
||||
const hasSourceControl = isInGitRepository() || isInMercurialRepository();
|
||||
argv.push(hasSourceControl ? '--watch' : '--watchAll');
|
||||
}
|
||||
|
||||
|
||||
jest.run(argv);
|
@ -1,228 +0,0 @@
|
||||
const api = {
|
||||
urlServer:
|
||||
process.env.NEXT_PUBLIC_SERVER_URL || "https://demo.mieuxvoter.fr/api/",
|
||||
feedbackForm:
|
||||
process.env.NEXT_PUBLIC_FEEDBACK_FORM ||
|
||||
"https://docs.google.com/forms/d/e/1FAIpQLScuTsYeBXOSJAGSE_AFraFV7T2arEYua7UCM4NRBSCQQfRB6A/viewform",
|
||||
routesServer: {
|
||||
setElection: "election/",
|
||||
getElection: "election/get/:slug/",
|
||||
getResults: "election/results/:slug",
|
||||
voteElection: "election/vote/",
|
||||
},
|
||||
};
|
||||
|
||||
const sendInviteMail = (res) => {
|
||||
/**
|
||||
* Send an invitation mail using a micro-service with Netlify
|
||||
*/
|
||||
const { id, title, mails, tokens, locale } = res;
|
||||
|
||||
if (!mails || !mails.length) {
|
||||
throw new Error("No emails are provided.");
|
||||
}
|
||||
|
||||
if (mails.length !== tokens.length) {
|
||||
throw new Error("The number of emails differ from the number of tokens");
|
||||
}
|
||||
|
||||
const origin =
|
||||
typeof window !== "undefined" && window.location.origin
|
||||
? window.location.origin
|
||||
: "http://localhost";
|
||||
const urlVote = (pid, token) => new URL(`/vote/${pid}/${token}`, origin);
|
||||
const urlResult = (pid) => new URL(`/result/${pid}`, origin);
|
||||
|
||||
const recipientVariables = {};
|
||||
tokens.forEach((token, index) => {
|
||||
recipientVariables[mails[index]] = {
|
||||
urlVote: urlVote(id, token),
|
||||
urlResult: urlResult(id),
|
||||
};
|
||||
});
|
||||
|
||||
const req = fetch("/.netlify/functions/send-invite-email/", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
recipientVariables,
|
||||
title,
|
||||
locale,
|
||||
}),
|
||||
});
|
||||
|
||||
return req.then((any) => res);
|
||||
};
|
||||
|
||||
const createElection = (
|
||||
title,
|
||||
candidates,
|
||||
{
|
||||
/**
|
||||
* Create an election from its title, its candidates and a bunch of options
|
||||
*/
|
||||
mails,
|
||||
numGrades,
|
||||
start,
|
||||
finish,
|
||||
restrictResult,
|
||||
locale,
|
||||
},
|
||||
successCallback,
|
||||
failureCallback
|
||||
) => {
|
||||
const endpoint = new URL(api.routesServer.setElection, api.urlServer);
|
||||
|
||||
console.log(endpoint.href);
|
||||
const onInvitationOnly = mails && mails.length > 0;
|
||||
|
||||
fetch(endpoint.href, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
title,
|
||||
candidates,
|
||||
on_invitation_only: onInvitationOnly,
|
||||
num_grades: numGrades,
|
||||
elector_emails: mails || [],
|
||||
start_at: start,
|
||||
finish_at: finish,
|
||||
select_language: locale || "en",
|
||||
front_url: window.location.origin,
|
||||
restrict_results: restrictResult,
|
||||
send_mail: false,
|
||||
}),
|
||||
})
|
||||
.then((response) => {
|
||||
if (!response.ok) {
|
||||
throw Error(response.statusText);
|
||||
}
|
||||
return response.json();
|
||||
})
|
||||
.then((res) => {
|
||||
if (onInvitationOnly) {
|
||||
return sendInviteMail({ locale, mails: mails, ...res });
|
||||
}
|
||||
return res;
|
||||
})
|
||||
.then(successCallback)
|
||||
.catch(failureCallback || console.log);
|
||||
};
|
||||
|
||||
const getResults = (pid, successCallback, failureCallback) => {
|
||||
/**
|
||||
* Fetch results from external API
|
||||
*/
|
||||
|
||||
const endpoint = new URL(
|
||||
api.routesServer.getResults.replace(new RegExp(":slug", "g"), pid),
|
||||
api.urlServer
|
||||
);
|
||||
|
||||
return fetch(endpoint.href)
|
||||
.then((response) => {
|
||||
if (!response.ok) {
|
||||
return Promise.reject(response.text());
|
||||
}
|
||||
return response.json();
|
||||
})
|
||||
.then(successCallback || ((res) => res))
|
||||
.catch(failureCallback || ((err) => err));
|
||||
};
|
||||
|
||||
const getDetails = (pid, successCallback, failureCallback) => {
|
||||
/**
|
||||
* Fetch data from external API
|
||||
*/
|
||||
|
||||
const detailsEndpoint = new URL(
|
||||
api.routesServer.getElection.replace(new RegExp(":slug", "g"), pid),
|
||||
api.urlServer
|
||||
);
|
||||
return fetch(detailsEndpoint.href)
|
||||
.then((response) => {
|
||||
if (!response.ok) {
|
||||
return Promise.reject(response.text());
|
||||
}
|
||||
return response.json();
|
||||
})
|
||||
.then(successCallback || ((res) => res))
|
||||
.catch(failureCallback || ((err) => err))
|
||||
.then((res) => res);
|
||||
};
|
||||
|
||||
const castBallot = (judgments, pid, token, callbackSuccess, callbackError) => {
|
||||
/**
|
||||
* Save a ballot on the remote database
|
||||
*/
|
||||
|
||||
const endpoint = new URL(api.routesServer.voteElection, api.urlServer);
|
||||
|
||||
const payload = {
|
||||
election: pid,
|
||||
grades_by_candidate: judgments,
|
||||
};
|
||||
if (token && token !== "") {
|
||||
payload["token"] = token;
|
||||
}
|
||||
|
||||
fetch(endpoint.href, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(payload),
|
||||
})
|
||||
.then(callbackSuccess || ((res) => res))
|
||||
.catch(callbackError || console.log);
|
||||
};
|
||||
|
||||
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 apiErrors = (error, t) => {
|
||||
if (error.includes(UNKNOWN_ELECTION_ERROR)) {
|
||||
return t("error.e1");
|
||||
}
|
||||
if (error.includes(ONGOING_ELECTION_ERROR)) {
|
||||
return t("error.e2");
|
||||
}
|
||||
if (error.includes(NO_VOTE_ERROR)) {
|
||||
return t("error.e3");
|
||||
}
|
||||
if (error.includes(ELECTION_NOT_STARTED_ERROR)) {
|
||||
return t("error.e4");
|
||||
}
|
||||
if (error.includes(ELECTION_FINISHED_ERROR)) {
|
||||
return t("error.e5");
|
||||
}
|
||||
if (error.includes(INVITATION_ONLY_ERROR)) {
|
||||
return t("error.e6");
|
||||
}
|
||||
if (error.includes(USED_TOKEN_ERROR)) {
|
||||
return t("error.e7");
|
||||
}
|
||||
if (error.includes(WRONG_ELECTION_ERROR)) {
|
||||
return t("error.e8");
|
||||
} else {
|
||||
return t("error.catch22");
|
||||
}
|
||||
};
|
||||
|
||||
export {
|
||||
api,
|
||||
getDetails,
|
||||
getResults,
|
||||
createElection,
|
||||
sendInviteMail,
|
||||
castBallot,
|
||||
};
|