import React from 'react';
import PropTypes from 'prop-types';
import { getPermissionDescription } from '../../../../helpers/utils/permission';
import { useI18nContext } from '../../../../hooks/useI18nContext';
import { formatDate } from '../../../../helpers/utils/util';
import Typography from '../../../ui/typography/typography';
import { COLORS } from '../../../../helpers/constants/design-system';
export default function UpdateSnapPermissionList({
approvedPermissions,
revokedPermissions,
newPermissions,
}) {
const t = useI18nContext();
const ApprovedPermissions = () => {
return Object.keys(approvedPermissions).map((approvedPermission) => {
const { label, rightIcon } = getPermissionDescription(
t,
approvedPermission,
);
const { date } = approvedPermissions[approvedPermission];
const formattedDate = formatDate(date, 'yyyy-MM-dd');
return (
{label}
{t('approvedOn', [formattedDate])}
{rightIcon &&
}
);
});
};
const RevokedPermissions = () => {
return Object.keys(revokedPermissions).map((revokedPermission) => {
const { label, rightIcon } = getPermissionDescription(
t,
revokedPermission,
);
return (
{label}
{t('permissionRevoked')}
{rightIcon &&
}
);
});
};
const NewPermissions = () => {
return Object.keys(newPermissions).map((newPermission) => {
const { label, rightIcon } = getPermissionDescription(t, newPermission);
return (
{label}
{t('permissionRequested')}
{rightIcon &&
}
);
});
};
return (
);
}
UpdateSnapPermissionList.propTypes = {
/**
* Permissions that have already been approved
*/
approvedPermissions: PropTypes.object.isRequired,
/**
* Previously used permissions that are now revoked
*/
revokedPermissions: PropTypes.object.isRequired,
/**
* New permissions that are being requested
*/
newPermissions: PropTypes.object.isRequired,
};