import { useFormContext } from "react-hook-form"; import { format } from "date-fns"; import { TSecretRotationV2Form } from "@app/components/secret-rotations-v2/forms/schemas"; import { SqlRotationReviewFields } from "@app/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/shared"; import { GenericFieldLabel } from "@app/components/v2"; import { getRotateAtLocal } from "@app/helpers/secretRotationsV2"; import { SecretRotation } from "@app/hooks/api/secretRotationsV2"; const COMPONENT_MAP: Record = { [SecretRotation.PostgresCredentials]: SqlRotationReviewFields, [SecretRotation.MsSqlCredentials]: SqlRotationReviewFields }; 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}
); };