import { FC, ReactNode } from 'react' import { Modal, Button, Typography, Input, Alert, Form } from '@supabase/ui' interface Props { loading: boolean visible: boolean title: string confirmLabel: string confirmPlaceholder: string confirmString: string alert: string text: string | ReactNode onConfirm: () => void onCancel: () => void } const TextConfirmModal: FC = ({ title, onConfirm, visible, onCancel, loading, confirmLabel, confirmPlaceholder, confirmString, alert, text, }) => { // [Joshen] Have to keep the loading prop here as this component itself doesn't // directly trigger any potential async job that follows onConfirm. It only triggers // the onConfirm callback function, and hence if anything fails in the callback, // have to depend on loading prop to unfreeze the UI state const validate = (values: any) => { const errors: any = {} if (values.confirmValue.length === 0) { errors.confirmValue = 'Enter the required value.' } else if (values.confirmValue !== confirmString) { errors.confirmValue = 'Value entered does not match.' } return errors } return (
{() => (
{alert && ( )}

{text}

Type {confirmString} to confirm. } placeholder={confirmPlaceholder} />
)}
) } export default TextConfirmModal