From bd8570341200f088044f396ea4619d316d1e5e92 Mon Sep 17 00:00:00 2001 From: Sylor-huang Date: Sat, 30 Jan 2021 22:06:52 +0800 Subject: [PATCH] add group setting pages --- src/forge/Component/layout.jsx | 9 ++ src/forge/Team/Group/SettingCommon.jsx | 115 ++++++++++++++----------- src/forge/css/index.scss | 8 +- 3 files changed, 82 insertions(+), 50 deletions(-) diff --git a/src/forge/Component/layout.jsx b/src/forge/Component/layout.jsx index 50cdffad7..c532934a7 100644 --- a/src/forge/Component/layout.jsx +++ b/src/forge/Component/layout.jsx @@ -154,3 +154,12 @@ export const Content = styled.div`{ background-color:#fff; justify-content: center; }` +export const RadioList = styled.span`{ + color:#888888; + margin-left: 8px; +}` +export const RadioListBold = styled.span`{ + color:#333 !important; + margin: 0 2px; +}` + diff --git a/src/forge/Team/Group/SettingCommon.jsx b/src/forge/Team/Group/SettingCommon.jsx index 885c62fed..afe1e4113 100644 --- a/src/forge/Team/Group/SettingCommon.jsx +++ b/src/forge/Team/Group/SettingCommon.jsx @@ -1,11 +1,9 @@ -import React, { forwardRef , useCallback , useEffect, useState } from 'react'; -import { Form , Input , Radio ,Checkbox , Divider , Button } from 'antd'; -import { WhiteBack , FlexAJ } from '../../Component/layout'; +import React, { forwardRef, useCallback, useEffect, useState } from 'react'; +import { Form, Input, Radio, Switch, Divider, Button } from 'antd'; +import { WhiteBack, RadioList, RadioListBold } from '../../Component/layout'; import Title from '../../Component/Title'; import styled from 'styled-components'; -import UploadImage from '../Component/UploadImage'; import axios from 'axios'; -import { getImageUrl } from 'educoder'; const TextArea = Input.TextArea; const Div = styled.div`{ @@ -17,28 +15,28 @@ const radioStyle = { lineHeight: '30px', }; export default Form.create()( - forwardRef(({ form , organizeDetail , showNotification , history , current_user })=>{ - const [ image , setImage ] = useState(undefined); - const [ imageFlag , setImageFlag ] = useState(false); - const [ password , setPassword ] = useState(undefined); - const [ passwordFlag , setPasswordFlag ] = useState(false); - const { getFieldDecorator , validateFields , setFieldsValue } = form; + forwardRef(({ form, organizeDetail, showNotification, history, current_user }) => { + const [image, setImage] = useState(undefined); + const [imageFlag, setImageFlag] = useState(false); + const [password, setPassword] = useState(undefined); + const [passwordFlag, setPasswordFlag] = useState(false); + const { getFieldDecorator, validateFields, setFieldsValue } = form; - useEffect(()=>{ - if(organizeDetail){ + useEffect(() => { + if (organizeDetail) { setFieldsValue({ ...organizeDetail }) setImage(organizeDetail.avatar_url); } - },[organizeDetail]) + }, [organizeDetail]) const helper = useCallback( - (label, name, rules, widget , isRequired , flag ) => ( + (label, name, rules, widget, isRequired, flag) => (
- {label} + {label} - {getFieldDecorator(name, { rules, validateFirst: true , valuePropName:flag ? "checked":"value" })(widget)} + {getFieldDecorator(name, { rules, validateFirst: true, valuePropName: flag ? "checked" : "value" })(widget)}
), @@ -46,45 +44,45 @@ export default Form.create()( ); // 更新 - function updateDetail(){ - validateFields((error,values)=>{ - if(!error){ + function updateDetail() { + validateFields((error, values) => { + if (!error) { const url = `/organizations/${organizeDetail.id}.json`; - axios.patch(url,{ - ...values,image:imageFlag ? image : undefined - }).then(result=>{ - if(result && result.data){ + axios.patch(url, { + ...values, image: imageFlag ? image : undefined + }).then(result => { + if (result && result.data) { showNotification("组织信息更新成功!"); history.push(`/organize/${values.name}/setting`); } - }).catch(error=>{}) + }).catch(error => { }) } }) } - function getImage(image){ + function getImage(image) { setImageFlag(true); setImage(image); } // 删除组织 - function deleteOrganize(){ - if(!password){ + function deleteOrganize() { + if (!password) { setPasswordFlag(true); return - }else{ + } else { setPasswordFlag(false); const url = `/organizations/${organizeDetail.id}.json`; - axios.delete(url,{ - params:{ password } - }).then(result=>{ - if(result && result.data){ + axios.delete(url, { + params: { password } + }).then(result => { + if (result && result.data) { // 删除后跳转到个人中心的组织页面 history.push(`/users/${current_user && current_user.login}/organizes`); } }) } } - return( + return (
基本设置 @@ -94,22 +92,25 @@ export default Form.create()( "团队名称:", "name", [{ required: true, message: "请输入团队名称:" }], - ,true + , true )} {helper( "团队描述:", "description", [], -