Commit 59860c5e authored by Zhanara's avatar Zhanara

мелкие изменения

parent ada9e5fc
...@@ -7,9 +7,10 @@ const Layout: FunctionComponent = (): ReactElement => { ...@@ -7,9 +7,10 @@ const Layout: FunctionComponent = (): ReactElement => {
const { user } = useAppSelector((state) => state.user); const { user } = useAppSelector((state) => state.user);
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
return ( return (
<div className="bg-gray-100"> <div className="bg-gray-100 flex">
<div className="container mx-auto flex justify-between items-center py-4"> <div className="w-1/6">
<p className="text-lg font-medium">Forum</p> <div className="container mx-auto py-4">
<p className="text-lg font-medium mb-8">Forum</p>
{!user.username ? ( {!user.username ? (
<div> <div>
<NavLink className="text-gray-700 hover:text-gray-900" to={'register'}> <NavLink className="text-gray-700 hover:text-gray-900" to={'register'}>
...@@ -17,12 +18,12 @@ const Layout: FunctionComponent = (): ReactElement => { ...@@ -17,12 +18,12 @@ const Layout: FunctionComponent = (): ReactElement => {
</NavLink> </NavLink>
</div> </div>
) : ( ) : (
<div className="flex items-center"> <div className="flex flex-col">
<p className="text-gray-700 mr-4"> <p className="text-gray-700 mb-4">
<span className="text-indigo-600">{user.username}</span> Hello
<span className="text-indigo-600"> {user.username}!</span>
</p> </p>
<NavLink className={'mx-4'} to={'/'}> <NavLink to={'/'} className=" mb-4">Add new Post
Add new Post
</NavLink> </NavLink>
<NavLink <NavLink
onClick={() => { onClick={() => {
...@@ -30,16 +31,21 @@ const Layout: FunctionComponent = (): ReactElement => { ...@@ -30,16 +31,21 @@ const Layout: FunctionComponent = (): ReactElement => {
dispatch(setInitialUser()); dispatch(setInitialUser());
}} }}
to={'/'} to={'/'}
className="text-gray-700 hover:text-gray-900"> className="text-gray-700 hover:text-gray-900"
>
Log out Log out
</NavLink> </NavLink>
</div> </div>
)} )}
</div> </div>
</div>
<div className="w-3/4">
<div className="container mx-auto py-8"> <div className="container mx-auto py-8">
<Outlet /> <Outlet />
</div> </div>
</div> </div>
</div>
); );
}; };
......
...@@ -11,17 +11,20 @@ const HomePage: FunctionComponent = (): ReactElement => { ...@@ -11,17 +11,20 @@ const HomePage: FunctionComponent = (): ReactElement => {
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const {posts} = useSelector((state: AppState) => state.posts, shallowEqual) const {posts} = useSelector((state: AppState) => state.posts, shallowEqual)
const { user } = useSelector((state: AppState) => state.user,shallowEqual);
useEffect(() => { useEffect(() => {
const token = window.sessionStorage.getItem('token'); const token = window.sessionStorage.getItem('token');
if (token) { if (token) {
dispatch(getUser(token)); dispatch(getUser(token));
dispatch(getPosts())
}
},[]);
if (!user) {
return <div>Loading...</div>;
} }
});
useEffect(() => {
dispatch(getPosts())
}, [])
return ( return (
<div className="bg-gray-50 dark:bg-gray-900 h-screen w-full container mx-auto"> <div className="bg-gray-50 dark:bg-gray-900 h-screen w-full container mx-auto">
<PostsList posts={posts}/> <PostsList posts={posts}/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment