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 | 1x 28x 28x 28x 28x 2x 28x 28x 28x 28x 28x 28x 4x 28x 28x | import Table from "componentsV2/Table/Table";
import GiveMerchantBanner from "@shared/Banner/GiveMerchantBanner";
import GiveMotionWrapper from "@shared/Motion/GiveMotionWrapper";
import { useMemo } from "react";
import BackgroundAnimation from "@shared/Banner/BackgroundAnimation";
import { useComponentHeight } from "@hooks/common/useComponentHeight";
import useTableSearch from "componentsV2/Table/hooks/useTableSearch";
import { useHandleScroll } from "componentsV2/Table/hooks/useHandleScroll";
import ContextualMenu from "@shared/ContextualMenu/ContextualMenu";
import { useCustomThemeV2 } from "@theme/hooks/useCustomThemeV2";
import {
GENERATE_MERCHANT_API_KEY_MODAL,
MERCHANT_DEVELOPER_API_PANEL,
} from "modals/modal_names";
import { useTable } from "componentsV2/Table/hooks/useTable";
import { QKEY_MERCHANTS_API_KEYS } from "@constants/queryKeys";
import { MerchantsKeyTableProps } from "@features/MerchantPortal/DeveloperApi/types";
import { useGetMerchantsApiKeyTable } from "@features/MerchantPortal/DeveloperApi/hooks/useGetMerchantsApiKeyTable";
import NiceModal from "@ebay/nice-modal-react";
import { CREATE_DENY_MESSAGE } from "@constants/permissions";
import { useGetCurrentMerchantId } from "@hooks/common";
const EnterpriseApiKeyTable = ({ ...props }: MerchantsKeyTableProps) => {
const { height } = useComponentHeight();
const { isMobileView } = useCustomThemeV2();
const {
isLoading,
page,
setPageDispatcher,
setPage,
totalRows,
allRows: rows,
columns,
getMenuActions,
onCloseMenu,
anchorEl,
isProductionOptionEnabled,
isDisabledCreation,
} = useGetMerchantsApiKeyTable();
const openCreateApiKeyModal = () => {
NiceModal.show(GENERATE_MERCHANT_API_KEY_MODAL, {
isProductionOptionEnabled,
});
};
const { setSelectedRowIdx, loadMore, numberOfPages, selectedRowIdx } =
useTable({
allRows: rows,
isLoading,
totalRows,
page,
setPageDispatcher,
setPage,
openModal: MERCHANT_DEVELOPER_API_PANEL,
});
const { onScroll } = useHandleScroll();
const { search, searchQuery, handleSearchChange } = useTableSearch({
queryKey: QKEY_MERCHANTS_API_KEYS,
});
const { isSponsor } = useGetCurrentMerchantId();
const hasNoPermissonToCreate = isDisabledCreation || isSponsor;
const emptyStateAction = useMemo(
() => ({
handleAction: openCreateApiKeyModal,
disabled: hasNoPermissonToCreate,
}),
[],
);
const menuActions = getMenuActions();
return (
<>
<BackgroundAnimation page="acquirerProviders" />
<GiveMotionWrapper
delay={30}
containerProps={{ sx: { height: "100%", zIndex: 2 } }}
customStyle={{
height: "100%",
display: "flex",
justifyContent: "center",
}}
>
<Table
{...props}
top={height}
allRows={rows}
columns={columns}
totalRows={totalRows}
type="developer"
Head={
<GiveMerchantBanner
title="Developer"
action="Add API Key"
filters={[]}
handleCreate={openCreateApiKeyModal}
type={"developer"}
handleSearchChange={!isSponsor ? handleSearchChange : undefined}
search={search}
disableCreate={hasNoPermissonToCreate}
tooltipProps={{
disableHoverListener: !isSponsor,
title: CREATE_DENY_MESSAGE,
}}
/>
}
isLoading={isLoading}
emptyStateAction={emptyStateAction}
emptyStateActionTooltipProps={{
disableHoverListener: !isSponsor,
title: CREATE_DENY_MESSAGE,
}}
queryKey={QKEY_MERCHANTS_API_KEYS}
onScroll={onScroll}
searchQuery={searchQuery}
handleSearchChange={handleSearchChange}
page={page}
setPageDispatcher={setPageDispatcher}
setPage={setPage}
setSelectedRowIdx={setSelectedRowIdx}
selectedRowIdx={selectedRowIdx}
loadMore={loadMore}
numberOfPages={numberOfPages}
isListPermissionAllowed={!isSponsor}
openModal={MERCHANT_DEVELOPER_API_PANEL}
hideCaret
customLoadingRowProps={{
height: isMobileView ? "120px" : undefined,
sx: { paddingInline: isMobileView ? "0" : undefined },
}}
sectionName="developer"
/>
</GiveMotionWrapper>
<ContextualMenu
handleClose={onCloseMenu}
anchorEl={anchorEl}
options={menuActions}
color={isMobileView ? "primary" : "tertiary"}
texture={isMobileView ? "solid" : "blurred"}
/>
</>
);
};
export default EnterpriseApiKeyTable;
|