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 | 24x 24x 24x | import { useBusinessProfileLinkRequest } from "@components/ProfilePage/BusinessProfileSetupNew/BusinessDetailsStep/hooks/useBusinessProfileLinkRequest";
import { useGetCurrentMerchantId } from "@hooks/common";
import { Box, Stack } from "@mui/material";
import { CheckIcon, LinkSimpleIcon, XCircleIcon } from "@phosphor-icons/react";
import ButtonWithSpinner from "@shared/Button/ButtonWithSpinner";
import GiveButton from "@shared/Button/GiveButton";
import GiveText from "@shared/Text/GiveText";
import { styled, useAppTheme } from "@theme/v2/Provider";
import { useState } from "react";
import { MERCHANT_SIDE_PANEL_PREVIEW_API_KEYS } from "../../constants";
import { useQueryClient } from "react-query";
import { checkPortals } from "@utils/routing";
enum LinkStatus {
Accepted = "accepted",
Rejected = "rejected",
}
type Props = {
taxId: string;
merchantAccId?: number;
showLinkedApprovalButtons?: boolean;
email?: string;
};
const LinkingBPInProgress = ({
taxId,
merchantAccId,
showLinkedApprovalButtons,
email,
}: Props) => {
const { palette } = useAppTheme();
const { merchantId } = useGetCurrentMerchantId();
const [activeButton, setActiveButton] = useState("");
const { isAcquirerPortal } = checkPortals();
const { handleUpdateLinkStatus, isLoading } = useBusinessProfileLinkRequest({
accID: merchantId,
merchantAccID: merchantAccId as number,
isPending: true,
});
const queryClient = useQueryClient();
const isApproveLoding = isLoading && activeButton == LinkStatus.Accepted;
const isRejectLoading = isLoading && activeButton == LinkStatus.Rejected;
const refetchOnSuccess = () => {
queryClient.invalidateQueries(
MERCHANT_SIDE_PANEL_PREVIEW_API_KEYS.GET_LEGAL_ENTITY,
);
queryClient.invalidateQueries(MERCHANT_SIDE_PANEL_PREVIEW_API_KEYS.GET);
};
const handleDecline = () => {
handleUpdateLinkStatus(LinkStatus.Rejected, refetchOnSuccess);
setActiveButton(LinkStatus.Rejected);
};
const handleApprove = () => {
handleUpdateLinkStatus(LinkStatus.Accepted, refetchOnSuccess);
setActiveButton(LinkStatus.Accepted);
};
return (
<Box>
<Stack spacing="20px" alignItems="center" padding="20px">
<IconContainer>
<LinkSimpleIcon size={20} />
</IconContainer>
<GiveText variant="bodyS" color="secondary" textAlign="center">
This Tax ID{" "}
<span style={{ color: palette.text.primary }}>{taxId}</span> has been
recognized as belonging to an active business. An email has been sent
to {email} to confirm the association.
</GiveText>
</Stack>
{showLinkedApprovalButtons && isAcquirerPortal && (
<Stack gap="12px" direction="row" width="100%">
<ButtonWithSpinner isLoading={isApproveLoding} sx={{ flex: 1 }}>
<StyledGiveButton
label="Allow"
endIcon={<CheckIcon />}
size="medium"
onClick={handleApprove}
disabled={isApproveLoding}
/>
</ButtonWithSpinner>
<ButtonWithSpinner isLoading={isRejectLoading} sx={{ flex: 1 }}>
<StyledGiveButton
label="Deny"
endIcon={<XCircleIcon />}
size="medium"
onClick={handleDecline}
disabled={isRejectLoading}
/>
</ButtonWithSpinner>
</Stack>
)}
</Box>
);
};
const IconContainer = styled(Box)(({ theme }) => ({
borderRadius: "50%",
height: 56,
width: 56,
background: theme.palette.primitive?.transparent["darken-5"],
display: "flex",
justifyContent: "center",
alignItems: "center",
}));
const StyledGiveButton = styled(GiveButton)(({ theme }) => ({
flex: 1,
background: theme.palette.primitive?.transparent["darken-5"],
"&:hover": {
background: theme.palette.primitive?.transparent["darken-5"],
},
color: theme.palette.text.primary,
}));
export default LinkingBPInProgress;
|