Skip to content

Commit

Permalink
fix: rSWTH price and select url variable
Browse files Browse the repository at this point in the history
  • Loading branch information
emidev98 committed Feb 2, 2024
1 parent 9a22a43 commit 8a6753d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Metadata } from 'next'
import '@/styles/globals.css';
import '../styles/globals.css';
import Nav from '../components/Nav';
import { Suspense } from 'react';
import CSSLoader from '../components/CSSLoader';
Expand Down
10 changes: 8 additions & 2 deletions app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { DEFAULT_CHAIN, SUPPORTED_CHAINS } from "../const/chains";
import { QueryAlliances } from "../lib/AllianceQuery";
import { AllianceAsset } from "@terra-money/feather.js/dist/client/lcd/api/AllianceAPI";
import Link from "next/link";
import { useSearchParams } from "next/navigation";
import { useSearchParams, useRouter } from "next/navigation";
import { Suspense, useEffect, useState } from "react";
import { mergePrices, Prices, TerraPriceServerResponse } from "../models/Prices";
import { Kpis } from "../const/kpis";
Expand All @@ -17,7 +17,13 @@ export default function Home() {
const [prices, setPrices] = useState<Prices>({});
const [data, setData] = useState<AllianceAsset[] | undefined>(undefined);
const params = useSearchParams();
const selectedChain = SUPPORTED_CHAINS[params.get("selected") ?? DEFAULT_CHAIN];
let selectedChain = SUPPORTED_CHAINS[params.get("selected") ?? DEFAULT_CHAIN];
const router = useRouter();

if (selectedChain === undefined) {
selectedChain = SUPPORTED_CHAINS[DEFAULT_CHAIN];
router.push(`?selected=${SUPPORTED_CHAINS[DEFAULT_CHAIN].id}`)
}

useEffect(() => {
setData(undefined);
Expand Down
2 changes: 1 addition & 1 deletion components/Dropdown.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";

import { useState } from "react";
import styles from "@/styles/Dropdown.module.css";
import styles from "../styles/Dropdown.module.css";
import { useRouter, useSearchParams } from "next/navigation";
import { DEFAULT_CHAIN, SUPPORTED_CHAINS } from "../const/chains";

Expand Down
2 changes: 1 addition & 1 deletion const/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export const SUPPORTED_CHAINS: { [key: string]: Chain } = {
allianceCoins: {
"ibc/0E90026619DD296AD4EF9546396F292B465BAB6B5BE00ABD6162AA1CE8E68098": {
name: "rSWTH",
priceKey: "ibc/0E90026619DD296AD4EF9546396F292B465BAB6B5BE00ABD6162AA1CE8E68098",
priceKey: "rSWTH",
icon: "https://raw.githubusercontent.com/terra-money/station-assets/main/img/coins/rSWTH.svg",
color: "#324ab2",
},
Expand Down

0 comments on commit 8a6753d

Please sign in to comment.