{
>
- setAiUserId(value)
- }
+ {...aiUserHelperFields}
+ error={dropdownHasError}
+ helperText={dropdownHasError && aiUserHelperFields.error}
+ value={aiUserNumIdField.value}
+ onSelect={(value: SingleTrackEditValues[typeof AI_USER_ID]) => {
+ setAiUserId(value ? encodeHashId(value) : null)
+ setAiUserNumId(value ?? null)
+ }}
/>
@@ -245,18 +301,22 @@ const AttributionModalFields = () => {
{`${messages.isrc.header} / ${messages.iswc.header}`}
-
-
+
+
+
+
+
+
/**
* This is a subform that expects to exist within a parent TrackEdit form.
@@ -90,7 +100,7 @@ export const RemixModalForm = () => {
const remixLink = initialRemixedTrack?.permalink
? fullTrackPage(initialRemixedTrack?.permalink)
- : null
+ : ''
const initialValues = useMemo(() => {
const initialValues = {}
@@ -101,6 +111,7 @@ export const RemixModalForm = () => {
!!remixOfValue?.tracks.some((track) => !!track)
)
set(initialValues, REMIX_LINK, remixLink)
+ set(initialValues, IS_VALID_REMIX_LINK, false)
return initialValues as RemixFormValues
}, [showRemixesValue, remixOfValue?.tracks, remixLink])
@@ -114,20 +125,22 @@ export const RemixModalForm = () => {
const onSubmit = useCallback(
(values: RemixFormValues) => {
- setShowRemixesValue(get(values, SHOW_REMIXES))
+ setShowRemixesValue(get(values, SHOW_REMIXES) ?? showRemixesValue)
if (get(values, IS_REMIX) && get(values, REMIX_LINK)) {
// TODO: handle undefined linkedTrack with form validation
setRemixOfValue({
tracks: [
{
// @ts-ignore only the track_id is required for the form
- parent_track_id: linkedTrack?.track_id
+ parent_track_id: linkedTrack
+ ? encodeHashId(linkedTrack?.track_id)
+ : undefined
}
]
})
}
},
- [setShowRemixesValue, setRemixOfValue, linkedTrack?.track_id]
+ [setShowRemixesValue, showRemixesValue, setRemixOfValue, linkedTrack]
)
const preview = (
@@ -145,15 +158,20 @@ export const RemixModalForm = () => {
initialValues={initialValues}
onSubmit={onSubmit}
+ validationSchema={toFormikValidationSchema(RemixFormSchema)}
enableReinitialize
>
- }
- preview={preview}
- >
-
-
+ {() => {
+ return (
+ }
+ preview={preview}
+ >
+
+
+ )
+ }}
)
}
@@ -165,6 +183,7 @@ type RemixModalFieldsProps = {
const RemixModalFields = (props: RemixModalFieldsProps) => {
const { setUrl } = props
const [{ onChange: onLinkFieldChange, ...linkField }] = useField(REMIX_LINK)
+ const [, , { setValue: setIsValidRemixLink }] = useField(IS_VALID_REMIX_LINK)
const permalink = getPathFromTrackUrl(linkField.value)
const currentUserId = useSelector(getUserId)
const { data: track } = useGetTrackByPermalink(
@@ -175,6 +194,10 @@ const RemixModalFields = (props: RemixModalFieldsProps) => {
{ disabled: !permalink }
)
+ useEffect(() => {
+ setIsValidRemixLink(!!track)
+ }, [setIsValidRemixLink, track])
+
return (
{
header={messages.remixOf.header}
description={messages.remixOf.description}
>
- {
const onSubmit = useCallback(
(values: SourceFilesFormValues) => {
- setAllowDownloadValue(get(values, ALLOW_DOWNLOAD))
- setFollowerGatedValue(get(values, FOLLOWER_GATED))
+ setAllowDownloadValue(
+ get(values, ALLOW_DOWNLOAD) ?? allowDownloadValue ?? false
+ )
+ setFollowerGatedValue(
+ get(values, FOLLOWER_GATED) ?? followerGatedValue ?? false
+ )
setStemsValue(get(values, STEMS))
},
- [setAllowDownloadValue, setFollowerGatedValue, setStemsValue]
+ [
+ allowDownloadValue,
+ followerGatedValue,
+ setAllowDownloadValue,
+ setFollowerGatedValue,
+ setStemsValue
+ ]
)
const preview = (
@@ -107,13 +120,13 @@ export const SourceFilesModalForm = () => {
icon={}
preview={preview}
>
-
+
)
}
-const SourceFilesModalFiels = () => {
+const SourceFilesModalFields = () => {
const [
{ onChange: allowDownloadOnChange },
,