This commit is contained in:
@@ -25,7 +25,6 @@ type Props = { user: User | null }
|
|||||||
export default ({ user }: Props) => {
|
export default ({ user }: Props) => {
|
||||||
const { id } = useParams ()
|
const { id } = useParams ()
|
||||||
|
|
||||||
const [editing, setEditing] = useState (true)
|
|
||||||
const [post, setPost] = useState<Post | null> (null)
|
const [post, setPost] = useState<Post | null> (null)
|
||||||
const [status, setStatus] = useState (200)
|
const [status, setStatus] = useState (200)
|
||||||
|
|
||||||
@@ -49,6 +48,8 @@ export default ({ user }: Props) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
useEffect (() => {
|
useEffect (() => {
|
||||||
|
setPost (null)
|
||||||
|
|
||||||
if (!(id))
|
if (!(id))
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -68,15 +69,6 @@ export default ({ user }: Props) => {
|
|||||||
fetchPost ()
|
fetchPost ()
|
||||||
}, [id])
|
}, [id])
|
||||||
|
|
||||||
useEffect (() => {
|
|
||||||
setEditing (false)
|
|
||||||
}, [post])
|
|
||||||
|
|
||||||
useEffect (() => {
|
|
||||||
if (!(editing))
|
|
||||||
setEditing (true)
|
|
||||||
}, [editing])
|
|
||||||
|
|
||||||
switch (status)
|
switch (status)
|
||||||
{
|
{
|
||||||
case 404:
|
case 404:
|
||||||
@@ -121,7 +113,7 @@ export default ({ user }: Props) => {
|
|||||||
<Tab name="関聯">
|
<Tab name="関聯">
|
||||||
<PostList posts={post.related} />
|
<PostList posts={post.related} />
|
||||||
</Tab>
|
</Tab>
|
||||||
{(['admin', 'member'].some (r => user?.role === r) && editing) && (
|
{['admin', 'member'].some (r => user?.role === r) && (
|
||||||
<Tab name="編輯">
|
<Tab name="編輯">
|
||||||
<PostEditForm post={post}
|
<PostEditForm post={post}
|
||||||
onSave={newPost => {
|
onSave={newPost => {
|
||||||
|
|||||||
Reference in New Issue
Block a user