-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
12fc68a
commit ff70555
Showing
151 changed files
with
1,113 additions
and
2,543 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ID } from '~/models/Identifiers' | ||
import { Nullable } from '~/utils/typeUtils' | ||
|
||
import { createModal } from './createModal' | ||
|
||
export type ArtistPickModalState = { | ||
trackId: Nullable<ID> | ||
} | ||
|
||
const artistPickModal = createModal<ArtistPickModalState>({ | ||
reducerPath: 'ArtistPick', | ||
initialState: { | ||
isOpen: false, | ||
trackId: null | ||
}, | ||
sliceSelector: (state) => state.ui.modals | ||
}) | ||
|
||
export const { | ||
hook: useArtistPickModal, | ||
reducer: artistPickModalReducer, | ||
actions: artistPickModalActions | ||
} = artistPickModal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
packages/web/src/components/artist-pick-modal/ArtistPickModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import { | ||
accountSelectors, | ||
tracksSocialActions, | ||
useArtistPickModal | ||
} from '@audius/common/store' | ||
import { | ||
Button, | ||
Modal, | ||
ModalContent, | ||
ModalContentText, | ||
ModalFooter, | ||
ModalHeader, | ||
ModalTitle | ||
} from '@audius/harmony' | ||
import { useDispatch } from 'react-redux' | ||
|
||
import { useSelector } from 'utils/reducer' | ||
|
||
const { setArtistPick, unsetArtistPick } = tracksSocialActions | ||
const getAccountUser = accountSelectors.getAccountUser | ||
|
||
const messagesMap = { | ||
add: { | ||
title: 'Set your Artist Pick', | ||
description: | ||
'This track will appear at the top of your profile, above your recent uploads, until you change or remove it.', | ||
confirm: 'Set Track' | ||
}, | ||
update: { | ||
title: 'Change your artist pick?', | ||
description: | ||
'This track will appear at the top of your profile and replace your previously picked track.', | ||
confirm: 'Change Track' | ||
}, | ||
remove: { | ||
title: 'Unset as Artist Pick', | ||
description: | ||
'Are you sure you want to remove your pick? This track will be displayed based on its release date.', | ||
confirm: 'Unset Track' | ||
} | ||
} | ||
|
||
export const ArtistPickModal = () => { | ||
const { | ||
isOpen, | ||
onClose, | ||
data: { trackId } | ||
} = useArtistPickModal() | ||
const dispatch = useDispatch() | ||
|
||
const currentArtistPickId = useSelector( | ||
(state) => getAccountUser(state)?.artist_pick_track_id | ||
) | ||
|
||
const action = !currentArtistPickId ? 'add' : trackId ? 'update' : 'remove' | ||
|
||
const messages = messagesMap[action] | ||
|
||
const handleSubmit = () => { | ||
if (trackId) { | ||
dispatch(setArtistPick(trackId)) | ||
} else { | ||
dispatch(unsetArtistPick()) | ||
} | ||
onClose() | ||
} | ||
|
||
return ( | ||
<Modal size='small' isOpen={isOpen} onClose={onClose}> | ||
<ModalHeader> | ||
<ModalTitle title={messages.title} /> | ||
</ModalHeader> | ||
<ModalContent> | ||
<ModalContentText css={{ textAlign: 'center' }}> | ||
{messages.description} | ||
</ModalContentText> | ||
</ModalContent> | ||
<ModalFooter> | ||
<Button variant='secondary' onClick={onClose} fullWidth> | ||
Cancel | ||
</Button> | ||
<Button variant='primary' onClick={handleSubmit} fullWidth> | ||
{messages.confirm} | ||
</Button> | ||
</ModalFooter> | ||
</Modal> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.