import {type AxiosResponse} from "axios"; import {AuthApi} from "~/utils/AuthApi"; import type {Account} from "~/auth/Account"; export class Session { static COOKIE = "session"; constructor ( public user: Account, public token: string ) {} static create(sessionCreation: SessionCreation, onSuccess: (token: string) => void, onError: () => void) { AuthApi.post("/sessions", sessionCreation) .then((response: AxiosResponse) => { onSuccess(response.data); }) .catch(() => { onError(); }); } } export class SessionCreation { constructor ( public email?: string, public password?: string ) {} }