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