Skip to content

Commit

Permalink
[QA-1742][QA-1818] Fix UPC persisting and add ean-13 compatibility (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
schottra authored Nov 12, 2024
1 parent bd8a723 commit 517d45d
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/common/src/messages/edit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export const advancedAlbumMessages = {
upcValue: 'UPC',
upcTitle: 'UPC (Universal Product Code)',
upcDescription:
'A Universal Product Code (UPC) is a unique barcode that identifies music releases.',
'A Universal Product Code (UPC) is a unique barcode that identifies music releases. EAN-13 compatible.',
upcInputLabel: 'UPC',
upcInputError: 'Invalid UPC',
releaseDate: {
Expand Down
5 changes: 4 additions & 1 deletion packages/libs/src/api/entityManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type PlaylistParam = {
release_date: Nullable<string>
is_scheduled_release: boolean
ddex_app?: string | null
upc?: string | null
}

/*
Expand Down Expand Up @@ -156,7 +157,8 @@ export class EntityManager extends Base {
is_stream_gated: playlist.is_stream_gated,
stream_conditions: playlist.stream_conditions,
release_date: playlist.release_date,
is_scheduled_release: playlist.is_scheduled_release
is_scheduled_release: playlist.is_scheduled_release,
upc: playlist.upc
}

this.creatorNode.validatePlaylistSchema(metadata)
Expand Down Expand Up @@ -245,6 +247,7 @@ export class EntityManager extends Base {
is_private: playlist.is_private,
is_image_autogenerated: playlist.is_image_autogenerated,
ddex_app: playlist.ddex_app,
upc: playlist.upc,
is_stream_gated: playlist.is_stream_gated,
stream_conditions: playlist.stream_conditions,
release_date: playlist.release_date,
Expand Down
1 change: 1 addition & 0 deletions packages/libs/src/services/creatorNode/CreatorNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export type PlaylistMetadata = {
release_date: Nullable<string>
is_scheduled_release: boolean
ddex_app?: string | null
upc?: string | null
}

export type ProgressCB = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
"type": "boolean",
"default": false
},
"upc": {
"type": ["string", "null"],
"default": null
},
"is_stream_gated": {
"type": "boolean",
"default": false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const AdvancedAlbumScreen = () => {
const [{ value: isHidden }] = useField('is_private')
const [{ value: releaseDate, onChange }] = useField('release_date')

const error = !upc || /^\d{12}$/.test(upc) ? null : messages.upcInputError
const error = !upc || /^\d{12,13}$/.test(upc) ? null : messages.upcInputError

return (
<FormScreen
Expand All @@ -36,7 +36,7 @@ export const AdvancedAlbumScreen = () => {
name='upc'
label={messages.upcInputLabel}
transformValueOnChange={(value) => value.replace(/\D/g, '')}
maxLength={12}
maxLength={13}
error={touched && !!error}
helperText={touched && error}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type AdvancedAlbumFieldValues = {
const advancedSchema = z.object({
upc: z
.string()
.regex(/^\d{12}$/, messages.upcInputError)
.regex(/^\d{12,13}$/, messages.upcInputError)
.nullable(),
release_date: z.optional(z.string()).nullable()
})
Expand Down Expand Up @@ -63,7 +63,7 @@ export const AdvancedAlbumField = () => {
name='upc'
label={messages.upcInputLabel}
transformValueOnChange={(value) => value.replace(/\D/g, '')}
maxLength={12}
maxLength={13}
/>
</Flex>
{isHidden ? null : (
Expand Down

0 comments on commit 517d45d

Please sign in to comment.