You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

46 lines
1.2 KiB

import { Client } from '../types'
import axios from 'axios'
import { client, clients, session } from '../data'
const apiUrl = '/api'
export const createClient = async (body: Client) => {
await axios.post(`${apiUrl}/clients`, body)
}
export const getClients = async (): Promise<Client[]> => {
return clients
const res = await axios.post<Client[]>(`${apiUrl}/clients`)
return res.data
}
export const getClient = async (id: string): Promise<Client> => {
return client
const res = await axios.post<Client>(`${apiUrl}/client/${id}`)
return res.data
}
export const startSession = async (clientId: string) => {
//
const res = await axios.post(`${apiUrl}/clients/${clientId}/session`)
return res.data // session data
}
export const getSession = async (
clientId: string,
): Promise<null | string[]> => {
return session
const res = await axios.get(`${apiUrl}/clients/${clientId}/session`)
return res.data as null | string[]
}
export const killSession = async (clientId: string) => {
await axios.delete(`${apiUrl}/clients/${clientId}/session`)
}
export const restartSession = async (clientId: string) => {
await killSession(clientId)
await startSession(clientId)
}
export const cleanup = () => {
// send
}