This repository has been archived by the owner on Oct 31, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 4
Added albums and item count to /albums #89
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { useHistory } from 'react-router-dom'; | ||
import { gql, useMutation } from '@apollo/client'; | ||
import { CircularProgress } from '@rmwc/circular-progress'; | ||
import { Dialog, DialogTitle, DialogActions, DialogButton } from '@rmwc/dialog'; | ||
import '@rmwc/dialog/styles'; | ||
|
||
const DELETE_ALBUM = gql` | ||
mutation deleteAlbum($id: String!) { | ||
deleteAlbum(id: $id) | ||
} | ||
`; | ||
|
||
const DeleteAlbumDialog = ({ open, setOpen, albumName, albumId }) => { | ||
const history = useHistory(); | ||
const [deleteAlbum, { data: delData, loading: delLoading, error: delError }] = | ||
useMutation(DELETE_ALBUM); | ||
|
||
const handleDeleteAlbum = (albumId) => { | ||
deleteAlbum({ | ||
variables: { id: albumId }, | ||
}); | ||
}; | ||
|
||
if (delData && delData.deleteAlbum) { | ||
setTimeout(() => { | ||
history.push('/albums'); | ||
}, 2000); | ||
} | ||
|
||
return ( | ||
<Dialog | ||
open={open} | ||
onClose={() => { | ||
setOpen(false); | ||
}} | ||
> | ||
<DialogTitle> | ||
Are you sure you want to delete album "{albumName}"? | ||
</DialogTitle> | ||
<br /> | ||
<br /> | ||
<DialogActions> | ||
{delLoading && <CircularProgress size="small" />} | ||
{delError && <>Sorry, some error occured!</>} | ||
<DialogButton | ||
unelevated | ||
onClick={() => handleDeleteAlbum(albumId)} | ||
style={{ color: '#fff' }} | ||
> | ||
Delete | ||
</DialogButton> | ||
| ||
<DialogButton outlined action="close"> | ||
Close | ||
</DialogButton> | ||
</DialogActions> | ||
</Dialog> | ||
); | ||
}; | ||
|
||
DeleteAlbumDialog.propTypes = { | ||
open: PropTypes.bool, | ||
setOpen: PropTypes.func, | ||
albumId: PropTypes.string, | ||
albumName: PropTypes.string, | ||
}; | ||
|
||
export default DeleteAlbumDialog; |
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,82 @@ | ||
import React, { useState } from 'react'; | ||
import { gql, useMutation } from '@apollo/client'; | ||
import PropTypes from 'prop-types'; | ||
import { Icon } from '@rmwc/icon'; | ||
import { Button } from '@rmwc/button'; | ||
import { TextField } from '@rmwc/textfield'; | ||
import { CircularProgress } from '@rmwc/circular-progress'; | ||
|
||
const UPDATE_ALBUM = gql` | ||
mutation updateAlbum($id: String!, $name: String!) { | ||
updateAlbum(id: $id, input: { name: $name }) | ||
} | ||
`; | ||
|
||
const EditAlbum = ({ albumId, albumName }) => { | ||
const [ | ||
updateAlbum, | ||
{ loading: updateAlbumNameLoading, error: updateAlbumNameyError }, | ||
] = useMutation(UPDATE_ALBUM); | ||
|
||
const [showEdit, setShowEdit] = useState(false); | ||
const [updatedAlbumName, setupdatedAlbumName] = useState(albumName); | ||
|
||
const handleEditAlbumName = (albumId, updatedAlbumName) => { | ||
updateAlbum({ variables: { id: albumId, name: updatedAlbumName } }); | ||
setShowEdit(false); | ||
}; | ||
|
||
return ( | ||
<> | ||
{showEdit ? ( | ||
<> | ||
<div className="edit-section"> | ||
<TextField | ||
defaultValue={updatedAlbumName} | ||
onChange={(e) => setupdatedAlbumName(e.target.value)} | ||
style={{ height: '36px' }} | ||
/> | ||
| ||
<Button | ||
onClick={() => handleEditAlbumName(albumId, updatedAlbumName)} | ||
label="update" | ||
unelevated | ||
disabled={updatedAlbumName ? false : true} | ||
style={{ color: '#fff' }} | ||
/> | ||
| ||
<Button | ||
onClick={() => setShowEdit(!showEdit)} | ||
label="cancel" | ||
outlined | ||
/> | ||
| ||
{updateAlbumNameLoading && <CircularProgress size="medium" />} | ||
{updateAlbumNameyError && ( | ||
<>Sorry, some error occured while updating name</> | ||
)} | ||
</div> | ||
<br /> | ||
<br /> | ||
</> | ||
) : ( | ||
<> | ||
<h2>{updatedAlbumName}</h2> | ||
| ||
<Icon | ||
onClick={() => setShowEdit(!showEdit)} | ||
style={{ cursor: 'pointer', color: '#424242' }} | ||
icon={{ icon: 'edit', size: 'small' }} | ||
/> | ||
</> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
EditAlbum.propTypes = { | ||
albumId: PropTypes.string, | ||
albumName: PropTypes.string, | ||
}; | ||
|
||
export default EditAlbum; |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't default justified as left?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. We have made it center for
/explore
which shows people name, places name etc. In center.