import React from "react" import * as antd from "antd" import CoverEditor from "@components/CoverEditor" import { Icons } from "@components/Icons" import EnhancedLyricsEditor from "@components/MusicStudio/EnhancedLyricsEditor" import { ReleaseEditorStateContext } from "@contexts/MusicReleaseEditor" import "./index.less" const TrackEditor = (props) => { const context = React.useContext(ReleaseEditorStateContext) const [track, setTrack] = React.useState(props.track ?? {}) async function handleChange(key, value) { setTrack((prev) => { return { ...prev, [key]: value, } }) } async function openEnhancedLyricsEditor() { context.renderCustomPage({ header: "Enhanced Lyrics", content: EnhancedLyricsEditor, props: { track: track, }, }) } async function handleOnSave() { setTrack((prev) => { const listData = [...context.items] const trackIndex = listData.findIndex( (item) => item.uid === prev.uid, ) if (trackIndex === -1) { return prev } listData[trackIndex] = prev context.setGlobalState({ ...context, items: listData, }) props.close() return prev }) } function setParentCover() { handleChange("cover", context.cover) } React.useEffect(() => { context.setCustomPageActions([ { label: "Save", icon: "FiSave", type: "primary", onClick: handleOnSave, disabled: props.track === track, }, ]) }, [track]) return (
Cover
handleChange("cover", url)} extraActions={[ Use Parent , ]} />
Title
handleChange("title", e.target.value)} />
Artist
handleChange("artist", e.target.value)} />
Album
handleChange("album", e.target.value)} />
Explicit
handleChange("explicit", value)} />
Public
handleChange("public", value)} />
Enhanced Lyrics
Edit {!track.params._id && ( You cannot edit Video and Lyrics without release first )}
) } export default TrackEditor