diff --git a/packages/react/src/components/about/request/ChannelPicker.tsx b/packages/react/src/components/about/request/ChannelPicker.tsx index 065046a99..7642abc44 100644 --- a/packages/react/src/components/about/request/ChannelPicker.tsx +++ b/packages/react/src/components/about/request/ChannelPicker.tsx @@ -43,7 +43,7 @@ export function ChannelPicker< const { t } = useTranslation(); const currentValue = useAtomValue(currentValueAtom); const [debouncedValue, setDebouncedValue] = useAtom(debouncedValueAtom); - const { data, mutate, isLoading } = useSearchAutoCompleteMutation(); + const { data, mutate, isPending } = useSearchAutoCompleteMutation(); useEffect(() => { if (debouncedValue) mutate({ q: debouncedValue, n: 10, t: "vtuber" }); @@ -86,7 +86,7 @@ export function ChannelPicker< {channel.name} ))} - {isLoading && ( + {isPending && (
diff --git a/packages/react/src/routes/about/placeholder.tsx b/packages/react/src/routes/about/placeholder.tsx index 6f6bdd9e4..c2a1d78c9 100644 --- a/packages/react/src/routes/about/placeholder.tsx +++ b/packages/react/src/routes/about/placeholder.tsx @@ -81,20 +81,34 @@ export default function AboutPlaceholder() { const { mutate } = usePlaceholderMutation(); - const onSubmit: SubmitHandler = (body) => { - mutate(body, { - onSuccess: () => { - toast({ - title: t("component.addPlaceholder.success"), - }); - }, - onError: (error) => { - console.error(error); - toast({ - title: t("component.addPlaceholder.error"), - description: error.message, - }); + const onSubmit: SubmitHandler = ({ + duration, + ...body + }) => { + mutate( + { duration: duration * 60, ...body }, + { + onSuccess: () => { + toast({ + title: t("component.addPlaceholder.success"), + }); + }, + onError: (error) => { + console.error(error); + toast({ + title: t("component.addPlaceholder.error"), + description: error.message, + variant: "error", + }); + }, }, + ); + }; + + const onInvalid = () => { + toast({ + title: t("component.addPlaceholder.error"), + variant: "error", }); }; @@ -107,19 +121,19 @@ export default function AboutPlaceholder() { ); useEffect(() => { - if (type === 'existing' && id && data) { - form.setValue("channel_id", data.channel_id); + if (type === "existing" && id && data) { + form.setValue("channel_id", data.channel.id ?? ""); form.setValue("liveTime", data.start_scheduled ?? ""); - form.setValue("duration", data.duration); - form.setValue("title.link", data.link); - form.setValue("title.name", data.name); - form.setValue("title.jp_name", data.jp_name); - form.setValue("title.thumbnail", data.thumbnail); - form.setValue("title.placeholderType", data.placeholderType); - form.setValue("title.certainty", data.certainty); + form.setValue("duration", data.duration / 60 ?? 60); + form.setValue("title.link", data.link ?? ""); + form.setValue("title.name", data.title ?? ""); + form.setValue("title.jp_name", data.jp_name ?? ""); + form.setValue("title.thumbnail", data.thumbnail ?? ""); + form.setValue("title.placeholderType", data.placeholderType ?? ""); + form.setValue("title.certainty", data.certainty ?? ""); } - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [data]); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [data]); return (
@@ -142,7 +156,7 @@ export default function AboutPlaceholder() {
setId(e.target.value) + onChange: (e) => setId(e.target.value), })} /> @@ -319,20 +333,21 @@ export default function AboutPlaceholder() { control={form.control} name="title.placeholderType" render={({ field }) => ( - + {t("component.addPlaceholder.eventType.label")} ( - + {t("component.addPlaceholder.certainty.label")} {t("component.addPlaceholder.dateLabel")} - + - + ( videoId: string, - config?: UseQueryOptions, + config?: Omit, "queryKey" | "queryFn">, ) { const client = useClient();