2022-03-04 17:56:31 +01:00
|
|
|
import React from 'react';
|
2021-12-02 18:22:18 +01:00
|
|
|
import PropTypes from 'prop-types';
|
2023-04-03 19:33:54 +02:00
|
|
|
import { getWeightedPermissions } from '../../../helpers/utils/permission';
|
2022-03-14 19:26:02 +01:00
|
|
|
import { useI18nContext } from '../../../hooks/useI18nContext';
|
2023-04-03 19:33:54 +02:00
|
|
|
import PermissionCell from '../permission-cell';
|
|
|
|
import Box from '../../ui/box';
|
2022-08-18 17:07:34 +02:00
|
|
|
|
2023-04-05 15:34:33 +02:00
|
|
|
export default function PermissionsConnectPermissionList({
|
|
|
|
permissions,
|
|
|
|
targetSubjectMetadata,
|
|
|
|
}) {
|
2022-03-14 19:26:02 +01:00
|
|
|
const t = useI18nContext();
|
2021-12-02 18:22:18 +01:00
|
|
|
|
|
|
|
return (
|
2023-04-03 19:33:54 +02:00
|
|
|
<Box paddingTop={2} paddingBottom={2}>
|
2023-04-05 15:34:33 +02:00
|
|
|
{getWeightedPermissions(t, permissions, targetSubjectMetadata).map(
|
|
|
|
(permission, index) => {
|
|
|
|
return (
|
|
|
|
<PermissionCell
|
|
|
|
title={permission.label}
|
|
|
|
description={permission.description}
|
|
|
|
weight={permission.weight}
|
|
|
|
avatarIcon={permission.leftIcon}
|
|
|
|
dateApproved={permission?.permissionValue?.date}
|
|
|
|
key={`${permission.permissionName}-${index}`}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
},
|
|
|
|
)}
|
2023-04-03 19:33:54 +02:00
|
|
|
</Box>
|
2021-12-02 18:22:18 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
PermissionsConnectPermissionList.propTypes = {
|
2022-02-15 01:02:51 +01:00
|
|
|
permissions: PropTypes.object.isRequired,
|
2023-04-05 15:34:33 +02:00
|
|
|
targetSubjectMetadata: PropTypes.object.isRequired,
|
2021-12-02 18:22:18 +01:00
|
|
|
};
|