import { useFormContext } from "react-hook-form"; import { format } from "date-fns"; import { TSecretRotationV2Form } from "@app/components/secret-rotations-v2/forms/schemas"; import { GenericFieldLabel } from "@app/components/v2"; import { getRotateAtLocal } from "@app/helpers/secretRotationsV2"; import { SecretRotation } from "@app/hooks/api/secretRotationsV2"; import { Auth0ClientSecretRotationReviewFields } from "./Auth0ClientSecretRotationReviewFields"; import { AzureClientSecretRotationReviewFields } from "./AzureClientSecretRotationReviewFields"; import { SqlCredentialsRotationReviewFields } from "./shared"; const COMPONENT_MAP: Record = { [SecretRotation.PostgresCredentials]: SqlCredentialsRotationReviewFields, [SecretRotation.MsSqlCredentials]: SqlCredentialsRotationReviewFields, [SecretRotation.Auth0ClientSecret]: Auth0ClientSecretRotationReviewFields, [SecretRotation.AzureClientSecret]: AzureClientSecretRotationReviewFields }; export const SecretRotationV2ReviewFields = () => { const { watch } = useFormContext(); const { environment, secretPath, connection, type, name, description, rotationInterval, rotateAtUtc } = watch(); const Component = COMPONENT_MAP[type]; return (
Configuration
{connection.name} {environment.name} {secretPath} {rotationInterval} Day{rotationInterval > 1 ? "s" : ""} {format(getRotateAtLocal(rotateAtUtc), "h:mm aa")}
Details
{name} {description}
); };