fix: url serverg

pull/89/head
Pierre-Louis Guhur 1 year ago
parent 5c067adbf0
commit 30069d197c

@ -142,7 +142,6 @@ const ConfirmField = ({ onSubmit, onSuccess, onFailure }) => {
!hasEnoughGrades(election) ||
!canBeFinished(election);
console.log(election.grades);
return (
<Container
fluid="xl"

@ -58,7 +58,6 @@ export async function getServerSideProps({ query, locale }) {
}));
const description = JSON.parse(payload.description);
const randomOrder = description.randomOrder;
console.log('FORCE CLOSE', payload.force_close);
const context: ElectionContextInterface = {
name: payload.name,

@ -56,7 +56,6 @@ export async function getServerSideProps({ query: { pid, tid }, locale }) {
!election.candidates ||
!Array.isArray(election.candidates)
) {
console.log(election);
return { notFound: true };
}

@ -155,13 +155,6 @@ function electionReducer(
*/
switch (action.type) {
case ElectionTypes.RESET: {
console.log(
'RESETTING',
election.name,
action.value.name,
election.ref,
action.value.ref
);
return { ...action.value };
}
case ElectionTypes.SET: {

@ -1,10 +1,7 @@
import { Candidate, Grade, Vote } from './type';
import { URL_SERVER } from './constants';
export const api = {
urlServer: process.env.NEXT_PUBLIC_SERVER_URL || 'https://api.mieuxvoter.fr/',
feedbackForm:
process.env.NEXT_PUBLIC_FEEDBACK_FORM ||
'https://docs.google.com/forms/d/e/1FAIpQLScuTsYeBXOSJAGSE_AFraFV7T2arEYua7UCM4NRBSCQQfRB6A/viewform',
routesServer: {
setElection: 'elections',
getElection: 'elections/:slug',
@ -102,7 +99,7 @@ export const createElection = async (
/**
* Create an election from its title, its candidates and a bunch of options
*/
const endpoint = new URL(api.routesServer.setElection, api.urlServer);
const endpoint = new URL(api.routesServer.setElection, URL_SERVER);
if (!restricted && numVoters > 0) {
throw Error('Set the election as not restricted!');
@ -163,7 +160,7 @@ export const updateElection = async (
/**
* Create an election from its title, its candidates and a bunch of options
*/
const endpoint = new URL(api.routesServer.setElection, api.urlServer);
const endpoint = new URL(api.routesServer.setElection, URL_SERVER);
try {
const req = await fetch(endpoint.href, {
@ -208,7 +205,7 @@ export const getResults = async (
const endpoint = new URL(
api.routesServer.getResults.replace(new RegExp(':slug', 'g'), pid),
api.urlServer
URL_SERVER
);
try {
@ -235,7 +232,7 @@ export const getElection = async (
new RegExp(':slug', 'g'),
pid
);
const endpoint = new URL(path, api.urlServer);
const endpoint = new URL(path, URL_SERVER);
try {
const response = await fetch(endpoint.href);
@ -260,7 +257,7 @@ export const castBallot = (
* Save a ballot on the remote database
*/
const endpoint = new URL(api.routesServer.voteElection, api.urlServer);
const endpoint = new URL(api.routesServer.voteElection, URL_SERVER);
const payload = {
election_ref: election.ref,

@ -2,8 +2,10 @@
* This file provides useful constants for the project
*/
export const MAX_NUM_CANDIDATES = process.env.NEXT_PUBLIC_MAX_NUM_CANDIDATES || 1000;
export const CONTACT_MAIL = process.env.NEXT_PUBLIC_CONTACT_MAIL || 'app@mieuxvoter.fr';
export const MAX_NUM_CANDIDATES =
process.env.NEXT_PUBLIC_MAX_NUM_CANDIDATES || 1000;
export const CONTACT_MAIL =
process.env.NEXT_PUBLIC_CONTACT_MAIL || 'app@mieuxvoter.fr';
export const DEFAULT_GRADES = process.env.NEXT_PUBLIC_DEFAULT_GRADES
? process.env.NEXT_PUBLIC_DEFAULT_GRADES.split(',')
: [
@ -25,12 +27,24 @@ export const GRADE_COLORS = [
'#F2F0FF',
];
export const FORM_FEEDBACK = process.env.NEXT_PUBLIC_FORM_FEEDBACK || "https://forms.gle/JZ1Mtbz8gt3Fpwnx5";
export const FORM_FEEDBACK =
process.env.NEXT_PUBLIC_FORM_FEEDBACK ||
'https://forms.gle/JZ1Mtbz8gt3Fpwnx5';
export const PAYPAL = process.env.NEXT_PUBLIC_PAYPAL || "https://www.paypal.com/donate/?hosted_button_id=QD6U4D323WV4S";
export const PAYPAL =
process.env.NEXT_PUBLIC_PAYPAL ||
'https://www.paypal.com/donate/?hosted_button_id=QD6U4D323WV4S';
export const BETTER_VOTE_LINK = process.env.NEXT_PUBLIC_BETTER_VOTE || "https://mieuxvoter.fr";
export const BETTER_VOTE_LINK =
process.env.NEXT_PUBLIC_BETTER_VOTE || 'https://mieuxvoter.fr';
export const MAJORITY_JUDGMENT_LINK = process.env.NEXT_PUBLIC_MAJORITY_JUDGMENT || "https://mieuxvoter.fr/le-jugement-majoritaire";
export const WHO_WE_ARE_LINK = process.env.NEXT_PUBLIC_WHO_WE_ARE || "https://mieuxvoter.fr/qui-sommes-nous";
export const NEWS_LINK = process.env.NEXT_PUBLIC_NEWS || "https://mieuxvoter.fr/presse";
export const MAJORITY_JUDGMENT_LINK =
process.env.NEXT_PUBLIC_MAJORITY_JUDGMENT ||
'https://mieuxvoter.fr/le-jugement-majoritaire';
export const WHO_WE_ARE_LINK =
process.env.NEXT_PUBLIC_WHO_WE_ARE || 'https://mieuxvoter.fr/qui-sommes-nous';
export const NEWS_LINK =
process.env.NEXT_PUBLIC_NEWS || 'https://mieuxvoter.fr/presse';
export const URL_SERVER =
process.env.NEXT_PUBLIC_BACKEND_URL || 'https://api.mieuxvoter.fr/';

Loading…
Cancel
Save