Skip to content

Commit

Permalink
Merge pull request #1051 from CruGlobal/MPDX-8184
Browse files Browse the repository at this point in the history
MPDX-8184 - Remove zero amount confirmation and logic and replace with a error
  • Loading branch information
dr-bizz authored Sep 11, 2024
2 parents a20bb7e + 5374480 commit 3cde16b
Show file tree
Hide file tree
Showing 3 changed files with 250 additions and 131 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
} from 'src/components/DonationTable/DonationTable';
import {
DonationTableQueryVariables,
useAccountListCurrencyQuery,
useDonationTableQuery,
} from 'src/components/DonationTable/DonationTable.generated';
import { useFetchAllPages } from 'src/hooks/useFetchAllPages';
Expand All @@ -33,13 +32,13 @@ import { currencyFormat, dateFormatShort } from 'src/lib/intlFormat';
type RenderCell = GridColDef<DonationRow>['renderCell'];

export interface DonationTableProps {
accountListId: string;
appealId: string;
filter: Partial<DonationTableQueryVariables>;
loading?: boolean;
onSelectContact?: (contactId: string) => void;
visibleColumnsStorageKey: string;
emptyPlaceholder: React.ReactElement;
accountCurrency: string;
selectedDonations: DonationRow[];
setSelectedDonations: React.Dispatch<React.SetStateAction<DonationRow[]>>;
totalSelectedDonationsAmount: number;
Expand Down Expand Up @@ -69,12 +68,12 @@ const StyledListItemIcon = styled(ListItemIcon)(() => ({
}));

export const DonationTable: React.FC<DonationTableProps> = ({
accountListId,
appealId,
filter,
loading: skipped = false,
visibleColumnsStorageKey,
emptyPlaceholder,
accountCurrency,
selectedDonations = [],
setSelectedDonations,
totalSelectedDonationsAmount = 0,
Expand Down Expand Up @@ -106,15 +105,8 @@ export const DonationTable: React.FC<DonationTableProps> = ({
setSelectedDonations(preselectedDonations);
}, [data]);

const { data: accountListData, loading: loadingAccountListData } =
useAccountListCurrencyQuery({
variables: { accountListId },
});

const nodes = data?.donations.nodes || [];

const accountCurrency = accountListData?.accountList.currency || 'USD';

const donations = useMemo(() => nodes.map(createDonationRow), [nodes]);

const date: RenderCell = ({ row }) => dateFormatShort(row.date, locale);
Expand Down Expand Up @@ -269,7 +261,7 @@ export const DonationTable: React.FC<DonationTableProps> = ({
</TotalsTable>
)}
</>
) : loadingAccountListData || loading || skipped ? (
) : loading || skipped ? (
<LoadingBox>
<LoadingIndicator data-testid="LoadingBox" color="primary" size={50} />
</LoadingBox>
Expand Down
Loading

0 comments on commit 3cde16b

Please sign in to comment.