Includes business, customer, and super-admin apps with shared packages and production deploy scripts. Co-authored-by: Cursor <cursoragent@cursor.com>
21 lines
567 B
TypeScript
21 lines
567 B
TypeScript
import { apiRequest, setTokens, clearTokens } from '../lib/api'
|
|
import type { LoginResponse, MeResponse } from '../types/auth'
|
|
|
|
export async function login(cellNumber: string, password: string) {
|
|
const data = await apiRequest<LoginResponse>('/auth/login', {
|
|
method: 'POST',
|
|
body: { cellNumber, password },
|
|
})
|
|
|
|
setTokens(data.accessToken, data.refreshToken)
|
|
return data
|
|
}
|
|
|
|
export async function fetchCurrentUser(signal?: AbortSignal) {
|
|
return apiRequest<MeResponse>('/auth/me', { auth: true, signal })
|
|
}
|
|
|
|
export function logout() {
|
|
clearTokens()
|
|
}
|