Files
Horux360/apps/web/lib/api/auth.ts
Consultoria AS 9986bc1dd3 feat(web): add login and register pages with auth store
- API client with token refresh interceptor
- Auth API functions (login, register, logout, getMe)
- Auth store with Zustand persistence
- Auth layout with centered card design
- Login page with form validation
- Register page with company and user data
- Environment example file

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 02:01:29 +00:00

23 lines
804 B
TypeScript

import { apiClient } from './client';
import type { LoginRequest, RegisterRequest, LoginResponse } from '@horux/shared';
export async function login(data: LoginRequest): Promise<LoginResponse> {
const response = await apiClient.post<LoginResponse>('/auth/login', data);
return response.data;
}
export async function register(data: RegisterRequest): Promise<LoginResponse> {
const response = await apiClient.post<LoginResponse>('/auth/register', data);
return response.data;
}
export async function logout(): Promise<void> {
const refreshToken = localStorage.getItem('refreshToken');
await apiClient.post('/auth/logout', { refreshToken });
}
export async function getMe(): Promise<LoginResponse['user']> {
const response = await apiClient.get('/auth/me');
return response.data.user;
}