add modal for user
This commit is contained in:
parent
d4d59bb5ac
commit
67c0ab9097
|
|
@ -2,6 +2,7 @@ import logo from '@assets/images/logo-only.svg';
|
||||||
import { useQuery } from '@tanstack/react-query';
|
import { useQuery } from '@tanstack/react-query';
|
||||||
import { useCookies } from 'react-cookie';
|
import { useCookies } from 'react-cookie';
|
||||||
import Avatar from '@components/Avatar';
|
import Avatar from '@components/Avatar';
|
||||||
|
import User from './User';
|
||||||
import { getMeInfo } from '@controllers/UserController';
|
import { getMeInfo } from '@controllers/UserController';
|
||||||
import { FiLogOut } from 'react-icons/fi';
|
import { FiLogOut } from 'react-icons/fi';
|
||||||
|
|
||||||
|
|
@ -31,9 +32,7 @@ const AppHeader = () => {
|
||||||
<div className="flex items-center gap-2 sm:gap-4">
|
<div className="flex items-center gap-2 sm:gap-4">
|
||||||
{meInfo.data && <Avatar user={meInfo.data} />}
|
{meInfo.data && <Avatar user={meInfo.data} />}
|
||||||
<div className="app-header__user__name">
|
<div className="app-header__user__name">
|
||||||
<span className="text-white">
|
{meInfo.data && <User author={meInfo.data} />}
|
||||||
{meInfo.isLoading ? '' : meInfo.data ? meInfo.data.firstName + ' ' + meInfo.data.lastName : ''}
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
className="group relative flex w-auto justify-center rounded-md border border-red bg-red py-2 px-2 text-sm font-medium text-white hover:bg-white hover:text-red focus:outline-none focus:ring-2 focus:ring-red focus:ring-offset-2"
|
className="group relative flex w-auto justify-center rounded-md border border-red bg-red py-2 px-2 text-sm font-medium text-white hover:bg-white hover:text-red focus:outline-none focus:ring-2 focus:ring-red focus:ring-offset-2"
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import Like from '@components/Like';
|
||||||
import { getMeInfo } from '@controllers/UserController';
|
import { getMeInfo } from '@controllers/UserController';
|
||||||
import { useQuery } from '@tanstack/react-query';
|
import { useQuery } from '@tanstack/react-query';
|
||||||
import { toastError } from '@controllers/Toasts';
|
import { toastError } from '@controllers/Toasts';
|
||||||
import { useState } from 'react';
|
import User from './User';
|
||||||
|
|
||||||
const Image = ({ image }: { image: string }) => {
|
const Image = ({ image }: { image: string }) => {
|
||||||
if (image === '' || image === null) {
|
if (image === '' || image === null) {
|
||||||
|
|
@ -44,9 +44,7 @@ const Message = ({ message }: any) => {
|
||||||
{message.author && <Avatar user={message.author} />}
|
{message.author && <Avatar user={message.author} />}
|
||||||
<div className="flex flex-col gap-2 relative flex-grow">
|
<div className="flex flex-col gap-2 relative flex-grow">
|
||||||
<div className="flex justify-between">
|
<div className="flex justify-between">
|
||||||
<div className="text-red-light text-xl username">
|
{message.author && <User author={message.author} />}
|
||||||
{message.author.firstName} {message.author.lastName}
|
|
||||||
</div>
|
|
||||||
{(me.data?.id === message.author.id) || (me.data?.role === 'ADMIN') ? (
|
{(me.data?.id === message.author.id) || (me.data?.role === 'ADMIN') ? (
|
||||||
<PopupMenu message={message} />
|
<PopupMenu message={message} />
|
||||||
) : null}
|
) : null}
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,8 @@ const MessageWrapper = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<main className="messages-wrapper rounded-md w-full max-w-3xl flex flex-col flex-shrink relative overflow-y-scroll">
|
<main className="messages-wrapper rounded-md w-full max-w-3xl flex flex-col flex-shrink relative overflow-y-hidden">
|
||||||
<ScrollToBottom className="message-container flex flex-col gap-4 w-full max-w-3xl pt-4 pb-6 -mb-3 px-2 md:px-0">
|
<ScrollToBottom className="message-container flex flex-col gap-4 w-full max-w-3xl overflow-scroll pt-4 pb-6 px-2 md:px-0">
|
||||||
{isLoading
|
{isLoading
|
||||||
? ''
|
? ''
|
||||||
: isError
|
: isError
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ const ScrollToBottom = ({ children, className = '' }: { children: ReactNode; cla
|
||||||
<div className={className}>
|
<div className={className}>
|
||||||
{children}
|
{children}
|
||||||
<div className="scroll-bottom" ref={bottom}></div>
|
<div className="scroll-bottom" ref={bottom}></div>
|
||||||
|
</div>
|
||||||
<button
|
<button
|
||||||
onClick={() => node?.scrollIntoView({ behavior: 'smooth' })}
|
onClick={() => node?.scrollIntoView({ behavior: 'smooth' })}
|
||||||
className={'absolute right-3 transition-all' + (show ? ' bottom-3' : ' -bottom-10')}
|
className={'absolute right-3 transition-all' + (show ? ' bottom-3' : ' -bottom-10')}
|
||||||
|
|
@ -41,7 +42,6 @@ const ScrollToBottom = ({ children, className = '' }: { children: ReactNode; cla
|
||||||
<FaChevronDown className="fill-grey-light hover:fill-grey-dark transition-all text-xl w-10 h-10 p-2.5" />
|
<FaChevronDown className="fill-grey-light hover:fill-grey-dark transition-all text-xl w-10 h-10 p-2.5" />
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
import { useState } from 'react';
|
||||||
|
import Modal from './Modal';
|
||||||
|
|
||||||
|
const User = ({ author }: any) => {
|
||||||
|
const [show, setShow] = useState(false);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<button className="text-red-light text-xl username" onClick={() => setShow(true)}>
|
||||||
|
{author.firstName} {author.lastName}
|
||||||
|
</button>
|
||||||
|
<Modal show={show}>
|
||||||
|
<div className="flex flex-col gap-5">
|
||||||
|
<div className="flex flex-col gap-2">
|
||||||
|
<div className="text-2xl text-white">User info</div>
|
||||||
|
<div className="text-white">First name: {author.firstName}</div>
|
||||||
|
<div className="text-white">Last name: {author.lastName}</div>
|
||||||
|
<div className="text-white">Email: {author.email}</div>
|
||||||
|
</div>
|
||||||
|
<button className="btn" onClick={() => setShow(false)}>
|
||||||
|
Close
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</Modal>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default User;
|
||||||
Loading…
Reference in New Issue