diff --git a/.env.production b/.env.production index cc70e9d..6ff4dc3 100644 --- a/.env.production +++ b/.env.production @@ -1,2 +1,3 @@ VITE_APP_NAME="DOADIFY PRODUCTION" -VITE_HEADER_TAG= \ No newline at end of file +VITE_HEADER_TAG= +BASE_API_URL="https://ticket-office.dataesr.ovh" diff --git a/.env.staging b/.env.staging index 8d59dfd..eb5cf9d 100644 --- a/.env.staging +++ b/.env.staging @@ -1,2 +1,3 @@ VITE_APP_NAME="DOADIFY STAGING" -VITE_HEADER_TAG=Staging \ No newline at end of file +VITE_HEADER_TAG=Staging +BASE_API_URL="https://ticket-office.staging.dataesr.ovh" diff --git a/client/src/api/send-mail/index.tsx b/client/src/api/send-mail/index.tsx index 691c59c..5c2b7cc 100644 --- a/client/src/api/send-mail/index.tsx +++ b/client/src/api/send-mail/index.tsx @@ -24,9 +24,10 @@ function EmailSender({ contribution, refetch }: EmailSenderProps) { ); const isDevelopment = import.meta.env.VITE_HEADER_TAG === "Development"; + const url = import.meta.env.BASE_API_URL; const apiBaseUrl = isDevelopment ? "http://localhost:3000/api/send-email" - : "https://ticket-office.staging.dataesr.ovh/api/send-email"; + : `${url}/api/send-email`; useEffect(() => { const profileFromLocalStorage = localStorage.getItem("selectedProfile"); diff --git a/client/src/api/utils/buildURL.tsx b/client/src/api/utils/buildURL.tsx index d721a3c..5b4dfae 100644 --- a/client/src/api/utils/buildURL.tsx +++ b/client/src/api/utils/buildURL.tsx @@ -8,9 +8,8 @@ export const buildURL = ( fromApplication?: string ): string => { const isDevelopment = import.meta.env.VITE_HEADER_TAG === "Development"; - const baseApiUrl = isDevelopment - ? "http://localhost:3000/api" - : `https://ticket-office.staging.dataesr.ovh/api`; + const url = import.meta.env.BASE_API_URL; + const baseApiUrl = isDevelopment ? "http://localhost:3000/api" : `${url}/api`; let baseUrl = "contacts"; if (location?.pathname?.includes("scanr-contributionPage")) { diff --git a/client/src/components/edit-modal/index.tsx b/client/src/components/edit-modal/index.tsx index bdc7bdb..9295794 100644 --- a/client/src/components/edit-modal/index.tsx +++ b/client/src/components/edit-modal/index.tsx @@ -51,9 +51,10 @@ const EditModal: React.FC = ({ } const isDevelopment = import.meta.env.VITE_HEADER_TAG === "Development"; + const baseURL = import.meta.env.BASE_API_URL; const url = isDevelopment ? `http://localhost:3000/api/${basePath}/${data?.id}` - : `https://ticket-office.staging.dataesr.ovh/api/${basePath}/${data?.id}`; + : `${baseURL}/api/${basePath}/${data?.id}`; useEffect(() => { if (!selectedProfile) { diff --git a/client/src/config/api.ts b/client/src/config/api.ts index a298815..a292d44 100644 --- a/client/src/config/api.ts +++ b/client/src/config/api.ts @@ -5,23 +5,24 @@ export const postHeaders = { ...headers, "Content-Type": "application/json", }; +const url = import.meta.env.VITE_BASE_API_URL || ""; export const contributionUrl = isDevelopment ? "http://localhost:3000/api/contribute?max_results=2000" - : "https://ticket-office.staging.dataesr.ovh/api/contribute?max_results=2000"; + : `${url}/api/contribute?max_results=2000`; export const contactUrl = isDevelopment ? "http://localhost:3000/api/contacts?max_results=2000" - : "https://ticket-office.staging.dataesr.ovh/api/contacts?max_results=2000"; + : `${url}api/contacts?max_results=2000`; export const productionUrl = isDevelopment ? "http://localhost:3000/api/production?max_results=2000" - : "https://ticket-office.staging.dataesr.ovh/api/productionsmax_results=2000"; + : `${url}/api/productionsmax_results=2000`; export const nameChangeUrl = isDevelopment ? "http://localhost:3000/api/update-user-data?max_results=2000" - : "https://ticket-office.staging.dataesr.ovh/api/update-user-datamax_results=2000"; + : `${url}/api/update-user-datamax_results=2000`; export const removeUserUrl = isDevelopment ? "http://localhost:3000/api/remove-user?max_results=2000" - : "https://ticket-office.staging.dataesr.ovh/api/remove-usermax_results=2000"; + : `${url}/api/remove-usermax_results=2000"`; diff --git a/server/routes/contacts/post/index.ts b/server/routes/contacts/post/index.ts index d898a4d..7fb6f61 100644 --- a/server/routes/contacts/post/index.ts +++ b/server/routes/contacts/post/index.ts @@ -57,8 +57,8 @@ postContactsRoutes.post( ...newContribution, id: result.insertedId.toHexString(), }; - - const contributionLink = `https://ticket-office.staging.dataesr.ovh/${body.fromApplication}-contact?page=1&query=${finalContribution.id}&searchInMessage=false&sort=DESC&status=choose`; + const url = process.env.BASE_API_URL; + const contributionLink = `${url}/${body.fromApplication}-contact?page=1&query=${finalContribution.id}&searchInMessage=false&sort=DESC&status=choose`; const BREVO_API_KEY = process.env.BREVO_API_KEY; if (!BREVO_API_KEY) { diff --git a/server/routes/contributionObjectRoutes/post/index.ts b/server/routes/contributionObjectRoutes/post/index.ts index 91a1011..6334818 100644 --- a/server/routes/contributionObjectRoutes/post/index.ts +++ b/server/routes/contributionObjectRoutes/post/index.ts @@ -54,7 +54,8 @@ postContributionObjectRoutes.post( id: result.insertedId.toHexString(), }; - const contributionLink = `https://ticket-office.staging.dataesr.ovh/scanr-contributionPage?page=1&query=${finalContribution.id}&searchInMessage=false&sort=DESC&status=choose`; + const url = process.env.BASE_API_URL; + const contributionLink = `${url}/scanr-contributionPage?page=1&query=${finalContribution.id}&searchInMessage=false&sort=DESC&status=choose`; const BREVO_API_KEY = process.env.BREVO_API_KEY; if (!BREVO_API_KEY) { diff --git a/server/routes/productions/post/index.ts b/server/routes/productions/post/index.ts index 8c1dfe2..3e69b58 100644 --- a/server/routes/productions/post/index.ts +++ b/server/routes/productions/post/index.ts @@ -44,7 +44,8 @@ postProductionRoutes.post( id: result.insertedId.toHexString(), }; - const contributionLink = `https://ticket-office.staging.dataesr.ovh/scanr-apioperations?page=1&query=${finalContribution.id}&searchInMessage=false&sort=DESC&status=choose`; + const url = process.env.BASE_API_URL; + const contributionLink = `${url}//scanr-apioperations?page=1&query=${finalContribution.id}&searchInMessage=false&sort=DESC&status=choose`; const BREVO_API_KEY = process.env.BREVO_API_KEY; if (!BREVO_API_KEY) { diff --git a/server/routes/remove-user/post/index.ts b/server/routes/remove-user/post/index.ts index 2be8810..f3b19e4 100644 --- a/server/routes/remove-user/post/index.ts +++ b/server/routes/remove-user/post/index.ts @@ -44,7 +44,8 @@ postRemoveUserRoutes.post( id: result.insertedId.toHexString(), }; - const contributionLink = `https://ticket-office.staging.dataesr.ovh/scanr-removeuser?page=1&query=${finalContribution.id}&searchInMessage=false&sort=DESC&status=choose`; + const url = process.env.BASE_API_URL; + const contributionLink = `${url}/scanr-removeuser?page=1&query=${finalContribution.id}&searchInMessage=false&sort=DESC&status=choose`; const BREVO_API_KEY = process.env.BREVO_API_KEY; if (!BREVO_API_KEY) { diff --git a/server/routes/update-user-data/post/index.ts b/server/routes/update-user-data/post/index.ts index 93dbd47..1a83996 100644 --- a/server/routes/update-user-data/post/index.ts +++ b/server/routes/update-user-data/post/index.ts @@ -50,7 +50,8 @@ postUpdateUserDataRoutes.post( id: result.insertedId.toHexString(), }; - const contributionLink = `https://ticket-office.staging.dataesr.ovh/scanr-namechange?page=1&query=${finalContribution.id}&searchInMessage=false&sort=DESC&status=choose`; + const url = process.env.BASE_API_URL; + const contributionLink = `${url}/scanr-namechange?page=1&query=${finalContribution.id}&searchInMessage=false&sort=DESC&status=choose`; const BREVO_API_KEY = process.env.BREVO_API_KEY; if (!BREVO_API_KEY) {