-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add notification center * Fix build * Apply pr feedback
- Loading branch information
Showing
10 changed files
with
203 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<div className={clsx("flex flex-row space-x-3", className)}> | ||
<div className="h-8 w-8 flex-none rounded-full bg-kiokuLightBlue" /> | ||
<div className="w-full"> | ||
<Text textSize="5xs" className="font-semibold text-black"> | ||
<Trans>Group Invitation</Trans> | ||
</Text> | ||
<Text textSize="5xs" className="text-gray-500"> | ||
<Trans> | ||
You have been invited to join{" "} | ||
<Link | ||
href={`/group/${invitation.groupID}`} | ||
className="underline hover:text-black" | ||
> | ||
{invitation.groupName} | ||
</Link> | ||
</Trans> | ||
</Text> | ||
</div> | ||
<div className="flex flex-row space-x-1"> | ||
<Button | ||
buttonSize="px-3" | ||
buttonStyle="tertiary" | ||
buttonIcon={<X strokeWidth={3}></X>} | ||
onClick={() => declineGroupInvitation(invitation.groupID)} | ||
/> | ||
<Button | ||
buttonSize="px-3 py-1" | ||
buttonStyle="secondary" | ||
buttonIcon={<Check strokeWidth={3}></Check>} | ||
onClick={() => sendGroupRequest(invitation.groupID)} | ||
/> | ||
</div> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<boolean>(false); | ||
|
||
return ( | ||
<> | ||
<NotificationCenterModal | ||
visible={showNotificationCenter} | ||
setVisible={setShowNotificationCenter} | ||
/> | ||
<div className="relative"> | ||
<Bell | ||
className="cursor-pointer" | ||
onClick={() => { | ||
setShowNotificationCenter(true); | ||
}} | ||
/> | ||
{invitations && ( | ||
<div className="absolute right-[-0.1rem] top-[-0.15rem] h-3 w-3 flex-none rounded-full bg-kiokuRed"> | ||
<div className="absolute h-full w-full animate-[ping_0.8s_ease-out_3] rounded-full bg-kiokuRed" /> | ||
</div> | ||
)} | ||
</div> | ||
</> | ||
); | ||
}; | ||
|
||
/** | ||
* Modal for creating decks | ||
*/ | ||
export const NotificationCenterModal = ({ | ||
className = "", | ||
setVisible, | ||
...props | ||
}: ModalProps) => { | ||
const { invitations } = useInvitations(); | ||
|
||
return ( | ||
<Modal header="Notification Center" setVisible={setVisible} {...props}> | ||
{invitations ? ( | ||
invitations.map((invitation) => ( | ||
<Invitation | ||
key={invitation.groupName} | ||
invitation={invitation} | ||
/> | ||
)) | ||
) : ( | ||
<div className="flex items-center justify-center space-x-3 rounded-md border border-dashed border-gray-500 p-10 text-gray-800"> | ||
<Info /> | ||
<Trans>You have no pending messages</Trans> | ||
</div> | ||
)} | ||
</Modal> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.