From 17285d480eea4434c048a9c5c042f4f2b529587f Mon Sep 17 00:00:00 2001 From: Andrew Lalis Date: Tue, 24 Jan 2023 12:51:36 +0100 Subject: [PATCH] Reformatted stuff. --- gymboard-app/src/api/gymboard-api.ts | 73 +++++++++++++------------ gymboard-app/src/api/gymboard-search.ts | 4 ++ 2 files changed, 43 insertions(+), 34 deletions(-) diff --git a/gymboard-app/src/api/gymboard-api.ts b/gymboard-app/src/api/gymboard-api.ts index 64f83d6..c220984 100644 --- a/gymboard-app/src/api/gymboard-api.ts +++ b/gymboard-app/src/api/gymboard-api.ts @@ -1,49 +1,54 @@ 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, - location: { - latitude: number, - longitude: number - }, - streetAddress: string + countryCode: string; + countryName: string; + cityShortName: string; + cityName: string; + createdAt: Date; + shortName: string; + displayName: string; + websiteUrl: string | null; + location: { + latitude: number; + longitude: number; + }; + streetAddress: string; }; -export async function getGym(countryCode: string, cityShortName: string, gymShortName: string): Promise { - const response = await api.get(`/gyms/${countryCode}/${cityShortName}/${gymShortName}`); - const d = response.data; - const gym: Gym = { - countryCode: d.countryCode, - countryName: d.countryName, - cityShortName: d.cityShortName, - cityName: d.cityName, - createdAt: new Date(d.createdAt), - shortName: d.shortName, - displayName: d.displayName, - websiteUrl: d.websiteUrl, - location: d.location, - streetAddress: d.streetAddress - }; - return gym; +export async function getGym( + countryCode: string, + cityShortName: string, + gymShortName: string +): Promise { + const response = await api.get( + `/gyms/${countryCode}/${cityShortName}/${gymShortName}` + ); + const d = response.data; + return { + countryCode: d.countryCode, + countryName: d.countryName, + cityShortName: d.cityShortName, + cityName: d.cityName, + createdAt: new Date(d.createdAt), + shortName: d.shortName, + displayName: d.displayName, + websiteUrl: d.websiteUrl, + location: d.location, + streetAddress: d.streetAddress, + }; } export function getGymRoute(gym: GymIdentifiable): string { - return `/g/${gym.countryCode}/${gym.cityShortName}/${gym.shortName}` + return `/g/${gym.countryCode}/${gym.cityShortName}/${gym.shortName}`; } diff --git a/gymboard-app/src/api/gymboard-search.ts b/gymboard-app/src/api/gymboard-search.ts index 4879fe1..4df48c6 100644 --- a/gymboard-app/src/api/gymboard-search.ts +++ b/gymboard-app/src/api/gymboard-search.ts @@ -1,3 +1,7 @@ +/** + * Module for interacting with the Gymboard search service's API. + */ + import axios from 'axios'; const api = axios.create({