refactor(auth, layouts): enhance UI components for improved aesthetics and usability
- Updated SignIn and Profile components with new background styles and layout adjustments for a more modern look. - Refined button styles in GoogleSigninButton and SigninWithPassword for better user interaction feedback. - Enhanced InputGroup and Select components with improved styling and error handling for a more consistent user experience. - Adjusted Sidebar and Header components for better responsiveness and visual appeal. - Implemented spotlight effect in UserInfo dropdown for a more engaging user interface.
This commit is contained in:
@@ -14,6 +14,10 @@ export const API_ENDPOINTS = {
|
||||
ADMIN_DETAILS: (id: string) => `users/${id}`,
|
||||
CHANGE_ADMIN_STATUS: (id: string) => `users/${id}/status`,
|
||||
},
|
||||
FILES: {
|
||||
UPLOAD: "files/upload",
|
||||
DOWNLOAD: (fileId: string) => `files/${fileId}/download`,
|
||||
},
|
||||
PROFILE: {
|
||||
READ: "profile",
|
||||
UPDATE: "profile",
|
||||
|
||||
@@ -108,4 +108,44 @@ export const userService = {
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
uploadProfileImage: async ({
|
||||
file,
|
||||
onProgress,
|
||||
}: {
|
||||
file: File;
|
||||
onProgress?: (percent: number) => void;
|
||||
}) => {
|
||||
try {
|
||||
const formData = new FormData();
|
||||
formData.append("file", file);
|
||||
formData.append("category", "profile_images");
|
||||
formData.append("tags", "user");
|
||||
formData.append("tags", "profile");
|
||||
formData.append("description", "Admin profile image");
|
||||
|
||||
const response = await api.post(API_ENDPOINTS.FILES.UPLOAD, formData, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data",
|
||||
},
|
||||
onUploadProgress: (progressEvent) => {
|
||||
if (!progressEvent.total) return;
|
||||
const percent = Math.round(
|
||||
(progressEvent.loaded * 100) / progressEvent.total,
|
||||
);
|
||||
onProgress?.(percent);
|
||||
},
|
||||
});
|
||||
|
||||
const fileId = response?.data?.file_id as string | undefined;
|
||||
if (!fileId) {
|
||||
throw new Error("No file id returned from upload");
|
||||
}
|
||||
|
||||
// /api/proxy/* is rewritten to /admin/v1/* in next.config.
|
||||
return `/api/proxy/${API_ENDPOINTS.FILES.DOWNLOAD(fileId)}`;
|
||||
} catch (error) {
|
||||
console.error("ERROR caught in User Service Upload Profile Image", error);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user