diff --git a/components/create/editor/Publishing.tsx b/components/create/editor/Publishing.tsx index 752af01d8..1c5273bf8 100644 --- a/components/create/editor/Publishing.tsx +++ b/components/create/editor/Publishing.tsx @@ -104,7 +104,7 @@ export const Publishing = ({ editor, creationParams }: PublishingProps) => { editor.form.moderation === "Permissionless" && editor.form.liquidity?.deploy && editor.form.currency === "ZTG" - ? new Decimal(editor.form.liquidity.amount ?? 0).toNumber() + ? new Decimal(editor.form.liquidity.amount || 0).toNumber() : 0, ) .plus(ztgTransactionFee ?? 0); @@ -121,7 +121,7 @@ export const Publishing = ({ editor, creationParams }: PublishingProps) => { const foreignCurrencyCost = editor.form.liquidity?.deploy && editor.form.currency !== "ZTG" - ? new Decimal(editor.form.liquidity.amount ?? 0) + ? new Decimal(editor.form.liquidity.amount || 0) .mul(2) .plus(baseAssetTransactionFee ?? 0) : null; @@ -314,7 +314,7 @@ export const Publishing = ({ editor, creationParams }: PublishingProps) => {
{new Decimal( - editor.form.liquidity.amount ?? 0, + editor.form.liquidity.amount || 0, ).toFixed(1)}{" "} {editor.form.currency}
diff --git a/components/front-page/HeroBanner.tsx b/components/front-page/HeroBanner.tsx index 97280a5bc..652e77583 100644 --- a/components/front-page/HeroBanner.tsx +++ b/components/front-page/HeroBanner.tsx @@ -15,12 +15,12 @@ export const HeroBanner = ({ bannerPlaceholder: string; chainProperties: GenericChainProperties; }) => { - const chartData = ztgHistory.prices.map(([timestamp, price]) => { + const chartData = ztgHistory.prices?.map(([timestamp, price]) => { return { v: price, t: 1 }; }); - const firstPrice = ztgHistory.prices[0][1]; - const latestPrice = ztgHistory.prices[ztgHistory.prices.length - 1][1]; + const firstPrice = ztgHistory.prices?.[0]?.[1]; + const latestPrice = ztgHistory.prices?.[ztgHistory.prices.length - 1]?.[1]; const prctChange = ((latestPrice - firstPrice) / firstPrice) * 100; return ( @@ -76,24 +76,26 @@ export const HeroBanner = ({ dot={false} strokeWidth={2} stroke={getColour( - chartData[0].v, - chartData[chartData.length - 1].v, + chartData?.[0].v, + chartData?.[chartData.length - 1].v, )} /> -
-
-
- ${latestPrice.toFixed(3)} -
-
- {!isNaN(prctChange) ? prctChange.toFixed(1) : 0}% + {latestPrice && ( +
+
+
+ ${latestPrice.toFixed(3)} +
+
+ {!isNaN(prctChange) ? prctChange.toFixed(1) : 0}% +
-
+ )}
diff --git a/lib/gql/historical-prices.ts b/lib/gql/historical-prices.ts index 92c08c87c..2323e5902 100644 --- a/lib/gql/historical-prices.ts +++ b/lib/gql/historical-prices.ts @@ -58,7 +58,7 @@ export const getBaseAssetHistoricalPrices = async (): Promise => { const findPrice = (timestamp: number, prices: [number, number][]) => { const date = new Date(Number(timestamp)); - const price = prices.find((p) => { + const price = prices?.find((p) => { return datesAreOnSameDay(date, new Date(p[0])); }); diff --git a/lib/state/market-creation/editor.ts b/lib/state/market-creation/editor.ts index e3e6418b9..afd15b430 100644 --- a/lib/state/market-creation/editor.ts +++ b/lib/state/market-creation/editor.ts @@ -367,7 +367,7 @@ export const useMarketDraftEditor = (): MarketDraftEditor => { ...draft.form, liquidity: { ...draft.form.liquidity, - amount: draft.form.liquidity.amount ?? liquidity, + amount: draft.form.liquidity.amount || liquidity, rows, }, },