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

Add global banner with new awards #90

Merged
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
24 changes: 24 additions & 0 deletions src/app/GlobalNotifications.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"use client";

import Link from "next/link";

import { trpc } from "~/app/_trpc/client";

export function GlobalNotifications() {
const { data: awards } = trpc.awardRouter.getAllAwardsForProfile.useQuery();

const hasUnclaimedAwards = awards?.some((award) => !award.imageId) ?? false;

if (!hasUnclaimedAwards) return null;

return (
<div className="my-2 bg-yellow-300 p-2 text-yellow-800">
<p className="text-center">
<Link href="/awards">
<strong>You have unclaimed awards!</strong> Go to the awards page to
claim them.
</Link>
</p>
</div>
);
}
2 changes: 2 additions & 0 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { getServerAuthSession } from "~/server/auth";

import Provider from "./_trpc/Provider";
import { NextAuthProvider } from "./authProvider";
import { GlobalNotifications } from "./GlobalNotifications";

import { UserMenuOrLogin } from "../components/UserMenuOrLogin";

Expand Down Expand Up @@ -40,6 +41,7 @@ export default async function RootLayout({
<UserMenuOrLogin />
</div>
</header>
<GlobalNotifications />
<main className="flex-1">
<div className="container flex max-w-[96rem] flex-col items-center gap-4 text-center">
{children}
Expand Down
3 changes: 3 additions & 0 deletions src/components/SentenceQuestionPractice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ export function SentenceQuestionPractice() {

// get the next sentence by invalidating query
await utils.questionRouter.getPossibleSentences.invalidate();

// this is needed to update the award banner
await utils.awardRouter.getAllAwardsForProfile.invalidate();
};

if (isLoadingSentences) {
Expand Down