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 | 8x 150x 150x 150x 57x 93x 8x 150x 150x 150x 150x 150x | import {
PaperIcon,
TeamMembersIcon,
EnterpriseIcon,
} from "@assets/emptyStatesIcons";
import { NotebookIcon } from "@assets/icons/RebrandedIcons";
import StoreFrontIcon from "@assets/icons/RebrandedIcons/StoreFrontIcon";
import {
CustomerPeopleIcon,
DisputesIcon,
JobsIcon,
TransfersIcon,
SettlementIcon,
MerchantsIcon,
} from "@assets/rebrandIcons";
import { EmptyState } from "@common/EmptyState";
import {
IEmptyStateProps,
TEmptyStateAction,
} from "@common/EmptyState/EmptyState";
import { useCreateMerchantActions } from "@components/AcquirerMerchants/hooks/useCreateMerchantActions";
import RESOURCE_BASE, {
CREATE_DENY_MESSAGE,
OPERATIONS,
} from "@constants/permissions";
import NiceModal from "@ebay/nice-modal-react";
import { Stack, SxProps } from "@mui/material";
import { useAccessControl } from "features/Permissions/AccessControl";
import { GIVE_CREATE_MERCHANT_PANEL_MODAL } from "modals/modal_names";
import React from "react";
import { TListWrapperSection } from "./types";
import { DeveloperIcon } from "@assets/icons";
interface ListWrapperWithStatesProps {
children?: React.ReactNode;
isEmpty?: boolean;
section?: TListWrapperSection;
sx?: SxProps;
action?: TEmptyStateAction | null;
isFilter?: boolean;
}
const ListWrapperWithStates = ({
isEmpty = false,
children,
section,
sx,
action,
isFilter = false,
}: ListWrapperWithStatesProps) => {
const { data } = useEmptyState({ isFilter });
const currentData = section ? data[section] : null;
if (isEmpty && section && currentData) {
return (
<EmptyState
{...currentData}
action={
action ? action : action === null ? undefined : currentData?.action
}
/>
);
}
return (
<Stack sx={sx} flexGrow={1} mb={section === "purchase" ? 3 : 0}>
{children}
</Stack>
);
};
const useEmptyState = ({ isFilter = false }: { isFilter?: boolean }) => {
const {
handleClickCreateMerchant,
isLoading,
isFetching,
isCreateMerchantAllowed,
} = useCreateMerchantActions();
const isCreatingMerchant = isLoading || isFetching;
const isCreateEnterpriseAllowed = useAccessControl({
resource: RESOURCE_BASE.ENTERPRISE,
operation: OPERATIONS.CREATE,
});
const data: Record<TListWrapperSection, IEmptyStateProps> = {
"merchant-list": {
Icon: <MerchantsIcon width={100} height={100} gradient />,
title: {
main: "You do not have any merchants",
secondary: "Let's create your first merchant",
},
action: {
label: "Create Merchant",
onClick: handleClickCreateMerchant,
disabled: isCreatingMerchant || !isCreateMerchantAllowed,
},
},
merchant: {
Icon: <StoreFrontIcon width={100} height={100} />,
title: {
main: "No merchants",
},
},
customer: {
Icon: <CustomerPeopleIcon width={100} height={100} gradient />,
title: {
main: "You do not have any customers",
},
},
riskMonitorTransactions: {
Icon: <JobsIcon width={100} height={100} gradient />,
title: {
main: "You do not have any transactions",
},
},
transaction: {
Icon: <JobsIcon width={100} height={100} gradient />,
title: {
main: isFilter ? "No results" : "You do not have any transactions",
},
height: "100%",
},
bankAccount: {
Icon: <JobsIcon width={100} height={100} gradient />,
title: {
main: "You do not have any bank account",
},
height: "100%",
},
transfers: {
Icon: <TransfersIcon width={100} height={100} gradient />,
title: {
main: "You do not have any transfers",
},
height: "100%",
},
settlement: {
Icon: <SettlementIcon width={100} height={100} gradient />,
title: {
main: "You do not have any settlement",
},
height: "100%",
},
disputes: {
Icon: <DisputesIcon width={100} height={100} gradient />,
title: {
main: "You do not have any disputes",
},
height: "100%",
},
enterprise: {
Icon: <EnterpriseIcon width={100} height={100} gradient />,
title: {
main: "You do not have any providers",
secondary: "Let's create your first provider",
},
action: {
label: "Create Provider",
onClick: () =>
NiceModal.show(GIVE_CREATE_MERCHANT_PANEL_MODAL, {
isProvider: true,
}),
disabled: !isCreateEnterpriseAllowed,
tooltipProps: {
show: !isCreateEnterpriseAllowed,
message: CREATE_DENY_MESSAGE,
},
},
},
purchase: {
Icon: <PaperIcon />,
title: {
main: `You do not have purchases`,
},
},
team: {
Icon: <TeamMembersIcon />,
title: {
main: "You do not have any team members",
secondary: "Invite people to your team.",
},
},
permissions: {
Icon: <NotebookIcon />,
title: {
main: "No permissions have been allocated to the user at this time",
secondary: "Begin by adding the first permission",
},
sx: {
padding: "50px",
flexGrow: 1,
},
},
"developer-api": {
Icon: <DeveloperIcon gradient width={100} height={100} />,
title: {
main: "You do not have any API keys",
},
},
};
return { data };
};
export default ListWrapperWithStates;
|