Fixed the errors coming out in csv.

This commit is contained in:
Owaise Imdad committed 2025-05-01 12:05:28 +05:30
1 parent ecce31ce34
commit 075559ffc3
3 files changed
+52 -28

No files matched your search

+4 -6
View File
@@ -3,11 +3,9 @@ import { networkService } from "../main";
export const useBulkMonitors = () => {
const [isLoading, setIsLoading] = useState(false);
const [error, setError] = useState(null);
const createBulkMonitors = async (file, user) => {
setIsLoading(true);
setError(null);
const formData = new FormData();
formData.append("csvFile", file);
@@ -16,14 +14,14 @@ export const useBulkMonitors = () => {
try {
const response = await networkService.createBulkMonitors(formData);
return response.data;
return [true, response.data, null]; // [success, data, error]
} catch (err) {
setError(err?.response?.data?.msg ?? err.message);
return null;
const errorMessage = err?.response?.data?.errors?.[0]?.message || err.message;
return [false, null, errorMessage];
} finally {
setIsLoading(false);
}
};
return [createBulkMonitors, isLoading, error];
return [createBulkMonitors, isLoading];
};