Skip to content

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
anonymous committed Feb 21, 2024
1 parent 0ceb446 commit 69059ae
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "moneywhere-user-fe",
"version": "1.0.58",
"version": "1.0.59",
"private": true,
"scripts": {
"analyze": "cross-env ANALYZE=1 max build",
Expand Down
1 change: 1 addition & 0 deletions src/locales/en-US/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ export default {
'register.account': 'Register',
'has.account.login': 'Has account, Login',
'wechat.login': 'Wechat Login',
'register.template': 'Book Template',
};
1 change: 1 addition & 0 deletions src/locales/zh-CN/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ export default {
'has.account.login': '已有账户,登录',
'register.success': '注册成功!',
'wechat.login': '微信扫码登录',
'register.template': '账本模板',
};
43 changes: 39 additions & 4 deletions src/pages/User/Register/index.jsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,38 @@
import {useEffect, useRef, useState} from "react";
import { LockOutlined, UserOutlined, VerifiedOutlined } from '@ant-design/icons';
import { LoginForm, ProFormText } from '@ant-design/pro-components';
import { SelectLang } from '@umijs/max';
import { register } from '@/services/user';
import { LoginForm, ProFormText, ProFormSelect } from '@ant-design/pro-components';
import {SelectLang, useRequest, getLocale} from '@umijs/max';
import {register} from '@/services/user';
import { allBookTemplates } from "@/services/book";
import { requiredRules } from '@/utils/rules';
import Footer from '@/components/Footer';
import {selectSingleProp} from "@/utils/prop";
import t from '@/utils/i18n';
import styles from '../index.less';


export default () => {

const formRef = useRef();

const handleSubmit = async (values) => {
await register({ ...values });
let form = JSON.parse(JSON.stringify(values));
form.templateId = form.templateId?.id;
await register(form);
};

const { data : bookTemplates = [], loading : bookTemplatesLoading} = useRequest(() => allBookTemplates(getLocale()), { manual: false });

const [defaultTemplate, setDefaultTemplate] = useState();

useEffect(() => {
formRef.current?.setFieldsValue({
templateId: bookTemplates[0]
});
}, [bookTemplates]);



return (
<div className={styles.container}>
<div className={styles.lang}>
Expand All @@ -31,9 +51,11 @@ export default () => {
submitText: t('register.account'),
},
}}
formRef={formRef}
>
<ProFormText
name="username"
label={t('username.placeholder')}
fieldProps={{
size: 'large',
autoComplete: 'off',
Expand All @@ -44,6 +66,7 @@ export default () => {
/>
<ProFormText.Password
name="password"
label={t('password.placeholder')}
fieldProps={{
size: 'large',
autoComplete: 'new-password',
Expand All @@ -54,13 +77,25 @@ export default () => {
/>
<ProFormText
name="inviteCode"
label={t('invite.code.placeholder')}
fieldProps={{
size: 'large',
prefix: <VerifiedOutlined className={styles.prefixIcon} />,
}}
rules={requiredRules()}
placeholder={t('invite.code.placeholder')}
/>
<ProFormSelect
name="templateId"
label={t('register.template')}
fieldProps={{
...selectSingleProp,
allowClear: false,
loading: bookTemplatesLoading,
options: bookTemplates,
}}
rules={requiredRules()}
/>
</LoginForm>
<div style={{ textAlign: 'center' }}>
<a href="/user/login">{t('has.account.login')}</a>
Expand Down
6 changes: 0 additions & 6 deletions src/services/api.js

This file was deleted.

16 changes: 16 additions & 0 deletions src/services/book.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,19 @@ export async function queryBookTemplates(lang) {
},
});
}

export async function allBookTemplates(lang) {
return request('book-templates/all', {
method: 'GET',
params: {
lang: lang
},
});
}







0 comments on commit 69059ae

Please sign in to comment.