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 { Badge } from "@app/components/v2"; import { SECRET_SYNC_INITIAL_SYNC_BEHAVIOR_MAP, SECRET_SYNC_MAP } from "@app/helpers/secretSyncs"; import { SecretSync } from "@app/hooks/api/secretSyncs"; import { AwsParameterStoreSyncReviewFields } from "./AwsParameterStoreSyncReviewFields"; import { GitHubSyncReviewFields } from "./GitHubSyncReviewFields"; export const SecretSyncReviewFields = () => { const { watch } = useFormContext(); let DestinationFieldsComponent: ReactNode; const { name, description, connection, environment, secretPath, syncOptions: { // appendSuffix, prependPrefix, initialSyncBehavior }, destination, isAutoSyncEnabled } = watch(); const destinationName = SECRET_SYNC_MAP[destination].name; switch (destination) { case SecretSync.AWSParameterStore: DestinationFieldsComponent = ; break; case SecretSync.GitHub: DestinationFieldsComponent = ; break; default: throw new Error(`Unhandled Destination Review Fields: ${destination}`); } return (
Source
{environment.name} {secretPath}
Destination
{connection.name} {DestinationFieldsComponent}
Options
{isAutoSyncEnabled ? "Enabled" : "Disabled"} {SECRET_SYNC_INITIAL_SYNC_BEHAVIOR_MAP[initialSyncBehavior](destinationName).name} {/* {prependPrefix} {appendSuffix} */}
Details
{name} {description}
); };