import React, { useState } from 'react' import { Link, useHistory } from 'react-router-dom' import Container from '@material-ui/core/Container' import TextField from '@material-ui/core/TextField' import Grid from '@material-ui/core/Grid' import Tabs from '@material-ui/core/Tabs' import Tab from '@material-ui/core/Tab' import Box from '@material-ui/core/Box' import Button from '@material-ui/core/Button' import { makeStyles } from '@material-ui/core/styles' import useAuth from '@wasp/auth/useAuth.js' import { useQuery } from '@wasp/queries' import getUser from '@wasp/queries/getUser' import getArticlesByUser from '@wasp/queries/getArticlesByUser' import getFavoritedArticles from '@wasp/queries/getFavoritedArticles' import followUser from '@wasp/actions/followUser' import Navbar from '../../Navbar' import ArticleListPaginated from '../../article/components/ArticleListPaginated' import smileyImageUrl from '../../smiley.jpg' const useStyles = makeStyles((theme) => ({ articles: { marginTop: theme.spacing(5) } })) const UserProfilePage = (props) => { const classes = useStyles() const history = useHistory() const { data: me } = useAuth() const username = props.match.params.username const { data: user, error: userError } = useQuery(getUser, { username }) // NOTE: use-query will retry multiple times in case of error, making user // wait relatively long before giving up on for example 404 and returning error, // while on the other hand we would probably like it to give up on 404 immediatelly! // Should we modify react-query default settings to not do any retrying? if (userError) { console.log(userError) history.push("/") } return user ? (

{ user.username }

{ user.bio }

{ me && me.username === username && (
)} { me && me.username !== username && (
)}
) : null } const FollowUserButton = (props) => { const user = props.user const { data: me } = useAuth() const toggleFollow = async () => { try { followUser({ username: user.username, follow: !user.following }) } catch (err) { console.error(err) window.alert(err) } } return me && me.username !== user.username ? ( ) : null } const useStylesFeedTabs = makeStyles((theme) => ({ root: { marginBottom: theme.spacing(2), }, })) const ProfileFeedTabs = (props) => { const classes = useStylesFeedTabs() const [value, setValue] = useState(0); const handleChange = (event, newValue) => setValue(newValue) return ( <> ({ username: props.user.username, skip, take })} pageSize={5} /> ({ username: props.user.username, skip, take })} pageSize={5} /> ) } function TabPanel(props) { const { children, value, index, ...other } = props return ( ) } const Articles = (props) => { const classes = useStyles() const user = props.user return (
) } export default UserProfilePage