import React, { useState } from 'react' import { Link, useHistory } from 'react-router-dom' import useAuth from '@wasp/auth/useAuth.js' import logout from '@wasp/auth/logout.js' import createArticle from '@wasp/actions/createArticle' import updateArticle from '@wasp/actions/updateArticle' import { useQuery } from '@wasp/queries' import getArticle from '@wasp/queries/getArticle' import Navbar from './Navbar' const ArticleEditorPage = (props) => { const { data: user, isError } = useAuth({ keepPreviousData: true }) // TODO: Here, as in some other places, it feels tricky to figure out what is happening regarding the state. // When is article null, when not, should I look into combination of article and articleSlug, then // there is this 'enabled' which I need on the other hand -> uff. And what if I get error? humpf! const articleSlug = props.match.params.articleSlug const { data: article, error: articleError } = useQuery(getArticle, { slug: articleSlug }, { enabled: articleSlug }) // TODO: Instead of this logic here, I wish I could use ACL via Wasp and just // receive user via props instead of useAuth(). if (!user || isError) { return Please log in. } return articleError ? articleError.message || articleError : (
{ submitError.message || submitError }
) }