Track HiveGrid Cloud planning reference
This commit is contained in:
1 parent
b3d5ea6764
commit
e341c5938a
5784 files changed
+1104929
-3
No files matched your search
@@ -0,0 +1,53 @@
|
||||
import { Colors } from "~/application/enums/shared/Colors";
|
||||
import SimpleBadge from "~/components/ui/badges/SimpleBadge";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
interface Props {
|
||||
startedAt: Date | null;
|
||||
finishedAt: Date | null;
|
||||
endpoint: string;
|
||||
status: number | null;
|
||||
}
|
||||
export default function StatusBadge({ startedAt, finishedAt, endpoint, status }: Props) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
function getState() {
|
||||
if (status === null && startedAt === null) {
|
||||
return t("events.webhookAttempts.status.notCaught");
|
||||
} else if (status === null && startedAt !== null && finishedAt === null) {
|
||||
return t("events.webhookAttempts.status.running");
|
||||
} else if (status !== null && finishedAt !== null) {
|
||||
if (status >= 200 && status < 300) {
|
||||
return `[${status}] ${t("events.webhookAttempts.status.success")}`;
|
||||
} else if (status >= 300 && status < 400) {
|
||||
return `[${status}] ${t("events.webhookAttempts.status.redirect")}`;
|
||||
} else if (status >= 400 && status < 500) {
|
||||
return `[${status}] ${t("events.webhookAttempts.status.clientError")}`;
|
||||
} else if (status >= 500) {
|
||||
return `[${status}] ${t("events.webhookAttempts.status.serverError")}`;
|
||||
} else {
|
||||
return `[${status}] ${t("events.webhookAttempts.status.unknown")}`;
|
||||
}
|
||||
} else {
|
||||
return t("events.webhookAttempts.status.unknown");
|
||||
}
|
||||
}
|
||||
function getColor() {
|
||||
if (status === null) {
|
||||
return Colors.YELLOW;
|
||||
} else if (status >= 200 && status < 300) {
|
||||
return Colors.GREEN;
|
||||
} else if (status >= 300 && status < 400) {
|
||||
return Colors.ORANGE;
|
||||
} else if (status >= 400 && status < 500) {
|
||||
return Colors.RED;
|
||||
} else {
|
||||
return Colors.UNDEFINED;
|
||||
}
|
||||
}
|
||||
return (
|
||||
<div title={endpoint}>
|
||||
<SimpleBadge title={getState()} color={getColor()} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user