add error toasts
This commit is contained in:
@@ -1,16 +1,15 @@
|
||||
// src/pages/Home.tsx
|
||||
import { Route, Routes } from 'react-router-dom';
|
||||
import { Navigate, Route, Routes } from 'react-router-dom';
|
||||
import Login from '../views/home/auth/Login';
|
||||
import Register from '../views/home/auth/Register';
|
||||
import Menu from '../views/home/menu/Menu';
|
||||
import { useAppDispatch, useAppSelector } from '../redux/hooks';
|
||||
import { useEffect } from 'react';
|
||||
import { fetchWhoAmI, logout } from '../redux/slices/auth';
|
||||
import { fetchWhoAmI } from '../redux/slices/auth';
|
||||
import Missions from '../views/home/missions/Missions';
|
||||
import Articles from '../views/home/articles/Articles';
|
||||
import Groups from '../views/home/groups/Groups';
|
||||
import Contests from '../views/home/contests/Contests';
|
||||
import { PrimaryButton } from '../components/button/PrimaryButton';
|
||||
import Group from '../views/home/group/Group';
|
||||
import Contest from '../views/home/contest/Contest';
|
||||
import Account from '../views/home/account/Account';
|
||||
@@ -19,14 +18,8 @@ import { MissionsRightPanel } from '../views/home/rightpanel/Missions';
|
||||
import { ArticlesRightPanel } from '../views/home/rightpanel/Articles';
|
||||
import { GroupRightPanel } from '../views/home/rightpanel/group/Group';
|
||||
import GroupInvite from '../views/home/groupinviter/GroupInvite';
|
||||
import {
|
||||
toastError,
|
||||
toastSuccess,
|
||||
toastWarning,
|
||||
} from '../lib/toastNotification';
|
||||
|
||||
const Home = () => {
|
||||
const name = useAppSelector((state) => state.auth.username);
|
||||
const jwt = useAppSelector((state) => state.auth.jwt);
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
@@ -59,53 +52,7 @@ const Home = () => {
|
||||
<Route path="contest/:contestId/*" element={<Contest />} />
|
||||
<Route
|
||||
path="*"
|
||||
element={
|
||||
<>
|
||||
<p>{jwt}</p>
|
||||
<PrimaryButton
|
||||
onClick={() => {
|
||||
if (jwt) {
|
||||
navigator.clipboard.writeText(jwt);
|
||||
alert(jwt);
|
||||
}
|
||||
}}
|
||||
text="скопировать токен"
|
||||
className="pt-[20px]"
|
||||
/>
|
||||
<p className="py-[20px]">{name}</p>
|
||||
<PrimaryButton
|
||||
onClick={() => {
|
||||
dispatch(logout());
|
||||
}}
|
||||
>
|
||||
выйти
|
||||
</PrimaryButton>
|
||||
|
||||
<div className="flex mt-[20px] gap-[20px]">
|
||||
<PrimaryButton
|
||||
color="success"
|
||||
text="Toast"
|
||||
onClick={() => {
|
||||
toastSuccess('Success');
|
||||
}}
|
||||
/>
|
||||
<PrimaryButton
|
||||
color="warning"
|
||||
text="Toast"
|
||||
onClick={() => {
|
||||
toastWarning('Warning');
|
||||
}}
|
||||
/>
|
||||
<PrimaryButton
|
||||
color="error"
|
||||
text="Toast"
|
||||
onClick={() => {
|
||||
toastError('Error');
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
}
|
||||
element={<Navigate to="/home/account" replace />}
|
||||
/>
|
||||
</Routes>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user