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