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 | 4x | import * as React from "react";
import { palette } from "@palette";
// mui
import Box from "@mui/material/Box";
import { useTheme } from "@mui/material/styles";
import useMediaQuery from "@mui/material/useMediaQuery";
// components
import { Text } from "@common/Text";
import { Select } from "@common/Select";
import CustomPagination from "./pagination/pagination";
import { Trailing } from "./trailing-element/trailing";
// types
import { Options } from "types/data.types";
// localization
import { useTranslation } from "react-i18next";
import { namespaces } from "localization/resources/i18n.constants";
import { useGetFeatureFlagValues } from "FeatureFlags/useGetFeatureFlagValues";
interface IPaginationprops {
records?: number;
centered?: boolean;
totalRecords: number;
noTrailing?: boolean;
noDescription?: boolean;
shortDescription?: boolean;
onChange?: any;
page?: number;
currentRowsPerPage?: number;
numberOfPages?: number;
sumPageAmount?: number;
totalAmount?: number;
emptyBox?: boolean;
}
const Pagination: React.FC<IPaginationprops> = ({
noTrailing,
totalRecords,
noDescription,
shortDescription,
onChange,
centered = false,
currentRowsPerPage,
page,
numberOfPages = 1,
records = 1,
sumPageAmount = 0,
totalAmount = 0,
emptyBox = true,
}) => {
const theme = useTheme();
const { t } = useTranslation(namespaces.pages.manageMoney);
const isDesktop = useMediaQuery(theme.breakpoints.up("sm"));
const mobileOptions = Array.from({ length: numberOfPages }, (_, i) => i + 1);
const options = mobileOptions.map((page) => ({
value: page,
label: `${page}`,
}));
// for (let i = 0; i < numberOfPages; i++) {
// options.push({
// label: `${i + 1}`,
// value: `${i + 1}`,
// });
// }
return (
<Box
sx={{
display: "flex",
alignItems: "center",
gap: "81px",
justifyContent: "center",
flexDirection: "row",
}}
>
{!noDescription && (
<Box mt={centered ? 1 : 0}>
<Text sx={{ fontSize: "14px" }} color={palette.neutral[80]}>
{!shortDescription && `${t("showing")} `}
<Box component="span">
{currentRowsPerPage && totalRecords < currentRowsPerPage
? totalRecords
: currentRowsPerPage}{" "}
</Box>
{shortDescription ? "of " : `${t("records_of")} `}
<Box component="span">{totalRecords}</Box>
</Text>
</Box>
)}
{isDesktop ? (
<>
<CustomPagination
page={page}
onChange={onChange}
pages={numberOfPages}
/>
{!centered ? (
noTrailing ? (
emptyBox ? (
<Box width={200} />
) : null
) : (
<Trailing pageTotal={sumPageAmount} total={totalAmount} />
)
) : (
<></>
)}
</>
) : (
<Box ml="auto" gap={1} display="flex" alignItems="center">
<Text fontWeight="medium">Page</Text>
<Select
name="pagination"
width={74}
value={page}
size="small"
options={options}
onChange={(e) => onChange(e, e.target.value)}
/>
</Box>
)}
</Box>
);
};
export default Pagination;
|