"use client"; import { useFormState } from "react-dom"; import { resetWebhookSecretAction, type WebhookSecretState, } from "../app/(app)/dashboard/actions"; import SecretCard from "./secret-card"; const initialState = (webhookSecret: string | null): WebhookSecretState => ({ webhookSecret, error: null, }); type WebhookSecretSectionProps = { webhookSecret: string | null; }; export default function WebhookSecretSection({ webhookSecret, }: WebhookSecretSectionProps) { const [state, formAction] = useFormState( resetWebhookSecretAction, initialState(webhookSecret) ); return (
{state.webhookSecret ? ( ) : (
Webhook secret unavailable. Reset to generate a new secret.
)} {state.error ? (

{state.error}

) : null}
); }