Moved the parsing logic to backend as suggested.
This commit is contained in:
1 parent
b2fd9b1e89
commit
bd8554707d
10 files changed
+165
-103
No files matched your search
@@ -0,0 +1,29 @@
|
||||
import { useState } from "react";
|
||||
import { networkService } from "../main"; // Your network service
|
||||
|
||||
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);
|
||||
formData.append("userId", user._id);
|
||||
formData.append("teamId", user.teamId);
|
||||
|
||||
try {
|
||||
const response = await networkService.createBulkMonitors(formData);
|
||||
return response.data;
|
||||
} catch (err) {
|
||||
setError(err?.response?.data?.msg ?? err.message);
|
||||
return null;
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
return { createBulkMonitors, isLoading, error };
|
||||
};
|
||||
Reference in new issue
Block a user