mirror of
https://github.com/fallenbagel/jellyseerr.git
synced 2026-01-08 15:48:08 -05:00
feat(uesrprofile): email requirement and validation
This commit is contained in:
@@ -14,6 +14,7 @@ import useClickOutside from '../../../hooks/useClickOutside';
|
||||
import { Permission, useUser } from '../../../hooks/useUser';
|
||||
import Transition from '../../Transition';
|
||||
import VersionStatus from '../VersionStatus';
|
||||
import UserWarnings from '../UserWarnings';
|
||||
|
||||
const messages = defineMessages({
|
||||
dashboard: 'Discover',
|
||||
@@ -177,6 +178,10 @@ const Sidebar: React.FC<SidebarProps> = ({ open, setClosed }) => {
|
||||
);
|
||||
})}
|
||||
</nav>
|
||||
<div className="px-2">
|
||||
<UserWarnings onClick={() => setClosed()} />
|
||||
</div>
|
||||
|
||||
{hasPermission(Permission.ADMIN) && (
|
||||
<div className="px-2">
|
||||
<VersionStatus onClick={() => setClosed()} />
|
||||
@@ -236,6 +241,9 @@ const Sidebar: React.FC<SidebarProps> = ({ open, setClosed }) => {
|
||||
);
|
||||
})}
|
||||
</nav>
|
||||
<div className="px-2">
|
||||
<UserWarnings />
|
||||
</div>
|
||||
{hasPermission(Permission.ADMIN) && (
|
||||
<div className="px-2">
|
||||
<VersionStatus />
|
||||
|
||||
66
src/components/Layout/UserWarnings/index.tsx
Normal file
66
src/components/Layout/UserWarnings/index.tsx
Normal file
@@ -0,0 +1,66 @@
|
||||
import React from 'react';
|
||||
import Link from 'next/link';
|
||||
import { ExclamationIcon } from '@heroicons/react/outline';
|
||||
import { defineMessages, useIntl } from 'react-intl';
|
||||
import { useUser } from '../../../hooks/useUser';
|
||||
|
||||
const messages = defineMessages({
|
||||
emailRequired: 'An email address is required.',
|
||||
emailInvalid: 'Email address is invalid.',
|
||||
passwordRequired: 'A password is required.',
|
||||
});
|
||||
|
||||
interface UserWarningsProps {
|
||||
onClick?: () => void;
|
||||
}
|
||||
|
||||
const UserWarnings: React.FC<UserWarningsProps> = ({ onClick }) => {
|
||||
const intl = useIntl();
|
||||
const { user } = useUser();
|
||||
if (!user) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let res = null;
|
||||
|
||||
//check if a user has warnings
|
||||
if (user.warnings.length > 0) {
|
||||
user.warnings.forEach((warning) => {
|
||||
let link = '';
|
||||
let warningText = '';
|
||||
let warningTitle = '';
|
||||
switch (warning) {
|
||||
case 'userEmailRequired':
|
||||
link = '/profile/settings/';
|
||||
warningTitle = 'Profile is incomplete';
|
||||
warningText = intl.formatMessage(messages.emailRequired);
|
||||
}
|
||||
|
||||
res = (
|
||||
<Link href={link}>
|
||||
<a
|
||||
onClick={onClick}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter' && onClick) {
|
||||
onClick();
|
||||
}
|
||||
}}
|
||||
role="button"
|
||||
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"
|
||||
>
|
||||
<ExclamationIcon className="h-6 w-6" />
|
||||
<div className="flex min-w-0 flex-1 flex-col truncate px-2 last:pr-0">
|
||||
<span className="font-bold">{warningTitle}</span>
|
||||
<span className="truncate">{warningText}</span>
|
||||
</div>
|
||||
</a>
|
||||
</Link>
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
export default UserWarnings;
|
||||
@@ -50,6 +50,7 @@ const Layout: React.FC = ({ children }) => {
|
||||
<div className="absolute top-0 h-64 w-full bg-gradient-to-bl from-gray-800 to-gray-900">
|
||||
<div className="relative inset-0 h-full w-full bg-gradient-to-t from-gray-900 to-transparent" />
|
||||
</div>
|
||||
|
||||
<Sidebar open={isSidebarOpen} setClosed={() => setSidebarOpen(false)} />
|
||||
|
||||
<div className="relative mb-16 flex w-0 min-w-0 flex-1 flex-col lg:ml-64">
|
||||
|
||||
Reference in New Issue
Block a user