-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.mjs
More file actions
60 lines (56 loc) · 2.19 KB
/
eslint.config.mjs
File metadata and controls
60 lines (56 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import { useMemo } from "react";
// ... other imports
// 商品別サマリー
const summaryByProduct = useMemo(() => {
// ... existing calculation code
}, [/* dependencies */]);
// 総合計(選択期間 & 時間帯の合計)
const grandTotal = useMemo(() => {
return summaryByProduct.reduce(
(acc, cur) => ({
qty: acc.qty + cur.qty,
revenue: acc.revenue + cur.revenue,
profit: acc.profit + cur.profit,
}),
{ qty: 0, revenue: 0, profit: 0 }
);
}, [summaryByProduct]);
// ... other code
<div style={{ overflowX: 'auto', marginTop: 12 }}>
<div style={{ marginBottom: 6, fontWeight: 600 }}>
{dateLabel ? `${dateLabel} ` : ''}{startHour}〜{endHour}時 の合計(商品別)
</div>
<table style={{ width: '100%', borderCollapse: 'collapse' }}>
<thead>
<tr>
<th style={th}>Product</th>
<th style={th}>num</th>
<th style={th}>sales</th>
<th style={th}>profit</th>
</tr>
</thead>
<tbody>
{summaryByProduct.map((r) => (
<tr key={r.product}>
<td style={td}>{r.product}</td>
<td style={td}>{r.qty}</td>
<td style={td}>{yen.format(r.revenue)}</td>
<td style={td}>{yen.format(r.profit)}</td>
</tr>
))}
{summaryByProduct.length === 0 && (
<tr><td style={td} colSpan={4}>(該当データなし)</td></tr>
)}
</tbody>
{summaryByProduct.length > 0 && (
<tfoot>
<tr>
<td style={{ ...td, fontWeight: 700 }}>合計</td>
<td style={{ ...td, fontWeight: 700 }}>{grandTotal.qty}</td>
<td style={{ ...td, fontWeight: 700 }}>{yen.format(grandTotal.revenue)}</td>
<td style={{ ...td, fontWeight: 700 }}>{yen.format(grandTotal.profit)}</td>
</tr>
</tfoot>
)}
</table>
</div>