From 69059ae2bfd0f2d2c9a02918ee1e43a751c55b01 Mon Sep 17 00:00:00 2001 From: anonymous Date: Wed, 21 Feb 2024 12:14:33 +0800 Subject: [PATCH] save --- package.json | 2 +- src/locales/en-US/user.ts | 1 + src/locales/zh-CN/user.ts | 1 + src/pages/User/Register/index.jsx | 43 ++++++++++++++++++++++++++++--- src/services/api.js | 6 ----- src/services/book.js | 16 ++++++++++++ 6 files changed, 58 insertions(+), 11 deletions(-) delete mode 100644 src/services/api.js diff --git a/package.json b/package.json index 3ce8b65..774c911 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/locales/en-US/user.ts b/src/locales/en-US/user.ts index b529d94..e779cac 100644 --- a/src/locales/en-US/user.ts +++ b/src/locales/en-US/user.ts @@ -12,4 +12,5 @@ export default { 'register.account': 'Register', 'has.account.login': 'Has account, Login', 'wechat.login': 'Wechat Login', + 'register.template': 'Book Template', }; diff --git a/src/locales/zh-CN/user.ts b/src/locales/zh-CN/user.ts index 833ed97..e91a51f 100644 --- a/src/locales/zh-CN/user.ts +++ b/src/locales/zh-CN/user.ts @@ -13,4 +13,5 @@ export default { 'has.account.login': '已有账户,登录', 'register.success': '注册成功!', 'wechat.login': '微信扫码登录', + 'register.template': '账本模板', }; diff --git a/src/pages/User/Register/index.jsx b/src/pages/User/Register/index.jsx index b06e7c5..24d679c 100644 --- a/src/pages/User/Register/index.jsx +++ b/src/pages/User/Register/index.jsx @@ -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 (
@@ -31,9 +51,11 @@ export default () => { submitText: t('register.account'), }, }} + formRef={formRef} > { /> { /> , @@ -61,6 +85,17 @@ export default () => { rules={requiredRules()} placeholder={t('invite.code.placeholder')} /> +
{t('has.account.login')} diff --git a/src/services/api.js b/src/services/api.js deleted file mode 100644 index 9ad3786..0000000 --- a/src/services/api.js +++ /dev/null @@ -1,6 +0,0 @@ -import { get } from "@/utils/http"; - -export async function queryBookTemplates(params) { - const response = await get('book-templates', params); - return response.data; -} diff --git a/src/services/book.js b/src/services/book.js index bee1545..e477ddd 100644 --- a/src/services/book.js +++ b/src/services/book.js @@ -31,3 +31,19 @@ export async function queryBookTemplates(lang) { }, }); } + +export async function allBookTemplates(lang) { + return request('book-templates/all', { + method: 'GET', + params: { + lang: lang + }, + }); +} + + + + + + +