-
Notifications
You must be signed in to change notification settings - Fork 0
[FE] 대시보드 편집창 - 매출추이 지표 카드 추가 #299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f7306a1
4c5edbf
f762ac0
b29662a
64083f2
f342e78
0358dd4
6f3ea5a
d588755
c38887d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| import { BarLineChart } from '@/components/shared'; | ||
| import { | ||
| DASHBOARD_METRIC_CARDS, | ||
| type DASHBOARD_METRICS, | ||
| type ExtractCardCodesFromSection, | ||
| } from '@/constants/dashboard'; | ||
| import { SALES_TREND } from '@/constants/sales'; | ||
| import { PERIOD_PRESETS } from '@/constants/shared'; | ||
| import type { BarLineChartSeries } from '@/types/shared'; | ||
| import { cn } from '@/utils/shared'; | ||
|
|
||
| type SalesTrendCardCode = ExtractCardCodesFromSection< | ||
| typeof DASHBOARD_METRICS.SALES.sections.SALES_TREND | ||
| >; | ||
|
|
||
| interface SalesTrendContentProps { | ||
| cardCode: SalesTrendCardCode; | ||
| salesTrendData: BarLineChartSeries; | ||
| trendChartWidth?: number; | ||
| trendChartHeight?: number; | ||
| className?: string; | ||
| } | ||
|
|
||
| export const SalesTrendContent = ({ | ||
| cardCode, | ||
| salesTrendData, | ||
| trendChartWidth, | ||
| trendChartHeight, | ||
| className, | ||
| }: SalesTrendContentProps) => { | ||
| const { period, label } = DASHBOARD_METRIC_CARDS[cardCode]; | ||
| const { | ||
| DEFAULT_TREND_CHART_WIDTH, | ||
| DEFAULT_TREND_CHART_WIDTH_FOR_RECENT_30_DAYS, | ||
| DEFAULT_TREND_CHART_HEIGHT, | ||
| } = SALES_TREND; | ||
|
|
||
| const trendChartWidthValue = | ||
| trendChartWidth ?? | ||
| (period === PERIOD_PRESETS.recentDays7_14_30.recent30Days | ||
| ? DEFAULT_TREND_CHART_WIDTH_FOR_RECENT_30_DAYS | ||
| : DEFAULT_TREND_CHART_WIDTH); | ||
|
|
||
| const trendChartHeightValue = trendChartHeight ?? DEFAULT_TREND_CHART_HEIGHT; | ||
|
|
||
| return ( | ||
| <article | ||
| className={cn( | ||
| 'flex flex-col items-start justify-start gap-4', | ||
| period === PERIOD_PRESETS.recentDays7_14_30.recent30Days | ||
| ? 'w-170' | ||
| : 'w-265', | ||
| className, | ||
| )} | ||
| > | ||
| <div className="flex items-center gap-3"> | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [p2] 제가 생각하기에는 다른 지표카드들과 마찬가지로 "일별 매출 추이"와 같은 제목(
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이건 디자인이 없어서 임의로 추가했는데, 이미 해당 카드 카테고리에 명시되어 있네요 |
||
| <h3 className="body-medium-semibold text-grey-700">{label}</h3> | ||
| <div className="caption-large-medium text-grey-600 flex items-center gap-2"> | ||
| <div className="flex items-center gap-1"> | ||
| <div className="h-4.5 w-2 rounded-t-[1px] bg-[linear-gradient(180deg,rgba(33,33,33,0.40)_0%,rgba(33,33,33,0.10)_100%)]" /> | ||
| <span>실매출</span> | ||
| </div> | ||
| <div className="flex items-center gap-1"> | ||
| <div className="bg-grey-400 size-1.25 rounded-full" /> | ||
| <span>주문건수</span> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| <BarLineChart | ||
| viewBoxWidth={trendChartWidthValue} | ||
| viewBoxHeight={trendChartHeightValue} | ||
| barLineChartSeries={salesTrendData} | ||
| hasXAxis | ||
| showYGuideLine | ||
| yGuideLineCount={5} | ||
| activeTooltip={false} | ||
| xAxisType="right-arrow" | ||
| /> | ||
| </article> | ||
| ); | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export { SalesTrendContent } from './SalesTrendContent'; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,20 +28,13 @@ export const BarLineSeries = ({ | |
| }: BarLineSeriesProps) => { | ||
| return ( | ||
| <g> | ||
| <path | ||
| d={interactionPathD} | ||
| fill="transparent" | ||
| stroke="transparent" | ||
| className="peer z-1" | ||
| pointerEvents="all" | ||
| /> | ||
| <path d={interactionPathD} fill="transparent" stroke="transparent" /> | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [p4] 툴팁 인터랙션 없애신 건가요? 상세분석에서 필요할 텐데 props로 내리지 않고 날려버리신 이유가 있나요..?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| <Dot | ||
| x={lineX} | ||
| y={lineY} | ||
| color={color} | ||
| ariaLabel={tooltipContentText} | ||
| hasHoverEffect | ||
| className="peer-hover:brightness-75 peer-hover:saturate-200" | ||
| hasHoverEffect={false} | ||
| /> | ||
| <Bar | ||
| barMiddleX={barX} | ||
|
|
@@ -51,8 +44,7 @@ export const BarLineSeries = ({ | |
| bgColor={color} | ||
| radius={BAR_CHART.BAR_RADIUS} | ||
| hasGradient | ||
| barColorChangeOnHover | ||
| className="peer-hover:[&_path]:fill-brand-main" | ||
| barColorChangeOnHover={false} | ||
| /> | ||
| </g> | ||
| ); | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -19,6 +19,7 @@ interface EditCardWrapperProps { | |||||
| innerClassName?: string; // 자식 컴포넌트 클래스명 | ||||||
| period: string; // 오늘, 이번주, 이번달 등 문구 | ||||||
| sizeX?: number; // 가로 크기 | ||||||
| sizeY?: number; // 세로 크기 | ||||||
| onClickDeleteButton?: () => void; // 대시보드에서 삭제하는 버튼 클릭 헨들러 | ||||||
| onClickAddButton?: () => void; // 대시보드에 추가하는 버튼 클릭 핸들러 | ||||||
| } | ||||||
|
|
@@ -31,6 +32,7 @@ export const EditCardWrapper = ({ | |||||
| className, | ||||||
| innerClassName, | ||||||
| sizeX = 1, | ||||||
| sizeY = 1, | ||||||
| period = '기간없음', | ||||||
| onClickDeleteButton, | ||||||
| onClickAddButton, | ||||||
|
|
@@ -47,10 +49,12 @@ export const EditCardWrapper = ({ | |||||
| <div | ||||||
| style={{ | ||||||
| width: | ||||||
| Math.max(EDIT_CARD_WRAPPER.MIN_WIDTH, computedCardWidth) * sizeX + | ||||||
| GRID_GAP * (sizeX - 1), // 최소 너비 220px, gap 20px | ||||||
| Math.max(EDIT_CARD_WRAPPER.MIN_WIDTH, computedCardWidth) + | ||||||
|
||||||
| Math.max(EDIT_CARD_WRAPPER.MIN_WIDTH, computedCardWidth) + | |
| Math.max(EDIT_CARD_WRAPPER.MIN_WIDTH, computedCardWidth) * sizeX + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이렇게 하면 높이 계산 때와 마찬가지로 너무 커지는 문제 있어 수정했습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[p4] 매출유입구조(도넛차트) 지표 카드에서 아래 height가 조금 남는데 정렬 문제일까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
음...?! 저는 괜찮은 것 같지만.. 내일 다같이 한번 보죠 ?!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 부분도 sizeX가 2이상일 때 스타일이 깨지는 문제가 있어서 수정했습니다.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export { SALES_TREND } from './salesTrend'; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| const createXData = (labels: string[]) => | ||
| labels.map((label) => ({ amount: label, unit: '' })); | ||
|
|
||
| const createYData = (values: number[]) => | ||
| values.map((value) => ({ amount: value, unit: '' })); | ||
|
|
||
| export const SALES_TREND = { | ||
| DEFAULT_TREND_CHART_WIDTH: 1040, | ||
| DEFAULT_TREND_CHART_WIDTH_FOR_RECENT_30_DAYS: 700, | ||
| DEFAULT_TREND_CHART_HEIGHT: 120, | ||
| EXAMPLE_DATA: { | ||
| SLS_09_04: { | ||
| data: { | ||
| mainX: createXData([ | ||
| '1월 15일', | ||
| '1월 16일', | ||
| '1월 17일', | ||
| '1월 18일', | ||
| '1월 19일', | ||
| '1월 20일', | ||
| '오늘', | ||
| ]), | ||
| mainY: createYData([520, 180, 330, 470, 600, 460, 220]), | ||
| subX: createXData([ | ||
| '1월 15일', | ||
| '1월 16일', | ||
| '1월 17일', | ||
| '1월 18일', | ||
| '1월 19일', | ||
| '1월 20일', | ||
| '오늘', | ||
| ]), | ||
| subY: createYData([16, 20, 14, 23, 20, 23, 14]), | ||
| }, | ||
| color: 'var(--color-grey-400)', | ||
| }, | ||
| SLS_10_07: { | ||
| data: { | ||
| mainX: createXData([ | ||
| '12월 1~7일', | ||
| '12월 8~14일', | ||
| '12월 15~21일', | ||
| '12월 22~28일', | ||
| '12월 29일~1월 4일', | ||
| '1월 5~11일', | ||
| '1월 12~18일', | ||
| '이번주', | ||
| ]), | ||
| mainY: createYData([460, 150, 280, 280, 620, 490, 280, 280]), | ||
| subX: createXData([ | ||
| '12월 1~7일', | ||
| '12월 8~14일', | ||
| '12월 15~21일', | ||
| '12월 22~28일', | ||
| '12월 29일~1월 4일', | ||
| '1월 5~11일', | ||
| '1월 12~18일', | ||
| '이번주', | ||
| ]), | ||
| subY: createYData([14, 18, 12, 20, 18, 18, 20, 12]), | ||
| }, | ||
| color: 'var(--color-grey-400)', | ||
| }, | ||
| SLS_11_07: { | ||
| data: { | ||
| mainX: createXData(['8월', '9월', '10월', '11월', '12월', '이번달']), | ||
| mainY: createYData([540, 180, 310, 310, 310, 310]), | ||
| subX: createXData(['8월', '9월', '10월', '11월', '12월', '이번달']), | ||
| subY: createYData([18, 15, 24, 21, 24, 15]), | ||
| }, | ||
| color: 'var(--color-grey-400)', | ||
| }, | ||
| } as const, | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export type { SalesTrendItem } from './salesTrend'; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| export interface SalesTrendItem { | ||
| label: string; | ||
| netAmount: number; | ||
| orderCount: number; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import type { SalesTrendItem } from '../dashboard-sales-trend'; | ||
|
|
||
| export interface GetSalesTrendResponseDto { | ||
| items: SalesTrendItem[]; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
삼항 연산자와 nullish coalescing 연산자(??)를 함께 사용할 때는 괄호로 우선순위를 명확히 해야 합니다. 현재 코드는 연산자 우선순위로 인해 의도한 대로 동작하지만, 가독성과 명확성을 위해 다음과 같이 수정하는 것을 권장합니다:
trendChartWidth ?? (period === PERIOD_PRESETS.recentDays7_14_30.recent30Days ? DEFAULT_TREND_CHART_WIDTH_FOR_RECENT_30_DAYS : DEFAULT_TREND_CHART_WIDTH)