-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdateLocation.tsx
More file actions
36 lines (33 loc) · 1.67 KB
/
Copy pathdateLocation.tsx
File metadata and controls
36 lines (33 loc) · 1.67 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
import React, { useMemo } from 'react';
import { useMontlyPlaceStates } from '@/hooks/home/useDatePlaceStates';
import MainCard from '@/components/home/mainCard';
function DateLocation() {
const { data } = useMontlyPlaceStates();
const maxCount = useMemo(() => {
return data?.result?.datePlaceLogList?.reduce((max, cur) => Math.max(max, cur.count), 0) ?? 0;
}, [data]);
return (
<MainCard>
<div className="py-[28px] flex flex-col">
<div className="text-xl font-bold text-[#616161] mb-6">WithTime에 등록된 데이트 장소 수</div>
<div className="flex items-end gap-8 w-full justify-center">
{data?.result.datePlaceLogList.map((graph, idx) => {
// 비율 계산
const height = maxCount ? (graph.count / maxCount) * 200 : 0; // 최대 높이 200px 기준
return (
<div className="flex flex-col items-center" key={idx}>
<span className="text-xs text-default-gray-500 mb-1">{graph.count}</span>
<div
className="w-10 bg-default-gray-400 mb-2 flex items-start justify-center transition-all duration-300"
style={{ height: `${height}px` }}
/>
<div className="text-default-gray-500 mt-1">{graph.month}월</div>
</div>
);
})}
</div>
</div>
</MainCard>
);
}
export default React.memo(DateLocation);