mirror of
https://github.com/fallenbagel/jellyseerr.git
synced 2026-01-09 16:17:53 -05:00
fix: length of undefined on users warnings (#875)
This commit is contained in:
@@ -17,47 +17,45 @@ interface UserWarningsProps {
|
|||||||
const UserWarnings: React.FC<UserWarningsProps> = ({ onClick }) => {
|
const UserWarnings: React.FC<UserWarningsProps> = ({ onClick }) => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const { user } = useUser();
|
const { user } = useUser();
|
||||||
if (!user) {
|
//check if a user has warnings
|
||||||
|
if (!user || !user.warnings || user.warnings.length === 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
let res = null;
|
let res = null;
|
||||||
|
|
||||||
//check if a user has warnings
|
user.warnings.forEach((warning) => {
|
||||||
if (user.warnings.length > 0) {
|
let link = '';
|
||||||
user.warnings.forEach((warning) => {
|
let warningText = '';
|
||||||
let link = '';
|
let warningTitle = '';
|
||||||
let warningText = '';
|
switch (warning) {
|
||||||
let warningTitle = '';
|
case 'userEmailRequired':
|
||||||
switch (warning) {
|
link = '/profile/settings/';
|
||||||
case 'userEmailRequired':
|
warningTitle = 'Profile is incomplete';
|
||||||
link = '/profile/settings/';
|
warningText = intl.formatMessage(messages.emailRequired);
|
||||||
warningTitle = 'Profile is incomplete';
|
}
|
||||||
warningText = intl.formatMessage(messages.emailRequired);
|
|
||||||
}
|
|
||||||
|
|
||||||
res = (
|
res = (
|
||||||
<Link
|
<Link
|
||||||
href={link}
|
href={link}
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
onKeyDown={(e) => {
|
onKeyDown={(e) => {
|
||||||
if (e.key === 'Enter' && onClick) {
|
if (e.key === 'Enter' && onClick) {
|
||||||
onClick();
|
onClick();
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
role="button"
|
role="button"
|
||||||
tabIndex={0}
|
tabIndex={0}
|
||||||
className="mx-2 mb-2 flex items-center rounded-lg bg-yellow-500 p-2 text-xs text-white ring-1 ring-gray-700 transition duration-300 hover:bg-yellow-400"
|
className="mx-2 mb-2 flex items-center rounded-lg bg-yellow-500 p-2 text-xs text-white ring-1 ring-gray-700 transition duration-300 hover:bg-yellow-400"
|
||||||
>
|
>
|
||||||
<ExclamationTriangleIcon className="h-6 w-6" />
|
<ExclamationTriangleIcon className="h-6 w-6" />
|
||||||
<div className="flex min-w-0 flex-1 flex-col truncate px-2 last:pr-0">
|
<div className="flex min-w-0 flex-1 flex-col truncate px-2 last:pr-0">
|
||||||
<span className="font-bold">{warningTitle}</span>
|
<span className="font-bold">{warningTitle}</span>
|
||||||
<span className="truncate">{warningText}</span>
|
<span className="truncate">{warningText}</span>
|
||||||
</div>
|
</div>
|
||||||
</Link>
|
</Link>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user