forked from reactplay/react-play
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request reactplay#382 from reactplay/like-feature
Like feature
- Loading branch information
Showing
14 changed files
with
307 additions
and
95 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
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,25 @@ | ||
import "./Like.scss"; | ||
import { AiOutlineLike, AiFillLike } from "react-icons/ai"; | ||
|
||
const Like = ({ onLikeClick, likeObj }) => { | ||
const {liked, number} = likeObj | ||
|
||
const likeClickHandler = () => { | ||
if (onLikeClick) return onLikeClick(); | ||
}; | ||
|
||
return ( | ||
<button className="action counted -mr-0.5" onClick={likeClickHandler}> | ||
<AiOutlineLike size='24px' className={liked ? "hidden" : "icon"}/> | ||
<AiFillLike size='24px' className={liked ? "icon" : "hidden"}/> | ||
{number > 0 ? (<div className="count-value">{number}</div>):(<div></div>)} | ||
|
||
</button> | ||
); | ||
}; | ||
|
||
Like.defaultProps = { | ||
onLikeClick: null, | ||
}; | ||
|
||
export default Like; |
Empty file.
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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
export const NHOST = { | ||
AUTH_URL: `https://rgkjmwftqtbpayoyolwh.nhost.run/v1/auth/signin/provider/github?redirectTo=${encodeURI( | ||
"http:https://localhost:3000/plays/create" | ||
)}`, | ||
const AUTH_URL = (redirectURL, provider = "github") => { | ||
return `${process.env.REACT_APP_NHOST_BACKEND_URL}/v1/auth/signin/provider/${provider}?redirectTo=${encodeURI( | ||
redirectURL | ||
)}`; | ||
}; | ||
|
||
export const NHOST = { AUTH_URL } |
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,29 @@ | ||
import { submit } from "common/services/request"; | ||
import { | ||
likeIndividualPlay, | ||
unlikeIndividualPlay, | ||
} from "common/services/request/query/like-play"; | ||
|
||
const useLikePlays = () => { | ||
const likePlay = async (obj) => { | ||
try { | ||
const likeExec = await submit(likeIndividualPlay(obj)); | ||
return Promise.resolve(likeExec); | ||
} catch (err) { | ||
return Promise.reject(err); | ||
} | ||
}; | ||
|
||
const unLikePlay = async (obj) => { | ||
try { | ||
const resp = await submit(unlikeIndividualPlay(obj)); | ||
return Promise.resolve(resp); | ||
} catch (err) { | ||
return Promise.reject(err); | ||
} | ||
}; | ||
|
||
return { likePlay, unLikePlay }; | ||
}; | ||
|
||
export default useLikePlays; |
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
Oops, something went wrong.