import { ReactNode } from "react"; import { useFormContext } from "react-hook-form"; import { SecretSyncLabel } from "@app/components/secret-syncs"; import { TSecretSyncForm } from "@app/components/secret-syncs/forms/schemas"; import { SecretSync } from "@app/hooks/api/secretSyncs"; import { GitHubSyncScope, TGitHubSync } from "@app/hooks/api/secretSyncs/types/github-sync"; export const GitHubSyncReviewFields = () => { const { watch } = useFormContext(); const config = watch("destinationConfig"); let ScopeComponents: ReactNode; switch (config.scope) { case GitHubSyncScope.Repository: ScopeComponents = ( {config.owner}/{config.repo} ); break; case GitHubSyncScope.Organization: ScopeComponents = ( <> {config.org} {config.visibility} ); break; case GitHubSyncScope.RepositoryEnvironment: ScopeComponents = ( <> {config.owner}/{config.repo} {config.env} ); break; default: throw new Error( `Unhandled GitHub Sync Review Field Scope ${(config as TGitHubSync["destinationConfig"]).scope}` ); } return ( <> {config.scope.replace("-", " ")} {ScopeComponents} ); };