このコミットが含まれているのは:
2026-07-12 12:23:53 +09:00
コミット 7bcb76516c
12個のファイルの変更1267行の追加479行の削除
ファイル差分が大きすぎるため省略します 差分を読込み
+24 -11
ファイルの表示
@@ -25,7 +25,13 @@ import type { User } from '@/types'
type Props = { user: User | null }
type PostFormField =
'url' | 'title' | 'tags' | 'parentPostIds' | 'videoMs' | 'originalCreatedAt' | 'thumbnail'
'url'
| 'title'
| 'tags'
| 'parentPostIds'
| 'videoMs'
| 'originalCreatedAt'
| 'thumbnail'
const PostNewPage: FC<Props> = ({ user }) => {
@@ -36,8 +42,10 @@ const PostNewPage: FC<Props> = ({ user }) => {
const { baseErrors, fieldErrors, clearValidationErrors, applyValidationError } =
useValidationErrors<PostFormField> ()
const [originalCreatedBefore, setOriginalCreatedBefore] = useState<string | null> (null)
const [originalCreatedFrom, setOriginalCreatedFrom] = useState<string | null> (null)
const [originalCreatedBefore, setOriginalCreatedBefore] =
useState<string | null> (null)
const [originalCreatedFrom, setOriginalCreatedFrom] =
useState<string | null> (null)
const [parentPostIds, setParentPostIds] = useState ('')
const [tags, setTags] = useState ('')
const [duration, setDuration] = useState ('')
@@ -50,8 +58,10 @@ const PostNewPage: FC<Props> = ({ user }) => {
const thumbnailPreviewRef = useRef ('')
const videoFlg =
useMemo (() => tags.split (/\s+/).some (tag => tag.replace (/\[.*\]$/, '') === '動画'),
[tags])
useMemo (() =>
tags.split (/\s+/).some (
tag => tag.replace (/\[.*\]$/, '') === '動画'),
[tags])
const handleSubmit = async () => {
clearValidationErrors ()
@@ -72,14 +82,15 @@ const PostNewPage: FC<Props> = ({ user }) => {
try
{
await apiPost ('/posts', formData, { headers: { 'Content-Type': 'multipart/form-data' } })
await apiPost ('/posts', formData,
{ headers: { 'Content-Type': 'multipart/form-data' } })
toast ({ title: '投稿成功!' })
navigate ('/posts')
}
catch (e)
{
applyValidationError (e)
toast ({ title: '投稿失敗', description: '入力を確認してください' })
toast ({ title: '投稿失敗', description: '入力を確認してください' })
}
}
@@ -87,7 +98,8 @@ const PostNewPage: FC<Props> = ({ user }) => {
setTitleLoading (true)
try
{
const data = await apiGet<{ title: string }> ('/preview/title', { params: { url } })
const data = await apiGet<{ title: string }> ('/preview/title',
{ params: { url } })
setTitle (data.title || '')
}
finally
@@ -105,7 +117,8 @@ const PostNewPage: FC<Props> = ({ user }) => {
try
{
const data = await apiGet<Blob> ('/preview/thumbnail',
{ params: { url }, responseType: 'blob' })
{ params: { url },
responseType: 'blob' })
const imageURL = URL.createObjectURL (data)
setThumbnailPreview (imageURL)
setThumbnailFile (new File ([data],
@@ -163,7 +176,7 @@ const PostNewPage: FC<Props> = ({ user }) => {
<Button
type="button"
variant="outline"
onClick={() => void fetchTitle ()}
onClick={fetchTitle}
disabled={!(url) || titleLoading}>
</Button>
@@ -180,7 +193,7 @@ const PostNewPage: FC<Props> = ({ user }) => {
<Button
type="button"
variant="outline"
onClick={() => void fetchThumbnail ()}
onClick={fetchThumbnail}
disabled={!(url) || thumbnailLoading}>
</Button>