ifixkart-admin/New admin panel/ikixkart-dashboard/services/api/authService.ts
Adithiyan bbd3a3e959 feat: initial commit — full platform snapshot
- Backend: FastAPI app with all models, services, schemas, routes
- Admin Panel: Next.js dashboard with all modules
  (CRM, POS, repairs, warranties, billing, notifications, etc.)
- Ecommerce: storefront (submodule) + product catalog
- AI Agents: .agents/ skill library for Antigravity IDE
- Docs: architecture, billing, notification gateway markdown
- Submodules: Backend/OpenWA, Ecommerce/File 2/storefront
2026-10-13 12:59:47 +05:30

40 lines
982 B
TypeScript

import { apiFetch, setAccessToken, clearTokens } from './client';
import { API_ENDPOINTS } from './config';
export interface LoginPayload {
email: string;
password: string;
device_fingerprint?: string;
latitude?: number;
longitude?: number;
location_name?: string;
}
export interface TokenResponse {
access_token: string;
refresh_token: string;
token_type: string;
}
export const authService = {
async login(payload: LoginPayload): Promise<TokenResponse> {
const data = await apiFetch<TokenResponse>(API_ENDPOINTS.AUTH_LOGIN, {
method: 'POST',
body: JSON.stringify(payload),
skipAuth: true,
});
setAccessToken(data.access_token);
if (typeof window !== 'undefined') {
localStorage.setItem('refresh_token', data.refresh_token);
}
return data;
},
async logout(): Promise<void> {
try {
await apiFetch(API_ENDPOINTS.AUTH_LOGOUT, { method: 'POST' });
} finally {
clearTokens();
}
},
};