From 2ae2fe7368d38413d5bd1cf147de12d4433e6715 Mon Sep 17 00:00:00 2001
From: ap-justin <89639563+ap-justin@users.noreply.github.com>
Date: Tue, 10 Sep 2024 22:09:53 +0800
Subject: [PATCH] movement data
---
.../Admin/Charity/Dashboard/Dashboard.tsx | 98 ++-----------
src/pages/Admin/Charity/Dashboard/Figure.tsx | 2 +
src/pages/Admin/Charity/Dashboard/Loaded.tsx | 130 ++++++++++++++++++
.../Admin/Charity/Dashboard/MoveFundForm.tsx | 86 ++++++++++++
.../Admin/Charity/Dashboard/Movements.tsx | 62 +++++++++
.../Charity/Dashboard/Schedule/Schedule.tsx | 4 +-
src/services/apes/apes.ts | 1 +
src/services/apes/donations.ts | 16 +++
src/services/apes/tags.ts | 2 +-
src/types/aws/apes/index.ts | 10 ++
10 files changed, 320 insertions(+), 91 deletions(-)
create mode 100644 src/pages/Admin/Charity/Dashboard/Loaded.tsx
create mode 100644 src/pages/Admin/Charity/Dashboard/MoveFundForm.tsx
create mode 100644 src/pages/Admin/Charity/Dashboard/Movements.tsx
diff --git a/src/pages/Admin/Charity/Dashboard/Dashboard.tsx b/src/pages/Admin/Charity/Dashboard/Dashboard.tsx
index 85b6d561ac..7509c18898 100644
--- a/src/pages/Admin/Charity/Dashboard/Dashboard.tsx
+++ b/src/pages/Admin/Charity/Dashboard/Dashboard.tsx
@@ -1,17 +1,11 @@
import { skipToken } from "@reduxjs/toolkit/query";
import ContentLoader from "components/ContentLoader";
-import Icon from "components/Icon";
import QueryLoader from "components/QueryLoader";
-import { Arrow, Content } from "components/Tooltip";
-import { humanize } from "helpers";
import { useEndowBalanceQuery } from "services/apes";
-import type { EndowmentBalances } from "types/aws";
import { useAdminContext } from "../../Context";
import Seo from "../Seo";
-import Figure from "./Figure";
-import { PayoutHistory } from "./PayoutHistory";
-import { Schedule } from "./Schedule";
-import { monthPeriod } from "./monthPeriod";
+
+import { Loaded } from "./Loaded";
export default function Dashboard() {
const { id } = useAdminContext();
@@ -34,90 +28,16 @@ export default function Dashboard() {
);
}
-function Loaded({
- classes = "",
- ...props
-}: EndowmentBalances & { classes?: string }) {
- const { id } = useAdminContext();
- const period = monthPeriod();
- return (
-
-
Account Balances
-
-
-
-
-
-
- Period
-
- {period.from} - {period.to}
-
-
- Ends in
-
- in {period.distance}
-
-
-
-
-
-
-
-
- );
-}
-
function LoaderSkeleton() {
return (
-
-
-
-
-
-
-
+
+
+
+
+
+
+
);
}
diff --git a/src/pages/Admin/Charity/Dashboard/Figure.tsx b/src/pages/Admin/Charity/Dashboard/Figure.tsx
index a414c79f99..26dca5bfbe 100644
--- a/src/pages/Admin/Charity/Dashboard/Figure.tsx
+++ b/src/pages/Admin/Charity/Dashboard/Figure.tsx
@@ -9,6 +9,7 @@ type Props = {
amount: string;
/** must be wrapped by tooltip content */
tooltip?: ReactNode;
+ actions?: ReactNode;
};
export default function Figure(props: Props) {
@@ -30,6 +31,7 @@ export default function Figure(props: Props) {
{props.icon}
{props.amount}
+ {props.actions}
);
}
diff --git a/src/pages/Admin/Charity/Dashboard/Loaded.tsx b/src/pages/Admin/Charity/Dashboard/Loaded.tsx
new file mode 100644
index 0000000000..2174107518
--- /dev/null
+++ b/src/pages/Admin/Charity/Dashboard/Loaded.tsx
@@ -0,0 +1,130 @@
+import Icon from "components/Icon";
+import { Arrow, Content } from "components/Tooltip";
+import { useModalContext } from "contexts/ModalContext";
+import { humanize } from "helpers";
+import { useAdminContext } from "pages/Admin/Context";
+import type { EndowmentBalances } from "types/aws";
+import Figure from "./Figure";
+import { MoveFundForm } from "./MoveFundForm";
+import { Movements } from "./Movements";
+import { PayoutHistory } from "./PayoutHistory";
+import { Schedule } from "./Schedule";
+import { monthPeriod } from "./monthPeriod";
+
+export function Loaded({
+ classes = "",
+ ...props
+}: EndowmentBalances & { classes?: string }) {
+ const { id } = useAdminContext();
+ const period = monthPeriod();
+ const { showModal } = useModalContext();
+
+ const mov = props.movementDetails ?? {
+ "liq-cash": 0,
+ "liq-lock": 0,
+ "lock-cash": 0,
+ };
+
+ const liqDeductions = Object.entries(mov).reduce(
+ (sum, [k, v]) => (k.startsWith("liq-") ? sum + v : sum),
+ 0
+ );
+ const lockDeductions = Object.entries(mov).reduce(
+ (sum, [k, v]) => (k.startsWith("liq-") ? sum + v : sum),
+ 0
+ );
+
+ const grantFromBal = Object.entries(mov).reduce(
+ (sum, [k, v]) => (k.endsWith("-cash") ? sum + v : sum),
+ 0
+ );
+
+ return (
+
+
Account Balances
+
+
+ Funds held in Fidelity Government Money Market (SPAXX) consisting
+ of cash, US Government Securities and Repurchase Agreements
+
+
+ }
+ icon={}
+ amount={`$ ${humanize(props.donationsBal - props.payoutsMade, 2)}`}
+ actions={
+
+
+
+ }
+ />
+
+
+ Funds invested in a diversified portfolio comprising
+
+