Skip to content

Commit

Permalink
Program name in donation records (#3316)
Browse files Browse the repository at this point in the history
* add programName in intent

* add in desktop table

* add in mobile

* bump version
  • Loading branch information
ap-justin committed Sep 23, 2024
1 parent a8c77c5 commit 0ff9ac3
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/components/donation/Steps/Submit/Crypto/DirectMode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ export default function DirectMode({ donation, classes = "" }: Props) {
? honorary.tributeNotif
: undefined,
}),
...(details.program.value && { programId: details.program.value }),
...(details.program.value && {
programId: details.program.value,
programName: details.program.label,
}),
});

const totalDisplayAmount = roundToCents(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ export default function ChariotCheckout(props: DafCheckoutStep) {
source: props.init.source,
...(props.details.program.value && {
programId: props.details.program.value,
programName: props.details.program.label,
}),
...(meta.honoraryFullName && {
inHonorOf: meta.honoraryFullName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ export default function Checkout(props: StripeCheckoutStep) {
...(honorary.honoraryFullName && {
inHonorOf: honorary.honoraryFullName,
}),
...(details.program.value && { programId: details.program.value }),
...(details.program.value && {
programId: details.program.value,
programName: details.program.label,
}),
}).unwrap()
}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ export default function StripeCheckout(props: StripeCheckoutStep) {
? honorary.tributeNotif
: undefined,
}),
...(details.program.value && { programId: details.program.value }),
...(details.program.value && {
programId: details.program.value,
programName: details.program.label,
}),
});

return (
Expand Down
2 changes: 2 additions & 0 deletions src/pages/Admin/Charity/Donations/DonationsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export default function DonationsTable({ classes = "" }) {
const amt = amount(d.splitLiqPct, d.finalAmountUsd);
return fill({
date: new Date(d.date).toLocaleDateString(),
programName: d.programName,
appUsed:
d.appUsed === "bg-widget"
? "Donation Form"
Expand Down Expand Up @@ -102,6 +103,7 @@ const csvHeaders: {
label: string;
}[] = [
{ key: "date", label: "Datetime" },
{ key: "programName", label: "Program" },
{ key: "appUsed", label: "Donation Origin" },
{ key: "paymentMethod", label: "Donation Type" },
{ key: "isRecurring", label: "Recurring Donation" },
Expand Down
13 changes: 13 additions & 0 deletions src/pages/Admin/Charity/Donations/Row.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import ExtLink from "components/ExtLink";
import Icon from "components/Icon";
import { Cells } from "components/TableSection";
import { appRoutes } from "constants/routes";
import { getTxUrl, humanize, maskAddress, roundDownToNum } from "helpers";
import { Link } from "react-router-dom";
import type { Donation } from "types/aws";

export default function Row(
Expand All @@ -17,6 +19,17 @@ export default function Row(
{new Date(props.date).toLocaleDateString()}
</span>

{props.programId ? (
<Link
className="text-blue hover:text-blue-d1"
to={`${appRoutes.profile}/${props.recipientId}/program/${props.programId}`}
>
{props.programName}
</Link>
) : (
<>--</>
)}

<>{props.appUsed === "bg-widget" ? "Donation Form" : "Marketplace"}</>
<>{props.paymentMethod ?? "--"}</>
<>{props.isRecurring ? "Yes" : "No"}</>
Expand Down
1 change: 1 addition & 0 deletions src/pages/Admin/Charity/Donations/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export default function Table({
>
Date
</HeaderButton>
<>Program</>
<HeaderButton
onClick={handleHeaderClick("appUsed")}
_activeSortKey={sortKey}
Expand Down
14 changes: 14 additions & 0 deletions src/pages/UserDashboard/Donations/MobileTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import {
} from "@headlessui/react";
import ExtLink from "components/ExtLink";
import Icon, { DrawerIcon } from "components/Icon";
import { appRoutes } from "constants/routes";
import { humanize } from "helpers";
import useSort from "hooks/useSort";
import type { PropsWithChildren } from "react";
import { Link } from "react-router-dom";
import type { Donation } from "types/aws";
import IntentResumer from "./IntentResumer";
import LoadMoreBtn from "./LoadMoreBtn";
Expand Down Expand Up @@ -69,6 +71,18 @@ export default function MobileTable({
</div>
</DisclosureButton>
<DisclosurePanel className="w-full divide-y divide-blue-l2">
<Row title="Program">
{row.programId ? (
<Link
className="text-blue hover:text-blue-d1"
to={`${appRoutes.profile}/${row.recipientId}/program/${row.programId}`}
>
{row.programName}
</Link>
) : (
<>--</>
)}
</Row>
<Row title="Donation Type" className="capitalize">
{donationMethod(
row.paymentMethod ?? { id: row.viaId, name: row.viaName }
Expand Down
11 changes: 11 additions & 0 deletions src/pages/UserDashboard/Donations/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export default function Table({
>
Recipient
</HeaderButton>
<>Program</>
<HeaderButton
onClick={handleHeaderClick("date")}
_activeSortKey={sortKey}
Expand Down Expand Up @@ -124,6 +125,16 @@ export default function Table({
</span>
<Icon type="ExternalLink" className="w-5 h-5" />
</Link>
{row.programId ? (
<Link
className="text-blue hover:text-blue-d1"
to={`${appRoutes.profile}/${row.recipientId}/program/${row.programId}`}
>
{row.programName}
</Link>
) : (
<>--</>
)}
<>{new Date(row.date).toLocaleDateString()}</>
<span className="capitalize">
{donationMethod(
Expand Down
2 changes: 1 addition & 1 deletion src/services/aws/aws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ export const aws = createApi({
providesTags: ["donations"],
query: (params) => {
return {
url: `${v(1)}/donations`,
url: `${v(2)}/donations`,
params,
headers: { authorization: TEMP_JWT },
};
Expand Down
2 changes: 2 additions & 0 deletions src/types/aws/ap/donations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ export namespace Donation {
/** endow id */
recipientId: number;
recipientName: string;
programId?: string;
programName?: string;

//details
/** ISODate string */
Expand Down
1 change: 1 addition & 0 deletions src/types/aws/apes/donation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type TributeNotif = {
export interface DonationIntent {
transactionId?: string;
programId?: string;
programName?: string;
amount: number;
tipAmount: number;
feeAllowance: number;
Expand Down

0 comments on commit 0ff9ac3

Please sign in to comment.