(feat) test slack alerts

This commit is contained in:
ishaan-jaff 2024-03-02 16:13:22 -08:00
parent cbd0851257
commit 768c3d8491
2 changed files with 51 additions and 2 deletions

View file

@ -12,7 +12,7 @@ import {
Select,
message,
} from "antd";
import { keyCreateCall } from "./networking";
import { keyCreateCall, slackBudgetAlertsHealthCheck } from "./networking";
const { Option } = Select;
@ -68,6 +68,20 @@ const CreateKey: React.FC<CreateKeyProps> = ({
}
};
const sendSlackAlert = async () => {
try {
console.log("Sending Slack alert...");
message.info("Sending Test Slack alert...");
const response = await slackBudgetAlertsHealthCheck(accessToken);
console.log("slackBudgetAlertsHealthCheck Response:", response);
message.success("Test Slack Alert worked - check your Slack!");
console.log("Testing Slack alert successful");
} catch (error) {
console.error("Error sending Slack alert:", error);
}
};
return (
<div>
<Button className="mx-auto" onClick={() => setIsModalVisible(true)}>
@ -183,7 +197,7 @@ const CreateKey: React.FC<CreateKeyProps> = ({
<Text>API Key: {apiKey}</Text>
<Title className="mt-6">Budgets</Title>
<Text>Soft Limit Budget: ${softBudget}</Text>
<Button className="mt-3">
<Button className="mt-3" onClick={sendSlackAlert}>
Test Alert
</Button>