Commit 4fdee9cc authored by 2breakegg's avatar 2breakegg

change language 按钮位置

parent 323eb459
......@@ -4,6 +4,8 @@
"rules": {
"react/jsx-space-before-closing":[0],
"generator-star-spacing": [0],
"semi":[0],
"no-console":[0],
"consistent-return": [0],
"react/forbid-prop-types": [0],
"react/jsx-filename-extension": [1, { "extensions": [".js"] }],
......
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="eb37985e-18dc-4e2f-82ba-9874832785ff" name="Default" comment="">
<list default="true" id="eb37985e-18dc-4e2f-82ba-9874832785ff" name="Default" comment="change language 按钮位置">
<change type="DELETED" beforePath="$PROJECT_DIR$/src/models/common.js" afterPath="" />
<change type="DELETED" beforePath="$PROJECT_DIR$/src/routes/Register.js" afterPath="" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.eslintrc" afterPath="$PROJECT_DIR$/.eslintrc" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.roadhogrc.js" afterPath="$PROJECT_DIR$/.roadhogrc.js" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/config.js" afterPath="$PROJECT_DIR$/src/config.js" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/routes/Index.js" afterPath="$PROJECT_DIR$/src/routes/Index.js" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/utils/request.js" afterPath="$PROJECT_DIR$/src/utils/request.js" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/package.json" afterPath="$PROJECT_DIR$/package.json" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/router.js" afterPath="$PROJECT_DIR$/src/router.js" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/routes/Profiles.js" afterPath="$PROJECT_DIR$/src/routes/Profiles.js" />
</list>
<ignored path="$PROJECT_DIR$/.tmp/" />
<ignored path="$PROJECT_DIR$/temp/" />
......@@ -61,36 +64,38 @@
</provider>
</entry>
</file>
<file leaf-file-name="user.js" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/models/user.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="3933">
<caret line="211" column="24" lean-forward="false" selection-start-line="211" selection-start-column="24" selection-end-line="211" selection-end-column="24" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="Index.js" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/routes/Index.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="246">
<caret line="166" column="15" lean-forward="true" selection-start-line="166" selection-start-column="15" selection-end-line="166" selection-end-column="15" />
<state relative-caret-position="1805">
<caret line="207" column="15" lean-forward="true" selection-start-line="207" selection-start-column="15" selection-end-line="207" selection-end-column="15" />
<folding>
<element signature="e#0#52#0" expanded="true" />
<element signature="e#398#2275#0" expanded="false" />
<marker date="1491533202282" expanded="true" signature="5092:5096" ph="{&quot;messages&quot;: messages...}" />
<marker date="1491534380238" expanded="true" signature="5091:5096" ph="{&quot;messages&quot;: messages...}" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name=".eslintrc" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/.eslintrc">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="399">
<caret line="27" column="23" lean-forward="false" selection-start-line="27" selection-start-column="23" selection-end-line="27" selection-end-column="23" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="config.js" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/config.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="76">
<caret line="4" column="0" lean-forward="true" selection-start-line="4" selection-start-column="0" selection-end-line="4" selection-end-column="0" />
<folding />
<folding>
<marker date="1491533542759" expanded="true" signature="36:50" ph="{&quot;apiRoot&quot;: apiRoot...}" />
</folding>
</state>
</provider>
</entry>
......@@ -99,8 +104,12 @@
<entry file="file://$PROJECT_DIR$/.roadhogrc.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="152">
<caret line="8" column="13" lean-forward="true" selection-start-line="8" selection-start-column="13" selection-end-line="8" selection-end-column="13" />
<folding />
<caret line="15" column="13" lean-forward="true" selection-start-line="15" selection-start-column="13" selection-end-line="15" selection-end-column="13" />
<folding>
<marker date="1491534380488" expanded="true" signature="252:254" ph="{...}" />
<marker date="1491534380488" expanded="true" signature="371:525" ph="{...}" />
<marker date="1491534380488" expanded="true" signature="400:519" ph="[...]" />
</folding>
</state>
</provider>
</entry>
......@@ -122,7 +131,11 @@
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="38">
<caret line="2" column="14" lean-forward="true" selection-start-line="2" selection-start-column="14" selection-end-line="2" selection-end-column="14" />
<folding />
<folding>
<marker date="1491534380518" expanded="true" signature="278:311" ph="{&quot;install-node&quot;: &quot;6.9.2&quot;...}" />
<marker date="1491534380518" expanded="true" signature="331:658" ph="{&quot;antd&quot;: &quot;^2.8.2&quot;...}" />
<marker date="1491534380518" expanded="true" signature="681:1148" ph="{&quot;babel-eslint&quot;: &quot;^7.1.1&quot;...}" />
</folding>
</state>
</provider>
</entry>
......@@ -140,10 +153,14 @@
<file leaf-file-name="Profiles.js" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/routes/Profiles.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="2033">
<caret line="107" column="22" lean-forward="true" selection-start-line="107" selection-start-column="22" selection-end-line="107" selection-end-column="22" />
<state relative-caret-position="2052">
<caret line="108" column="22" lean-forward="true" selection-start-line="108" selection-start-column="22" selection-end-line="108" selection-end-column="22" />
<folding>
<element signature="e#0#61#0" expanded="true" />
<marker date="1491534380538" expanded="true" signature="895:5442" ph="{...}" />
<marker date="1491534380538" expanded="true" signature="2128:5440" ph="{...}" />
<marker date="1491534380538" expanded="true" signature="5476:5868" ph="{...}" />
<marker date="1491534380538" expanded="true" signature="5710:5865" ph="{&quot;user&quot;: user...}" />
</folding>
</state>
</provider>
......@@ -195,7 +212,6 @@
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/.eslintrc" />
<option value="$PROJECT_DIR$/.gitignore" />
<option value="$PROJECT_DIR$/package.json" />
<option value="$PROJECT_DIR$/src/components/Example.js" />
......@@ -223,10 +239,11 @@
<option value="$PROJECT_DIR$/src/routes/Verify.js" />
<option value="$PROJECT_DIR$/src/routes/Profiles.js" />
<option value="$PROJECT_DIR$/i18n.json" />
<option value="$PROJECT_DIR$/src/routes/Index.js" />
<option value="$PROJECT_DIR$/src/utils/request.js" />
<option value="$PROJECT_DIR$/.roadhogrc.js" />
<option value="$PROJECT_DIR$/src/config.js" />
<option value="$PROJECT_DIR$/.eslintrc" />
<option value="$PROJECT_DIR$/src/routes/Index.js" />
</list>
</option>
</component>
......@@ -295,6 +312,24 @@
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
<PATH>
<PATH_ELEMENT>
<option name="myItemId" value="mycard-account-web" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="mycard-account-web" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="src" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
<option name="myItemId" value="models" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
</PATH>
</subPane>
</pane>
<pane id="Scope" />
......@@ -451,7 +486,7 @@
<workItem from="1491362317876" duration="18018000" />
<workItem from="1491448144293" duration="3984000" />
<workItem from="1491459521278" duration="9381000" />
<workItem from="1491532261913" duration="1785000" />
<workItem from="1491532261913" duration="2395000" />
</task>
<task id="LOCAL-00001" summary="i18n">
<created>1490948057319</created>
......@@ -593,11 +628,18 @@
<option name="project" value="LOCAL" />
<updated>1491475345189</updated>
</task>
<option name="localTasksCounter" value="21" />
<task id="LOCAL-00021" summary="change language 按钮位置">
<created>1491534110082</created>
<option name="number" value="00021" />
<option name="presentableId" value="LOCAL-00021" />
<option name="project" value="LOCAL" />
<updated>1491534110082</updated>
</task>
<option name="localTasksCounter" value="22" />
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="95522000" />
<option name="totallyTimeSpent" value="96132000" />
</component>
<component name="TodoView" selected-index="3">
<todo-panel id="selected-file">
......@@ -611,15 +653,15 @@
<component name="ToolWindowManager">
<frame x="-8" y="-8" width="1936" height="1176" extended-state="6" />
<layout>
<window_info id="Project" active="true" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.25237092" sideWeight="0.6646489" order="0" side_tool="false" content_ui="combo" />
<window_info id="Project" active="true" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.25237092" sideWeight="0.6641318" order="0" side_tool="false" content_ui="combo" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32917467" sideWeight="0.49578503" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32917467" sideWeight="0.5021075" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32917467" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.21743697" sideWeight="0.49789253" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.2428023" sideWeight="0.49789253" order="7" side_tool="false" content_ui="tabs" />
<window_info id="npm" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.25237092" sideWeight="0.33535108" order="2" side_tool="true" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.2428023" sideWeight="0.49789253" order="7" side_tool="false" content_ui="tabs" />
<window_info id="npm" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.25237092" sideWeight="0.33586818" order="2" side_tool="true" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.20729366" sideWeight="0.49367756" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.20729366" sideWeight="0.49367756" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
......@@ -668,7 +710,8 @@
<MESSAGE value="travis" />
<MESSAGE value="change language" />
<MESSAGE value="i18n" />
<option name="LAST_COMMIT_MESSAGE" value="i18n" />
<MESSAGE value="change language 按钮位置" />
<option name="LAST_COMMIT_MESSAGE" value="change language 按钮位置" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
......@@ -679,6 +722,7 @@
</line-breakpoint>
<line-breakpoint enabled="true" type="javascript">
<url>file://$PROJECT_DIR$/src/router.js</url>
<line>1</line>
<option name="timeStamp" value="3" />
</line-breakpoint>
</breakpoints>
......@@ -753,13 +797,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/.eslintrc">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="242">
<caret line="27" column="23" lean-forward="false" selection-start-line="27" selection-start-column="23" selection-end-line="27" selection-end-column="23" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/routes/IndexPage.js" />
<entry file="file://$PROJECT_DIR$/src/components/Haha.css" />
<entry file="file://$PROJECT_DIR$/src/components/Haha.js" />
......@@ -868,7 +905,7 @@
<state relative-caret-position="114">
<caret line="8" column="14" lean-forward="false" selection-start-line="8" selection-start-column="14" selection-end-line="8" selection-end-column="14" />
<folding>
<element signature="e#0#31#0" expanded="true" />
<element signature="e#0#31#0" expanded="false" />
</folding>
</state>
</provider>
......@@ -964,10 +1001,14 @@
</entry>
<entry file="file://$PROJECT_DIR$/src/routes/Profiles.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="2033">
<caret line="107" column="22" lean-forward="true" selection-start-line="107" selection-start-column="22" selection-end-line="107" selection-end-column="22" />
<state relative-caret-position="2052">
<caret line="108" column="22" lean-forward="true" selection-start-line="108" selection-start-column="22" selection-end-line="108" selection-end-column="22" />
<folding>
<element signature="e#0#61#0" expanded="true" />
<marker date="1491534380538" expanded="true" signature="895:5442" ph="{...}" />
<marker date="1491534380538" expanded="true" signature="2128:5440" ph="{...}" />
<marker date="1491534380538" expanded="true" signature="5476:5868" ph="{...}" />
<marker date="1491534380538" expanded="true" signature="5710:5865" ph="{&quot;user&quot;: user...}" />
</folding>
</state>
</provider>
......@@ -980,14 +1021,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/i18n.json">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="190">
<caret line="10" column="13" lean-forward="false" selection-start-line="10" selection-start-column="13" selection-end-line="10" selection-end-column="13" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/services/upload.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
......@@ -1000,7 +1033,11 @@
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="38">
<caret line="2" column="14" lean-forward="true" selection-start-line="2" selection-start-column="14" selection-end-line="2" selection-end-column="14" />
<folding />
<folding>
<marker date="1491534380518" expanded="true" signature="278:311" ph="{&quot;install-node&quot;: &quot;6.9.2&quot;...}" />
<marker date="1491534380518" expanded="true" signature="331:658" ph="{&quot;antd&quot;: &quot;^2.8.2&quot;...}" />
<marker date="1491534380518" expanded="true" signature="681:1148" ph="{&quot;babel-eslint&quot;: &quot;^7.1.1&quot;...}" />
</folding>
</state>
</provider>
</entry>
......@@ -1025,8 +1062,12 @@
<entry file="file://$PROJECT_DIR$/.roadhogrc.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="152">
<caret line="8" column="13" lean-forward="true" selection-start-line="8" selection-start-column="13" selection-end-line="8" selection-end-column="13" />
<folding />
<caret line="15" column="13" lean-forward="true" selection-start-line="15" selection-start-column="13" selection-end-line="15" selection-end-column="13" />
<folding>
<marker date="1491534380488" expanded="true" signature="252:254" ph="{...}" />
<marker date="1491534380488" expanded="true" signature="371:525" ph="{...}" />
<marker date="1491534380488" expanded="true" signature="400:519" ph="[...]" />
</folding>
</state>
</provider>
</entry>
......@@ -1034,21 +1075,39 @@
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="76">
<caret line="4" column="0" lean-forward="true" selection-start-line="4" selection-start-column="0" selection-end-line="4" selection-end-column="0" />
<folding>
<marker date="1491533542759" expanded="true" signature="36:50" ph="{&quot;apiRoot&quot;: apiRoot...}" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/.eslintrc">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="399">
<caret line="27" column="23" lean-forward="false" selection-start-line="27" selection-start-column="23" selection-end-line="27" selection-end-column="23" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/routes/Index.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="246">
<caret line="166" column="15" lean-forward="true" selection-start-line="166" selection-start-column="15" selection-end-line="166" selection-end-column="15" />
<state relative-caret-position="1805">
<caret line="207" column="15" lean-forward="true" selection-start-line="207" selection-start-column="15" selection-end-line="207" selection-end-column="15" />
<folding>
<element signature="e#0#52#0" expanded="true" />
<element signature="e#398#2275#0" expanded="false" />
<marker date="1491533202282" expanded="true" signature="5092:5096" ph="{&quot;messages&quot;: messages...}" />
<marker date="1491534380238" expanded="true" signature="5091:5096" ph="{&quot;messages&quot;: messages...}" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/i18n.json">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="190">
<caret line="10" column="13" lean-forward="false" selection-start-line="10" selection-start-column="13" selection-end-line="10" selection-end-column="13" />
<folding />
</state>
</provider>
</entry>
</component>
</project>
\ No newline at end of file
let publicPath = 'https://cdn01.moecube.com/accounts/'
const API_ROOT = {
test: 'http://192.168.1.9:3000',
dev: 'http://114.215.243.95:8082',
prod: 'https://api.moeube.com/accounts'
}
let defineConf = {
apiRoot: process.env["API_ROOT"]
apiRoot: API_ROOT[process.env["ENV"]],
}
export default {
......
{
"private": true,
"scripts": {
"start": "cross-env API_ROOT=http://192.168.1.9:3000 roadhog server",
"build:dev": "cross-env API_ROOT=http://114.215.243.95:8082 roadhog build",
"build": "cross-env API_ROOT=https://api.moeube.com/accounts roadhog build",
"start": "cross-env ENV=test roadhog server",
"build:dev": "cross-env ENV=dev roadhog build",
"build": "cross-env ENV=prod roadhog build",
"lint": "eslint --ext .js src test",
"precommit": "npm run lint"
},
......
import i18n from '../../i18n.json';
export default {
namespace: 'common',
state: {
language: 'zh-CN',
messages: {},
},
reducers: {
init(state, action) {
return {
...state, ...action.payload,
};
},
changeLanguage(state, { payload: id }) {
localStorage.setItem('locale', id.id);
history.go(0);
return state;
},
},
effects: {},
subscriptions: {
setup({ dispatch }) {
const language = localStorage.getItem('locale') || navigator.language || (navigator.languages && navigator.languages[0]) || navigator.userLanguage;
const languageWithoutRegionCode = language.toLowerCase().split(/[_-]+/)[0];
const messages = i18n[languageWithoutRegionCode];
dispatch({ type: 'init', payload: { language: languageWithoutRegionCode, messages } });
},
},
};
import { Route, Router } from 'dva/router';
import { Route, Router, Redirect } from 'dva/router';
import React from 'react';
import Active from './routes/Activate.js';
......
......@@ -95,6 +95,7 @@ class Profiles extends React.Component {
/* eslint-disable jsx-a11y/label-has-for */
return (
<div style={{ flex: 1, height: '100%' }}>
<Spin spinning={loading} delay={100}>
<Tabs defaultActiveKey="1" className="app-detail-nav">
<TabPane tab={<span><Icon type="user"/><Format id={'user-info'}/> </span>} key="1">
......@@ -107,7 +108,7 @@ class Profiles extends React.Component {
this.cropper = cropper;
}}
src={imageUrl || defaultAvatar}
style={{ height: '20vw', width: '20vw' }}
style={{ maxHeight: '20vw', maxWidth: '20vw' }}
aspectRatio={1 / 1}
guides
/>
......@@ -164,6 +165,7 @@ class Profiles extends React.Component {
</TabPane>
</Tabs>
</Spin>
</div>
);
}
}
......
import { Button, Form, Icon, Input, Spin, Steps } from 'antd';
import { connect } from 'dva';
import { Link } from 'dva/router';
import React, { PropTypes } from 'react';
import { FormattedMessage as Format } from 'react-intl';
const FormItem = Form.Item;
const Step = Steps.Step;
class Register extends React.Component {
static contextTypes = {
intl: PropTypes.object.isRequired,
};
onSubmitLogin = (e) => {
const { form, dispatch } = this.props;
if (e) {
e.preventDefault();
}
form.validateFieldsAndScroll((err, values) => {
if (!err) {
console.log('Received values of form: ', values);
const { email, username, password } = values;
dispatch({ type: 'auth/register', payload: { email, username, password } });
}
});
};
checkPassword = (rule, value, callback) => {
const form = this.props.form;
if (value && value !== form.getFieldValue('password')) {
callback(this.context.intl.messages['Incorrect-password.2']);
} else {
callback();
}
};
checkConfirm = (rule, value, callback) => {
const form = this.props.form;
if (value) {
form.validateFields(['confirm'], { force: true });
}
callback();
};
render() {
const {
dispatch, form, checkEmail, checkUsername,
isEmailExists, isUserNameExists, loading,
} = this.props;
const { getFieldDecorator } = form;
const { intl: { messages } } = this.context;
const emailProps = {
hasFeedback: true,
validateStatus: checkEmail,
extra: isEmailExists ? messages.i_email_exists : '',
};
const emailInputProps = {
onBlur: () => !form.getFieldError('email') && dispatch({ type: 'auth/checkEmail', payload: { ...form.getFieldsValue() } }),
placeholder: messages.email,
};
const usernameProps = {
hasFeedback: true,
validateStatus: checkUsername,
extra: isUserNameExists ? 'username exists' : '',
};
const usernameInputProps = {
onBlur: () => !form.getFieldError('username') && dispatch({ type: 'auth/checkUsername', payload: { ...form.getFieldsValue() } }),
placeholder: messages.username,
};
return (
<div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', height: '100%' }}>
<Spin spinning={loading} delay={100}>
<Steps size="large" current={0}>
<Step title={messages['sign-up']} icon={<Icon type="solution"/>}/>
<Step title={messages['verify-email']} icon={<Icon type="mail"/>}/>
</Steps>
<Form onSubmit={this.onSubmitLogin} className="login-form" style={{ marginTop: '24px' }}>
<FormItem {...emailProps} >
{getFieldDecorator('email', {
rules: [{
required: true,
message: messages['Please-use-a-correct-E-Mail-address.'],
pattern: /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/,
}],
}, {})(
<Input {...emailInputProps} />,
)}
</FormItem>
<FormItem {...usernameProps}>
{getFieldDecorator('username', {
rules: [{
required: true,
message: messages['You-can-not-use-this-username.'],
pattern: /^[A-Za-z0-9_\u4E00-\u9FD5\u3400-\u4DBF\u{20000}-\u{2A6DF}\u{2A700}-\u{2CEAF}\uF900–\uFAFF\u{2F800}-\u{2FA1D}\uAC00–\uD7AF\u3040-\u30FF\u31F0–\u31FF\u{1B000}–\u{1B0FF}\u3005]+$/u,
}],
}, {})(
<Input {...usernameInputProps} />,
)}
</FormItem>
<FormItem hasFeedback>
{getFieldDecorator('password', {
rules: [{
required: true,
message: messages['Password-length-must-be-between-8-and-24-characters.'],
pattern: /^.{8,24}$/,
}],
}, {
validator: this.checkConfirm,
})(
<Input
prefix={<Icon type="lock" style={{ fontSize: 13 }}/>}
type="password"
placeholder={messages.password}
/>,
)}
</FormItem>
<FormItem hasFeedback>
{getFieldDecorator('confirm', {
rules: [{
required: true,
message: messages['Password-length-must-be-between-8-and-24-characters.'],
pattern: /^.{8,24}$/,
}, {
validator: this.checkPassword,
}],
})(
<Input
prefix={<Icon type="lock" style={{ fontSize: 13 }}/>}
type="password"
onBlur={this.handleConfirmBlur}
placeholder={messages['password-again']}
/>,
)}
</FormItem>
<FormItem>
<Button type="primary" htmlType="submit" className="login-form-button">
<Format id={'sign-up'}/>
</Button>
</FormItem>
<div>
<Link to="/signin"><Format id={'sign-in'}/></Link>
</div>
</Form>
</Spin>
</div>
);
}
}
function mapStateToProps(state) {
const {
auth: {
register, checkEmail, checkUsername, isEmailExists,
isUserNameExists, isRegisterSubmit,
},
} = state;
const loading = state.loading.global || false;
return {
loading,
register,
checkEmail,
checkUsername,
isEmailExists,
isUserNameExists,
isRegisterSubmit,
};
}
const WrapperRegister = Form.create()(Register);
export default connect(mapStateToProps)(WrapperRegister);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment