fix: length of undefined on users warnings (#875)

This commit is contained in:
Francisco Sales
2024-07-21 22:37:01 +01:00
committed by GitHub
parent 4db1df2ba5
commit c600566ac0

View File

@@ -17,14 +17,13 @@ interface UserWarningsProps {
const UserWarnings: React.FC<UserWarningsProps> = ({ onClick }) => {
const intl = useIntl();
const { user } = useUser();
if (!user) {
//check if a user has warnings
if (!user || !user.warnings || user.warnings.length === 0) {
return null;
}
let res = null;
//check if a user has warnings
if (user.warnings.length > 0) {
user.warnings.forEach((warning) => {
let link = '';
let warningText = '';
@@ -57,7 +56,6 @@ const UserWarnings: React.FC<UserWarningsProps> = ({ onClick }) => {
</Link>
);
});
}
return res;
};