Skip to content

Commit 95a6b4a

Browse files
committed
fix: refactor SubmitJobModal to use dynamic submitReport service
1 parent 8fcb3fa commit 95a6b4a

1 file changed

Lines changed: 6 additions & 17 deletions

File tree

dashboard-frontend/src/components/SubmitJobModal.tsx

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { useState } from "react";
2+
import { submitReport } from "../services/api";
23

34
interface SubmitJobModalProps {
45
onClose: () => void;
@@ -16,23 +17,11 @@ const SubmitJobModal: React.FC<SubmitJobModalProps> = ({ onClose, onSubmitSucces
1617
setLoading(true);
1718

1819
try {
19-
const response = await fetch("http://localhost:5001/api/v1/reports/generate", {
20-
method: "POST",
21-
headers: { "Content-Type": "application/json" },
22-
body: JSON.stringify({
23-
reportType,
24-
data: { period, revenue },
25-
}),
26-
});
27-
28-
if (response.ok) {
29-
alert("✅ Report job submitted successfully!");
30-
onSubmitSuccess();
31-
onClose();
32-
} else {
33-
const error = await response.json();
34-
alert(`❌ Error: ${error.message || "Failed to submit"}`);
35-
}
20+
await submitReport(reportType, { period, revenue });
21+
22+
alert("✅ Report job submitted successfully!");
23+
onSubmitSuccess();
24+
onClose();
3625
} catch (err) {
3726
alert(`❌ Network error: ${typeof err === "object" && err !== null && "message" in err ? (err as { message: string }).message : String(err)}`);
3827
} finally {

0 commit comments

Comments
 (0)