You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
110 lines
2.3 KiB
JavaScript
110 lines
2.3 KiB
JavaScript
import { useParams } from "react-router-dom";
|
|
import { useEffect } from 'react';
|
|
import { observer } from "mobx-react";
|
|
import { Row, Col, Space, Button, Table, Tag } from 'antd';
|
|
import { useStore } from '../stores/StoreContext.js';
|
|
|
|
const columns = [
|
|
{
|
|
title: 'Name',
|
|
dataIndex: 'name',
|
|
key: 'name',
|
|
render: (text) => <a>{text}</a>,
|
|
},
|
|
{
|
|
title: 'Age',
|
|
dataIndex: 'age',
|
|
key: 'age',
|
|
},
|
|
{
|
|
title: 'Address',
|
|
dataIndex: 'address',
|
|
key: 'address',
|
|
},
|
|
{
|
|
title: 'Tags',
|
|
key: 'tags',
|
|
dataIndex: 'tags',
|
|
render: (_, { tags }) => (
|
|
<>
|
|
{tags.map((tag) => {
|
|
let color = tag.length > 5 ? 'geekblue' : 'green';
|
|
if (tag === 'loser') {
|
|
color = 'volcano';
|
|
}
|
|
return (
|
|
<Tag color={color} key={tag}>
|
|
{tag.toUpperCase()}
|
|
</Tag>
|
|
);
|
|
})}
|
|
</>
|
|
),
|
|
},
|
|
{
|
|
title: 'Action',
|
|
key: 'action',
|
|
render: (_, record) => (
|
|
<Space size="middle">
|
|
<a>Invite {record.name}</a>
|
|
<a>Delete</a>
|
|
</Space>
|
|
),
|
|
},
|
|
];
|
|
const data = [
|
|
{
|
|
key: '1',
|
|
name: 'John Brown',
|
|
age: 32,
|
|
address: 'New York No. 1 Lake Park',
|
|
tags: ['nice', 'developer'],
|
|
},
|
|
{
|
|
key: '2',
|
|
name: 'Jim Green',
|
|
age: 42,
|
|
address: 'London No. 1 Lake Park',
|
|
tags: ['loser'],
|
|
},
|
|
{
|
|
key: '3',
|
|
name: 'Joe Black',
|
|
age: 32,
|
|
address: 'Sydney No. 1 Lake Park',
|
|
tags: ['cool', 'teacher'],
|
|
},
|
|
];
|
|
|
|
function Plan() {
|
|
|
|
const {planId} = useParams();
|
|
const store = useStore();
|
|
const planStore = store.plan;
|
|
|
|
useEffect(() => {
|
|
console.info('planId: ' + planId);
|
|
}, [planId]);
|
|
|
|
return (
|
|
<Space direction="vertical" style={{ width: '100%' }}>
|
|
<Row gutter={{ md: 24 }} justify="end">
|
|
<Col span={4}>
|
|
Parameter: {planId}
|
|
</Col>
|
|
|
|
<Col span={20}>
|
|
<Button onClick={() => planStore.increase()}>increase {planStore.count}</Button>
|
|
<Button onClick={() => planStore.decrease()}>decrease {planStore.count}</Button>
|
|
</Col>
|
|
</Row>
|
|
<Row>
|
|
<Col span={24}>
|
|
<Table columns={columns} dataSource={data} />
|
|
</Col>
|
|
</Row>
|
|
</Space>
|
|
);
|
|
}
|
|
|
|
export default observer(Plan); |