WIP user bio
This commit is contained in:
parent
56a3dc9793
commit
027ba6a048
|
@ -22,7 +22,6 @@ async function comments (models, id) {
|
|||
}
|
||||
|
||||
export async function getItem (parent, { id }, { models }) {
|
||||
console.log(id)
|
||||
const [item] = await models.$queryRaw(`
|
||||
${SELECT}
|
||||
FROM "Item"
|
||||
|
|
|
@ -73,7 +73,6 @@ export default {
|
|||
return Math.floor(user.msats / 1000)
|
||||
},
|
||||
bio: async (user, args, { models }) => {
|
||||
console.log(user)
|
||||
return getItem(user, { id: user.bioId }, { models })
|
||||
},
|
||||
hasNewNotes: async (user, args, { models }) => {
|
||||
|
|
|
@ -9,8 +9,11 @@ import { gql, useQuery } from '@apollo/client'
|
|||
import styles from '../styles/item.module.css'
|
||||
import { NOFOLLOW_LIMIT } from '../lib/constants'
|
||||
import { useRouter } from 'next/router'
|
||||
import Link from 'next/link'
|
||||
import { useMe } from './me'
|
||||
|
||||
function BioItem ({ item }) {
|
||||
const me = useMe()
|
||||
if (!item.text) {
|
||||
return null
|
||||
}
|
||||
|
@ -18,6 +21,10 @@ function BioItem ({ item }) {
|
|||
return (
|
||||
<>
|
||||
<ItemText item={item} />
|
||||
{me?.name === item.user.name &&
|
||||
<Link href={`/items/${item.id}/edit`} passHref>
|
||||
<a className='text-right'>edit bio</a>
|
||||
</Link>}
|
||||
<Reply parentId={item.id} />
|
||||
</>
|
||||
)
|
||||
|
|
|
@ -13,6 +13,7 @@ import * as Yup from 'yup'
|
|||
import { Form, MarkdownInput, SubmitButton } from '../components/form'
|
||||
import ActionTooltip from '../components/action-tooltip'
|
||||
import TextareaAutosize from 'react-textarea-autosize'
|
||||
import { useMe } from '../components/me'
|
||||
|
||||
export async function getServerSideProps ({ req, params }) {
|
||||
const { error, data: { user } } = await (await ApolloClient(req)).query({
|
||||
|
@ -52,7 +53,7 @@ const BioSchema = Yup.object({
|
|||
bio: Yup.string().required('required').trim()
|
||||
})
|
||||
|
||||
function BioForm () {
|
||||
export function BioForm () {
|
||||
const [createBio] = useMutation(
|
||||
gql`
|
||||
mutation createBio($bio: String!) {
|
||||
|
@ -103,8 +104,7 @@ function BioForm () {
|
|||
export default function User ({ user }) {
|
||||
const [create, setCreate] = useState(false)
|
||||
const [session] = useSession()
|
||||
|
||||
// need to check if this is the user's page before exposing create/edit
|
||||
const me = useMe()
|
||||
|
||||
return (
|
||||
<Layout noSeo containClassName={styles.contain}>
|
||||
|
@ -112,7 +112,7 @@ export default function User ({ user }) {
|
|||
<UserHeader user={user} />
|
||||
{user.bio
|
||||
? <ItemFull item={user.bio} bio />
|
||||
: (
|
||||
: (me?.name === user.name &&
|
||||
<div className={styles.create}>
|
||||
{create
|
||||
? <BioForm />
|
||||
|
|
Loading…
Reference in New Issue