This commit is contained in:
E
2021-03-07 19:21:31 -07:00
parent d08a6e77f4
commit 963939d511
27 changed files with 123 additions and 9 deletions

View File

@@ -1,6 +1,7 @@
import { Client } from '../types'
import axios from 'axios'
import { client, clients, session } from '../data'
import settings from '../settings'
const apiUrl = '/api'
@@ -9,12 +10,12 @@ export const createClient = async (body: Client) => {
}
export const getClients = async (): Promise<Client[]> => {
return clients
if (settings.env === 'jank') return clients
const res = await axios.post<Client[]>(`${apiUrl}/clients`)
return res.data
}
export const getClient = async (id: string): Promise<Client> => {
return client
if (settings.env === 'jank') return client
const res = await axios.post<Client>(`${apiUrl}/client/${id}`)
return res.data
}
@@ -27,7 +28,7 @@ export const startSession = async (clientId: string) => {
export const getSession = async (
clientId: string,
): Promise<null | string[]> => {
return session
if (settings.env === 'jank') return session
const res = await axios.get(`${apiUrl}/clients/${clientId}/session`)
return res.data as null | string[]
}