fix(users): align otp and profile picture api contracts

This commit is contained in:
2026-04-24 22:21:50 +03:30
parent 57e727da19
commit dfe280d9a1

View File

@@ -20,14 +20,14 @@ export const sendOtp = async (mobile: string, mode: string) => {
return response.json(); return response.json();
}; };
export const loginWithOtp = async (mobile: string, otp: string) => { export const loginWithOtp = async (mobile: string, otp: string) => {
const response = await authFetch('/api/users/otp/login/', { const response = await authFetch('/api/users/otp/login/', {
method: 'POST', method: 'POST',
body: JSON.stringify({ mobile, otp }) body: JSON.stringify({ mobile, code: otp })
}); });
if (!response.ok) throw new Error('Failed to login with OTP'); if (!response.ok) throw new Error('Failed to login with OTP');
return response.json(); return response.json();
}; };
export const logoutUser = async (refreshToken: string) => { export const logoutUser = async (refreshToken: string) => {
const response = await authFetch('/api/users/logout/', { const response = await authFetch('/api/users/logout/', {
@@ -69,15 +69,13 @@ export const updateProfilePicture = async (file: File) => {
return response.json(); return response.json();
}; };
export const removeProfilePicture = async () => { export const removeProfilePicture = async () => {
const formData = new FormData(); const response = await authFetch(`/api/users/profile/picture/`, {
formData.append('profile_picture', ''); method: 'DELETE',
});
return authFetch(`/api/users/profile/picture/`, { if (!response.ok) throw new Error('Failed to remove profile picture');
method: 'POST', return response.json();
body: formData, };
});
};
export interface SearchedUser { export interface SearchedUser {
@@ -96,4 +94,4 @@ export const searchUserByExactMobile = async (mobile: string): Promise<SearchedU
} catch (error) { } catch (error) {
return null; return null;
} }
}; };