Skip to content

Commit

Permalink
disable the story buttons if they are already in any of accepted and …
Browse files Browse the repository at this point in the history
…rejected arrays
  • Loading branch information
sridhar02 committed Jun 3, 2020
1 parent fa29346 commit 5bed878
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/components/story.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ export default function Story() {
fetchStory();
setRole(localStorage.getItem("role"));
}, []);

console.log(
typeof rejected,
rejected.includes(story.id, accepted.includes(story.id))
);
return (
<div className={classes.container}>
{isLoggedIn === false && <Redirect to="/" />}
Expand Down Expand Up @@ -145,10 +148,15 @@ export default function Story() {
<p>$ {story.cost}</p>
</div>
{role === "Admin" && (
// rejected.includes(story.id) &&
// accepted.includes(story.id)
<div className={classes.buttons}>
<Button
color="secondary"
variant="contained"
disabled={
rejected.includes(story.id) || accepted.includes(story.id)
}
className={classes.cancelButton}
onClick={() => rejectedStory(story.id)}
>
Expand All @@ -157,6 +165,9 @@ export default function Story() {
<Button
color="primary"
variant="contained"
disabled={
rejected.includes(story.id) || accepted.includes(story.id)
}
className={classes.saveButton}
onClick={() => AcceptedStory(story.id)}
>
Expand Down

0 comments on commit 5bed878

Please sign in to comment.