admin-panel-front/src/features/auth/authService.ts
2026-08-03 10:50:37 +03:30

26 lines
712 B
TypeScript

import { authApi } from '@/services/authApi';
import type { AuthSessionPayload, RequestOtpResponse } from '@/types/auth';
export const authService = {
sendOtp: async (phoneNumber: string): Promise<RequestOtpResponse> => {
return authApi.requestOtp(phoneNumber);
},
verifyOtp: async (phoneNumber: string, otp: string): Promise<AuthSessionPayload> => {
const tokenResponse = await authApi.verifyOtp(phoneNumber, otp);
return {
accessToken: tokenResponse.access_token,
refreshToken: tokenResponse.refresh_token,
user: {
id: 1,
phoneNumber,
role: 'admin',
},
};
},
logout: async (): Promise<void> => {
await authApi.logout();
},
};