Skip to content
Snippets Groups Projects
Commit 710deab6 authored by Lucas Eduardo Schoenfelder's avatar Lucas Eduardo Schoenfelder
Browse files

added function to provide feedback when the user edits a collection

parent c6e03c14
No related branches found
No related tags found
4 merge requests!57Merge of develop into master,!56Fixed buttons reportar, seguir, compartilhar, guardar and entrar (in comments...,!39Update admin system,!35Fix remaining bugs
......@@ -54,6 +54,7 @@ export default function ColCardOwnerOptions (props) {
/>
<ModalEditarColecao id={props.id}
open={modalEditarOpen} handleClose={() => {toggleModalEditar(false)}}
changeColName={props.changeColName} changeColPrivacy={props.changeColPrivacy}
/>
<div style={{fontSize: "12px"}}>
......
......@@ -42,7 +42,6 @@ import Snackbar from '@material-ui/core/Snackbar';
import MuiAlert from '@material-ui/lab/Alert';
export default function CollectionCardFunction(props) {
// console.log(props);
const { state } = useContext(Store)
// eslint-disable-next-line
......@@ -50,6 +49,12 @@ export default function CollectionCardFunction(props) {
const [userFollowingCol, toggleUserFollowingCol] = useState(props.followed ? props.followed : false)
const handleToggleUserFollowingCol = () => { toggleUserFollowingCol(!userFollowingCol) }
const [name, setName] = useState(props.name)
const changeColName = (newName) => {setName(newName)}
const [privacy, setPrivacy] = useState(props.privacy)
const changeColPrivacy = (newPrivacy) => {setPrivacy(newPrivacy)}
const [likesCount, setLikesCount] = useState(props.likeCount)
const [liked, toggleLiked] = useState(props.liked)
......@@ -88,49 +93,6 @@ export default function CollectionCardFunction(props) {
}
useEffect(() => {
// setTimeout(function () {
// if (state.currentUser.id) {
// const config = getAxiosConfig();
// axios({
// method: 'get',
// url: `${apiUrl}/users/${state.currentUser.id}/following/Collection`,
// headers: config.headers
// }).then(
// (response) => {
// const data = response.data
// for (let i = 0; i < data.length; i++)
// if (data[i].followable.id === props.id)
// toggleUserFollowingCol(true)
// saveHeaders(response)
// })
// }
// else {
// toggleLiked(false);
// toggleUserFollowingCol(false);
// }
// }, 1000);
// setTimeout(function () {
// if (state.currentUser.id) {
// const config = getAxiosConfig();
// axios({
// method: 'get',
// url: `${apiUrl}/users/${state.currentUser.id}/collections/liked`,
// headers: config.headers
// }).then(
// (response) => {
// const data = response.data
// for (let i = 0; i < data.length; i++)
// if (data[i].id === props.id)
// toggleLiked(true)
// saveHeaders(response)
// })
// }
// else {
// toggleLiked(false);
// toggleUserFollowingCol(false);
// }
// }, 2000);
if (!state.currentUser.id) {
toggleLiked(false);
toggleUserFollowingCol(false);
......@@ -240,7 +202,7 @@ export default function CollectionCardFunction(props) {
}} />
<UserAndTitle>
<span>{props.author}</span>
<span className={"col-name"}>{props.name}</span>
<span className={"col-name"}>{name}</span>
</UserAndTitle>
</UserInfo>
<StyledGrid container direction="row">
......@@ -291,13 +253,15 @@ export default function CollectionCardFunction(props) {
<Grid container>
<Grid item xs={6} style={{ display: "flex", justifyContent: "center" }}>
{
props.privacy === 'private' &&
privacy === 'private' &&
<LockIcon style={{ color: "#666" }} />
}
</Grid>
<Grid item xs={6} style={{ display: "flex", justifyContent: "flex-end" }}>
<ColCardOwnerOptions
id={props.id}
changeColName={changeColName}
changeColPrivacy={changeColPrivacy}
/>
</Grid>
</Grid>
......@@ -370,20 +334,6 @@ const UserAndTitle = styled.div`
}
`
// const AvatarDiv = styled.div`
// z-index : 5;
// overflow : hidden;
// img {
// border-radius : 50%;
// height : 70px;
// width : 70px;
// border : 2px solid #fff !important;
// background-color : #fff;
// box-shadow : 0 1px 3px rgba(0,0,0,.45);
// }
// `
const UserInfo = styled.div`
position : absolute;
display : flex;
......
......@@ -43,7 +43,7 @@ export default function EditarColecaoForm (props) {
const [value, setValue] = useState(-1);
/*values are set according to backend complaint id*/
const [options] = [
const options = [
{value : "pública", text :'Pública (Sua coleção estará disponível para todos)'},
{value : "privada", text : 'Privada (Somente você poderá visualizar esta coleção)'}
]
......@@ -69,7 +69,7 @@ export default function EditarColecaoForm (props) {
}
function handleSuccessfulSubmit (data) {
props.finalize(data.id)
props.finalize(data.name, data.privacy)
}
const formSubmit = (e) => {
e.preventDefault()
......
......@@ -25,6 +25,12 @@ import CloseModalButton from './CloseModalButton'
import EditarColecaoForm from './EditarColecaoForm.js'
export default function ModalEditarColecao (props) {
function finalize (newName, newPrivacy) {
props.changeColName(newName)
props.changeColPrivacy(newPrivacy)
props.handleClose()
}
return (
<StyledModal
aria-labelledby="transition-modal-title"
......@@ -47,7 +53,7 @@ export default function ModalEditarColecao (props) {
<CloseModalButton handleClose={props.handleClose} id={props.id}/>
</Header>
<Content style={{paddingTop : "0"}}>
<EditarColecaoForm id={props.id} handleClose={props.handleClose} finalize={props.handleClose}/>
<EditarColecaoForm id={props.id} handleClose={props.handleClose} finalize={finalize}/>
</Content>
</Container>
</Fade>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment