Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove like list #4

Merged
merged 1 commit into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 0 additions & 30 deletions app/api/backend/likes.js

This file was deleted.

48 changes: 7 additions & 41 deletions app/components/VideoCard/Item/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@ import { Card, CardBody, CardTitle } from 'reactstrap';
import PropTypes from 'prop-types';
import { library } from '@fortawesome/fontawesome-svg-core';
import { faListAlt, faHeading, faMoneyBillAlt, faBuilding } from '@fortawesome/free-solid-svg-icons';
import ThumbUpAltOutlinedIcon from '@material-ui/icons/ThumbUpAltOutlined';
import ThumbDownAltOutlinedIcon from '@material-ui/icons/ThumbDownAltOutlined';
import ThumbUpAltIcon from '@material-ui/icons/ThumbUpAlt';
import ThumbDownIcon from '@material-ui/icons/ThumbDown';
import LikeAPI from '../../../api/backend/likes';
import UserUtils from '../../../utils/user/UserUtils';
import Button from '@material-ui/core/Button';
library.add(faListAlt, faHeading, faMoneyBillAlt, faBuilding);

export default class VideoCard extends PureComponent {
Expand All @@ -19,35 +12,14 @@ export default class VideoCard extends PureComponent {
this.state = {};
}

like = id => LikeAPI.likeMovie(UserUtils.getAccessToken(), id).then(response => location.reload())
disLike = id => LikeAPI.disLikeMovie(UserUtils.getAccessToken(), id).then(response => location.reload())

renderVoting = (movie, movieID, showVoted) => {
if (!UserUtils.getAccessToken()) return null
if (showVoted) return <div>{ movie && movie.status === 'like' ? <span><ThumbUpAltIcon/>(Voted Up)</span> : <span><ThumbDownIcon/>(Voted Down)</span> }</div>
return (
<div>
<Button onClick={() => this.like(movieID)}><ThumbUpAltOutlinedIcon className="VideoCard-likeButton" /></Button>
<Button><ThumbDownAltOutlinedIcon className="VideoCard-likeButton" onClick={() => this.disLike(movieID)} /></Button>(un-voted)
</div>
)
}

render() {
const {
const {
title,
embedUrl,
description,
sharedByEmail,
movieID,
totalLikes,
totalDisLikes,
currentUser,
likeList
sharedByEmail
} = this.props;
const movieLikedByUser = likeList.filter(item => item.user_id === currentUser.id)
const showVoted = movieLikedByUser && movieLikedByUser.length > 0
const movieLiked = movieLikedByUser && movieLikedByUser[0]

return (
<div className="VideoCard">
<Card className="VideoCard-container">
Expand All @@ -56,13 +28,10 @@ export default class VideoCard extends PureComponent {
</div>
<CardBody className="col-md-6">
<CardTitle>
<span className="VideoCard-title">{ title }</span>
{ this.renderVoting(movieLiked, movieID, showVoted) }
<span className="VideoCard-title">{title}</span>
</CardTitle>
<CardTitle><span>{ `Shared by: ${sharedByEmail}` }</span></CardTitle>
{ totalLikes } <ThumbUpAltOutlinedIcon></ThumbUpAltOutlinedIcon>
{ totalDisLikes } <ThumbDownAltOutlinedIcon></ThumbDownAltOutlinedIcon>
<CardTitle>Description: <br/><span>{ description }</span></CardTitle>
<CardTitle><span>{`Shared by: ${sharedByEmail}`}</span></CardTitle>
<CardTitle>Description: <br /><span>{description}</span></CardTitle>
</CardBody>
</Card>
</div>
Expand All @@ -76,8 +45,5 @@ VideoCard.propTypes = {
sharedByEmail: PropTypes.string,
embedUrl: PropTypes.string,
movieID: PropTypes.any,
totalLikes: PropTypes.any,
totalDisLikes: PropTypes,
currentUser: PropTypes.any,
likeList: PropTypes.any
currentUser: PropTypes.any
};
7 changes: 2 additions & 5 deletions app/containers/HomePage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ export default function HomePage() {
const token = localStorage.getItem("accessToken")
console.log("Socket #####", token)
// const cable = new WebSocket(`ws://${config.API_BASE_URL}/cable?token=${token}`);
// const cable = new WebSocket(`ws://localhost:3001/cable?token=${token}`);
const cable = new WebSocket(`ws://remitano-backend-api.onrender.com/cable?token=${token}`)
const cable = new WebSocket(`ws://localhost:3001/cable?token=${token}`);
// const cable = new WebSocket(`ws://remitano-backend-api.onrender.com/cable?token=${token}`)
cable.onopen = () => {
console.log('Connected to Action Cable')

Expand Down Expand Up @@ -125,10 +125,7 @@ export default function HomePage() {
sharedByEmail={item.shared_by}
embedUrl={item.embed_url}
movieID={item.id}
totalLikes={item.total_likes}
totalDisLikes={item.total_dislikes}
currentUser={currentUser}
likeList={item.like_list}
/>
</div>))
}
Expand Down
Loading