diff --git a/frontend/components/group/Invitation.tsx b/frontend/components/group/Invitation.tsx
new file mode 100644
index 00000000..9859e59b
--- /dev/null
+++ b/frontend/components/group/Invitation.tsx
@@ -0,0 +1,62 @@
+import { Trans } from "@lingui/macro";
+import clsx from "clsx";
+import Link from "next/link";
+import { Check, X } from "react-feather";
+
+import { Button } from "@/components/input/Button";
+import { Invitation as InvitationType } from "@/types/Invitation";
+import { declineGroupInvitation, sendGroupRequest } from "@/util/api";
+
+import { Text } from "../Text";
+
+interface InvitationProps {
+ /**
+ * Invitation
+ */
+ invitation: InvitationType;
+ /**
+ * Additional classes
+ */
+ className?: string;
+}
+
+/**
+ * Component for displaying a group invitation in the notification center
+ */
+export const Invitation = ({ invitation, className }: InvitationProps) => {
+ return (
+
+
+
+
+ Group Invitation
+
+
+
+ You have been invited to join{" "}
+
+ {invitation.groupName}
+
+
+
+
+
+
+
+ );
+};
diff --git a/frontend/components/input/Button.tsx b/frontend/components/input/Button.tsx
index 4be8a283..44ad9592 100644
--- a/frontend/components/input/Button.tsx
+++ b/frontend/components/input/Button.tsx
@@ -37,7 +37,7 @@ const getStyle = {
secondary:
"bg-black font-medium text-white hover:scale-[1.02] hover:bg-neutral-900",
tertiary:
- "bg-transparent font-medium text-kiokuDarkBlue hover:scale-105 hover:bg-gray-100",
+ "bg-transparent font-medium text-black hover:scale-105 hover:bg-gray-100",
cancel: "bg-transparent font-normal text-gray-400 hover:bg-gray-100",
error: "bg-kiokuRed font-medium text-white hover:scale-105",
warning: "bg-kiokuYellow font-medium text-white hover:scale-105",
@@ -78,12 +78,15 @@ export const Button = ({
>
);
const classNames = [
- "flex items-center space-x-1 rounded-md outline-none transition",
+ "flex items-center rounded-md outline-none transition",
className,
];
if (buttonStyle) {
classNames.push(getStyle[buttonStyle]);
}
+ if (buttonIcon && children) {
+ classNames.push("space-x-1");
+ }
classNames.push(buttonSize);
return href ? (
diff --git a/frontend/components/modal/NotificationCenter.tsx b/frontend/components/modal/NotificationCenter.tsx
new file mode 100644
index 00000000..b34fe0c5
--- /dev/null
+++ b/frontend/components/modal/NotificationCenter.tsx
@@ -0,0 +1,68 @@
+import { Trans } from "@lingui/macro";
+import { useState } from "react";
+import { Bell, Info } from "react-feather";
+
+import { Invitation } from "@/components/group/Invitation";
+import { Modal, ModalProps } from "@/components/modal/modal";
+import { useInvitations } from "@/util/swr";
+
+/**
+ * Component for displaying an icon that opens the notification center
+ */
+export const NotificationCenter = () => {
+ const { invitations } = useInvitations();
+
+ const [showNotificationCenter, setShowNotificationCenter] =
+ useState(false);
+
+ return (
+ <>
+
+
+
{
+ setShowNotificationCenter(true);
+ }}
+ />
+ {invitations && (
+
+ )}
+
+ >
+ );
+};
+
+/**
+ * Modal for creating decks
+ */
+export const NotificationCenterModal = ({
+ className = "",
+ setVisible,
+ ...props
+}: ModalProps) => {
+ const { invitations } = useInvitations();
+
+ return (
+
+ {invitations ? (
+ invitations.map((invitation) => (
+
+ ))
+ ) : (
+
+
+ You have no pending messages
+
+ )}
+
+ );
+};
diff --git a/frontend/components/modal/modal.tsx b/frontend/components/modal/modal.tsx
index 64faa12a..0a0449f7 100644
--- a/frontend/components/modal/modal.tsx
+++ b/frontend/components/modal/modal.tsx
@@ -53,7 +53,7 @@ export const Modal = ({
{header}
diff --git a/frontend/components/navigation/Navbar.tsx b/frontend/components/navigation/Navbar.tsx
index e433698a..f45aba36 100644
--- a/frontend/components/navigation/Navbar.tsx
+++ b/frontend/components/navigation/Navbar.tsx
@@ -6,8 +6,9 @@ import { ArrowRight, LogOut } from "react-feather";
import { Logo } from "@/components/graphics/Logo";
import { Button } from "@/components/input/Button";
+import { NotificationCenter } from "@/components/modal/NotificationCenter";
+import { postRequest } from "@/util/api";
import { logoutRoute } from "@/util/endpoints";
-import { authedFetch } from "@/util/reauth";
interface NavbarProps {
/**
@@ -21,7 +22,9 @@ interface NavbarProps {
*/
export const Navbar = ({ className = "" }: NavbarProps) => {
const router = useRouter();
+
const [loggedIn, setLoggedIn] = useState
();
+
useEffect(() => {
if (router.pathname == "/login") {
setLoggedIn(undefined);
@@ -29,26 +32,29 @@ export const Navbar = ({ className = "" }: NavbarProps) => {
setLoggedIn(hasCookie("access_token"));
}
}, [router.pathname]);
+
if (loggedIn == undefined) {
return <>>;
}
+
return (
);
};
diff --git a/frontend/locales/de/messages.po b/frontend/locales/de/messages.po
index 0e39424f..e61d0626 100644
--- a/frontend/locales/de/messages.po
+++ b/frontend/locales/de/messages.po
@@ -53,21 +53,17 @@ msgstr "Verfügbar"
msgid "Back to Deck!"
msgstr "Zurück zum Stapel!"
-#: components/modal/CreateCardModal.tsx:76
+#: components/modal/CreateCardModal.tsx:73
#: components/modal/CreateDeckModal.tsx:91
#: components/modal/CreateGroupModal.tsx:79
msgid "Cancel"
msgstr "Abbrechen"
-#: components/modal/CreateCardModal.tsx:59
+#: components/modal/CreateCardModal.tsx:56
msgid "Card back"
msgstr "Kartenrückseite"
-#: components/modal/CreateCardModal.tsx:113
-msgid "Card created!"
-msgstr "Karte erstellt!"
-
-#: components/modal/CreateCardModal.tsx:47
+#: components/modal/CreateCardModal.tsx:44
msgid "Card front"
msgstr "Kartenvorderseite"
@@ -117,7 +113,7 @@ msgstr "Glückwunsch!"
msgid "Create and customize your own flashcards tailored to your needs and preferences. Set your own pace with our spaced repetition system to maximize your potential!"
msgstr "Erstelle und individualisiere Karteikarten, die genau auf Deine Bedürfnisse und Vorlieben zugeschnitten sind. Bestimme Dein eigenes Tempo mit unserem Spaced Repetition System, um Dein Potenzial zu maximieren!"
-#: components/modal/CreateCardModal.tsx:87
+#: components/modal/CreateCardModal.tsx:90
msgid "Create Card"
msgstr "Karte erstellen"
@@ -129,7 +125,7 @@ msgstr "Stapel erstellen"
msgid "Create Group"
msgstr "Gruppe erstellen"
-#: components/modal/CreateCardModal.tsx:37
+#: components/modal/CreateCardModal.tsx:34
msgid "Create new Card"
msgstr "Neue Karte erstellen"
@@ -147,7 +143,7 @@ msgstr "Gruppe erstellen"
msgid "Danger Zone"
msgstr "Gefahrenzone"
-#: pages/index.tsx:42
+#: pages/index.tsx:40
msgid "Dashboard"
msgstr "Dashboard"
@@ -162,7 +158,7 @@ msgid "Deck Name"
msgstr "Stapelname"
#: pages/group/[id]/index.tsx:41
-#: pages/index.tsx:49
+#: pages/index.tsx:47
msgid "Decks"
msgstr "Stapel"
@@ -219,11 +215,11 @@ msgstr "Einfach"
msgid "Email"
msgstr "E-Mail"
-#: components/modal/CreateCardModal.tsx:61
+#: components/modal/CreateCardModal.tsx:58
msgid "Enter card back"
msgstr "Kartenrückseite eingeben"
-#: components/modal/CreateCardModal.tsx:50
+#: components/modal/CreateCardModal.tsx:47
msgid "Enter card front"
msgstr "Kartenvorderseite eingeben"
@@ -286,6 +282,10 @@ msgstr "Los geht's"
msgid "Group Description"
msgstr "Gruppenbeschreibung"
+#: components/group/Invitation.tsx:32
+msgid "Group Invitation"
+msgstr "Gruppeneinladung"
+
#: components/modal/CreateGroupModal.tsx:49
#: components/navigation/Tabs/GroupSettingsTab.tsx:49
msgid "Group Name"
@@ -295,7 +295,7 @@ msgstr "Gruppenname"
msgid "Group Statistics"
msgstr "Gruppenstatistiken"
-#: pages/index.tsx:56
+#: pages/index.tsx:54
msgid "Groups"
msgstr "Gruppen"
@@ -368,7 +368,7 @@ msgstr "Erfahre mehr"
msgid "Leave Group"
msgstr "Gruppe verlassen"
-#: components/navigation/Navbar.tsx:62
+#: components/navigation/Navbar.tsx:68
msgid "Login"
msgstr "Einloggen"
@@ -472,7 +472,7 @@ msgstr "Wähle \"Installieren\""
#: pages/deck/[id]/index.tsx:42
#: pages/group/[id]/index.tsx:51
-#: pages/index.tsx:63
+#: pages/index.tsx:61
msgid "Settings"
msgstr "Einstellungen"
@@ -573,6 +573,14 @@ msgstr "Du hast es geschafft! Für heute gibt es keine Karten mehr zu lernen."
msgid "You first need to install Kioku before you can subscribe and receive notifications. Follow the instructions below to install the app and enjoy a native experience."
msgstr "Bevor die Benachrichtigungen aktiviert werden können, muss Kioku installiert werden. Folge der Installationsanleitung, um die App zu installieren und ein natives Erlebnis zu genießen."
+#: components/group/Invitation.tsx:35
+msgid "You have been invited to join <0>{0}0>"
+msgstr "Du wurdest eingeladen <0>{0}0> beizutreten"
+
+#: components/modal/NotificationCenter.tsx:63
+msgid "You have no pending messages"
+msgstr "Du hast keine neuen Nachrichten"
+
#: components/navigation/Tabs/GroupSettingsTab.tsx:87
msgid "You must either be invited or request to join the group again."
msgstr "Du musst eingeladen werden oder eine Anfrage stellen, um der Gruppe erneut beitreten zu können."
diff --git a/frontend/locales/en/messages.po b/frontend/locales/en/messages.po
index 79f4d80e..b49ec63d 100644
--- a/frontend/locales/en/messages.po
+++ b/frontend/locales/en/messages.po
@@ -53,21 +53,17 @@ msgstr "Available"
msgid "Back to Deck!"
msgstr "Back to Deck!"
-#: components/modal/CreateCardModal.tsx:76
+#: components/modal/CreateCardModal.tsx:73
#: components/modal/CreateDeckModal.tsx:91
#: components/modal/CreateGroupModal.tsx:79
msgid "Cancel"
msgstr "Cancel"
-#: components/modal/CreateCardModal.tsx:59
+#: components/modal/CreateCardModal.tsx:56
msgid "Card back"
msgstr "Card back"
-#: components/modal/CreateCardModal.tsx:113
-msgid "Card created!"
-msgstr "Card created!"
-
-#: components/modal/CreateCardModal.tsx:47
+#: components/modal/CreateCardModal.tsx:44
msgid "Card front"
msgstr "Card front"
@@ -117,7 +113,7 @@ msgstr "Congratulations!"
msgid "Create and customize your own flashcards tailored to your needs and preferences. Set your own pace with our spaced repetition system to maximize your potential!"
msgstr "Create and customize your own flashcards tailored to your needs and preferences. Set your own pace with our spaced repetition system to maximize your potential!"
-#: components/modal/CreateCardModal.tsx:87
+#: components/modal/CreateCardModal.tsx:90
msgid "Create Card"
msgstr "Create Card"
@@ -129,7 +125,7 @@ msgstr "Create Deck"
msgid "Create Group"
msgstr "Create Group"
-#: components/modal/CreateCardModal.tsx:37
+#: components/modal/CreateCardModal.tsx:34
msgid "Create new Card"
msgstr "Create new Card"
@@ -147,7 +143,7 @@ msgstr "Create new Group"
msgid "Danger Zone"
msgstr "Danger Zone"
-#: pages/index.tsx:42
+#: pages/index.tsx:40
msgid "Dashboard"
msgstr "Dashboard"
@@ -162,7 +158,7 @@ msgid "Deck Name"
msgstr "Deck Name"
#: pages/group/[id]/index.tsx:41
-#: pages/index.tsx:49
+#: pages/index.tsx:47
msgid "Decks"
msgstr "Decks"
@@ -219,11 +215,11 @@ msgstr "Easy"
msgid "Email"
msgstr "Email"
-#: components/modal/CreateCardModal.tsx:61
+#: components/modal/CreateCardModal.tsx:58
msgid "Enter card back"
msgstr "Enter card back"
-#: components/modal/CreateCardModal.tsx:50
+#: components/modal/CreateCardModal.tsx:47
msgid "Enter card front"
msgstr "Enter card front"
@@ -286,6 +282,10 @@ msgstr "Get started"
msgid "Group Description"
msgstr "Group Description"
+#: components/group/Invitation.tsx:32
+msgid "Group Invitation"
+msgstr "Group Invitation"
+
#: components/modal/CreateGroupModal.tsx:49
#: components/navigation/Tabs/GroupSettingsTab.tsx:49
msgid "Group Name"
@@ -295,7 +295,7 @@ msgstr "Group Name"
msgid "Group Statistics"
msgstr "Group Statistics"
-#: pages/index.tsx:56
+#: pages/index.tsx:54
msgid "Groups"
msgstr "Groups"
@@ -368,7 +368,7 @@ msgstr "Learn more"
msgid "Leave Group"
msgstr "Leave Group"
-#: components/navigation/Navbar.tsx:62
+#: components/navigation/Navbar.tsx:68
msgid "Login"
msgstr "Login"
@@ -472,7 +472,7 @@ msgstr "Select \"Install\""
#: pages/deck/[id]/index.tsx:42
#: pages/group/[id]/index.tsx:51
-#: pages/index.tsx:63
+#: pages/index.tsx:61
msgid "Settings"
msgstr "Settings"
@@ -573,6 +573,14 @@ msgstr "You did it! There are no cards left in this deck to learn today."
msgid "You first need to install Kioku before you can subscribe and receive notifications. Follow the instructions below to install the app and enjoy a native experience."
msgstr "You first need to install Kioku before you can subscribe and receive notifications. Follow the instructions below to install the app and enjoy a native experience."
+#: components/group/Invitation.tsx:35
+msgid "You have been invited to join <0>{0}0>"
+msgstr "You have been invited to join <0>{0}0>"
+
+#: components/modal/NotificationCenter.tsx:63
+msgid "You have no pending messages"
+msgstr "You have no pending messages"
+
#: components/navigation/Tabs/GroupSettingsTab.tsx:87
msgid "You must either be invited or request to join the group again."
msgstr "You must either be invited or request to join the group again."
diff --git a/frontend/pages/index.tsx b/frontend/pages/index.tsx
index a93d8e41..1e5d0b83 100644
--- a/frontend/pages/index.tsx
+++ b/frontend/pages/index.tsx
@@ -8,13 +8,12 @@ import { FetchHeader } from "@/components/layout/Header";
import { DashboardTab } from "@/components/navigation/Tabs/DashboardTab";
import { DecksTab } from "@/components/navigation/Tabs/DecksTab";
import { GroupsTab } from "@/components/navigation/Tabs/GroupsTab";
-import { InvitationsTab } from "@/components/navigation/Tabs/InvitationsTabs";
import { StatisticsTab } from "@/components/navigation/Tabs/StatisticsTab";
import { TabBar } from "@/components/navigation/Tabs/TabBar";
import { TabHeader } from "@/components/navigation/Tabs/TabHeader";
import { UserSettingsTab } from "@/components/navigation/Tabs/UserSettingsTab";
import { loadCatalog } from "@/pages/_app";
-import { useGroups, useInvitations, useUser, useUserDue } from "@/util/swr";
+import { useGroups, useUser, useUserDue } from "@/util/swr";
export const getStaticProps: GetStaticProps = async (ctx) => {
const translation = await loadCatalog(ctx.locale!);
@@ -28,7 +27,6 @@ export const getStaticProps: GetStaticProps = async (ctx) => {
export default function Home() {
const { user } = useUser();
const { due } = useUserDue();
- const { invitations } = useInvitations();
const { groups } = useGroups();
const homeGroup = groups?.filter((group) => group.isDefault)[0];
@@ -105,11 +103,6 @@ export default function Home() {
),
groups: ,
- invitations: invitations && (
-
- ),
settings: ,
statistics: ,
dashboard: homeGroup && ,