feat: add refferal feature
This commit is contained in:
+27
-1
@@ -1,5 +1,5 @@
|
||||
import { apiClient } from './client';
|
||||
import { User, Product, ApiResponse } from '@/types/user';
|
||||
import { User, Product, ApiResponse, UpdateUserProfileData } from '@/types/user';
|
||||
|
||||
export const usersApi = {
|
||||
// Get user status by email or mobile - package name is now a parameter
|
||||
@@ -47,5 +47,31 @@ export const usersApi = {
|
||||
// Get products for a specific package
|
||||
getProductsByPackage: async (packageName: string, token: string): Promise<Product[]> => {
|
||||
return apiClient.get<Product[]>(`/package-names/${packageName}/products`, token);
|
||||
},
|
||||
|
||||
// Update a user's profile (admin). Uses FormData because avatar may be an image file.
|
||||
updateUserProfile: async (
|
||||
identifier: string,
|
||||
data: UpdateUserProfileData,
|
||||
token: string
|
||||
): Promise<ApiResponse<any>> => {
|
||||
const formData = new FormData();
|
||||
|
||||
Object.entries(data).forEach(([key, value]) => {
|
||||
if (value !== null && value !== undefined && value !== '') {
|
||||
if (key === 'avatar' && value instanceof File) {
|
||||
formData.append('avatar', value);
|
||||
} else if (key !== 'avatar') {
|
||||
formData.append(key, String(value));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return apiClient.post<ApiResponse<any>>(`/admin/users/${identifier}/profile`, formData, token);
|
||||
},
|
||||
|
||||
// Delete a user (admin)
|
||||
deleteUser: async (identifier: string, token: string): Promise<ApiResponse<any>> => {
|
||||
return apiClient.delete<ApiResponse<any>>(`/admin/users/${identifier}`, undefined, token);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user