このコミットが含まれているのは:
@@ -1,4 +1,8 @@
|
||||
import type { FC } from 'react'
|
||||
|
||||
import ErrorScreen from '@/components/ErrorScreen'
|
||||
|
||||
|
||||
export default () => <ErrorScreen status={403}/>
|
||||
const Forbidden: FC = () => <ErrorScreen status={403}/>
|
||||
|
||||
export default Forbidden
|
||||
|
||||
@@ -11,7 +11,7 @@ import type { FC } from 'react'
|
||||
import type { User } from '@/types'
|
||||
|
||||
|
||||
export default (() => {
|
||||
const MorePage: FC = () => {
|
||||
const menu = menuOutline (
|
||||
{ tag: null, wikiId: null, user: { } as User, pathName: location.pathname })
|
||||
|
||||
@@ -43,4 +43,6 @@ export default (() => {
|
||||
</section>))}
|
||||
</div>))}
|
||||
</MainArea>)
|
||||
}) satisfies FC
|
||||
}
|
||||
|
||||
export default MorePage
|
||||
@@ -1,4 +1,8 @@
|
||||
import type { FC } from 'react'
|
||||
|
||||
import ErrorScreen from '@/components/ErrorScreen'
|
||||
|
||||
|
||||
export default () => <ErrorScreen status={404}/>
|
||||
const NotFound: FC = () => <ErrorScreen status={404}/>
|
||||
|
||||
export default NotFound
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
import type { FC } from 'react'
|
||||
|
||||
import ErrorScreen from '@/components/ErrorScreen'
|
||||
|
||||
|
||||
export default () => <ErrorScreen status={503}/>
|
||||
const ServiceUnavailable: FC = () => <ErrorScreen status={503}/>
|
||||
|
||||
export default ServiceUnavailable
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import { useParams } from 'react-router-dom'
|
||||
|
||||
import TagLink from '@/components/TagLink'
|
||||
@@ -18,7 +18,7 @@ import type { FC, FormEvent } from 'react'
|
||||
import type { Deerjikist, Platform } from '@/types'
|
||||
|
||||
|
||||
export default (() => {
|
||||
const DeerjikistDetailPage: FC = () => {
|
||||
const { id } = useParams ()
|
||||
const tagId = String (id ?? '')
|
||||
const tagKey = tagsKeys.deerjikists (tagId)
|
||||
@@ -26,7 +26,7 @@ export default (() => {
|
||||
const { data: qData, isLoading: loading } =
|
||||
useQuery ({ queryKey: tagKey, queryFn: () => fetchDeerjikistsByTag (tagId) })
|
||||
const tag = qData?.tag
|
||||
const deerjikists = qData?.deerjikists ?? []
|
||||
const deerjikists = useMemo (() => qData?.deerjikists ?? [], [qData])
|
||||
|
||||
const [data, setData] =
|
||||
useState<(Omit<Deerjikist, 'platform'> & { platform: Platform | null })[]> ([])
|
||||
@@ -152,4 +152,6 @@ export default (() => {
|
||||
</div>
|
||||
)}
|
||||
</MainArea>)
|
||||
}) satisfies FC
|
||||
}
|
||||
|
||||
export default DeerjikistDetailPage
|
||||
|
||||
@@ -5,8 +5,10 @@ import MaterialSidebar from '@/components/MaterialSidebar'
|
||||
import type { FC } from 'react'
|
||||
|
||||
|
||||
export default (() => (
|
||||
const MaterialBasePage: FC = () => (
|
||||
<div className="md:flex md:flex-1 overflow-y-auto md:overflow-y-hidden">
|
||||
<MaterialSidebar/>
|
||||
<Outlet/>
|
||||
</div>)) satisfies FC
|
||||
</div>)
|
||||
|
||||
export default MaterialBasePage
|
||||
@@ -21,7 +21,7 @@ import type { Material, Tag } from '@/types'
|
||||
type MaterialWithTag = Material & { tag: Tag }
|
||||
|
||||
|
||||
export default (() => {
|
||||
const MaterialDetailPage: FC = () => {
|
||||
const { id } = useParams ()
|
||||
|
||||
const [file, setFile] = useState<File | null> (null)
|
||||
@@ -179,4 +179,6 @@ export default (() => {
|
||||
</TabGroup>
|
||||
</>))}
|
||||
</MainArea>)
|
||||
}) satisfies FC
|
||||
}
|
||||
|
||||
export default MaterialDetailPage
|
||||
@@ -41,7 +41,7 @@ const MaterialCard = ({ tag }: { tag: TagWithMaterial }) => {
|
||||
}
|
||||
|
||||
|
||||
export default (() => {
|
||||
const MaterialListPage: FC = () => {
|
||||
const [loading, setLoading] = useState (false)
|
||||
const [tag, setTag] = useState<TagWithMaterial | null> (null)
|
||||
|
||||
@@ -69,7 +69,7 @@ export default (() => {
|
||||
setLoading (false)
|
||||
}
|
||||
}) ()
|
||||
}, [location.search])
|
||||
}, [location.search, tagQuery])
|
||||
|
||||
return (
|
||||
<MainArea>
|
||||
@@ -163,4 +163,6 @@ export default (() => {
|
||||
</ul>
|
||||
</>))}
|
||||
</MainArea>)
|
||||
}) satisfies FC
|
||||
}
|
||||
|
||||
export default MaterialListPage
|
||||
|
||||
@@ -15,7 +15,7 @@ import { apiPost } from '@/lib/api'
|
||||
import type { FC } from 'react'
|
||||
|
||||
|
||||
export default (() => {
|
||||
const MaterialNewPage: FC = () => {
|
||||
const location = useLocation ()
|
||||
const query = new URLSearchParams (location.search)
|
||||
const tagQuery = query.get ('tag') ?? ''
|
||||
@@ -121,4 +121,6 @@ export default (() => {
|
||||
</Button>
|
||||
</Form>
|
||||
</MainArea>)
|
||||
}) satisfies FC
|
||||
}
|
||||
|
||||
export default MaterialNewPage
|
||||
@@ -10,7 +10,7 @@ import { SITE_TITLE } from '@/config'
|
||||
import type { FC, FormEvent } from 'react'
|
||||
|
||||
|
||||
export default (() => {
|
||||
const MaterialSearchPage: FC = () => {
|
||||
const [tagName, setTagName] = useState ('')
|
||||
const [parentTagName, setParentTagName] = useState ('')
|
||||
|
||||
@@ -46,4 +46,6 @@ export default (() => {
|
||||
</form>
|
||||
</div>
|
||||
</MainArea>)
|
||||
}) satisfies FC
|
||||
}
|
||||
|
||||
export default MaterialSearchPage
|
||||
@@ -13,6 +13,7 @@ import MainArea from '@/components/layout/MainArea'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { toast } from '@/components/ui/use-toast'
|
||||
import { SITE_TITLE } from '@/config'
|
||||
import { isApiError } from '@/lib/api'
|
||||
import { fetchPost, toggleViewedFlg } from '@/lib/posts'
|
||||
import { postsKeys, tagsKeys } from '@/lib/queryKeys'
|
||||
import { cn } from '@/lib/utils'
|
||||
@@ -26,7 +27,7 @@ import type { NiconicoViewerHandle, Post, User } from '@/types'
|
||||
type Props = { user: User | null }
|
||||
|
||||
|
||||
export default (({ user }: Props) => {
|
||||
const PostDetailPage: FC<Props> = ({ user }) => {
|
||||
const { id } = useParams ()
|
||||
const postId = String (id ?? '')
|
||||
const postKey = postsKeys.show (postId)
|
||||
@@ -44,16 +45,16 @@ export default (({ user }: Props) => {
|
||||
|
||||
const changeViewedFlg = useMutation ({
|
||||
mutationFn: async () => {
|
||||
const cur = qc.getQueryData<any> (postKey)
|
||||
const cur = qc.getQueryData<Post> (postKey)
|
||||
const next = !(cur?.viewed)
|
||||
await toggleViewedFlg (postId, next)
|
||||
return next
|
||||
},
|
||||
onMutate: async () => {
|
||||
await qc.cancelQueries ({ queryKey: postKey })
|
||||
const prev = qc.getQueryData<any> (postKey)
|
||||
const prev = qc.getQueryData<Post> (postKey)
|
||||
qc.setQueryData (postKey,
|
||||
(cur: any) => cur ? { ...cur, viewed: !(cur.viewed) } : cur)
|
||||
(cur: Post | undefined) => cur ? { ...cur, viewed: !(cur.viewed) } : cur)
|
||||
return { prev }
|
||||
},
|
||||
onError: (...[, , ctx]) => {
|
||||
@@ -69,7 +70,7 @@ export default (({ user }: Props) => {
|
||||
if (!(errorFlg))
|
||||
return
|
||||
|
||||
const code = (error as any)?.response.status ?? (error as any)?.status
|
||||
const code = isApiError (error) ? error.response?.status : undefined
|
||||
if (code)
|
||||
setStatus (code)
|
||||
}, [errorFlg, error])
|
||||
@@ -169,9 +170,9 @@ export default (({ user }: Props) => {
|
||||
<Tab name="編輯">
|
||||
<PostEditForm
|
||||
post={post}
|
||||
onSave={newPost => {
|
||||
onSave={newPost => {
|
||||
qc.setQueryData (postsKeys.show (postId),
|
||||
(prev: any) => newPost ?? prev)
|
||||
(prev: Post | undefined) => newPost ?? prev)
|
||||
qc.invalidateQueries ({ queryKey: postsKeys.root })
|
||||
qc.invalidateQueries ({ queryKey: tagsKeys.root })
|
||||
}}/>
|
||||
@@ -185,4 +186,6 @@ export default (({ user }: Props) => {
|
||||
{post && <TagDetailSidebar post={post} sp/>}
|
||||
</div>
|
||||
</div>)
|
||||
}) satisfies FC<Props>
|
||||
}
|
||||
|
||||
export default PostDetailPage
|
||||
@@ -35,7 +35,7 @@ const renderDiff = (diff: { current: string | null; prev: string | null }) => (
|
||||
</>)
|
||||
|
||||
|
||||
export default (() => {
|
||||
const PostHistoryPage: FC = () => {
|
||||
const dialogue = useDialogue ()
|
||||
|
||||
const location = useLocation ()
|
||||
@@ -48,11 +48,11 @@ export default (() => {
|
||||
// 投稿列の結合で使用
|
||||
let rowsCnt: number
|
||||
|
||||
const { data: tag } =
|
||||
tagId
|
||||
? useQuery ({ queryKey: tagsKeys.show (tagId),
|
||||
queryFn: () => fetchTag (tagId) })
|
||||
: { data: null }
|
||||
const tagQueryId = tagId ?? ''
|
||||
const { data: tag } = useQuery ({
|
||||
enabled: Boolean (tagId),
|
||||
queryKey: tagsKeys.show (tagQueryId),
|
||||
queryFn: () => fetchTag (tagQueryId) })
|
||||
|
||||
const { data, isLoading: loading } = useQuery ({
|
||||
queryKey: postsKeys.changes ({ ...(id && { post: id }),
|
||||
@@ -290,4 +290,6 @@ export default (() => {
|
||||
<Pagination page={page} totalPages={totalPages}/>
|
||||
</>)}
|
||||
</MainArea>)
|
||||
}) satisfies FC
|
||||
}
|
||||
|
||||
export default PostHistoryPage
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { useLayoutEffect, useRef, useState } from 'react'
|
||||
import { useLayoutEffect, useMemo, useRef, useState } from 'react'
|
||||
import { Helmet } from 'react-helmet-async'
|
||||
import { useLocation } from 'react-router-dom'
|
||||
|
||||
@@ -20,7 +20,7 @@ import type { FC } from 'react'
|
||||
import type { WikiPage } from '@/types'
|
||||
|
||||
|
||||
export default (() => {
|
||||
const PostListPage: FC = () => {
|
||||
const containerRef = useRef<HTMLDivElement | null> (null)
|
||||
|
||||
const [wikiPage, setWikiPage] = useState<WikiPage | null> (null)
|
||||
@@ -30,7 +30,7 @@ export default (() => {
|
||||
const tagsQuery = query.get ('tags') ?? ''
|
||||
const anyFlg = query.get ('match') === 'any'
|
||||
const match = anyFlg ? 'any' : 'all'
|
||||
const tags = tagsQuery.split (' ').filter (e => e !== '')
|
||||
const tags = useMemo (() => tagsQuery.split (' ').filter (e => e !== ''), [tagsQuery])
|
||||
const tagsKey = tags.join (' ')
|
||||
const page = Number (query.get ('page') ?? 1)
|
||||
const limit = Number (query.get ('limit') ?? 20)
|
||||
@@ -66,7 +66,7 @@ export default (() => {
|
||||
;
|
||||
}
|
||||
}) ()
|
||||
}, [location.search])
|
||||
}, [location.search, tags])
|
||||
|
||||
return (
|
||||
<div
|
||||
@@ -76,7 +76,7 @@ export default (() => {
|
||||
<title>
|
||||
{tags.length
|
||||
? `${ tags.join (anyFlg ? ' or ' : ' and ') } | ${ SITE_TITLE }`
|
||||
: `${ SITE_TITLE } 〜 ぼざろクリーチャーシリーズ綜合リンク集サイト`}
|
||||
: `${ SITE_TITLE }\u3000〜 ぼざろクリーチャーシリーズ綜合リンク集サイト`}
|
||||
</title>
|
||||
</Helmet>
|
||||
|
||||
@@ -112,4 +112,6 @@ export default (() => {
|
||||
</TabGroup>
|
||||
</MainArea>
|
||||
</div>)
|
||||
}) satisfies FC
|
||||
}
|
||||
|
||||
export default PostListPage
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useEffect, useState, useRef } from 'react'
|
||||
import { useCallback, useEffect, useState, useRef } from 'react'
|
||||
import { Helmet } from 'react-helmet-async'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
|
||||
@@ -21,9 +21,8 @@ import type { User } from '@/types'
|
||||
type Props = { user: User | null }
|
||||
|
||||
|
||||
export default (({ user }: Props) => {
|
||||
if (!(['admin', 'member'].some (r => user?.role === r)))
|
||||
return <Forbidden/>
|
||||
const PostNewPage: FC<Props> = ({ user }) => {
|
||||
const editable = ['admin', 'member'].some (r => user?.role === r)
|
||||
|
||||
const navigate = useNavigate ()
|
||||
|
||||
@@ -41,6 +40,7 @@ export default (({ user }: Props) => {
|
||||
const [url, setURL] = useState ('')
|
||||
|
||||
const previousURLRef = useRef ('')
|
||||
const thumbnailPreviewRef = useRef ('')
|
||||
|
||||
const handleSubmit = async () => {
|
||||
const formData = new FormData
|
||||
@@ -67,16 +67,6 @@ export default (({ user }: Props) => {
|
||||
}
|
||||
}
|
||||
|
||||
useEffect (() => {
|
||||
if (titleAutoFlg && url)
|
||||
fetchTitle ()
|
||||
}, [titleAutoFlg])
|
||||
|
||||
useEffect (() => {
|
||||
if (thumbnailAutoFlg && url)
|
||||
fetchThumbnail ()
|
||||
}, [thumbnailAutoFlg])
|
||||
|
||||
const handleURLBlur = () => {
|
||||
if (!(url) || url === previousURLRef.current)
|
||||
return
|
||||
@@ -88,20 +78,20 @@ export default (({ user }: Props) => {
|
||||
previousURLRef.current = url
|
||||
}
|
||||
|
||||
const fetchTitle = async () => {
|
||||
const fetchTitle = useCallback (async () => {
|
||||
setTitle ('')
|
||||
setTitleLoading (true)
|
||||
const data = await apiGet<{ title: string }> ('/preview/title', { params: { url } })
|
||||
setTitle (data.title || '')
|
||||
setTitleLoading (false)
|
||||
}
|
||||
}, [url])
|
||||
|
||||
const fetchThumbnail = async () => {
|
||||
const fetchThumbnail = useCallback (async () => {
|
||||
setThumbnailPreview ('')
|
||||
setThumbnailFile (null)
|
||||
setThumbnailLoading (true)
|
||||
if (thumbnailPreview)
|
||||
URL.revokeObjectURL (thumbnailPreview)
|
||||
if (thumbnailPreviewRef.current)
|
||||
URL.revokeObjectURL (thumbnailPreviewRef.current)
|
||||
const data = await apiGet<Blob> ('/preview/thumbnail',
|
||||
{ params: { url }, responseType: 'blob' })
|
||||
const imageURL = URL.createObjectURL (data)
|
||||
@@ -110,7 +100,24 @@ export default (({ user }: Props) => {
|
||||
'thumbnail.png',
|
||||
{ type: data.type || 'image/png' }))
|
||||
setThumbnailLoading (false)
|
||||
}
|
||||
}, [url])
|
||||
|
||||
useEffect (() => {
|
||||
thumbnailPreviewRef.current = thumbnailPreview
|
||||
}, [thumbnailPreview])
|
||||
|
||||
useEffect (() => {
|
||||
if (titleAutoFlg && url)
|
||||
fetchTitle ()
|
||||
}, [fetchTitle, titleAutoFlg, url])
|
||||
|
||||
useEffect (() => {
|
||||
if (thumbnailAutoFlg && url)
|
||||
fetchThumbnail ()
|
||||
}, [fetchThumbnail, thumbnailAutoFlg, url])
|
||||
|
||||
if (!(editable))
|
||||
return <Forbidden/>
|
||||
|
||||
return (
|
||||
<MainArea>
|
||||
@@ -207,4 +214,6 @@ export default (({ user }: Props) => {
|
||||
</Button>
|
||||
</Form>
|
||||
</MainArea>)
|
||||
}) satisfies FC<Props>
|
||||
}
|
||||
|
||||
export default PostNewPage
|
||||
|
||||
@@ -32,7 +32,7 @@ const setIf = (qs: URLSearchParams, k: string, v: string | null) => {
|
||||
}
|
||||
|
||||
|
||||
export default (() => {
|
||||
const PostSearchPage: FC = () => {
|
||||
const location = useLocation ()
|
||||
|
||||
const navigate = useNavigate ()
|
||||
@@ -96,7 +96,8 @@ export default (() => {
|
||||
setUpdatedTo (qUpdatedTo)
|
||||
|
||||
document.querySelector ('table')?.scrollIntoView ({ behavior: 'smooth' })
|
||||
}, [location.search])
|
||||
}, [location.search, qCreatedFrom, qCreatedTo, qMatch, qOriginalCreatedFrom,
|
||||
qOriginalCreatedTo, qTags, qTitle, qUpdatedFrom, qUpdatedTo, qURL])
|
||||
|
||||
const search = async () => {
|
||||
const qs = new URLSearchParams ()
|
||||
@@ -336,4 +337,6 @@ export default (() => {
|
||||
<Pagination page={page} totalPages={totalPages}/>
|
||||
</div>) : '結果ないよ(笑)')}
|
||||
</MainArea>)
|
||||
}) satisfies FC
|
||||
}
|
||||
|
||||
export default PostSearchPage
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import type { FC } from 'react'
|
||||
|
||||
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import { Helmet } from 'react-helmet-async'
|
||||
|
||||
import TagLink from '@/components/TagLink'
|
||||
@@ -14,7 +16,7 @@ import type { NicoTag, Tag, User } from '@/types'
|
||||
type Props = { user: User | null }
|
||||
|
||||
|
||||
export default ({ user }: Props) => {
|
||||
const NicoTagListPage: FC<Props> = ({ user }) => {
|
||||
const [cursor, setCursor] = useState ('')
|
||||
const [editing, setEditing] = useState<{ [key: number]: boolean }> ({ })
|
||||
const [loading, setLoading] = useState (false)
|
||||
@@ -25,12 +27,8 @@ export default ({ user }: Props) => {
|
||||
|
||||
const memberFlg = ['admin', 'member'].some (r => user?.role === r)
|
||||
|
||||
const loadMore = async (withCursor: boolean) => {
|
||||
setLoading (true)
|
||||
|
||||
const data = await apiGet<{ tags: NicoTag[]; nextCursor: string }> (
|
||||
'/tags/nico', { params: withCursor ? { cursor } : { } })
|
||||
|
||||
const applyLoadedTags = useCallback ((data: { tags: NicoTag[]; nextCursor: string },
|
||||
withCursor: boolean) => {
|
||||
setNicoTags (tags => [...(withCursor ? tags : []), ...data.tags])
|
||||
setCursor (data.nextCursor)
|
||||
|
||||
@@ -40,9 +38,26 @@ export default ({ user }: Props) => {
|
||||
const newRawTags = Object.fromEntries (
|
||||
data.tags.map (t => [t.id, t.linkedTags.map (lt => lt.name).join (' ')]))
|
||||
setRawTags (rawTags => ({ ...rawTags, ...newRawTags }))
|
||||
}, [])
|
||||
|
||||
const loadInitial = useCallback (async () => {
|
||||
setLoading (true)
|
||||
|
||||
const data = await apiGet<{ tags: NicoTag[]; nextCursor: string }> ('/tags/nico')
|
||||
applyLoadedTags (data, false)
|
||||
|
||||
setLoading (false)
|
||||
}
|
||||
}, [applyLoadedTags])
|
||||
|
||||
const loadMore = useCallback (async () => {
|
||||
setLoading (true)
|
||||
|
||||
const data = await apiGet<{ tags: NicoTag[]; nextCursor: string }> (
|
||||
'/tags/nico', { params: { cursor } })
|
||||
applyLoadedTags (data, true)
|
||||
|
||||
setLoading (false)
|
||||
}, [applyLoadedTags, cursor])
|
||||
|
||||
const handleEdit = async (id: number) => {
|
||||
if (editing[id])
|
||||
@@ -67,7 +82,7 @@ export default ({ user }: Props) => {
|
||||
useEffect(() => {
|
||||
const observer = new IntersectionObserver (entries => {
|
||||
if (entries[0].isIntersecting && !(loading) && cursor)
|
||||
loadMore (true)
|
||||
loadMore ()
|
||||
}, { threshold: 1 })
|
||||
|
||||
const target = loaderRef.current
|
||||
@@ -78,12 +93,12 @@ export default ({ user }: Props) => {
|
||||
if (target)
|
||||
observer.unobserve (target)
|
||||
}
|
||||
}, [loaderRef, loading])
|
||||
}, [cursor, loadMore, loading])
|
||||
|
||||
useEffect (() => {
|
||||
setNicoTags ([])
|
||||
loadMore (false)
|
||||
}, [])
|
||||
loadInitial ()
|
||||
}, [loadInitial])
|
||||
|
||||
return (
|
||||
<MainArea>
|
||||
@@ -147,3 +162,5 @@ export default ({ user }: Props) => {
|
||||
</div>
|
||||
</MainArea>)
|
||||
}
|
||||
|
||||
export default NicoTagListPage
|
||||
|
||||
@@ -18,7 +18,7 @@ import type { FC, FormEvent } from 'react'
|
||||
import type { Category, Tag } from '@/types'
|
||||
|
||||
|
||||
export default (() => {
|
||||
const TagDetailPage: FC = () => {
|
||||
const { id } = useParams ()
|
||||
const tagId = String (id ?? '')
|
||||
const tagKey = tagsKeys.show (tagId)
|
||||
@@ -155,4 +155,6 @@ export default (() => {
|
||||
</form>
|
||||
</div>)}
|
||||
</MainArea>)
|
||||
}) satisfies FC
|
||||
}
|
||||
|
||||
export default TagDetailPage
|
||||
@@ -31,7 +31,7 @@ const renderDiff = (diff: { current: string | null; prev: string | null }) => (
|
||||
</>)
|
||||
|
||||
|
||||
export default (() => {
|
||||
const TagHistoryPage: FC = () => {
|
||||
const location = useLocation ()
|
||||
const query = new URLSearchParams (location.search)
|
||||
const id = query.get ('id')
|
||||
@@ -209,4 +209,6 @@ export default (() => {
|
||||
<Pagination page={page} totalPages={totalPages}/>
|
||||
</>)}
|
||||
</MainArea>)
|
||||
}) satisfies FC
|
||||
}
|
||||
|
||||
export default TagHistoryPage
|
||||
@@ -29,7 +29,7 @@ const setIf = (qs: URLSearchParams, k: string, v: string | null) => {
|
||||
}
|
||||
|
||||
|
||||
export default (() => {
|
||||
const TagListPage: FC = () => {
|
||||
const location = useLocation ()
|
||||
|
||||
const navigate = useNavigate ()
|
||||
@@ -87,7 +87,8 @@ export default (() => {
|
||||
setUpdatedTo (qUpdatedTo)
|
||||
|
||||
document.querySelector ('table')?.scrollIntoView ({ behavior: 'smooth' })
|
||||
}, [location.search])
|
||||
}, [location.search, qCategory, qCreatedFrom, qCreatedTo, qName, qPostCountGTE,
|
||||
qPostCountLTE, qUpdatedFrom, qUpdatedTo])
|
||||
|
||||
const handleSearch = (e: FormEvent) => {
|
||||
e.preventDefault ()
|
||||
@@ -296,4 +297,6 @@ export default (() => {
|
||||
<Pagination page={page} totalPages={totalPages}/>
|
||||
</div>) : '結果ないよ(笑)')}
|
||||
</MainArea>)
|
||||
}) satisfies FC
|
||||
}
|
||||
|
||||
export default TagListPage
|
||||
|
||||
@@ -9,7 +9,7 @@ import TagDetailSidebar from '@/components/TagDetailSidebar'
|
||||
import MainArea from '@/components/layout/MainArea'
|
||||
import SidebarComponent from '@/components/layout/SidebarComponent'
|
||||
import { SITE_TITLE } from '@/config'
|
||||
import { apiGet, apiPatch, apiPost, apiPut } from '@/lib/api'
|
||||
import { apiGet, apiPatch, apiPost, apiPut, isApiError } from '@/lib/api'
|
||||
import { fetchPost } from '@/lib/posts'
|
||||
import { dateString } from '@/lib/utils'
|
||||
|
||||
@@ -34,11 +34,12 @@ const INITIAL_THEATRE_INFO =
|
||||
watchingUsers: [] as { id: number; name: string }[] } as const
|
||||
|
||||
|
||||
export default (() => {
|
||||
const TheatreDetailPage: FC = () => {
|
||||
const { id } = useParams ()
|
||||
|
||||
const commentsRef = useRef<HTMLDivElement> (null)
|
||||
const embedRef = useRef<NiconicoViewerHandle> (null)
|
||||
const loadingRef = useRef (false)
|
||||
const theatreInfoRef = useRef<TheatreInfo> (INITIAL_THEATRE_INFO)
|
||||
const videoLengthRef = useRef (0)
|
||||
const lastCommentNoRef = useRef (0)
|
||||
@@ -53,6 +54,10 @@ export default (() => {
|
||||
const [post, setPost] = useState<Post | null> (null)
|
||||
const [videoLength, setVideoLength] = useState (0)
|
||||
|
||||
useEffect (() => {
|
||||
loadingRef.current = loading
|
||||
}, [loading])
|
||||
|
||||
useEffect (() => {
|
||||
theatreInfoRef.current = theatreInfo
|
||||
}, [theatreInfo])
|
||||
@@ -87,7 +92,7 @@ export default (() => {
|
||||
}
|
||||
catch (error)
|
||||
{
|
||||
setStatus ((error as any)?.response.status ?? 200)
|
||||
setStatus (isApiError (error) ? error.response?.status ?? 200 : 200)
|
||||
}
|
||||
}) ()
|
||||
|
||||
@@ -160,7 +165,7 @@ export default (() => {
|
||||
}, [id])
|
||||
|
||||
useEffect (() => {
|
||||
if (!(id) || !(theatreInfo.hostFlg) || loading || theatreInfo.postId != null)
|
||||
if (!(id) || !(theatreInfo.hostFlg) || loadingRef.current || theatreInfo.postId != null)
|
||||
return
|
||||
|
||||
let cancelled = false
|
||||
@@ -338,4 +343,6 @@ export default (() => {
|
||||
{post && <TagDetailSidebar post={post} sp/>}
|
||||
</div>
|
||||
</div>)
|
||||
}) satisfies FC
|
||||
}
|
||||
|
||||
export default TheatreDetailPage
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import type { FC } from 'react'
|
||||
|
||||
import { useEffect, useState } from 'react'
|
||||
import { Helmet } from 'react-helmet-async'
|
||||
|
||||
@@ -18,7 +20,7 @@ type Props = { user: User | null
|
||||
setUser: React.Dispatch<React.SetStateAction<User | null>> }
|
||||
|
||||
|
||||
export default ({ user, setUser }: Props) => {
|
||||
const SettingPage: FC<Props> = ({ user, setUser }) => {
|
||||
const [name, setName] = useState ('')
|
||||
const [userCodeVsbl, setUserCodeVsbl] = useState (false)
|
||||
const [inheritVsbl, setInheritVsbl] = useState (false)
|
||||
@@ -110,3 +112,5 @@ export default ({ user, setUser }: Props) => {
|
||||
setUser={setUser}/>
|
||||
</MainArea>)
|
||||
}
|
||||
|
||||
export default SettingPage
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import type { FC } from 'react'
|
||||
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { useEffect, useMemo } from 'react'
|
||||
import { Helmet } from 'react-helmet-async'
|
||||
@@ -19,7 +21,7 @@ import { fetchWikiPage, fetchWikiPageByTitle } from '@/lib/wiki'
|
||||
import type { Tag } from '@/types'
|
||||
|
||||
|
||||
export default () => {
|
||||
const WikiDetailPage: FC = () => {
|
||||
const params = useParams ()
|
||||
const title = params.title ?? ''
|
||||
|
||||
@@ -126,3 +128,5 @@ export default () => {
|
||||
</article>
|
||||
</MainArea>)
|
||||
}
|
||||
|
||||
export default WikiDetailPage
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import type { FC } from 'react'
|
||||
|
||||
import { useEffect, useState } from 'react'
|
||||
import { Helmet } from 'react-helmet-async'
|
||||
import { useLocation, useParams } from 'react-router-dom'
|
||||
@@ -11,7 +13,7 @@ import { cn } from '@/lib/utils'
|
||||
import type { WikiPageDiff } from '@/types'
|
||||
|
||||
|
||||
export default () => {
|
||||
const WikiDiffPage: FC = () => {
|
||||
const { id } = useParams ()
|
||||
|
||||
const location = useLocation ()
|
||||
@@ -26,7 +28,7 @@ export default () => {
|
||||
void (async () => {
|
||||
setDiff (await apiGet<WikiPageDiff> (`/wiki/${ id }/diff`, { params: { from, to } }))
|
||||
}) ()
|
||||
}, [])
|
||||
}, [from, id, to])
|
||||
|
||||
return (
|
||||
<MainArea>
|
||||
@@ -46,3 +48,5 @@ export default () => {
|
||||
</div>
|
||||
</MainArea>)
|
||||
}
|
||||
|
||||
export default WikiDiffPage
|
||||
|
||||
@@ -23,9 +23,8 @@ const mdParser = new MarkdownIt
|
||||
type Props = { user: User | null }
|
||||
|
||||
|
||||
export default (({ user }: Props) => {
|
||||
if (!(['admin', 'member'].some (r => user?.role === r)))
|
||||
return <Forbidden/>
|
||||
const WikiEditPage: FC<Props> = ({ user }) => {
|
||||
const editable = ['admin', 'member'].some (r => user?.role === r)
|
||||
|
||||
const { id } = useParams ()
|
||||
|
||||
@@ -59,6 +58,9 @@ export default (({ user }: Props) => {
|
||||
}
|
||||
|
||||
useEffect (() => {
|
||||
if (!(editable))
|
||||
return
|
||||
|
||||
void (async () => {
|
||||
setLoading (true)
|
||||
const data = await apiGet<WikiPage> (`/wiki/${ id }`)
|
||||
@@ -66,7 +68,10 @@ export default (({ user }: Props) => {
|
||||
setBody (data.body)
|
||||
setLoading (false)
|
||||
}) ()
|
||||
}, [id])
|
||||
}, [editable, id])
|
||||
|
||||
if (!(editable))
|
||||
return <Forbidden/>
|
||||
|
||||
return (
|
||||
<MainArea>
|
||||
@@ -105,4 +110,6 @@ export default (({ user }: Props) => {
|
||||
</>)}
|
||||
</div>
|
||||
</MainArea>)
|
||||
}) satisfies FC<Props>
|
||||
}
|
||||
|
||||
export default WikiEditPage
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import type { FC } from 'react'
|
||||
|
||||
import { useEffect, useState } from 'react'
|
||||
import { Helmet } from 'react-helmet-async'
|
||||
import { useLocation } from 'react-router-dom'
|
||||
@@ -12,7 +14,7 @@ import { dateString } from '@/lib/utils'
|
||||
import type { WikiPageChange } from '@/types'
|
||||
|
||||
|
||||
export default () => {
|
||||
const WikiHistoryPage: FC = () => {
|
||||
const [changes, setChanges] = useState<WikiPageChange[]> ([])
|
||||
|
||||
const location = useLocation ()
|
||||
@@ -23,7 +25,7 @@ export default () => {
|
||||
void (async () => {
|
||||
setChanges (await apiGet<WikiPageChange[]> ('/wiki/changes', { params: id ? { id } : { } }))
|
||||
}) ()
|
||||
}, [location.search])
|
||||
}, [id, location.search])
|
||||
|
||||
return (
|
||||
<MainArea>
|
||||
@@ -73,3 +75,5 @@ export default () => {
|
||||
</table>
|
||||
</MainArea>)
|
||||
}
|
||||
|
||||
export default WikiHistoryPage
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import type { FC } from 'react'
|
||||
|
||||
import MarkdownIt from 'markdown-it'
|
||||
import { useState } from 'react'
|
||||
import { Helmet } from 'react-helmet-async'
|
||||
@@ -19,9 +21,8 @@ const mdParser = new MarkdownIt
|
||||
type Props = { user: User | null }
|
||||
|
||||
|
||||
export default ({ user }: Props) => {
|
||||
if (!(['admin', 'member'].some (r => user?.role === r)))
|
||||
return <Forbidden/>
|
||||
const WikiNewPage: FC<Props> = ({ user }) => {
|
||||
const editable = ['admin', 'member'].some (r => user?.role === r)
|
||||
|
||||
const location = useLocation ()
|
||||
const navigate = useNavigate ()
|
||||
@@ -50,6 +51,9 @@ export default ({ user }: Props) => {
|
||||
}
|
||||
}
|
||||
|
||||
if (!(editable))
|
||||
return <Forbidden/>
|
||||
|
||||
return (
|
||||
<MainArea>
|
||||
<Helmet>
|
||||
@@ -85,3 +89,5 @@ export default ({ user }: Props) => {
|
||||
</div>
|
||||
</MainArea>)
|
||||
}
|
||||
|
||||
export default WikiNewPage
|
||||
|
||||
@@ -8,12 +8,12 @@ import { SITE_TITLE } from '@/config'
|
||||
import { apiGet } from '@/lib/api'
|
||||
import { dateString } from '@/lib/utils'
|
||||
|
||||
import type { FormEvent } from 'react'
|
||||
import type { FormEvent , FC } from 'react'
|
||||
|
||||
import type { WikiPage } from '@/types'
|
||||
|
||||
|
||||
export default () => {
|
||||
const WikiSearchPage: FC = () => {
|
||||
const [title, setTitle] = useState ('')
|
||||
const [text, setText] = useState ('')
|
||||
const [results, setResults] = useState<WikiPage[]> ([])
|
||||
@@ -28,7 +28,9 @@ export default () => {
|
||||
}
|
||||
|
||||
useEffect (() => {
|
||||
search ()
|
||||
void (async () => {
|
||||
setResults (await apiGet ('/wiki', { params: { title: '' } }))
|
||||
}) ()
|
||||
}, [])
|
||||
|
||||
return (
|
||||
@@ -93,3 +95,5 @@ export default () => {
|
||||
</div>
|
||||
</MainArea>)
|
||||
}
|
||||
|
||||
export default WikiSearchPage
|
||||
|
||||
新しい課題から参照
ユーザをブロックする