Skip to content

Commit

Permalink
Merge branch 'feature-fixuser' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasleal570 committed Jun 8, 2020
2 parents 65bb248 + 41fab40 commit 8a7bc13
Show file tree
Hide file tree
Showing 9 changed files with 420 additions and 44 deletions.
100 changes: 60 additions & 40 deletions components/auth/Navbar.tsx
Original file line number Diff line number Diff line change
@@ -1,64 +1,84 @@
import React from 'react'
import React, { useState } from 'react'
import { useSelector, useDispatch } from 'react-redux';
import Link from 'next/link';
import { useRouter } from 'next/router';
import { logout } from '../../store/actions/authAction';
import { authCheckState, logout } from '../../store/actions/authAction';
import AccountCircleIcon from '@material-ui/icons/AccountCircle';
import AccountBalanceIcon from '@material-ui/icons/AccountBalance';
import SettingsIcon from '@material-ui/icons/Settings';
import HelpIcon from '@material-ui/icons/Help';
import ArrowDropDownIcon from '@material-ui/icons/ArrowDropDown';

const Navbar = () => {

const { user } = useSelector((state: any) => state.auth)
const dispatch = useDispatch();
const router = useRouter();
const [toggled, toggle] = useState(false)
const [toggled1, toggle1] = useState(false)
const [toggled2, toggle2] = useState(false)
const [toggled3, toggle3] = useState(false)
const [toggled4, toggle4] = useState(false)

const handleLogout = () => {
router.push('/');
dispatch(logout());
}



return (
<nav className="relative">
{/* <div className="bg-red-500">
<p>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Aspernatur repellat quaerat odit laboriosam sunt eaque obcaecati ratione! Sequi, quaerat? Temporibus!</p>
</div> */}
<div className="relative h-full flex-col pt-4 bg-purple-700 overflow-y-auto">
<div className="flex justify-center items-center mx-auto bg-purple-600 rounded-full overflow-hidden w-24 h-24">
<img className='w-full h-full object-cover' src={user?.avatar} alt='profile' />
</div>
<h1 className="font-bold capitalize text-xl text-center text-white pt-4">Welcome Back</h1>
<h1 className="font-base capitalize text-xl text-center text-white pb-4">{user?.first_name} {user?.last_name}</h1>
<nav>
<div className='fixed w-1/6 bg-purple-700 h-screen'>

{/* Btn logout */}
<div className="w-full mb-4">
<button
onClick={handleLogout}
type="button"
className="text-sm py-2 px-3 bg-red-600 rounded text-white text-center mx-auto block cursor-pointer"
>Cerrar Sesión</button>
</div>

<hr className='border-solid border-1' ></hr>
<div className='mt-10'>
<img src='/assets/icons/logo1.png' className='mx-auto'
height='200' width='200' />
<div className='flex flex-col'>

{/* Menu items */}
<div className="">
<Link href='/dashboard'>
<h2 className="font-semibold capitalize text-l text-center text-white py-4"><span className='cursor-pointer'>Dashboard</span></h2>
</Link>
<h1 className='font-mono bold text-center text-white text-5xl'>iHappy</h1>
<h1 className="font-bold text-l text-center text-white pb-4">Welcome back, {user?.first_name || user?.username}! </h1>

<Link href='/profile'>
<h2 className="font-semibold capitalize text-l text-center text-white py-4"><span className='cursor-pointer'>Account Overview</span></h2>
</Link>
<h2 className="font-semibold capitalize text-l text-center text-white py-4">My Payments</h2>
<h2 className="font-semibold capitalize text-l text-center text-white py-4">Make an Appointment</h2>
<h1 className='cursor-pointer text-white semi-bold hover:bg-purple-500 py-2 text-center text-lg'
onClick={() => toggle1(toggled1 => !toggled1)}><AccountCircleIcon style={{ fill: 'white', paddingRight: 2, marginRight: 10, fontSize: 30 }} />Account Overview {<ArrowDropDownIcon style={{ paddingRight: 2 }} />}</h1>
{toggled1 && <><ul>
<li className='text-center px-3 pl-5 py-1 cursor-pointer text-white text-md hover:bg-purple-500 hover:text-white'> <a href='/profile'>My Account</a></li>
</ul></>}
</div>
<div className=''>
<h1 className='cursor-pointer text-white semi-bold hover:bg-purple-500 py-2 text-center text-lg'
onClick={() => toggle2(toggled2 => !toggled2)}><AccountBalanceIcon style={{ fill: 'white', paddingRight: 2, marginRight: 10, fontSize: 28 }} />Billing information {<ArrowDropDownIcon style={{ paddingRight: 2 }} />}</h1>
{toggled2 && <><ul>
<li className='text-center px-3 pl-5 py-1 cursor-pointer text-white text-md hover:bg-purple-500 hover:text-white'>My Payments</li>
</ul></>}
</div>
<div className='hover:bg-purple-500'>
<h1 className='cursor-pointer text-white semi-bold hover:bg-purple-500 py-2 text-center mr-32 pl-4 text-lg'
onClick={() => toggle3(toggled3 => !toggled3)}><SettingsIcon style={{ fill: 'white', paddingRight: 2, marginRight: 10, fontSize: 28 }} />Settings</h1>
{toggled3 && <><ul>
{/* <li className='text-center px-3 pl-10 py-1 cursor-pointer text-white text-md hover:bg-purple-500 hover:text-white'></li> */}
</ul></>}
</div>
<div className='hover:bg-purple-500'>
<h1 className='cursor-pointer text-white semi-bold hover:bg-purple-500 py-2 text-center mr-32 pr-3 text-lg'
onClick={() => toggle4(toggled4 => !toggled4)}><HelpIcon style={{ fill: 'white', paddingRight: 2, marginRight: 10, fontSize: 28 }} />Help</h1>
{toggled4 && <><ul>
{/* <li className='text-center px-3 pl-10 py-1 cursor-pointer text-white text-md hover:bg-purple-500 hover:text-white'>Contact</li> */}
</ul></>}
</div>
</div>
<div className="px-6 py-2 w-full flex justify-between items-center">
<h4 className="font-bold capitalize text-l text-white">Help</h4>
<div className='flex'>
<div className="w-8 h-8 mr-3 overflow-hidden">
<img className='w-auto h-full' src='/assets/icons/discord.png/' />
</div>
<div className="w-8 h-8 overflow-hidden">
<img className='w-full' src='/assets/icons/gmail.webp/' />
</div>
</div>

<div className="z-40 w-4/5 ml-20 bg-white">
<div className='absolute z-40 top-0 right-0 mr-5 mt-5'>
<button onClick={() => toggle(toggled => !toggled)} className='z-40 block rounded-full overflow-hidden border-2 border-white focus:outline-none focus:border-purple-600'>
<img className='z-40 mx-auto object-cover' src={user?.avatar || ''} alt='profile' height="40" width="40" />
</button>
<div className='z-40 py-2 mt-2 bg-gray-400 rounded-lg shadow-xl'> {toggled && <> <a href='/account' className='block px-4 py-2 text-gray-800 hover:bg-purple-400 hover:text-white'>Account Overview</a>
<a href='#' className='z-40 block px-4 py-2 text-gray-800 hover:bg-purple-400 hover:text-white'>Support</a>
<a href='#' onClick={handleLogout} className='z-40 block px-4 py-2 text-gray-800 hover:bg-purple-400 hover:text-white cursor-pointer'>Log out</a>
</>}
</div>
</div>
</div>
Expand Down
135 changes: 135 additions & 0 deletions components/auth/Sidebar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
import { useState, useEffect } from 'react';
import Link from 'next/link';
import { authCheckState, logout } from '../../store/actions/authAction';
import { useSelector, useDispatch } from 'react-redux';
import { useRouter } from 'next/router';
interface Psychologists {
name: String;
imgUrl: string;
}

const Psychologists = ({ name, imgUrl }: Psychologists) => (
<div className='container'>
<div className="flex flex-col">
<img src={imgUrl} className="w-48 ml-10" alt="Doctors" />
<h3 className="font-bold capitalize ml-20">{name}</h3>
</div>
</div>
);



export default function Sidebar() {
const [toggled, toggle] = useState(false)


const { user } = useSelector((state: any) => state.auth)
const dispatch = useDispatch();
const router = useRouter();

useEffect(() => {
dispatch(authCheckState())
}, [])

const handleLogout = () => {
dispatch(logout());
router.push('/');
}

return (
<div className="flex">
<div className="w-1/5">
{/* <div className="flex-col pt-10 bg-purple-700">
<img className='mx-auto' src='assets/icons/male_avatar.svg/' alt='profile' height="200" width="200" />
<h1 className="font-bold capitalize text-xl text-center text-white pt-8">Welcome Back</h1>
<h1 className="font-bold capitalize text-xl text-center text-white pb-4">User</h1>
<hr className='border-solid border-1' ></hr>
<h2 className="font-semibold capitalize text-l text-center text-white py-4">Account Overview</h2>
<h2 className="font-semibold capitalize text-l text-center text-white py-4">My Payments</h2>
<h2 className="font-semibold capitalize text-l text-center text-white py-4">Make an Appointment</h2>
<div className='absolute bottom-0 h-10 pl-10'>
<div className='flex flex-auto'>
<h4 className="font-bold capitalize text-l text-white">Help</h4>
<div className='flex flex-align ml-24'>
<div className='flex content-around'>
<img className='mr-2' src='/assets/icons/discord.png/' height='25' width='25' />
<img className='mr-32' src='/assets/icons/gmail.webp/' height='25' width='30' />
</div>
</div>
</div>
</div>
</div> */}
</div>
<div className="w-4/5 ml-20 bg-white">
{/* <div className='absolute top-0 right-0 mr-5 mt-5'>
<button onClick={() => toggle(toggled => !toggled)} className='block rounded-full overflow-hidden border-2 border-white focus:outline-none focus:border-purple-600'>
<img className='mx-auto object-cover' src='assets/icons/male_avatar.svg/' alt='profile' height="40" width="40" />
</button>
<div className='py-2 mt-2 bg-gray-400 rounded-lg shadow-xl'> {toggled && <> <a href='#' className='block px-4 py-2 text-gray-800 hover:bg-purple-400 hover:text-white'>Account Overview</a>
<a href='#' className='block px-4 py-2 text-gray-800 hover:bg-purple-400 hover:text-white'>Support</a>
<a href='#' onClick={handleLogout} className='block px-4 py-2 text-gray-800 hover:bg-purple-400 hover:text-white cursor-pointer'>Log out</a>
</>}
</div>
</div> */}
<div className='flex flex-column'>
<div className='container mx-auto'>
<div className='flex flex-align mt-10'>
<h1 className="font-bold capitalize text-xl text-left pl-6 py-2">Connect: </h1>
<input className="inline-block ml-5 pr-5 py-2 transition duration-300 ease-in-out bg-transparent border-2 border-purple-600 hover:bg-transparent hover:border-purple-800 rounded "></input>
<img src='/assets/icons/lupa.png/' className='w-8 h-8 ml-5 mt-2 cursor-pointer' />
</div>
<div className='container mx-auto mt-10 ml-5'>
<Link href='/reviews'>
<h1 className="font-bold capitalize text-xl text-left ml-2 py-8">Online Psychologists</h1>
</Link>
<div className='flex'>

<Psychologists
name='Dr. Luis Silva'
imgUrl='/assets/icons/profile.svg'
/>

<Psychologists
name='Dr. Luis Silva'
imgUrl='/assets/icons/profile.svg'
/>
<Psychologists
name='Dr. Luis Silva'
imgUrl='/assets/icons/profile.svg'
/>
<Psychologists
name='Dr. Luis Silva'
imgUrl='/assets/icons/profile.svg'
/>
</div>
<h1 className="font-bold capitalize text-xl text-left ml-2 py-8" >Charts</h1>
<div className='flex'>
<img src='/assets/icons/chart.png' className='w-70 h-40' />
<img src='/assets/icons/chart.png' className='w-70 h-40 pl-10' />
<img src='/assets/icons/chart.png' className='w-70 h-40' />
</div>
</div>
</div>
</div>
</div>
<div className="w-1/5">
{/* <div className='bg-gray-300 mt-10 mr-5'>
<h1 className="font-bold capitalize text-xl text-center ">Activities of the Week</h1>
<hr className='border border-solid'></hr>
<h2 className="font-bold capitalize text-xl text-left ml-5 py-5">Read</h2>
<img src='/assets/img/tasty_pride.jpg' className='w-150 pd-5' />
<h2 className="font-bold capitalize text-xl text-left ml-5">Excercise</h2>
<div className="bg-blue-400">
<h2 className="font-bold capitalize antialiased text-xl text-left ml-10 pl-10">WITH</h2>
</div>
<img src='/assets/img/runtastic.png' />
<h2 className="font-bold capitalize antialiased text-xl text-left ml-10 pt-2">Play</h2>
<img src='/assets/img/cod.jpg' className='w-25 h-40' /> */}
{/* </div> */}


</div>
</div>
)

}
4 changes: 2 additions & 2 deletions components/auth/review.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ export default function Reviews({ slug }: any) {
type="submit"
className={`
inline-block px-4 py-2 transition duration-300 ease-in-out rounded cursor-pointer ml-2 h-12
${sendingComment ? 'border-2 border-gray-400 bg-gray-400 text-gray-600 cursor-not-allowed'
: 'border-2 border-purple-600 hover:bg-purple-800 hover:border-purple-800 bg-purple-600 text-white cursor-pointer'}
${sendingComment ? 'border-2 border-gray-400 bg-gray-400 text-gray-600 cursor-not-allowed'
: 'border-2 border-purple-600 hover:bg-purple-800 hover:border-purple-800 bg-purple-600 text-white cursor-pointer'}
`}
disabled={sendingComment}
>Comentar</button>
Expand Down
Loading

0 comments on commit 8a7bc13

Please sign in to comment.