'use client' import { deleteThread } from '@/app/actions' import { createRef, useEffect } from 'react' import { useFormState, useFormStatus } from 'react-dom' import { Button, Input_Shadcn_, Modal } from 'ui' import { ThreadType } from './Threads' const ConfirmDeleteThreadModal = ({ thread, onClose, visible, }: { thread: ThreadType onClose: () => void visible: boolean }) => { const formRef = createRef() const initialState = { message: '', success: false, data: { thread_id: thread.thread_id, }, } const [state, formAction] = useFormState(deleteThread, initialState) useEffect(() => { if (state?.success === true) { onClose() formRef.current?.reset() state.success = false } }, [state, onClose, formRef]) useEffect(() => { if (state?.success === true) { onClose() formRef.current?.reset() state.success = false } }, [state, onClose, formRef]) function SubmitButton() { const { pending } = useFormStatus() return ( ) } return (

Once the thread is deleted, it cannot be recovered.

) } export default ConfirmDeleteThreadModal