From 6e9f3791917c7d221946bd314552a981d181f22b Mon Sep 17 00:00:00 2001 From: Mihoub Date: Wed, 29 May 2024 08:32:19 +0200 Subject: [PATCH] fix(urls): redo url for staging --- src/api/send-mail/index.tsx | 22 ++++++++++------------ src/api/utils/buildURL.tsx | 4 ++-- src/components/edit-modal/index.tsx | 4 ++-- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/api/send-mail/index.tsx b/src/api/send-mail/index.tsx index 5f61276..9c75440 100644 --- a/src/api/send-mail/index.tsx +++ b/src/api/send-mail/index.tsx @@ -51,9 +51,8 @@ function EmailSender({

${userResponse}

`, }; - console.log(contribution); - // const responseBrevo = await fetch("/email/", { - const responseBrevo = await fetch("https://api.brevo.com/v3/smtp/email", { + const responseBrevo = await fetch("/email/", { + // const responseBrevo = await fetch("https://api.brevo.com/v3/smtp/email", { method: "POST", headers: { "api-key": import.meta.env.VITE_BREVO_API_AUTHORIZATION, @@ -71,15 +70,14 @@ function EmailSender({ responseFrom: selectedProfile, }; - // const responseScanR = await fetch(`/api/${basePath}/${contribution._id}`, { - const responseScanR = await fetch( - `https://scanr-api.dataesr.ovh/${basePath}/${contribution._id}`, - { - method: "PATCH", - headers: postHeaders, - body: JSON.stringify(dataForScanR), - } - ); + const responseScanR = await fetch(`/api/${basePath}/${contribution._id}`, { + // const responseScanR = await fetch( + // `https://scanr-api.dataesr.ovh/${basePath}/${contribution._id}`, + // { + method: "PATCH", + headers: postHeaders, + body: JSON.stringify(dataForScanR), + }); if (!responseScanR.ok) { throw new Error(`HTTP error! status: ${responseScanR.status}`); diff --git a/src/api/utils/buildURL.tsx b/src/api/utils/buildURL.tsx index 262e689..1b65271 100644 --- a/src/api/utils/buildURL.tsx +++ b/src/api/utils/buildURL.tsx @@ -29,6 +29,6 @@ export const buildURL = ( const whereQuery = Object.keys(where).length > 0 ? `&where=${JSON.stringify(where)}` : ""; - // return `/api/${baseUrl}?${sorted}&page=${page}&max_results=20${whereQuery}`; - return `https://scanr-api.dataesr.ovh/${baseUrl}?${sorted}&page=${page}&max_results=20${whereQuery}`; + return `/api/${baseUrl}?${sorted}&page=${page}&max_results=20${whereQuery}`; + // return `https://scanr-api.dataesr.ovh/${baseUrl}?${sorted}&page=${page}&max_results=20${whereQuery}`; }; diff --git a/src/components/edit-modal/index.tsx b/src/components/edit-modal/index.tsx index d65e5a6..292f3f7 100644 --- a/src/components/edit-modal/index.tsx +++ b/src/components/edit-modal/index.tsx @@ -78,8 +78,8 @@ const EditModal: React.FC = ({ const handleSubmit = async () => { try { const response = await fetch( - `https://scanr-api.dataesr.ovh/${basePath}/${data._id}`, - // `${window.location.origin}/api/${basePath}/${data._id}`, + // `https://scanr-api.dataesr.ovh/${basePath}/${data._id}`, + `${window.location.origin}/api/${basePath}/${data._id}`, { method: "PATCH", headers: postHeaders,