Update NewChannelForm.tsx

This commit is contained in:
talksik
2022-05-20 07:05:42 -05:00
parent da0b1c60e0
commit f1ce7727ec
@@ -6,8 +6,7 @@ import toast from 'react-hot-toast';
import { Avatar, Divider, Skeleton, Spin } from 'antd'; import { Avatar, Divider, Skeleton, Spin } from 'antd';
import { User } from '@nirvana/core/models/user.model'; import { User } from '@nirvana/core/models/user.model';
import CreateLineRequest from '@nirvana/core/requests/createLine.request'; import CreateLineRequest from '@nirvana/core/requests/createLine.request';
import { maxChannelUserCount } from '../rules';
const maxUserCount = 8;
export default function NewChannelForm({ handleClose }: { handleClose: () => void }) { export default function NewChannelForm({ handleClose }: { handleClose: () => void }) {
const [peopleSearchQuery, setPeopleSearchQuery] = useState<string>(''); const [peopleSearchQuery, setPeopleSearchQuery] = useState<string>('');
@@ -61,7 +60,7 @@ export default function NewChannelForm({ handleClose }: { handleClose: () => voi
return prevUsers; return prevUsers;
} }
if (prevUsers.length === maxUserCount - 1) { if (prevUsers.length === maxChannelUserCount - 1) {
toast.error('you can only have 8 people per channel!'); toast.error('you can only have 8 people per channel!');
return prevUsers; return prevUsers;
@@ -100,8 +99,8 @@ export default function NewChannelForm({ handleClose }: { handleClose: () => voi
return; return;
} }
if (selectedUsers.length === maxUserCount - 1) { if (selectedUsers.length === maxChannelUserCount - 1) {
toast.error(`Max ${maxUserCount} people per channel including you!`); toast.error(`Max ${maxChannelUserCount} people per channel including you!`);
return; return;
} }
@@ -182,7 +181,7 @@ export default function NewChannelForm({ handleClose }: { handleClose: () => voi
<span className="text-gray-500 ">{`Selected`}</span> <span className="text-gray-500 ">{`Selected`}</span>
<span className="text-gray-400"> <span className="text-gray-400">
{selectedUsers.length}/${maxUserCount - 1} {selectedUsers.length}/${maxChannelUserCount - 1}
</span> </span>
</span> </span>