Skip to content

Commit

Permalink
[C-3332] Fix playlist edit after create (#6873)
Browse files Browse the repository at this point in the history
  • Loading branch information
sliptype authored Dec 6, 2023
1 parent 6da7e8c commit 6ccf322
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
17 changes: 11 additions & 6 deletions packages/web/src/components/create-playlist/PlaylistForm.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { Collection, CollectionMetadata, SquareSizes } from '@audius/common'
import {
Collection,
CollectionMetadata,
Nullable,
SquareSizes
} from '@audius/common'
import { Flex } from '@audius/harmony'
import { Form, Formik } from 'formik'
import { toFormikValidationSchema } from 'zod-formik-adapter'
Expand All @@ -25,13 +30,13 @@ const messages = {
createPlaylistButtonText: 'Create Playlist'
}

export type EditPlaylistValuess = Collection & {
artwork: {
export type EditPlaylistValues = Omit<Collection, 'artwork'> & {
artwork: Nullable<{
file?: Blob
url?: string
source?: 'unsplash' | 'original' | 'generated'
error?: string
}
}>
}

type PlaylistFormProps = {
Expand Down Expand Up @@ -65,10 +70,10 @@ const PlaylistForm = ({
)

return (
<Formik<EditPlaylistValuess>
<Formik<EditPlaylistValues>
initialValues={{
...metadata,
artwork: { url: coverArtUrl },
artwork: coverArtUrl ? { url: coverArtUrl } : null,
description: metadata.description ?? ''
}}
onSubmit={onSave}
Expand Down
13 changes: 9 additions & 4 deletions packages/web/src/pages/upload-page/validation.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { imageBlank } from '@audius/common'
import {
Genre,
HashId,
Expand Down Expand Up @@ -125,10 +126,14 @@ const createCollectionSchema = (collectionType: 'playlist' | 'album') =>
url: z.string()
})
.nullable()

.refine((artwork) => artwork !== null, {
message: messages.artworkRequiredError
}),
.refine(
(artwork) => {
return artwork !== null && artwork.url !== imageBlank
},
{
message: messages.artworkRequiredError
}
),
playlist_name: z.string({
required_error: messages[collectionType].nameRequiredError
}),
Expand Down

0 comments on commit 6ccf322

Please sign in to comment.