Skip to content

Commit

Permalink
fix(base-api-url): replace url
Browse files Browse the repository at this point in the history
  • Loading branch information
Mihoub2 committed Oct 9, 2024
1 parent 5565475 commit d82b88a
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 18 deletions.
3 changes: 2 additions & 1 deletion .env.production
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
VITE_APP_NAME="DOADIFY PRODUCTION"
VITE_HEADER_TAG=
VITE_HEADER_TAG=
BASE_API_URL="https://ticket-office.dataesr.ovh"
3 changes: 2 additions & 1 deletion .env.staging
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
VITE_APP_NAME="DOADIFY STAGING"
VITE_HEADER_TAG=Staging
VITE_HEADER_TAG=Staging
BASE_API_URL="https://ticket-office.staging.dataesr.ovh"
3 changes: 2 additions & 1 deletion client/src/api/send-mail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
5 changes: 2 additions & 3 deletions client/src/api/utils/buildURL.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
Expand Down
3 changes: 2 additions & 1 deletion client/src/components/edit-modal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ const EditModal: React.FC<EditModalProps> = ({
}

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) {
Expand Down
11 changes: 6 additions & 5 deletions client/src/config/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"`;
4 changes: 2 additions & 2 deletions server/routes/contacts/post/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion server/routes/contributionObjectRoutes/post/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion server/routes/productions/post/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion server/routes/remove-user/post/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion server/routes/update-user-data/post/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit d82b88a

Please sign in to comment.