Skip to content

Commit 65da66a

Browse files
authored
Merge pull request #164 from Frnn4268/Frnn
Adding new folders names, and creating new UsualCustomers.jsx compone…
2 parents c4f37b6 + 0aee737 commit 65da66a

File tree

9 files changed

+112
-101
lines changed

9 files changed

+112
-101
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import React from 'react';
2+
import { Table, Tag } from 'antd';
3+
import moment from 'moment';
4+
5+
const UsualCustomersTable = ({ usualCustomers }) => {
6+
const currentMonthYear = moment().format('MMMM YYYY');
7+
8+
const columns = [
9+
{
10+
title: 'Nombre',
11+
dataIndex: '_id',
12+
key: 'firstname_owner',
13+
render: (_, record) => record._id.firstname_owner
14+
},
15+
{
16+
title: 'Apellido',
17+
dataIndex: '_id',
18+
key: 'lastname_owner',
19+
render: (_, record) => record._id.lastname_owner
20+
},
21+
{
22+
title: 'Teléfono',
23+
dataIndex: ['_id', 'phone_number'],
24+
key: 'phone_number'
25+
},
26+
{
27+
title: 'Cantidad de visitas',
28+
dataIndex: 'count',
29+
key: 'count',
30+
render: count => (
31+
<Tag color={count >= 5 ? 'green' : 'default'}>
32+
{count}
33+
</Tag>
34+
)
35+
},
36+
{
37+
title: 'Mes/Año',
38+
key: 'month_year',
39+
render: () => (
40+
<Tag color='orange'>
41+
{currentMonthYear}
42+
</Tag>
43+
)
44+
}
45+
];
46+
47+
return (
48+
<Table
49+
dataSource={usualCustomers}
50+
columns={columns}
51+
rowKey={(record) => record._id.phone_number}
52+
pagination={{
53+
pageSize: 10,
54+
showSizeChanger: false,
55+
pageSizeOptions: ['5', '10', '20'],
56+
showTotal: (total, range) => `${range[0]}-${range[1]} de ${total} filas`,
57+
}}
58+
/>
59+
);
60+
};
61+
62+
export default UsualCustomersTable;

frontend/src/App.jsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ import ContactComponent from "./pages/dashboard/ContactComponent.jsx";
2323
import InformationComponent from "./pages/dashboard/InformationComponent.jsx";
2424

2525
// Parking
26-
import ParkingSpace from "./pages/parking space/ParkingSpace.jsx";
27-
import ParkingHistory from "./pages/parking space/ParkingHistory.jsx";
28-
import ParkingStatistics from "./pages/parking space/ParkingStatistics.jsx";
29-
import ParkingTime from "./pages/parking time/ParkingTime.jsx";
30-
import TimeParkingSearch from "./pages/parking space/TimeParkingSearch.jsx";
26+
import ParkingSpace from "./pages/parkingSpace/ParkingSpace.jsx";
27+
import ParkingHistory from "./pages/parkingSpace/ParkingHistory.jsx";
28+
import ParkingStatistics from "./pages/parkingSpace/ParkingStatistics.jsx";
29+
import ParkingTime from "./pages/parkingTime/ParkingTime.jsx";
30+
import TimeParkingSearch from "./pages/parkingSpace/TimeParkingSearch.jsx";
3131

3232
// Users
3333
import Users from "./pages/users/Users.jsx";
Lines changed: 44 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,54 @@
11
import React, { useEffect, useState } from 'react';
2-
import { Layout, Table, Typography, Tag } from 'antd';
3-
import moment from 'moment';
2+
import { Layout, Typography } from 'antd';
43

54
import TopMenu from '../dashboard/TopMenu.jsx';
65
import LeftMenu from '../dashboard/LeftMenu.jsx';
6+
import UsualCustomersTable from '../../../components/usualCustomer/UsualCustomersTable.jsx';
77

88
import '../../css/DashboardMenu.css';
9-
import '../../css/UsualCustomers.css'
9+
import '../../css/UsualCustomers.css';
1010

1111
const { Header } = Layout;
1212

