import {Modal, Button, Tabs, Form, Input, message} from 'antd'; import React, {Component} from "react"; import './add-folder-modal.less' import {SearchOutlined, UserOutlined} from "@ant-design/icons"; import getCookie from "../../utils/getCookie"; import {apiCreateGroup, apiJoinGroup, apiQuitGroup} from "../../services/API/API"; const {TabPane} = Tabs; class GroupModal extends Component { state = { visible: false, } showModal = () => { this.setState({ visible: true }) } setVisible = visible => { this.setState({ visible: visible }) } handleOk = () => { this.Child.clickButton() setTimeout(() => { this.setVisible(false); }, 1000); }; handleJoinGroup = values => { let params = { username: getCookie('username'), token: getCookie('token'), ...values } apiJoinGroup(params).then(res => { if (res.data.code === 200) { message.success('加入成功'); this.props.getGroupList() this.handleCancel() } else if (res.data.code === 401) { message.error('未登录') window.location.href = ""; } else if (res.data.code === 402) { message.error('你已在群内') } else if (res.data.code === 403) { message.error('该群不存在') } else { message.error('错误') } }) } handleCreateGroup = values => { let params = { username: getCookie('username'), token: getCookie('token'), ...values } apiCreateGroup(params).then(res => { if (res.data.code === 200) { message.success('建群成功'); this.props.getGroupList() this.handleCancel() } else if (res.data.code === 401) { message.error('未登录') window.location.href = ""; } else if (res.data.code === 500) { message.error('新建失败') } else { message.error('错误') } }) } handleQuitGroup = () => { let params = { username: getCookie('username'), token: getCookie('token'), group_id: this.props.group_id, } apiQuitGroup(params).then(res => { if (res.data.code === 200) { message.success('退出成功'); this.props.getGroupList() this.handleCancel() } else if (res.data.code === 401) { message.error('未登录') window.location.href = ""; } else if (res.data.code === 403) { message.error('该群不存在') } else if (res.data.code === 421) { message.error('群主不可退群') } else { message.error('错误') } }) } handleCancel = () => { this.setVisible(false); }; render() { return (
} placeholder="Group Name" size="large" />
) } } export default GroupModal;