import { Input, Modal, Note, Spacer } from "@geist-ui/core" import { useState } from "react" type Props = { warning?: boolean isOpen: boolean onClose: () => void onSubmit: (password: string) => void } const PasswordModal = ({ isOpen, onClose, onSubmit: onSubmitAfterVerify, warning }: Props) => { const [password, setPassword] = useState() const [confirmPassword, setConfirmPassword] = useState() const [error, setError] = useState() const onSubmit = () => { if (!password || !confirmPassword) { setError('Please enter a password') return } if (password !== confirmPassword) { setError("Passwords do not match") return } onSubmitAfterVerify(password) } return (<> { Enter a password {!error && warning && This doesn't protect your post from the server administrator. } {error && {error} } setPassword(e.target.value)} /> setConfirmPassword(e.target.value)} /> Cancel Submit } ) } export default PasswordModal