chore(env): update application version to 2.2.7 in production environment
feat(image-upload): introduce ImageUploadField component for enhanced image uploads - Added ImageUploadField component to streamline image uploads with improved UI and functionality. - Integrated file upload handling with a new file service for better management of image uploads. - Updated SectionStep component to utilize ImageUploadField for icon uploads, enhancing user experience. - Refactored TenderListFilters to use isDateRangeActive utility for improved date range filtering logic.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import api from "../axios";
|
||||
import { buildFileDownloadUrl, extractFileId } from "../config";
|
||||
import { extractFileId } from "../config";
|
||||
import { API_ENDPOINTS } from "../endpoints";
|
||||
import { fileService } from "./file-service";
|
||||
import {
|
||||
ApiResponse,
|
||||
IAdminListResponse,
|
||||
@@ -128,34 +129,15 @@ export const userService = {
|
||||
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");
|
||||
}
|
||||
|
||||
// Persisted on the backend as the profile image, so it must be an
|
||||
// absolute, directly-loadable URL — not the frontend `/api/proxy` path.
|
||||
return buildFileDownloadUrl(fileId);
|
||||
return fileService.uploadFile({
|
||||
file,
|
||||
category: "profile_images",
|
||||
tags: ["user", "profile"],
|
||||
description: "Admin profile image",
|
||||
onProgress,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("ERROR caught in User Service Upload Profile Image", error);
|
||||
throw error;
|
||||
|
||||
Reference in New Issue
Block a user