From 30069d197c01462f146e3ba1af0fd611abaf2f04 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Guhur Date: Thu, 5 Jan 2023 11:45:15 +0100 Subject: [PATCH] fix: url serverg --- components/admin/ConfirmField.tsx | 1 - pages/admin/[pid]/[tid].tsx | 1 - pages/ballot/[pid]/[[...tid]].tsx | 1 - services/ElectionContext.tsx | 7 ------ services/api.ts | 15 +++++------ services/constants.ts | 42 ++++++++++++++++++++----------- 6 files changed, 34 insertions(+), 33 deletions(-) diff --git a/components/admin/ConfirmField.tsx b/components/admin/ConfirmField.tsx index 5a44270..0ab1c32 100644 --- a/components/admin/ConfirmField.tsx +++ b/components/admin/ConfirmField.tsx @@ -142,7 +142,6 @@ const ConfirmField = ({ onSubmit, onSuccess, onFailure }) => { !hasEnoughGrades(election) || !canBeFinished(election); - console.log(election.grades); return ( 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, diff --git a/services/constants.ts b/services/constants.ts index 971c437..7c02860 100644 --- a/services/constants.ts +++ b/services/constants.ts @@ -2,17 +2,19 @@ * 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(',') : [ - 'grades.very-good', - 'grades.good', - 'grades.passable', - 'grades.inadequate', - 'grades.mediocre', - ]; + 'grades.very-good', + 'grades.good', + 'grades.passable', + 'grades.inadequate', + 'grades.mediocre', + ]; export const IMGPUSH_URL = process.env.NEXT_PUBLIC_IMGPUSH_URL || 'https://imgpush.mieuxvoter.fr'; export const GRADE_COLORS = [ @@ -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/';