Skip to content

Commit

Permalink
made alert toast clickable
Browse files Browse the repository at this point in the history
  • Loading branch information
bwsarge committed May 29, 2024
1 parent ba9761d commit 95598af
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 deletions.
39 changes: 24 additions & 15 deletions checkers-app/src/components/dashboard/PendingMsgAlert.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,38 @@
import { Alert } from "@material-tailwind/react";
import { EnvelopeIcon } from "@heroicons/react/20/solid";
import { BellAlertIcon } from "@heroicons/react/20/solid";
import { useNavigate } from "react-router-dom";

//true for pending messages, fale for update on pending VOTE
//true for pending messages, false for update on pending VOTE
export default function PendingMessageAlert({
hasPending,
pendingCount,
}: {
hasPending: boolean;
pendingCount: number;
}) {
const navigate = useNavigate();

const handleAlertClick = () => {
navigate("/votes");
};

return (
<Alert
icon={
hasPending ? (
<EnvelopeIcon className="h-6 w-6 text-highlight-color" />
) : (
<BellAlertIcon className="h-6 w-6 text-highlight-color" />
)
}
className="rounded items-center border-l-4 border-highlight-color bg-[highlight-color]/5 font-medium text-highlight-color shadow-md"
>
{hasPending
? `${pendingCount} pending message(s) yet to vote!`
: `${"TBD"} Crowd Vote updates!`}
</Alert>
<div onClick={handleAlertClick} className="cursor-pointer">
<Alert
icon={
hasPending ? (
<EnvelopeIcon className="h-6 w-6 text-highlight-color" />
) : (
<BellAlertIcon className="h-6 w-6 text-highlight-color" />
)
}
className="rounded items-center border-l-4 border-highlight-color bg-[highlight-color]/5 font-medium text-highlight-color shadow-md"
>
{hasPending
? `${pendingCount} pending message(s) yet to vote!`
: `${"TBD"} Crowd Vote updates!`}
</Alert>
</div>
);
}
2 changes: 1 addition & 1 deletion checkers-app/src/components/dashboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function Dashboard() {
return;
}
const checker: Checker = await getChecker(checkerDetails.checkerId);
if (checker) {
if (checker && checker.last30days) {
setTotalVotes(checker.last30days.totalVoted);
setAccuracyRate(checker.last30days.accuracyRate);
setAvgResponseTime(checker.last30days.averageResponseTime);
Expand Down

0 comments on commit 95598af

Please sign in to comment.