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 | 7x 7x 7x 7x 7x 7x 7x 7x 7x 21x 21x | import { Stack } from "@mui/material";
import {
CaretDownIcon,
CaretUpIcon,
FunnelSimpleIcon,
ExportIcon,
} from "@phosphor-icons/react";
import { XIcon } from "@phosphor-icons/react";
import GiveButton from "@shared/Button/GiveButton";
import GiveIconButton from "@shared/IconButton/GiveIconButton";
import ContextualMenu from "@shared/ContextualMenu/ContextualMenu";
import { FilterPagesEnum } from "@shared/GiveFilter/constants";
import { useFilterButton } from "@shared/GiveFilter/hooks/useFilterButton";
import GiveSearchBar from "@shared/SearchBar/GiveSearchBar";
import { useCustomThemeV2 } from "@theme/hooks/useCustomThemeV2";
import useTableSearch from "componentsV2/Table/hooks/useTableSearch";
import { MouseEventHandler, useState } from "react";
import { SortValues } from "./types";
import { QKEY_RISK_MONITOR_TRANSACTIONS } from "@constants/queryKeys";
import { styled } from "@theme/v2/Provider";
import { useMerchantSidePanelContext } from "@features/Merchants/MerchantSidePanel/Provider/MerchantSidePanelProvider";
interface Props {
sort: SortValues;
setSort: (val: SortValues) => void;
}
export default function HeaderActions({ sort, setSort }: Props) {
const { isMobileView } = useCustomThemeV2();
const { handlers } = useMerchantSidePanelContext();
const { search, handleSearchChange } = useTableSearch({
queryKey: QKEY_RISK_MONITOR_TRANSACTIONS,
});
const [anchor, setMenuAnchor] = useState<null | HTMLButtonElement>(null);
const { filtersAmount, handleResetFilters } = useFilterButton({
filterPage: FilterPagesEnum.MERCHANT_RISK_PANEL,
});
const handleOpenMenu: MouseEventHandler<HTMLButtonElement> = (e) => {
setMenuAnchor(e.currentTarget);
};
const filterLabel =
filtersAmount > 0 ? `Filters (${filtersAmount})` : "Filter";
const timeArray = [
{
text: SORT_LABELS[SortValues.New],
value: SortValues.New,
onClick: () => setSort(SortValues.New),
},
{
text: SORT_LABELS[SortValues.Old],
value: SortValues.Old,
onClick: () => setSort(SortValues.Old),
},
];
return (
<Stack padding="0px 16px" gap="20px">
<GiveSearchBar
value={search}
handleChange={handleSearchChange}
searchOnEnter
resetOnClose={false}
/>
<ActionsStack>
<GiveButton
label={SORT_LABELS[sort]}
size="large"
color="light"
variant="filled"
onClick={handleOpenMenu}
endIcon={
anchor ? <CaretUpIcon size={16} /> : <CaretDownIcon size={16} />
}
sx={{
width: "fit-content",
whiteSpace: "nowrap",
flexShrink: 0,
}}
/>
<ContextualMenu
handleClose={() => {
setMenuAnchor(null);
}}
anchorEl={anchor}
options={timeArray}
color={isMobileView ? "primary" : "tertiary"}
texture={isMobileView ? "solid" : "blurred"}
transformOrigin={{
vertical: "top",
horizontal: "left",
}}
anchorOrigin={{
vertical: "bottom",
horizontal: "left",
}}
/>
<Stack
direction="row"
alignItems="center"
gap="12px"
sx={{
flexShrink: 0,
}}
>
<GiveButton
label={filterLabel}
size="large"
color="light"
variant={isMobileView ? "filled" : "ghost"}
startIcon={<FunnelSimpleIcon size={18} />}
endIcon={
filtersAmount > 0 ? (
<GiveIconButton
Icon={XIcon}
size="extraSmall"
onClick={handleResetFilters}
/>
) : undefined
}
sx={{
whiteSpace: "nowrap",
}}
onClick={handlers.handleOpenRiskFilter}
/>
<GiveButton
label="Export"
size="large"
color="light"
onClick={handlers.handleOpenRiskExport}
variant={isMobileView ? "filled" : "ghost"}
startIcon={<ExportIcon size={18} />}
sx={{
whiteSpace: "nowrap",
}}
/>
</Stack>
</ActionsStack>
</Stack>
);
}
const SORT_LABELS = {
[SortValues.New]: "Newest First",
[SortValues.Old]: "Oldest First",
};
const ActionsStack = styled(Stack)(({ theme }) => ({
flexDirection: "row",
alignItems: "center",
gap: "12px",
justifyContent: "space-between",
overflowX: "auto",
width: "100%",
[theme.breakpoints.down("v2_sm")]: {
flexWrap: "nowrap",
"&::-webkit-scrollbar": {
display: "none",
},
scrollbarWidth: "none",
justifyContent: "normal",
},
}));
|