Skip to content

Commit

Permalink
working edit & upload
Browse files Browse the repository at this point in the history
  • Loading branch information
DejayJD committed Apr 9, 2024
1 parent 16869d3 commit 80d5ad3
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 21 deletions.
2 changes: 0 additions & 2 deletions packages/common/src/hooks/useAccessAndRemixSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ export const useAccessAndRemixSettings = ({
return numEthCollectibles + numSolCollectibles === 0
})

console.log({ isInitiallyUnlisted, isUpload, initialStreamConditions })

const isInitiallyPublic =
!isInitiallyUnlisted && !isUpload && !initialStreamConditions

Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/schemas/upload/uploadFormSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ export const createCollectionSchema = (collectionType: 'playlist' | 'album') =>
USDCPurchaseConditionsSchema,
z.object({
usdc_purchase: z.object({
albumTrackPrice: z.number().optional() // Albums can set a price for all tracks
albumTrackPrice: z.number().optional() // Album uploads can set a price for all tracks
})
})
)
Expand Down
4 changes: 1 addition & 3 deletions packages/web/src/components/create-playlist/PlaylistForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const createCollectionFormSchema = (collectionType: 'album' | 'playlist') => {
return createCollectionSchema(collectionType).pick({
artwork: true,
playlist_name: true,
description: true,
description: true
})
}

Expand All @@ -72,8 +72,6 @@ const PlaylistForm = ({
SquareSizes.SIZE_1000_BY_1000
)

console.log({ metadata })

return (
<Formik<EditPlaylistValues>
initialValues={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ const EditPlaylistModal = () => {

const handleSubmit = useCallback(
(formFields: any) => {
console.log({ formFields })
if (playlistId) {
dispatch(editPlaylist(playlistId, formFields))
}
Expand Down
34 changes: 22 additions & 12 deletions packages/web/src/pages/upload-page/fields/AccessAndSaleField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import {
USDCPurchaseConditions,
AccessConditions
} from '@audius/common/models'
import { accountSelectors } from '@audius/common/store'
import { CollectionValues } from '@audius/common/schemas'
import { accountSelectors, EditPlaylistValues } from '@audius/common/store'
import { formatPrice, Nullable } from '@audius/common/utils'
import {
IconCart,
Expand All @@ -25,7 +26,7 @@ import {
IconVisibilityPublic,
Text
} from '@audius/harmony'
import { useField } from 'formik'
import { useField, useFormikContext } from 'formik'
import { get, isEmpty, set } from 'lodash'
import { useSelector } from 'react-redux'
import { z } from 'zod'
Expand All @@ -40,7 +41,7 @@ import DynamicImage from 'components/dynamic-image/DynamicImage'
import { defaultFieldVisibility } from 'pages/track-page/utils'

import { useIndexedField, useTrackField } from '../hooks'
import { SingleTrackEditValues } from '../types'
import { SingleTrackEditValues, TrackEditFormValues } from '../types'

import styles from './AccessAndSaleField.module.css'
import { AccessAndSaleMenuFields } from './AccessAndSaleMenuFields'
Expand Down Expand Up @@ -170,7 +171,7 @@ export const AccessAndSaleFormSchema = (
// Check for albumTrackPrice price >= min price (if applicable)
.refine(
(values) =>
isAlbum && !isUpload
isAlbum && isUpload
? refineMinPrice('albumTrackPrice', minContentPriceCents)(values)
: true,
{
Expand All @@ -185,7 +186,7 @@ export const AccessAndSaleFormSchema = (
})
.refine(
(values) =>
isAlbum && !isUpload
isAlbum && isUpload
? refineMaxPrice('albumTrackPrice', maxContentPriceCents)(values)
: true,
{
Expand Down Expand Up @@ -237,7 +238,7 @@ type AccessAndSaleFieldProps = {
}

export const AccessAndSaleField = (props: AccessAndSaleFieldProps) => {
const { isUpload, isAlbum, forceOpen, setForceOpen } = props
const { isUpload = false, isAlbum, forceOpen, setForceOpen } = props

const [{ value: index }] = useField('trackMetadatasIndex')
const [{ value: trackLength }] = useIndexedField<number>(
Expand All @@ -248,6 +249,16 @@ export const AccessAndSaleField = (props: AccessAndSaleFieldProps) => {

const usdcPurchaseConfig = useUSDCPurchaseConfig()

// For edit flows we need to track initial stream conditions from the parent form (not from inside contextual menu)
// So we take this from the parent form and pass it down to the menu fields
const { initialValues: parentFormInitialValues } = useFormikContext<
EditPlaylistValues | CollectionValues | TrackEditFormValues
>()
const parentFormInitialStreamConditions =
'stream_conditions' in parentFormInitialValues
? (parentFormInitialValues.stream_conditions as AccessConditions)
: undefined

// Fields from the outer form
const [{ value: isUnlisted }, , { setValue: setIsUnlistedValue }] =
useTrackField<SingleTrackEditValues[typeof IS_UNLISTED]>(IS_UNLISTED)
Expand Down Expand Up @@ -597,15 +608,14 @@ export const AccessAndSaleField = (props: AccessAndSaleFieldProps) => {
</div>
)
}, [
fieldVisibility,
isUnlisted,
savedStreamConditions,
isUnlisted,
isScheduledRelease,
fieldVisibility,
preview,
isScheduledRelease
isUpload
])

console.log({ inititak: initialValues[STREAM_CONDITIONS] })

return (
<ContextualMenu
label={messages.title}
Expand All @@ -629,7 +639,7 @@ export const AccessAndSaleField = (props: AccessAndSaleFieldProps) => {
isUpload={isUpload}
isAlbum={isAlbum}
initialStreamConditions={
initialValues[STREAM_CONDITIONS] ?? undefined
parentFormInitialStreamConditions ?? undefined
}
isScheduledRelease={isScheduledRelease}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ const messages = {
albumTrackPrice: {
title: 'Track Price',
description:
'Set the price fans must pay to unlock a single track on your album (minimum price of $0.99)',
'Set the price fans must pay to unlock a single track on your album (minimum price of $1.00)',
label: 'Track price',
placeholder: '1.00'
},
// Album purchase flow
albumPrice: {
title: 'Album Price',
description:
'Set the price fans must pay to unlock this album (minimum price of $0.99) ',
'Set the price fans must pay to unlock this album (minimum price of $1.00) ',
label: 'Album price',
placeholder: '5.00'
}
Expand Down

0 comments on commit 80d5ad3

Please sign in to comment.