Skip to content

Commit

Permalink
⚡️: null 제거 및 파일명 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
seongyun4359 committed Jan 10, 2025
1 parent f6c6572 commit 5ed2431
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 38 deletions.
2 changes: 1 addition & 1 deletion src/app/(main)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { BidPieChart } from "@/features/realtime/components/chart/bid-pie-chart"
import WeeklyPowerChart from "@/features/realtime/components/chart/weekly-power-chart"
import { RegionalEnergyChart } from "@/features/region/components/RegionalEnergyChart"
import { MainPageSummaryCard } from "@/features/summary-data/components/main-page"
import { MainPageSummaryCard } from "@/features/summary-data/components/main-page-mini-card"
import {
Card,
CardHeader,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { MiniCard } from "@/common/components/card"
import { useTodayElcGen } from "@/features/summary-data/hooks/uesTodayElcGen"
import { useTodayRECData } from "@/features/summary-data/hooks/useTodayRECData"
import { useTodaySMPData } from "@/features/summary-data/hooks/useTodaySMPData"
import { useTodayElcGen } from "@/features/summary-data/hooks/uesTodayElcGen"
import { getMiniCardData } from "@/features/summary-data/utils/mainMiniCardUtils"

export function MainPageSummaryCard() {
Expand Down
49 changes: 13 additions & 36 deletions src/features/summary-data/utils/mainMiniCardUtils.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
import type { TElcGen } from "@/features/summary-data/types/TodayElcGen"
import type { TRECData } from "@/features/summary-data/types/TodayREC"
import type { TSMPData } from "@/features/summary-data/types/TodaySmp"
import type { TElcGen } from "@/features/summary-data/types/TodayElcGen"

export function getMiniCardData(
todaySMPData: TSMPData[] | null,
todayRECData: TRECData[] | null,
todayElcGenData: TElcGen[] | null,
todaySMPData: TSMPData[],
todayRECData: TRECData[],
todayElcGenData: TElcGen[],
) {
// 최신 및 이전 SMP 데이터 처리
const recentSMPData: TSMPData | null =
todaySMPData && todaySMPData.length > 0
? todaySMPData[todaySMPData.length - 1]
: null

const previousSMPData: TSMPData | null =
todaySMPData && todaySMPData.length > 1
? todaySMPData[todaySMPData.length - 2]
: null
const recentSMPData = todaySMPData[todaySMPData.length - 1]
const previousSMPData = todaySMPData[todaySMPData.length - 2]

const smpDifference =
recentSMPData && previousSMPData
Expand All @@ -26,15 +19,8 @@ export function getMiniCardData(
const smpAmount = Math.round(Math.abs(smpDifference) * 100) / 100

// 최신 및 이전 REC 데이터 처리
const recentRECData: TRECData | null =
todayRECData && todayRECData.length > 0
? todayRECData[todayRECData.length - 1]
: null

const previousRECData: TRECData | null =
todayRECData && todayRECData.length > 1
? todayRECData[todayRECData.length - 2]
: null
const recentRECData = todayRECData[todayRECData.length - 1]
const previousRECData = todayRECData[todayRECData.length - 2]

const recDifference =
recentRECData && previousRECData
Expand All @@ -44,15 +30,8 @@ export function getMiniCardData(
const recAmount = Math.round(Math.abs(recDifference) * 100) / 100

// 최신 및 이전 전력생산량 데이터 처리
const recentElcGenData: TElcGen | null =
todayElcGenData && todayElcGenData.length > 0
? todayElcGenData[todayElcGenData.length - 1]
: null

const previousElcGenData: TElcGen | null =
todayElcGenData && todayElcGenData.length > 1
? todayElcGenData[todayElcGenData.length - 2]
: null
const recentElcGenData = todayElcGenData[todayElcGenData.length - 1]
const previousElcGenData = todayElcGenData[todayElcGenData.length - 2]

const elcGenDifference =
recentElcGenData && previousElcGenData
Expand All @@ -65,9 +44,7 @@ export function getMiniCardData(
return [
{
title: "일일전력생산량",
value: recentElcGenData
? recentElcGenData.cumulative_generation_kwh
: "데이터 없음",
value: recentElcGenData?.cumulative_generation_kwh || "데이터 없음",
unit: "Mwh",
isIncreased: isElcGenIncreased,
amount: elcGenAmount,
Expand All @@ -83,15 +60,15 @@ export function getMiniCardData(
},
{
title: "SMP 현재가",
value: recentSMPData ? recentSMPData.Land : "데이터 없음",
value: recentSMPData?.Land || "데이터 없음",
unit: "원/kWh",
isIncreased: isSMPIncreased,
amount: smpAmount,
color: "bg-[#F6FCF3]",
},
{
title: "REC 현재가",
value: recentRECData ? recentRECData.closing_price : "데이터 없음",
value: recentRECData?.closing_price || "데이터 없음",
unit: "원/REC",
isIncreased: isRECIncreased,
amount: recAmount,
Expand Down

0 comments on commit 5ed2431

Please sign in to comment.