Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | 34x 1624x 1624x 1624x 1624x 1624x 1624x 1624x 1420x 39x 1381x 204x 34x 243x 34x | import { useBulkMarkMerchants } from "@components/AcquirerMerchants/hooks/useBulkMarkMerchants";
import { Box, Stack } from "@mui/material";
import GiveButton from "@shared/Button/GiveButton";
import GiveText from "@shared/Text/GiveText";
import { useGetMerchantsTableColumns } from "features/Merchants/MerchantsTable/hooks/useGetMerchantsTableColumns";
import { styled, useAppTheme } from "@theme/v2/Provider";
import NiceModal from "@ebay/nice-modal-react";
import { GIVE_CONFIRMATION_POP_UP } from "modals/modal_names";
import { BellRingingIcon } from "@phosphor-icons/react";
import { useBulkUpdateSponsorStatus } from "@components/AcquirerMerchants/hooks/useBulkUpdateSponsorStatus";
import { memo } from "react";
import TablePaginationCount from "./components/TablePaginationCount";
import TablePaginationMaxSelect from "./components/TablePaginationMaxSelect";
import { MERCHANTS_ROWS_PER_PAGE } from "@hooks/common/usePagination";
const TableFooterContainer = ({
children,
hasPagination,
rowsPerPage = MERCHANTS_ROWS_PER_PAGE,
page = 1,
totalRows,
storageKey,
setPageDispatcher,
showRowRange = false,
isInfiniteScroll = false,
loadedRows = 0,
}: {
children: React.ReactNode;
hasPagination: boolean;
rowsPerPage?: number;
page: number;
totalRows?: number;
storageKey?: string;
setPageDispatcher?: React.Dispatch<React.SetStateAction<number>>;
// TRA013 AC007: opt-in row-range indicator for infinite-scroll tables.
showRowRange?: boolean;
isInfiniteScroll?: boolean;
loadedRows?: number;
}) => {
const { selectedMerchantsCount } = useBulkMarkMerchants();
const { bulkUpdateSponsorStatus } = useBulkUpdateSponsorStatus();
const {
selectedTabStatus: { isSponsorTabSelected },
} = useGetMerchantsTableColumns();
const isShowBulkActions = isSponsorTabSelected && !!selectedMerchantsCount;
const handleDecline = () => {
NiceModal.show(GIVE_CONFIRMATION_POP_UP, {
modalType: "declined",
title: "Decline Merchants",
description: (
<Stack gap="16px">
<GiveText variant="bodyS" color="secondary">
Are you sure you want to decline the selected merchants? This action
will result in the rejection of the merchants' application.
</GiveText>
<WarningComponent />
</Stack>
),
actions: {
handleSuccess: { onClick: () => bulkUpdateSponsorStatus("decline") },
},
});
};
const handleApprove = () => {
NiceModal.show(GIVE_CONFIRMATION_POP_UP, {
modalType: "approved",
title: "Approve Merchants",
description: (
<Stack gap="16px">
<GiveText variant="bodyS" color="secondary">
Are you sure you want to approve the selected merchants? This action
will finalize their approval process.
</GiveText>
<WarningComponent />
</Stack>
),
actions: {
handleSuccess: { onClick: () => bulkUpdateSponsorStatus("approve") },
},
});
};
if (!hasPagination && !isShowBulkActions) {
// TRA013 AC007: infinite-scroll tables have no pagination footer, but still
// show the loaded row range ("Showing 1 – N of Total"), updating on scroll.
if (showRowRange && isInfiniteScroll && (totalRows ?? 0) > 0) {
return (
<StyledStack
direction="row"
justifyContent="flex-start"
alignItems="center"
>
<TablePaginationCount
rowsPerPage={rowsPerPage}
page={page}
totalRows={totalRows}
loadedRows={loadedRows}
isInfiniteScroll
/>
</StyledStack>
);
}
return null;
}
return (
<StyledStack
direction="row"
justifyContent={"space-between"}
alignItems="center"
>
{isShowBulkActions ? (
<GiveText variant="bodyS" color="secondary">
{`${selectedMerchantsCount} Merchant${
selectedMerchantsCount > 1 ? "s" : ""
} Selected`}
</GiveText>
) : (
<TablePaginationCount
rowsPerPage={rowsPerPage}
page={page}
totalRows={totalRows}
/>
)}
{hasPagination && children}
{isShowBulkActions ? (
<Stack direction="row" alignItems="center" gap="8px">
<GiveButton
size="large"
label="Decline"
variant="ghost"
color="destructive"
onClick={handleDecline}
/>
<GiveButton
size="large"
label="Approve"
variant="filled"
onClick={handleApprove}
/>
</Stack>
) : (
<TablePaginationMaxSelect
storageKey={storageKey}
totalRows={totalRows}
page={page}
setPageDispatcher={setPageDispatcher}
/>
)}
</StyledStack>
);
};
export default memo(TableFooterContainer);
const StyledStack = styled(Stack)(({ theme }) => {
return {
width: "100%",
position: "absolute",
bottom: 0,
left: 0,
right: 0,
backgroundColor: theme.palette.surface?.["primary-transparent"],
backdropFilter: "blur(8px)",
alignItems: "center",
borderTop: `1px solid ${theme.palette.border?.primary}`,
zIndex: 2,
padding: "0 64px",
[theme.breakpoints.down("v2_sm")]: {
padding: "16px 20px",
},
};
});
const WarningComponent = () => {
const { palette } = useAppTheme();
return (
<Stack
direction="row"
gap="12px"
alignItems="flex-start"
sx={{
backgroundColor: palette.primitive?.transparent["darken-5"],
padding: "12px",
borderRadius: "8px",
}}
>
<Box
sx={{
width: 24,
height: 24,
display: "flex",
alignItems: "center",
justifyContent: "center",
}}
>
<BellRingingIcon size={24} />
</Box>
<GiveText variant="bodyS" color="primary" mt="2px">
You won’t be able to perform another bulk action until it’s complete. We
will notify you once it’s finished.
</GiveText>
</Stack>
);
};
|