Skip to content

Commit

Permalink
add homepage stats (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
alecananian authored Jul 10, 2024
1 parent db37020 commit 5743223
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 316 deletions.
11 changes: 4 additions & 7 deletions app/api/stats.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,16 @@ import type { ExecutionResult } from "graphql";

import { GetStatsDocument, type GetStatsQuery, execute } from ".graphclient";

const fetchStats = async () => {
export const fetchStats = async () => {
const result = (await execute(
GetStatsDocument,
{}
)) as ExecutionResult<GetStatsQuery>;
const { factories = [], dayDatas = [] } = result.data ?? {};
return {
global: factories[0],
day: dayDatas[0],
};
const { factories = [] } = result.data ?? {};
return factories[0];
};

export const fetchMagicUSD = async () => {
const stats = await fetchStats();
return Number(stats.global?.magicUSD ?? 0);
return Number(stats?.magicUSD ?? 0);
};
12 changes: 1 addition & 11 deletions app/components/Landing/StatisticCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,11 @@ import { cn } from "~/lib/utils";
interface Props {
Icon?: React.ElementType;
iconClass?: string;
Background?: React.ElementType;
value: string | number;
title: string;
}

const StatisticCard = ({
Icon,
iconClass,
Background,
value,
title,
}: Props) => {
const StatisticCard = ({ Icon, iconClass, value, title }: Props) => {
return (
<div className="relative flex h-[88px] w-full flex-col justify-center overflow-hidden rounded-lg border-t border-t-night-800 bg-night-1000 px-6 shadow-xl lg:h-[110px] lg:px-8">
<div className="relative z-10 flex items-center gap-2 lg:gap-3">
Expand All @@ -28,9 +21,6 @@ const StatisticCard = ({
<p className="relative z-10 text-sm uppercase leading-[130%] text-night-400">
{title}
</p>
{!!Background && (
<Background className="absolute -bottom-[100px] -right-[80px] h-[132px] w-[132px] -translate-x-1/2 -translate-y-1/2 text-night-1100" />
)}
</div>
);
};
Expand Down
7 changes: 0 additions & 7 deletions app/components/Layout.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { Link, NavLink } from "@remix-run/react";
import { MagicSwapLogo, MagicSwapLogoFull } from "@treasure-project/branding";
import { MenuIcon } from "lucide-react";
import { useState } from "react";

import { ConnectButton } from "./ConnectButton";
import { Footer } from "./Footer";
import { DiscordIcon, TwitterIcon } from "./Icons";
import SearchPopup from "./SearchPopup";
import { Button } from "./ui/Button";
import {
DropdownMenu,
Expand All @@ -32,8 +30,6 @@ const Pages = [
];

export const Layout = ({ children }: { children: React.ReactNode }) => {
const [showSearchPopup, setShowSearchPopup] = useState(false);

return (
<div className="flex min-h-full flex-col">
<header className="container flex h-24 items-center">
Expand Down Expand Up @@ -140,9 +136,6 @@ export const Layout = ({ children }: { children: React.ReactNode }) => {
</header>
<div className="relative flex-1">{children}</div>
<Footer />
{showSearchPopup && (
<SearchPopup onClose={() => setShowSearchPopup(false)} />
)}
</div>
);
};
242 changes: 0 additions & 242 deletions app/components/SearchPopup.tsx

This file was deleted.

3 changes: 2 additions & 1 deletion app/components/pools/PoolDepositTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -352,10 +352,11 @@ export const PoolDepositTab = ({
if (!isApproved0) {
return approveBaseToken?.();
}

if (!isApproved1) {
return approveQuoteToken?.();
}
console.log("here");

return addLiquidity?.();
}}
>
Expand Down
5 changes: 2 additions & 3 deletions app/graphql/stats.graphql
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
query GetStats {
factories {
pairCount
reserveNFT
txCount
userCount
magicUSD
}
dayDatas(orderBy: date, orderDirection: desc, first: 1) {
volumeUSD
}
}
4 changes: 0 additions & 4 deletions app/hooks/useAddLiquidity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,6 @@ export const useAddLiquidity = ({
// nftNFTAddLiquidity.writeContract(nftNFTAddLiquidityConfig?.request);
// } else
if (pool.hasNFT && nftAddLiquidityConfig?.request) {
console.log(
"nftAddLiquidityConfig?.request",
nftAddLiquidityConfig?.request
);
nftAddLiquidity.writeContract(nftAddLiquidityConfig?.request);
} else if (tokenAddLiquidityConfig?.request) {
tokenAddLiquidity.writeContract(tokenAddLiquidityConfig?.request);
Expand Down
Loading

0 comments on commit 5743223

Please sign in to comment.