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 | 1x 1x 10x 10x 10x 11x 10x 10x 10x 10x 27x | import { Box } from "@mui/material";
import LoadingSpinner from "@components/Snipper/LoadingSpinner";
import { FormProvider } from "react-hook-form";
import useUpdateAcqirerLegalDocuments from "@hooks/acquirer-api/settings/business-details/useUpdateAcquirerLegalDocuments";
import RESOURCE_BASE, {
EDIT_DENY_MESSAGE,
OPERATIONS,
} from "@constants/permissions";
import { useAccessControl } from "features/Permissions/AccessControl";
import { WithTooltipWrapper } from "@common/Menu/NewDropdownMenu";
import { useAppSelector } from "@redux/hooks";
import { WithMissingPermissionModule } from "@common/WithMissingPermissionModule";
import { Stack } from "@mui/material";
import { SettingsFormWrapperV2 } from "@features/MerchantPortal/MerchantSettings/components/atomsV2";
import { HFGiveInput } from "@shared/HFInputs/HFGiveInput/HFGiveInput";
import GiveText from "@shared/Text/GiveText";
import GiveMotionWrapper from "@shared/Motion/GiveMotionWrapper";
const ACTION_BAR_HEIGHT = "68px";
const LegalDocuments = () => {
const { onSubmit, methods, isLoading, data, reset, isDirty, acquirerData } =
useUpdateAcqirerLegalDocuments();
const resetHandler = () => {
reset({
enterpriseMSAVersion:
data?.enterpriseMSAVersion || acquirerData?.enterpriseMSAVersion,
submerchantMSAVersion:
data?.submerchantMSAVersion || acquirerData?.submerchantMSAVersion,
globalMSAVersion: data?.globalMSAVersion || data?.globalVersion,
});
};
const missingPermissionsMerchantId = useAppSelector(
(state) => state.app.permissions?.["get_merchant_by_id"],
);
const isUpdateAllowed = useAccessControl({
resource: RESOURCE_BASE.ACQUIRER,
operation: OPERATIONS.UPDATE,
});
const tooltipProps = {
show: !isUpdateAllowed,
message: EDIT_DENY_MESSAGE,
};
const versions = [
{
title: "Terms of Service",
name: "globalMSAVersion",
},
{
title: "Merchant Agreement",
name: "submerchantMSAVersion",
},
{
title: "Provider Agreement",
name: "enterpriseMSAVersion",
},
];
return (
<WithMissingPermissionModule
message="You don't have the right permission to access Legal Documents section"
notAuthorized={missingPermissionsMerchantId}
>
<FormProvider {...methods}>
{isLoading || !data ? (
<LoadingSpinner />
) : (
<SettingsFormWrapperV2
isDirty={isDirty}
formProps={{
onSubmit: methods.handleSubmit(onSubmit),
}}
formActions={{
formName: "acquirer-legal-documents-form",
primaryAction: {
label: "Save",
disabled: !isDirty,
},
secondaryAction: {
label: "Discard changes",
onClick: resetHandler,
disabled: !isDirty,
},
}}
sx={{
paddingBottom: ACTION_BAR_HEIGHT,
}}
>
<Stack spacing={3}>
<GiveMotionWrapper delay={30}>
<GiveText variant="bodyL" sx={{ mb: "8px" }}>
Legal Documents
</GiveText>
</GiveMotionWrapper>
{versions.map(({ name, title }, index) => (
<Box key={index}>
<GiveMotionWrapper delay={50 * (index + 1)}>
<GiveText variant="bodyS" sx={{ mb: "8px" }}>
{title}
</GiveText>
</GiveMotionWrapper>
<GiveMotionWrapper delay={100 * (index + 1)}>
<WithTooltipWrapper
hasTooltip={!isUpdateAllowed}
tooltipProps={tooltipProps}
>
<HFGiveInput
name={name}
fullWidth
placeholder="Enter Version"
disabled={!isUpdateAllowed}
leftContent="Version"
/>
</WithTooltipWrapper>
</GiveMotionWrapper>
</Box>
))}
</Stack>
</SettingsFormWrapperV2>
)}
</FormProvider>
</WithMissingPermissionModule>
);
};
export default LegalDocuments;
|