diff --git a/src/pages/Admin/Charity/Dashboard/Dashboard.tsx b/src/pages/Admin/Charity/Dashboard/Dashboard.tsx index 5eab73b59f..b69f4770b5 100644 --- a/src/pages/Admin/Charity/Dashboard/Dashboard.tsx +++ b/src/pages/Admin/Charity/Dashboard/Dashboard.tsx @@ -1,6 +1,6 @@ import { PropsWithChildren } from "react"; import { useAdminContext } from "pages/Admin/Context"; -import { useProfileQuery } from "services/aws/aws"; +import { useEndowBalanceQuery } from "services/apes"; import ContentLoader from "components/ContentLoader"; import QueryLoader from "components/QueryLoader"; import Seo from "../Seo"; @@ -8,7 +8,7 @@ import Balance from "./Balance"; export default function Dashboard() { const { id } = useAdminContext(); - const queryState = useProfileQuery({ endowId: id }, { skip: !id }); + const queryState = useEndowBalanceQuery(id, { skip: !id }); return (
diff --git a/src/pages/Profile/Body/GeneralInfo/DetailsColumn/Balances.tsx b/src/pages/Profile/Body/GeneralInfo/DetailsColumn/Balances.tsx index e63078877e..c561b602d7 100644 --- a/src/pages/Profile/Body/GeneralInfo/DetailsColumn/Balances.tsx +++ b/src/pages/Profile/Body/GeneralInfo/DetailsColumn/Balances.tsx @@ -1,12 +1,17 @@ import { useProfileContext } from "pages/Profile/ProfileContext"; +import { useEndowBalanceQuery } from "services/apes"; import { humanize } from "helpers"; export default function Balances() { - const { totalContributions } = useProfileContext(); + const { id } = useProfileContext(); + const { data } = useEndowBalanceQuery(id); return (
- +
); } diff --git a/src/services/apes/apes.ts b/src/services/apes/apes.ts index f77c2881e8..a77423e613 100644 --- a/src/services/apes/apes.ts +++ b/src/services/apes/apes.ts @@ -1,5 +1,5 @@ import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react"; -import { Token } from "types/aws"; +import { EndowmentBalances, Token } from "types/aws"; import { ChainID } from "types/chain"; import { appRoutes } from "constants/routes"; import { APIs } from "constants/urls"; @@ -37,12 +37,17 @@ export const apes = createApi({ }), } ), + endowBalance: builder.query({ + providesTags: ["balance"], + query: (endowId) => `${v(1)}/balances/${endowId}`, + }), }), }); export const { useTokensQuery, useStripeSessionURLMutation, + useEndowBalanceQuery, util: { invalidateTags: invalidateApesTags, updateQueryData: updateApesQueryData, diff --git a/src/services/apes/tags.ts b/src/services/apes/tags.ts index ae06df24c7..9413d0abf3 100644 --- a/src/services/apes/tags.ts +++ b/src/services/apes/tags.ts @@ -1 +1 @@ -export const tags = ["chain", "donations", "tokens"] as const; +export const tags = ["chain", "donations", "tokens", "balance"] as const; diff --git a/src/types/aws/ap/index.ts b/src/types/aws/ap/index.ts index e44c5e3765..a4777d5452 100644 --- a/src/types/aws/ap/index.ts +++ b/src/types/aws/ap/index.ts @@ -2,16 +2,6 @@ import { APIEnvironment, EndowmentType, UNSDG_NUMS } from "../../lists"; export type EndowmentTierNum = 1 | 2 | 3; -type EndowmentBalances = { - contributionsCount: number; - donationsBal: number; - payoutsMade: number; - payoutsPending: number; - sustainabilityFundBal: number; - totalContributions: number; - totalEarnings: number; -}; - export type MileStone = { milestone_date: string; //isoDate milestone_description: string; @@ -68,7 +58,7 @@ export type EndowmentProfile = EndowmentBase & { street_address: string; //or empty url: string; wise_recipient_id: number; -} & EndowmentBalances; +}; export type EndowmentCard = EndowmentBase & { endow_type: EndowmentType; diff --git a/src/types/aws/apes/index.ts b/src/types/aws/apes/index.ts index 2888213530..0fdae0f33f 100644 --- a/src/types/aws/apes/index.ts +++ b/src/types/aws/apes/index.ts @@ -20,3 +20,13 @@ export type Token = { coingecko_denom: string; type: TokenType; }; + +export type EndowmentBalances = { + contributionsCount: number; + donationsBal: number; + payoutsMade: number; + payoutsPending: number; + sustainabilityFundBal: number; + totalContributions: number; + totalEarnings: number; +};