From 64211054cfeb59211f1c4563200bf1cad6bb4f0a Mon Sep 17 00:00:00 2001 From: mnsrulz Date: Mon, 7 Oct 2024 21:03:26 -0400 Subject: [PATCH] making historical page as server side --- src/app/seasonal/[symbol]/page.tsx | 9 +++----- src/components/HistoricalSeason.tsx | 26 +++++++++++------------ src/components/TickerSearchNavigation.tsx | 1 + 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/src/app/seasonal/[symbol]/page.tsx b/src/app/seasonal/[symbol]/page.tsx index 6324bda..2a48922 100644 --- a/src/app/seasonal/[symbol]/page.tsx +++ b/src/app/seasonal/[symbol]/page.tsx @@ -6,10 +6,7 @@ export default async function Page({ params }: { params: { symbol: string } }) { const { symbol } = params; const dt = await getSeasonalView(symbol, '5y', 'monthly'); return <> - {/* not working due to clientside and serverside battle.. let's look at it later */} - {/* */} - + + -} - - +} \ No newline at end of file diff --git a/src/components/HistoricalSeason.tsx b/src/components/HistoricalSeason.tsx index e46761a..8e8c3a4 100644 --- a/src/components/HistoricalSeason.tsx +++ b/src/components/HistoricalSeason.tsx @@ -4,8 +4,8 @@ import { HistoricalDataResponse } from "@/lib/types" import { GridColDef, DataGrid, gridClasses } from "@mui/x-data-grid"; import dayjs from "dayjs"; import { ConditionalFormattingBox } from "./ConditionalFormattingBox"; -import { numberFormatter, percentageFormatter } from "@/lib/formatters"; - +import { percentageFormatter } from "@/lib/formatters"; +import { Box, Typography } from "@mui/material"; const months = [ 'January', @@ -22,8 +22,8 @@ const months = [ 'December', ]; -export const HistoricalSeason = (props: { data: HistoricalDataResponse }) => { - const currentYear = dayjs().year(); +export const HistoricalSeason = (props: { data: HistoricalDataResponse, symbol: string }) => { + // const currentYear = dayjs().year(); // use to render the graph/chart // const dkk = dt.history.day.reduce((acc: Record, current) => { // const year = dayjs(current.date).format('YYYY'); @@ -51,7 +51,7 @@ const seriesData = Object.keys(dkk).map(year => ({ */ const dt = props.data; const years: string[] = [] - const dkk = dt.history.day.reduce((acc: { id: string }[], current) => { + const rowsData = dt.history.day.reduce((acc: { id: string }[], current) => { const year = dayjs(current.date).format('YYYY'); const pm = ((current.close - current.open) / current.open); const month = dayjs(current.date).month(); @@ -59,22 +59,22 @@ const seriesData = Object.keys(dkk).map(year => ({ if (!years.includes(year)) years.push(year); return acc }, months.map(j => ({ id: j }))); - debugger; const columns: GridColDef[] = [ - { field: 'id', width: 120, headerName: 'month' }, + { field: 'id', width: 120, headerName: 'Month' }, ...years.map(j => { return { - field: `d${j}`, width: 120, headerName: j, - valueFormatter: percentageFormatter, + field: `d${j}`, width: 10, headerName: j, align: 'right', + valueFormatter: percentageFormatter, type: 'number', - renderCell: (p) => + renderCell: (p) => } as GridColDef }) ] - return
- + Ticker: {props.symbol} + ({ }, }} /> -
+ } \ No newline at end of file diff --git a/src/components/TickerSearchNavigation.tsx b/src/components/TickerSearchNavigation.tsx index 41f1814..a2cd4cc 100644 --- a/src/components/TickerSearchNavigation.tsx +++ b/src/components/TickerSearchNavigation.tsx @@ -1,3 +1,4 @@ +'use client'; import { TickerSearch } from '@/components/TickerSearch'; import { useRouter } from 'next/navigation';