Skip to content

Commit 9646508

Browse files
authored
Merge pull request #171 from Frnn4268/Frnn
Adding new IncomeHistory.jsx components
2 parents 204a328 + 076372a commit 9646508

File tree

3 files changed

+248
-243
lines changed

3 files changed

+248
-243
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import React from 'react';
2+
import { Drawer, Form, Input, Button } from 'antd';
3+
4+
const IncomeDrawer = ({ drawerVisible, setDrawerVisible, form, onFinish }) => (
5+
<Drawer
6+
title="Editar historial de ingresos"
7+
width={500}
8+
onClose={() => setDrawerVisible(false)}
9+
visible={drawerVisible}
10+
>
11+
<Form form={form} onFinish={onFinish}>
12+
<Form.Item
13+
label="Día"
14+
name="day"
15+
rules={[{ required: true, message: '¡Por favor ingresa el día del ingreso!' }]}
16+
>
17+
<Input />
18+
</Form.Item>
19+
<Form.Item
20+
label="Mes"
21+
name="month"
22+
rules={[{ required: true, message: '¡Por favor ingresa el mes del ingreso!' }]}
23+
>
24+
<Input />
25+
</Form.Item>
26+
<Form.Item
27+
label="Año"
28+
name="year"
29+
rules={[{ required: true, message: '¡Por favor ingresa el año del ingreso!' }]}
30+
>
31+
<Input />
32+
</Form.Item>
33+
<Form.Item
34+
label="Monto monetario"
35+
name="income"
36+
rules={[{ required: true, message: '¡Por favor ingresa el monto del ingreso!' }]}
37+
>
38+
<Input />
39+
</Form.Item>
40+
<Form.Item
41+
label="Fecha y hora"
42+
name="hour_date"
43+
rules={[{ required: true, message: '¡Por favor ingresa la fecha y hora del ingreso!' }]}
44+
>
45+
<Input />
46+
</Form.Item>
47+
<Form.Item>
48+
<Button type="primary" htmlType="submit" style={{ textAlign: 'center' }}>Guardar cambios</Button>
49+
</Form.Item>
50+
</Form>
51+
</Drawer>
52+
);
53+
54+
export default IncomeDrawer;
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import React from 'react';
2+
import { Table, Tag, Button, Space } from 'antd';
3+
import { DeleteOutlined, SyncOutlined } from '@ant-design/icons';
4+
5+
const IncomeTable = ({ incomes, handleUpdate, handleDelete, getRandomColor }) => {
6+
const columns = [
7+
{
8+
title: 'ID',
9+
dataIndex: 'id',
10+
key: 'id',
11+
},
12+
{
13+
title: 'Dia',
14+
dataIndex: 'day',
15+
key: 'day',
16+
},
17+
{
18+
title: 'Mes',
19+
dataIndex: 'month',
20+
key: 'month',
21+
},
22+
{
23+
title: 'Año',
24+
dataIndex: 'year',
25+
key: 'year',
26+
},
27+
{
28+
title: 'Monto monetario',
29+
dataIndex: 'income',
30+
key: 'income',
31+
},
32+
{
33+
title: 'Fecha y hora',
34+
dataIndex: 'hour_date',
35+
key: 'hour_date',
36+
render: (hour_date) => (
37+
<Tag color={getRandomColor()}>{hour_date}</Tag>
38+
),
39+
},
40+
{
41+
title: 'Acción',
42+
key: 'action',
43+
render: (_, record) => (
44+
<Space size="middle">
45+
<Button type="primary" icon={<SyncOutlined />} onClick={() => handleUpdate(record)}>Editar</Button>
46+
<Button danger icon={<DeleteOutlined />} onClick={() => handleDelete(record.id)}>Eliminar</Button>
47+
</Space>
48+
),
49+
},
50+
];
51+
52+
return (
53+
<Table
54+
dataSource={incomes}
55+
columns={columns}
56+
rowKey="id"
57+
pagination={{
58+
pageSize: 10,
59+
showSizeChanger: false,
60+
pageSizeOptions: ['5', '10', '20'],
61+
showTotal: (total, range) => `${range[0]}-${range[1]} de ${total} filas`,
62+
}}
63+
/>
64+
);
65+
};
66+
67+
export default IncomeTable;

0 commit comments

Comments
 (0)