diff --git a/packages/app/src/pages/studio/tv/components/ProfileCreator/index.jsx b/packages/app/src/pages/studio/tv/components/ProfileCreator/index.jsx index 91f0f256..5d4c0c90 100644 --- a/packages/app/src/pages/studio/tv/components/ProfileCreator/index.jsx +++ b/packages/app/src/pages/studio/tv/components/ProfileCreator/index.jsx @@ -6,69 +6,65 @@ import Streaming from "@models/spectrum" import "./index.less" const ProfileCreator = (props) => { - const [loading, setLoading] = React.useState(false) - const [name, setName] = React.useState(props.editValue ?? null) + const [loading, setLoading] = React.useState(false) + const [name, setName] = React.useState(props.editValue ?? null) - function handleChange(e) { - setName(e.target.value.trim()) - } + function handleChange(e) { + setName(e.target.value.trim()) + } - async function handleSubmit() { - setLoading(true) + async function handleSubmit() { + setLoading(true) - if (props.editValue) { - if (typeof props.onEdit === "function") { - await props.onEdit(name) - } - } else { - const result = await Streaming.createOrUpdateStream({ profile_name: name }).catch((error) => { - console.error(error) - app.message.error("Failed to create") - return null - }) + if (props.editValue) { + if (typeof props.onEdit === "function") { + await props.onEdit(name) + } + } else { + const result = await Streaming.createOrUpdateProfile({ + profile_name: name, + }).catch((error) => { + console.error(error) + app.message.error("Failed to create") + return null + }) - if (result) { - app.message.success("Created") - app.eventBus.emit("app:new_profile", result) - props.onCreate(result._id, result) - } - } + if (result) { + app.message.success("Created") + app.eventBus.emit("app:new_profile", result) + props.onCreate(result._id, result) + } + } - props.close() + props.close() - setLoading(false) - } + setLoading(false) + } - return