Reformatted stuff.

This commit is contained in:
Andrew Lalis 2023-01-24 12:51:36 +01:00
parent d5244de1ce
commit 17285d480e
2 changed files with 43 additions and 34 deletions

View File

@ -1,35 +1,41 @@
import axios from 'axios';
const api = axios.create({
baseURL: 'http://localhost:8080'
baseURL: 'http://localhost:8080',
});
export interface GymIdentifiable {
countryCode: string,
cityShortName: string,
shortName: string
countryCode: string;
cityShortName: string;
shortName: string;
}
export type Gym = {
countryCode: string,
countryName: string,
cityShortName: string,
cityName: string,
createdAt: Date,
shortName: string,
displayName: string,
websiteUrl: string | null,
countryCode: string;
countryName: string;
cityShortName: string;
cityName: string;
createdAt: Date;
shortName: string;
displayName: string;
websiteUrl: string | null;
location: {
latitude: number,
longitude: number
},
streetAddress: string
latitude: number;
longitude: number;
};
streetAddress: string;
};
export async function getGym(countryCode: string, cityShortName: string, gymShortName: string): Promise<Gym> {
const response = await api.get(`/gyms/${countryCode}/${cityShortName}/${gymShortName}`);
export async function getGym(
countryCode: string,
cityShortName: string,
gymShortName: string
): Promise<Gym> {
const response = await api.get(
`/gyms/${countryCode}/${cityShortName}/${gymShortName}`
);
const d = response.data;
const gym: Gym = {
return {
countryCode: d.countryCode,
countryName: d.countryName,
cityShortName: d.cityShortName,
@ -39,11 +45,10 @@ export async function getGym(countryCode: string, cityShortName: string, gymShor
displayName: d.displayName,
websiteUrl: d.websiteUrl,
location: d.location,
streetAddress: d.streetAddress
streetAddress: d.streetAddress,
};
return gym;
}
export function getGymRoute(gym: GymIdentifiable): string {
return `/g/${gym.countryCode}/${gym.cityShortName}/${gym.shortName}`
return `/g/${gym.countryCode}/${gym.cityShortName}/${gym.shortName}`;
}

View File

@ -1,3 +1,7 @@
/**
* Module for interacting with the Gymboard search service's API.
*/
import axios from 'axios';
const api = axios.create({