-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
107 additions
and
80 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,44 @@ | ||
"use client"; | ||
|
||
import { Bell } from "lucide-react"; | ||
import { Badge } from "@/components/ui/badge"; | ||
import { ButtonV2 } from "@/components/common/ButtonV2"; | ||
import NotificationModal from "@/components/models/NotificationModel"; | ||
import { useState } from "react"; | ||
import { useGetAllPatientNotifications } from "@/lib/hooks/notification/useSlotPatient"; | ||
import { INotification } from "@/types"; | ||
|
||
const NotificationButton = () => { | ||
const [isNotificationModalOpen, setIsNotificationModalOpen] = useState(false); | ||
const { data: notifications, isLoading } = useGetAllPatientNotifications(); | ||
|
||
const notificationCount = notifications?.length || 0; | ||
|
||
const handleNotificationClick = () => { | ||
setIsNotificationModalOpen(true); | ||
}; | ||
|
||
return ( | ||
<> | ||
<ButtonV2 variant="ghost" size="icon" className="relative" onClick={handleNotificationClick}> | ||
<Bell className="h-5 w-5" /> | ||
{notificationCount > 0 && ( | ||
<Badge | ||
variant="destructive" | ||
className="absolute -right-1 -top-1 h-5 w-5 rounded-full p-0 text-xs flex items-center justify-center" | ||
> | ||
{notificationCount} | ||
</Badge> | ||
)} | ||
<span className="sr-only">View notifications</span> | ||
</ButtonV2> | ||
<NotificationModal | ||
open={isNotificationModalOpen} | ||
setOpen={setIsNotificationModalOpen} | ||
notifications={notifications as INotification[] || []} | ||
/> | ||
</> | ||
); | ||
}; | ||
|
||
export default NotificationButton; |
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 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,26 @@ | ||
import { NotificationTypes } from "@/types"; | ||
|
||
export default function getNotificationDetails(type: NotificationTypes) { | ||
switch (type) { | ||
case NotificationTypes.APPOINTMENT_CANCELED: | ||
return { | ||
icon: '/assets/icons/utils/calendar-cancel.svg', | ||
title: 'Appointment Canceled' | ||
}; | ||
case NotificationTypes.APPOINTMENT_CONFIRMED: | ||
return { | ||
icon: '/assets/icons/utils/verified.svg', | ||
title: 'Appointment Confirmed' | ||
}; | ||
case NotificationTypes.APPOINTMENT_REMINDER: | ||
return { | ||
icon: '/assets/icons/utils/alarm-plus.svg', | ||
title: 'Appointment Reminder' | ||
}; | ||
default: | ||
return { | ||
icon: '/assets/icons/notification.svg', | ||
title: 'Notification' | ||
}; | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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