Skip to content

Open-source status page, incident response and uptime monitoring

fix: tcp test action

Maximilian Kaskeb056f5a33c62
diff --git a/apps/web/src/components/data-table/monitor/data-table-row-actions.tsx b/apps/web/src/components/data-table/monitor/data-table-row-actions.tsx
index b4fc4d05d..8a5069c1a 100644
--- a/apps/web/src/components/data-table/monitor/data-table-row-actions.tsx
+++ b/apps/web/src/components/data-table/monitor/data-table-row-actions.tsx
@@ -30,6 +30,9 @@ import { LoadingAnimation } from "@/components/loading-animation";
import type { RegionChecker } from "@/components/ping-response-analysis/utils";
import { toast, toastAction } from "@/lib/toast";
import { api } from "@/trpc/client";
+
+import type { TCPResponse } from "@/app/api/checker/test/tcp/schema";
+
interface DataTableRowActionsProps<TData> {
row: Row<TData>;
}
@@ -72,9 +75,17 @@ export function DataTableRowActions<TData>({
}),
body: JSON.stringify({ url, body, method, headers }),
});
- const data = (await res.json()) as RegionChecker;
+ const data = (await res.json()) as
+ | RegionChecker
+ | z.infer<typeof TCPResponse>;
+
+ // FIXME: assertions
+ const success =
+ data.type === "http"
+ ? data.status >= 200 && data.status < 300
+ : !data.error;
- if (data.status >= 200 && data.status < 300) {
+ if (success) {
toastAction("test-success");
} else {
toastAction("test-error");