Skip to content

Commit

Permalink
Fix build errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ckoopmann committed May 24, 2024
1 parent 64fe18a commit b869865
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
22 changes: 14 additions & 8 deletions src/mainsite/components/MarketCapRatioWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Highcharts from "highcharts";
import HighchartsReact from "highcharts-react-official";
import highchartsAnnotations from "highcharts/modules/annotations";
import _merge from "lodash/merge";
import type { FC } from "react";
import type { FC, RefObject } from "react";
import TranslationsContext from "../contexts/TranslationsContext";
import { useContext, useEffect, useMemo, useRef } from "react";
import colors from "../../colors";
Expand All @@ -15,8 +15,7 @@ import _first from "lodash/first";
import { formatDate } from "../utils/metric-utils";
import { formatOneDecimal } from "../../format";
import styles from "./MarketCapRatioWidget.module.scss";
import { COLORS, defaultOptions } from "../utils/chart-defaults";
import { warn } from "console";
import { COLORS } from "../utils/chart-defaults";

export type MarketCapRatioPoint = [JsTimestamp, number];

Expand Down Expand Up @@ -126,7 +125,7 @@ const makeBarrier = (barrier: number) => ({
});

type Props = {
marketCapsMap: Record<number, { ethMarketCap: number; btcMarketCap: number }>;
marketCapsMap: Record<number, { ethMarketcap: number; btcMarketcap: number }>;
marketCapRatiosSeries: MarketCapRatioPoint[] | undefined;
maxMarketCap: number | undefined;
exponentialGrowthCurveSeries: MarketCapRatioPoint[] | undefined;
Expand Down Expand Up @@ -161,8 +160,12 @@ const MarketCapRatiosWidget: FC<Props> = ({
}, []);

const barrier = 1;
const flippeningDataPoint =
exponentialGrowthCurveSeries === undefined
? undefined
: exponentialGrowthCurveSeries[exponentialGrowthCurveSeries.length - 1];
const flippeningTimestamp =
exponentialGrowthCurveSeries[exponentialGrowthCurveSeries.length - 1][0];
flippeningDataPoint === undefined ? undefined : flippeningDataPoint[0];

const options = useMemo((): Highcharts.Options => {
const min = marketCapRatiosSeries?.reduce(
Expand Down Expand Up @@ -257,7 +260,7 @@ const MarketCapRatiosWidget: FC<Props> = ({
xDateFormat: "%Y-%m-%d",
useHTML: true,
formatter: function () {
let points = (this.points || []).slice(0);
const points = (this.points || []).slice(0);

const firstPoint = _first(points);

Expand Down Expand Up @@ -295,9 +298,9 @@ const MarketCapRatiosWidget: FC<Props> = ({
</tr>`,
);

if (!isProjected) {
if (!isProjected && firstPoint?.x !== undefined) {
console.log("First Point", firstPoint);
const marketCaps = marketCapsMap[firstPoint.x];
const marketCaps = marketCapsMap[firstPoint.x as number];
console.log("Market caps Map", marketCapsMap);
console.log("Market caps", marketCaps);
const marketCapRows = [
Expand Down Expand Up @@ -392,6 +395,9 @@ const MarketCapRatiosWidget: FC<Props> = ({
</div>
)}
</div>
<LabelText color="text-slateus-400 mt-2" className="text-right">
Not financial advice
</LabelText>
</WidgetBackground>
</WidgetErrorBoundary>
);
Expand Down
19 changes: 12 additions & 7 deletions src/mainsite/sections/FlippeningSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ const pointsFromMarketCapRatiosOverTime = (

const FlippeningSection: FC = () => {
const flippeningData = useFlippeningData();
console.log("flippeningData", flippeningData);

const [
marketCapRatiosSeries,
Expand All @@ -69,7 +68,7 @@ const FlippeningSection: FC = () => {
return [undefined, undefined];
}

let series = pointsFromMarketCapRatiosOverTime(flippeningData);
const series = pointsFromMarketCapRatiosOverTime(flippeningData);
const maxMarketCap = _maxBy(series, (point) => point[1]);

let expontentialGrowthCurve: MarketCapRatioPoint[] = [];
Expand All @@ -94,14 +93,20 @@ const FlippeningSection: FC = () => {
}, [flippeningData]);

const marketCapSeries = flippeningData?.map(
({ t, ethMarketcap, btcMarketcap }) => [t*1000, { ethMarketcap, btcMarketcap }],
({ t, ethMarketcap, btcMarketcap }) => [
t * 1000,
{ ethMarketcap, btcMarketcap },
],
);
console.log("marketCapSeries", marketCapSeries);
const marketCapsMap =
const marketCapsMap:
| Record<number, { ethMarketcap: number; btcMarketcap: number }>
| undefined =
marketCapSeries === undefined
? undefined
: Object.fromEntries(marketCapSeries);

: (Object.fromEntries(marketCapSeries) as Record<
number,
{ ethMarketcap: number; btcMarketcap: number }
>);
return (
<Section
link="flippening"
Expand Down

0 comments on commit b869865

Please sign in to comment.