Skip to content

Commit

Permalink
Merge pull request #35 from AntaresSimulatorTeam/fix/url_back_end
Browse files Browse the repository at this point in the history
feat:make back url variable
  • Loading branch information
marlenetienne authored Jan 22, 2025
2 parents f7d8d00 + e67883b commit 1ba042e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/pages/pegase/home/components/studyService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

import { notifyToast } from '@/shared/notification/notification';
import { getEnvVariables } from '@/envVariables';

interface StudyData {
name: string;
Expand All @@ -14,10 +15,11 @@ interface StudyData {
horizon: string;
trajectoryIds: number[];
}
const BASE_URL = getEnvVariables('VITE_BACK_END_BASE_URL');

export const saveStudy = async (studyData: StudyData, toggleModal: () => void) => {
try {
const response = await fetch('http://localhost:8093/v1/study', {
const response = await fetch(`${BASE_URL}/v1/study`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand All @@ -42,7 +44,7 @@ export const saveStudy = async (studyData: StudyData, toggleModal: () => void) =
}
};
export const fetchSuggestedKeywords = async (query: string): Promise<string[]> => {
const response = await fetch(`http://localhost:8093/v1/study/keywords/search?partialName=${query}`);
const response = await fetch(`${BASE_URL}/v1/study/keywords/search?partialName=${query}`);
if (!response.ok) {
throw new Error('Failed to fetch suggested keywords');
}
Expand All @@ -52,7 +54,7 @@ export const fetchSuggestedKeywords = async (query: string): Promise<string[]> =

export const handleDelete = async (id: number) => {
try {
const response = await fetch(`http://localhost:8093/v1/study/${id}`, {
const response = await fetch(`${BASE_URL}/v1/study/${id}`, {
method: 'DELETE',
});
if (!response.ok) {
Expand Down
4 changes: 3 additions & 1 deletion src/pages/pegase/studies/ProjectInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@
// src/components/ProjectInput.tsx
import React, { useState, useEffect } from 'react';
import { RdsInputText } from 'rte-design-system-react';
import { getEnvVariables } from '@/envVariables';

interface ProjectManagerProps {
value: string;
onChange: (value: string) => void;
}
const BASE_URL = getEnvVariables('VITE_BACK_END_BASE_URL');

const fetchProjects = async (query: string): Promise<string[]> => {
const response = await fetch(`http://localhost:8093/v1/project/autocomplete?partialName=${query}`);
const response = await fetch(`${BASE_URL}/v1/project/autocomplete?partialName=${query}`);
if (!response.ok) {
throw new Error('Failed to fetch projects');
}
Expand Down

0 comments on commit 1ba042e

Please sign in to comment.