1313
const UsualCustomers = () => {
14-
const [usualCustomers, setUsualCustomers] = useState([]);
15-
16-
useEffect(() => {
17-
fetchUsualCustomers();
18-
}, []);
19-
20-
const fetchUsualCustomers = async () => {
21-
try {
22-
const response = await fetch(`${import.meta.env.VITE_APP_API_URL}/parking-space/usual-customers`);
23-
if (response.ok) {
24-
const data = await response.json();
25-
setUsualCustomers(data.frequentCustomers);
26-
} else {
27-
console.error('Error fetching frequent customers');
28-
}
29-
} catch (error) {
30-
console.error(error);
31-
}
32-
}
33-
34-
const currentMonthYear = moment().format('MMMM YYYY');
35-
36-
const columns = [
37-
{
38-
title: 'Nombre',
39-
dataIndex: '_id',
40-
key: 'firstname_owner',
41-
render: (_, record) => record._id.firstname_owner
42-
},
43-
{
44-
title: 'Apellido',
45-
dataIndex: '_id',
46-
key: 'lastname_owner',
47-
render: (_, record) => record._id.lastname_owner
48-
},
49-
{
50-
title: 'Teléfono',
51-
dataIndex: ['_id', 'phone_number'],
52-
key: 'phone_number'
53-
},
54-
{
55-
title: 'Cantidad de visitas',
56-
dataIndex: 'count',
57-
key: 'count',
58-
render: count => (
59-
<Tag color={count >= 5 ? 'green' : 'default'}>
60-
{count}
61-
</Tag>
62-
)
63-
},
64-
{
65-
title: 'Mes/Año',
66-
key: 'month_year',
67-
render: () => (
68-
<Tag color='orange'>
69-
{currentMonthYear}
70-
</Tag>
71-
)
72-
}
73-
];
74-
75-
return (
76-
<Layout>
77-
<Header className='home-header-dashboard'>
78-
<TopMenu />
79-
</Header>
80-
<Layout>
81-
<Layout.Sider>
82-
<LeftMenu />
83-
</Layout.Sider>
84-
<Layout.Content className='layout-content-usual-customers'>
85-
<Typography.Title className='table-title-usual-customers' level={2}>
86-
Clientes Frecuentes
87-
</Typography.Title>
88-
<Table
89-
dataSource={usualCustomers}
90-
columns={columns}
91-
rowKey={(record) => record._id.phone_number}
92-
pagination={{
93-
pageSize: 10,
94-
showSizeChanger: false,
95-
pageSizeOptions: ['5', '10', '20'],
96-
showTotal: (total, range) => `${range[0]}-${range[1]} de ${total} filas`,
97-
}}
98-
/>
99-
</Layout.Content>
100-
</Layout>
101-
</Layout>
102-
);
103-
}
104-
105-
export default UsualCustomers;
14+
const [usualCustomers, setUsualCustomers] = useState([]);
15+
16+
useEffect(() => {
17+
fetchUsualCustomers();
18+
}, []);
19+
20+
const fetchUsualCustomers = async () => {
21+
try {
22+
const response = await fetch(`${import.meta.env.VITE_APP_API_URL}/parking-space/usual-customers`);
23+
if (response.ok) {
24+
const data = await response.json();
25+
setUsualCustomers(data.frequentCustomers);
26+
} else {
27+
console.error('Error fetching frequent customers');
28+
}
29+
} catch (error) {
30+
console.error(error);
31+
}
32+
};
33+
34+
return (
35+
<Layout>
36+
<Header className='home-header-dashboard'>
37+
<TopMenu />
38+
</Header>
39+
<Layout>
40+
<Layout.Sider>
41+
<LeftMenu />
42+
</Layout.Sider>
43+
<Layout.Content className='layout-content-usual-customers'>
44+
<Typography.Title className='table-title-usual-customers' level={2}>
45+
Clientes Frecuentes
46+
</Typography.Title>
47+
<UsualCustomersTable usualCustomers={usualCustomers} />
48+
</Layout.Content>
49+
</Layout>
50+
</Layout>
51+
);
52+
};
53+
54+
export default UsualCustomers;

frontend/src/pages/parking time/ParkingTime.jsx renamed to frontend/src/pages/parkingTime/ParkingTime.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
QuestionCircleOutlined
1010
} from '@ant-design/icons';
1111

12-
import TopMenuCustomer from '../parking time/TopMenuCustomer';
12+
import TopMenuCustomer from './TopMenuCustomer';
1313

1414
import '../../css/ParkingTimeCustomer.css';
1515

0 commit comments

Comments
 (0)