Compare commits
No commits in common. "85b178ca07172d4a55b7886f0e599efa3f00df3a" and "4cd5994798ea1cd4be7efbd9b3064954cb7bb2c6" have entirely different histories.
85b178ca07
...
4cd5994798
3 changed files with 47 additions and 3883 deletions
|
@ -1,39 +1,53 @@
|
|||
const API_URL = "https://ale-dev.teck-developer.com/api";
|
||||
const API_URL = "http://localhost:8000/api";
|
||||
|
||||
const getAllRoutes = async () => {
|
||||
let data = [];
|
||||
|
||||
const response = await fetch(`${API_URL}/all-routes`);
|
||||
const json = await response.json();
|
||||
data = json;
|
||||
if (import.meta.env.DEV && import.meta.env.PROD) {
|
||||
const response = await fetch(`${API_URL}/all-routes`);
|
||||
const json = await response.json();
|
||||
data = json;
|
||||
} else {
|
||||
data = (await import('./mock/routes.json')).default;
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
const getRouteCategories = async () => {
|
||||
let data = [];
|
||||
|
||||
const response = await fetch(`${API_URL}/route-categories`);
|
||||
const json = await response.json();
|
||||
data = json;
|
||||
if (import.meta.env.DEV && import.meta.env.PROD) {
|
||||
const response = await fetch(`${API_URL}/route-categories`);
|
||||
const json = await response.json();
|
||||
data = json;
|
||||
} else {
|
||||
data = (await import('./mock/routeCategories.json')).default;
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
const getRouteByCategory = async (categoryId: number) => {
|
||||
let data = [];
|
||||
const response = await fetch(`${API_URL}/route-by-category/${categoryId}`);
|
||||
const json = await response.json();
|
||||
data = json;
|
||||
if (import.meta.env.DEV && import.meta.env.PROD) {
|
||||
const response = await fetch(`${API_URL}/route-by-category/${categoryId}`);
|
||||
const json = await response.json();
|
||||
data = json;
|
||||
} else {
|
||||
data = (await import('./mock/routeByCategory.json')).default;
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
const getRoute = async (routeId: number) => {
|
||||
let data = {};
|
||||
const response = await fetch(`${API_URL}/route/${routeId}`);
|
||||
const json = await response.json();
|
||||
data = json;
|
||||
if (import.meta.env.DEV && import.meta.env.PROD) {
|
||||
const response = await fetch(`${API_URL}/route/${routeId}`);
|
||||
const json = await response.json();
|
||||
data = json;
|
||||
} else {
|
||||
data = (await import('./mock/route.json')).default;
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
@ -41,18 +55,30 @@ const getRoute = async (routeId: number) => {
|
|||
|
||||
const getSport = async (routeId: number, sportId: number) => {
|
||||
let data = {};
|
||||
const response = await fetch(`${API_URL}/route/${routeId}/${sportId}`);
|
||||
const json = await response.json();
|
||||
data = json;
|
||||
if (import.meta.env.DEV && import.meta.env.PROD) {
|
||||
const response = await fetch(`${API_URL}/route/${routeId}/${sportId}`);
|
||||
const json = await response.json();
|
||||
data = json;
|
||||
} else {
|
||||
data = (await import('./mock/sport.json')).default;
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
const downloadGPX = async (routeId: number, sportId: number) => {
|
||||
// Code for downloading this gpx
|
||||
}
|
||||
|
||||
const getPlacemarks = async (routeId: number, sportId: number) => {
|
||||
let data = {};
|
||||
const response = await fetch(`${API_URL}/getPlacemarks/${routeId}/${sportId}`);
|
||||
const json = await response.json();
|
||||
data = json;
|
||||
if (import.meta.env.DEV && import.meta.env.PROD) {
|
||||
const response = await fetch(`${API_URL}/getPlacemarks/${routeId}/${sportId}`);
|
||||
const json = await response.json();
|
||||
data = json;
|
||||
} else {
|
||||
data = (await import('./mock/placemark.json')).default;
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue