Openstatus www.openstatus.dev

fix: tcp test action

authored by

Maximilian Kaske and committed by
Maximilian Kaske
b056f5a3 c96a71ab

+13 -2
+13 -2
apps/web/src/components/data-table/monitor/data-table-row-actions.tsx
··· 30 30 import type { RegionChecker } from "@/components/ping-response-analysis/utils"; 31 31 import { toast, toastAction } from "@/lib/toast"; 32 32 import { api } from "@/trpc/client"; 33 + 34 + import type { TCPResponse } from "@/app/api/checker/test/tcp/schema"; 35 + 33 36 interface DataTableRowActionsProps<TData> { 34 37 row: Row<TData>; 35 38 } ··· 72 75 }), 73 76 body: JSON.stringify({ url, body, method, headers }), 74 77 }); 75 - const data = (await res.json()) as RegionChecker; 78 + const data = (await res.json()) as 79 + | RegionChecker 80 + | z.infer<typeof TCPResponse>; 76 81 77 - if (data.status >= 200 && data.status < 300) { 82 + // FIXME: assertions 83 + const success = 84 + data.type === "http" 85 + ? data.status >= 200 && data.status < 300 86 + : !data.error; 87 + 88 + if (success) { 78 89 toastAction("test-success"); 79 90 } else { 80 91 toastAction("test-error");