Skip to content

Commit

Permalink
remove liq lock columns
Browse files Browse the repository at this point in the history
  • Loading branch information
ap-justin committed Sep 3, 2024
1 parent 534a5bb commit 1f74067
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 73 deletions.
12 changes: 0 additions & 12 deletions src/pages/Admin/Charity/Donations/DonationsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export default function DonationsTable({ classes = "" }) {
)
.map<Donation.Record | Donation.KYC>(
({ donorDetails: donor, ...d }) => {
const amt = amount(d.splitLiqPct, d.finalAmountUsd);
return fill({
date: new Date(d.date).toLocaleDateString(),
appUsed:
Expand All @@ -64,8 +63,6 @@ export default function DonationsTable({ classes = "" }) {
symbol: d.symbol,
initAmount: humanize(d.initAmount, 2),
finalAmountUsd: humanize(d.finalAmountUsd ?? 0, 2),
directDonateAmount: humanize(amt.directDonate, 2),
sfDonateAmount: humanize(amt.sfDonate, 2),
id: d.id,
receipt: donor.address?.country ? "Yes" : "No",
fullName: donor.fullName,
Expand Down Expand Up @@ -108,8 +105,6 @@ const csvHeaders: {
{ key: "symbol", label: "Donation Asset" },
{ key: "initAmount", label: "Donation Amount" },
{ key: "finalAmountUsd", label: "Donation Value USD" },
{ key: "directDonateAmount", label: "Direct Donation" },
{ key: "sfDonateAmount", label: "Donation to Sustainability Fund" },
{ key: "id", label: "Transaction Hash" },
{ key: "receipt", label: "Receipt Provided" },
{ key: "fullName", label: "Full Name" },
Expand All @@ -121,10 +116,3 @@ const csvHeaders: {
{ key: "zipCode", label: "Zip Code" },
{ key: "country", label: "Country" },
];

/** compute for direct and SF donation amounts */
function amount(splitLiqPct: number, amount = 0) {
const directDonate = amount * (splitLiqPct / 100);
const sfDonate = amount - directDonate;
return { directDonate, sfDonate };
}
21 changes: 6 additions & 15 deletions src/pages/Admin/Charity/Donations/Row.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import ExtLink from "components/ExtLink";
import Icon from "components/Icon";
import { Cells } from "components/TableSection";
import { getTxUrl, humanize, maskAddress, roundDownToNum } from "helpers";
import { getTxUrl, humanize, maskAddress } from "helpers";
import type { Donation } from "types/aws";

const Amount = ({ amount = 0 }) => {
return amount >= 0.01 ? <>${humanize(amount)}</> : <>--</>;
};

export default function Row(
props: Donation.Record & { hasMore?: boolean; classes?: string }
) {
const Amount = amount(props.splitLiqPct, props.finalAmountUsd);
return (
<Cells
type="td"
Expand All @@ -23,9 +26,7 @@ export default function Row(
<>{props.symbol}</>
<>{humanize(props.initAmount)}</>

<Amount type="total" />
<Amount type="liq" />
<Amount type="locked" />
<Amount amount={props.finalAmountUsd} />

{props.viaId === "staging" || props.viaId === "fiat" ? (
<>--</>
Expand Down Expand Up @@ -67,13 +68,3 @@ export default function Row(
</Cells>
);
}

const amount = (splitLiqPct: number, amount = 0) => {
const liq = roundDownToNum(amount * (splitLiqPct / 100), 2);
const locked = amount - liq;
const amounts = { total: amount, liq, locked };
return ({ type }: { type: keyof typeof amounts }) => {
const val = amounts[type];
return val >= 0.01 ? <>${humanize(val)}</> : <>--</>;
};
};
2 changes: 0 additions & 2 deletions src/pages/Admin/Charity/Donations/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ export default function Table({
>
Donation Value USD
</HeaderButton>
<>Direct Donation</>
<>Donation to Sustainability Fund</>
<>Transaction Hash</>
<>Receipt Provided</>
<>Full Name</>
Expand Down
11 changes: 0 additions & 11 deletions src/pages/UserDashboard/Donations/MobileTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,6 @@ export default function MobileTable({
? `$${humanize(row.initAmountUsd, 2)}`
: "--"}
</Row>
<Row title="Direct Donation">
{row.directDonateAmount
? `$${humanize(row.directDonateAmount, 2)}`
: "--"}
</Row>
<Row title="Donation to Sustainability Fund">
{row.sfDonateAmount
? `$${humanize(row.sfDonateAmount, 2)}`
: "--"}
</Row>

<Row title={lastHeaderName[status]} className="rounded-b">
<LastRowContent {...row} status={status} />
</Row>
Expand Down
26 changes: 0 additions & 26 deletions src/pages/UserDashboard/Donations/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,22 +79,6 @@ export default function Table({
>
USD Value
</HeaderButton>
<HeaderButton
onClick={handleHeaderClick("directDonateAmount")}
_activeSortKey={sortKey}
_sortKey="directDonateAmount"
_sortDirection={sortDirection}
>
Direct Donation
</HeaderButton>
<HeaderButton
onClick={handleHeaderClick("sfDonateAmount")}
_activeSortKey={sortKey}
_sortKey="sfDonateAmount"
_sortDirection={sortDirection}
>
Donation to Sustainability Fund
</HeaderButton>
<span className="flex justify-center">{lastHeaderName[status]}</span>
</Cells>
</TableSection>
Expand Down Expand Up @@ -137,16 +121,6 @@ export default function Table({
? `$${humanize(row.initAmountUsd, 2)}`
: "--"}
</>
<>
{row.directDonateAmount
? `$${humanize(row.directDonateAmount, 2)}`
: "--"}
</>
<>
{row.sfDonateAmount
? `$${humanize(row.sfDonateAmount, 2)}`
: "--"}
</>
<LastRowColContent {...row} status={status} />
</Cells>
))
Expand Down
4 changes: 0 additions & 4 deletions src/pages/UserDashboard/Donations/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ export default function Donations() {
symbol: item.symbol,
initAmount: humanize(item.initAmount, 2),
initAmountUsd: humanize(item.initAmountUsd ?? 0, 2),
directDonateAmount: humanize(item.directDonateAmount ?? 0, 2),
sfDonateAmount: humanize(item.sfDonateAmount ?? 0, 2),
id: item.id,
receipt: item.donorDetails?.address?.country
? "Yes"
Expand Down Expand Up @@ -153,8 +151,6 @@ const csvHeaders: { key: keyof Donation.Record | "receipt"; label: string }[] =
{ key: "symbol", label: "Currency" },
{ key: "initAmount", label: "Amount" },
{ key: "initAmountUsd", label: "USD Value" },
{ key: "directDonateAmount", label: "Direct Donation" },
{ key: "sfDonateAmount", label: "Donation to Sustainability Fund" },
{ key: "id", label: "Transaction Hash" },
{ key: "receipt", label: "Receipt" },
];
3 changes: 0 additions & 3 deletions src/types/aws/ap/donations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ export namespace Donation {
initAmount: number;
initAmountUsd?: number;
finalAmountUsd?: number;
directDonateAmount?: number;
sfDonateAmount?: number;
splitLiqPct: number;
isRecurring?: boolean;
appUsed: DonationSource;
} & (
Expand Down

0 comments on commit 1f74067

Please sign in to comment.