67 lines
1.7 KiB
TypeScript
67 lines
1.7 KiB
TypeScript
import { PartnerProfile } from '@app-types/index';
|
|
import { LoginResponse, VerifyOtpResponse } from '@interfaces';
|
|
import { apiClient } from '@services';
|
|
// import apiClient from '../services/apiClient'; // Used when connecting to real backend
|
|
|
|
// Mock responses
|
|
const mockSendOtpResponse = { requestId: 'req_mock_001' };
|
|
const mockVerifyOtpResponse = {
|
|
token: 'mock_token_xyz',
|
|
partnerId: 'partner_001',
|
|
};
|
|
const mockProfile: PartnerProfile = {
|
|
partnerId: 'partner_001',
|
|
fullName: 'Rahul Kumar',
|
|
email: 'rahul@example.com',
|
|
phone: '9876543210',
|
|
locationType: 'home',
|
|
location: {
|
|
coordinates: { latitude: 12.9716, longitude: 77.5946 },
|
|
address: 'Koramangala 4th Block',
|
|
city: 'Bengaluru',
|
|
state: 'Karnataka',
|
|
pincode: '560034',
|
|
},
|
|
avatarUri: null,
|
|
rating: 4.8,
|
|
totalDeliveries: 342,
|
|
acceptanceRate: 95,
|
|
completionRate: 98,
|
|
isVerified: true,
|
|
};
|
|
|
|
export const loginApi = async (phone: string) => {
|
|
const result = await apiClient.post<LoginResponse>('/auth/otp/request', {
|
|
phone,
|
|
});
|
|
return result;
|
|
};
|
|
|
|
export const verifyOtpApi = async (
|
|
phone: string,
|
|
code: string,
|
|
role: string,
|
|
) => {
|
|
return await apiClient.post<VerifyOtpResponse>('/auth/otp/verify', {
|
|
phone,
|
|
code,
|
|
role,
|
|
});
|
|
};
|
|
|
|
export const getProfile = async (
|
|
partnerId: string,
|
|
): Promise<PartnerProfile> => {
|
|
// return (await apiClient.get(`/profile/${partnerId}`)).data;
|
|
await new Promise<void>(r => setTimeout(r, 500));
|
|
return mockProfile;
|
|
};
|
|
|
|
export const updateProfile = async (
|
|
updates: Partial<PartnerProfile>,
|
|
): Promise<PartnerProfile> => {
|
|
// return (await apiClient.patch('/profile', updates)).data;
|
|
await new Promise<void>(r => setTimeout(r, 800));
|
|
return { ...mockProfile, ...updates };
|
|
};
|