Skip to content

Commit

Permalink
progress
Browse files Browse the repository at this point in the history
  • Loading branch information
Angryman18 committed Jul 20, 2022
1 parent e980fac commit c3c1bba
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 54 deletions.
28 changes: 15 additions & 13 deletions src/common/components/Like/Like.jsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
import "./Like.scss";
import { useState, useEffect } from "react";
import { useState, useEffect, useLayoutEffect } from "react";
import { useAuthenticated } from "@nhost/react";

const Like = ({ onLikeClick }) => {
const Like = ({ onLikeClick, likeStatus }) => {
const [liked, setLiked] = useState(false);
const isAuthenticated = useAuthenticated();

// const likeClickHandler = (e) => {
// if (onLikeClick) {
// if (isAuthenticated) {
// setLiked(e.target.checked);
// }
// onLikeClick();
// }
// };
const clickHandler = () => {
setLiked(!liked);
useLayoutEffect(() => {
setLiked(likeStatus);
}, [likeStatus])

const likeClickHandler = (e) => {
if (onLikeClick) {
if (isAuthenticated) {
setLiked(e.target.checked);
}
onLikeClick();
}
};

return (
<div className="like-container">
<div className="like-icon" onClick={clickHandler}>
<div className="like-icon" onClick={likeClickHandler}>
<svg
viewBox="-4 -8 42 42"
className={`${liked ? "liked back" : "back"}`}
Expand Down
39 changes: 36 additions & 3 deletions src/common/playlists/PlayHeaderActions.jsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,48 @@
import React, { useState } from "react";
import { useAuthenticated } from "@nhost/react";
import { BsGithub } from "react-icons/bs";
import { IoLogoYoutube } from "react-icons/io";
import { AiOutlineRead } from "react-icons/ai";
import { BiComment } from "react-icons/bi";
import { MdClose } from "react-icons/md";
import Like from "common/components/Like/Like";

import SignInMethods from "./SignInMethods";
import Comment from "common/components/Comment";
import { NhostClient } from "@nhost/nhost-js";
import MuiModal from "common/modal/MuiModal";

const nhost = new NhostClient({
subdomain: process.env.REACT_APP_NHOST_SUBDOMAIN,
region: process.env.REACT_APP_NHOST_REGION,
});

const PlayHeaderActions = ({ play }) => {
console.log(play);
const [showComment, setShowComment] = useState(false);
const [showSignInMethods, setShowSignInMethods] = useState(false);
const isAuthenticated = useAuthenticated();

// handle the Button Clicks
const handleLogin = async (value) => {
return await nhost.auth.signIn({
provider: value,
options: {
redirectTo: window.location.href,
},
});
};

// handles the modal
const modalHandler = (e) => {
if (!isAuthenticated) {
return setShowSignInMethods(!showSignInMethods);
}
console.log(isAuthenticated)
return null;
};

return (
<>
<Like />
<Like onLikeClick={modalHandler} />
<button className="action badged" onClick={() => setShowComment(true)}>
<BiComment className="icon" size="24px" />
{/*<div className="badge-count">99</div>*/}
Expand Down Expand Up @@ -72,6 +100,11 @@ const PlayHeaderActions = ({ play }) => {
</div>
</div>
)}
<MuiModal
open={showSignInMethods}
handleClose={modalHandler}
component={<SignInMethods loginHandler={handleLogin} />}
/>
</>
);
};
Expand Down
38 changes: 0 additions & 38 deletions src/common/playlists/PlayHeaderInfo.jsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
import { IoMdArrowBack } from "react-icons/io";
import { Link } from "react-router-dom";
import LevelBadge from "common/components/LevelBadge";
import { NhostClient } from "@nhost/nhost-js";
import MuiModal from "common/modal/MuiModal";
import { useAuthenticated } from "@nhost/react";
import SignInMethods from "./SignInMethods";
import { useState } from "react";

const nhost = new NhostClient({
subdomain: process.env.REACT_APP_NHOST_SUBDOMAIN,
region: process.env.REACT_APP_NHOST_REGION,
});

const Author = ({ user, githubUsername }) => {
return (
Expand Down Expand Up @@ -47,29 +37,6 @@ const Tags = ({ tags }) => {
};

const PlayHeaderInfo = ({ play }) => {
const [showSignInMethods, setShowSignInMethods] = useState(false);
const isAuthenticated = useAuthenticated();

// handle the Button Clicks
const handleLogin = async (value) => {
return await nhost.auth.signIn({
provider: value,
options: {
redirectTo: window.location.href,
},
});
};

// handles the modal
const modalHandler = (e) => {
if (!isAuthenticated) {
return setShowSignInMethods(!showSignInMethods);
}
return null;
};

// actual lik

return (
<div className="header-leftcol overflow-hidden">
<div className="header-leftcol-action">
Expand All @@ -92,11 +59,6 @@ const PlayHeaderInfo = ({ play }) => {
)}
</div>
</div>
<MuiModal
open={showSignInMethods}
handleClose={modalHandler}
component={<SignInMethods loginHandler={handleLogin} />}
/>
</div>
);
};
Expand Down

0 comments on commit c3c1bba

Please sign in to comment.