import {
deleteIntegration,
redeliverIntegration,
runGithubJob,
testIntegration,
updateIntegration,
} from "~/fns/integrations";
import { useAction } from "~/hooks/use-action";
import { Button } from "~/ui/Button";
import { CheckboxField, SelectField, TextAreaField, TextField } from "~/ui/Field";
import { ErrorBanner } from "~/ui/Callout";
import { Badge } from "~/ui/Badge";
import { Panel } from "~/ui/Panel";
import { RelativeTime } from "~/ui/RelativeTime";
import {
DEFAULT_LINEAR_MAPPING,
INTEGRATION_EVENT_LABELS,
INTEGRATION_EVENTS,
INTEGRATION_KIND_LABELS,
} from "~/lib/integrations";
import type { GithubMirrorDirection, IntegrationEvent, SlackChannelRoute } from "~/lib/integrations";
import type { IntegrationsData, ScopeParams } from "./IntegrationsPage";
type Integration = IntegrationsData["integrations"][number];
const DELIVERY_OPTIONS = [
{ value: "instant", label: "Instant" },
{ value: "digest", label: "Digest (batched)" },
];
const MIRROR_OPTIONS = [
{ value: "none", label: "Off" },
{ value: "push", label: "gitfor → GitHub" },
{ value: "pull", label: "GitHub → gitfor" },
];
const STATUS_TONE = { success: "success", failed: "danger", dead: "danger", pending: "warning" } as const;
function isEvent(value: string): value is IntegrationEvent {
return INTEGRATION_EVENTS.some((event) => event === value);
}