test: add client services

This commit is contained in:
Vladislav Syrochkin 2025-06-10 17:06:19 +05:00
parent 958f00069f
commit 15bc323ee4
4 changed files with 39 additions and 0 deletions

View File

@ -0,0 +1,22 @@
import api from '../api/api';
import { useUserStore } from '../store/user';
import { Auth } from '../types/auth';
export class AuthService {
static async login(auth: Auth) {
const token = await api.login(auth);
console.log(token)
localStorage.setItem('accessToken', token.accessToken);
}
static async logout() {
useUserStore.getState().removeUser();
localStorage.removeItem('userInfo');
localStorage.removeItem('accessToken');
}
static async refresh() {
const token = await api.refreshToken();
localStorage.setItem('accessToken', token.accessToken);
}
}

View File

@ -0,0 +1,10 @@
import api from '../api/api';
import { User } from '../types/user';
export class UserService {
static async getProfile(): Promise<User> {
const user = api.getProfile();
return user;
}
}

6
package-lock.json generated Normal file
View File

@ -0,0 +1,6 @@
{
"name": "connect",
"lockfileVersion": 3,
"requires": true,
"packages": {}
}

1
package.json Normal file
View File

@ -0,0 +1 @@
{}