skyouc
昨天 644daa26317482e84540699efcdfa2233879e128
代码优化
1个文件已修改
42 ■■■■ 已修改文件
rsf-admin/src/page/dashboard/NbChart.jsx 42 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
rsf-admin/src/page/dashboard/NbChart.jsx
@@ -19,28 +19,28 @@
const dateFormatter = (date) =>
    new Date(date).toLocaleDateString();
const aggregateOrdersByDay = (orders) =>
    orders
        .filter((order) => order.status !== 'cancelled')
        .reduce(
            (acc, curr) => {
                const day = format(curr.date, 'yyyy-MM-dd');
                if (!acc[day]) {
                    acc[day] = 0;
                }
                acc[day] += curr.total;
                return acc;
            },
            {}
        );
// const aggregateOrdersByDay = (orders) =>
//     orders
//         .filter((order) => order.status !== 'cancelled')
//         .reduce(
//             (acc, curr) => {
//                 const day = format(curr.date, 'yyyy-MM-dd');
//                 if (!acc[day]) {
//                     acc[day] = 0;
//                 }
//                 acc[day] += curr.total;
//                 return acc;
//             },
//             {}
//         );
const getRevenuePerDay = (orders) => {
    const daysWithRevenue = aggregateOrdersByDay(orders);
    return lastMonthDays.map(date => ({
        date: date.getTime(),
        total: daysWithRevenue[format(date, 'yyyy-MM-dd')] || 0,
    }));
};
// const getRevenuePerDay = (orders) => {
//     const daysWithRevenue = aggregateOrdersByDay(orders);
//     return lastMonthDays.map(date => ({
//         date: date.getTime(),
//         total: daysWithRevenue[format(date, 'yyyy-MM-dd')] || 0,
//     }));
// };
const NbChart = (props) => {
    const { orders } = props;