50 lines
1023 B
TypeScript
50 lines
1023 B
TypeScript
import { apiClient } from './apiClient';
|
|
import { User } from '../interfaces';
|
|
|
|
const mockUser: User = {
|
|
id: 'user-001',
|
|
mobileNumber: '',
|
|
name: '',
|
|
email: '',
|
|
locationLabels: [],
|
|
};
|
|
|
|
export const authService = {
|
|
async login(mobileNumber: string) {
|
|
return apiClient.post(
|
|
'/auth/login',
|
|
{ mobileNumber },
|
|
{ success: true, message: 'OTP sent successfully' },
|
|
);
|
|
},
|
|
|
|
async verifyOtp(mobileNumber: string, otp: string) {
|
|
return apiClient.post(
|
|
'/auth/verify-otp',
|
|
{ mobileNumber, otp },
|
|
{
|
|
success: true,
|
|
user: {
|
|
...mockUser,
|
|
mobileNumber,
|
|
id: 'user-001',
|
|
},
|
|
},
|
|
);
|
|
},
|
|
|
|
async updateProfile(data: { name: string; email: string; locationLabels: string[] }) {
|
|
return apiClient.put('/auth/profile', data, {
|
|
success: true,
|
|
user: {
|
|
...mockUser,
|
|
...data,
|
|
},
|
|
});
|
|
},
|
|
|
|
async logout() {
|
|
return apiClient.post('/auth/logout', {}, { success: true });
|
|
},
|
|
};
|