import { useTranslation } from "react-i18next" import type { ChannelConfig } from "@/api/channels" import { getSecretInputPlaceholder } from "@/components/channels/channel-config-fields" import { Field, KeyInput, SwitchCardField } from "@/components/shared-form" import { Card, CardContent } from "@/components/ui/card" import { Input } from "@/components/ui/input" interface FeishuFormProps { config: ChannelConfig onChange: (key: string, value: unknown) => void configuredSecrets: string[] fieldErrors?: Record } function asString(value: unknown): string { return typeof value === "string" ? value : "" } function asBool(value: unknown): boolean { return typeof value === "boolean" ? value : false } function asStringArray(value: unknown): string[] { if (!Array.isArray(value)) return [] return value.filter((item): item is string => typeof item === "string") } export function FeishuForm({ config, onChange, configuredSecrets, fieldErrors = {}, }: FeishuFormProps) { const { t } = useTranslation() return (
onChange("app_id", e.target.value)} placeholder="cli_xxxx" /> onChange("_app_secret", v)} placeholder={getSecretInputPlaceholder( configuredSecrets, "app_secret", t("channels.field.secretHintSet"), t("channels.field.secretPlaceholder"), )} /> onChange("_verification_token", v)} placeholder={getSecretInputPlaceholder( configuredSecrets, "verification_token", t("channels.field.secretHintSet"), t("channels.field.secretPlaceholder"), )} /> onChange("_encrypt_key", v)} placeholder={getSecretInputPlaceholder( configuredSecrets, "encrypt_key", t("channels.field.secretHintSet"), t("channels.field.secretPlaceholder"), )} /> onChange( "allow_from", e.target.value .split(",") .map((s: string) => s.trim()) .filter(Boolean), ) } placeholder={t("channels.field.allowFromPlaceholder")} />
onChange("is_lark", checked)} ariaLabel={t("channels.field.isLark")} />
) }