30 lines
1.6 KiB
JavaScript
30 lines
1.6 KiB
JavaScript
import React from "react";
|
|
import { Form, Input, Button, Result, } from 'antd';
|
|
import Verify from '../verify';
|
|
import Styles from './pc.module.less';
|
|
export default function Render(props) {
|
|
const { once, pwd, again, error, successful, needVerifyPassword, tip, pwdMax } = props.data;
|
|
const { t, setPwd, setAgain, commit, onConfirm } = props.methods;
|
|
if (needVerifyPassword) {
|
|
return (<Verify />);
|
|
}
|
|
if (successful) {
|
|
return (<Result status="success" title={t('success.title')} subTitle={t('success.desc')} extra={<Button type="primary" onClick={onConfirm}>
|
|
{t('common::action.confirm')}
|
|
</Button>}/>);
|
|
}
|
|
return (<div className={Styles.container}>
|
|
<Form labelCol={{ span: 8 }} wrapperCol={{ span: 16 }} style={{ maxWidth: 600 }}>
|
|
<Form.Item label={t('label.pwd')} tooltip={tip}>
|
|
<Input autoFocus onChange={({ currentTarget }) => setPwd(currentTarget.value)} placeholder={t('placeholder.pwd')} value={pwd} maxLength={pwdMax ?? 24} type="password"/>
|
|
</Form.Item>
|
|
{!once && <Form.Item label={t('label.again')}>
|
|
<Input onChange={({ currentTarget }) => setAgain(currentTarget.value)} placeholder={t('placeholder.again')} value={again} type="password"/>
|
|
</Form.Item>}
|
|
</Form>
|
|
<Button className={Styles.btn} type={error ? "text" : "primary"} danger={!!error} onClick={commit} disabled={!!error}>
|
|
{error || t('common::action.confirm')}
|
|
</Button>
|
|
</div>);
|
|
}
|