diff --git a/src/components/links/links.tsx b/src/components/links/links.tsx index c9e68ba..6a73236 100644 --- a/src/components/links/links.tsx +++ b/src/components/links/links.tsx @@ -8,6 +8,7 @@ import { StyledH2 } from '../styled'; import { Icon } from '../icons'; import { NewLink } from '../new-link'; import { Button } from '../button'; +import { useUser } from '../../shared/hooks'; interface ILinkProps { links: ILink[]; @@ -44,20 +45,24 @@ const StyledLinks = styled.div` export const Links: React.FC = ({ links }) => { const [isEditing, setIsEditing] = useState(false); + const [user] = useUser(); + const { isAdmin } = user; return (
Link utili - + {isAdmin && ( + + )}
) diff --git a/src/components/quote/quote.tsx b/src/components/quote/quote.tsx index 979b55f..d35d369 100644 --- a/src/components/quote/quote.tsx +++ b/src/components/quote/quote.tsx @@ -6,6 +6,7 @@ import { Icon } from '../icons'; import { QuoteForm } from '../forms'; import { Button } from '../button'; import { IQuote } from '../../services/firebase/types'; +import { useUser } from '../../shared/hooks'; interface IQuoteProps { quote: IQuote; @@ -64,10 +65,12 @@ const StyledQuote = styled.div` `; export const Quote: React.FC = ({ quote, refresh }) => { - const [isEditing, setIsEditing] = useState(false) + const [isEditing, setIsEditing] = useState(false); + const [user] = useUser(); + const { isAdmin } = user; const { url, text } = quote; - const onSave = () => { + const onSave = (): void => { refresh(); setIsEditing(false); } @@ -76,12 +79,14 @@ export const Quote: React.FC = ({ quote, refresh }) => {
Citazione del mese - + {isAdmin && ( + + )}
- {isEditing ? ( + {isAdmin && isEditing ? ( ) : (

{text}