= ({
+ 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() {