import React, {Component} from 'react'; import {Layout, Card, Button, Avatar, Spin, Icon} from 'antd'; import lo from '../../../images/lo.png' import './index.css' import {graphqlUrl} from "../../../config"; import {SHOW_ALL_CASE} from "../../../gql"; import {FormattedMessage} from 'react-intl'; import {request} from 'graphql-request' const {Content} = Layout; const {Meta} = Card; class CaseShow extends Component { constructor(props) { super(props); this.state = { examplesIoobot: [], examplesOthers: [] } } componentWillMount() { this._isMounted = true; request(graphqlUrl, SHOW_ALL_CASE, {}).then(data => { let cases = data.case_by_props; console.log(cases); let examplesIoobot = cases.filter(case1 => case1.user_id.id === 'ioobot'); let examplesOthers = cases.filter(case2 => case2.user_id.id !== 'ioobot'); if (this._isMounted) { this.setState({ examplesIoobot, examplesOthers }) } } ) } componentWillUnmount() { this._isMounted = false; } render() { return (
{ this.state.examplesIoobot.length === 0 ? : this.state.examplesIoobot.map((item, index) => ( {item.title
} actions={[ 已部署: {item.deployedNum}, : {item.like}, ]} > } title={item.title} description={item.description} /> )) }
{ this.state.examplesOthers.length === 0 ? : this.state.examplesOthers.map((item, index) => ( {item.title
} actions={[ 已部署: {item.deployedNum}, : {item.like}, ]} > } title={item.title} description={item.description} /> )) }
) } } export default CaseShow;