panel uzytkownika

This commit is contained in:
2026-08-24 14:14:54 +02:00
parent 6c35589e70
commit 1a067cce8c
6 changed files with 476 additions and 263 deletions
+11 -1
View File
@@ -41,6 +41,7 @@ type NotificationsContextValue = {
unreadCount: number;
markRead: (id: number) => void;
markAllRead: () => void;
clearAll: () => void;
notify: (input: NotifyInput) => void;
// Kasuje powiadomienia o kluczu zaczynajacym sie od prefiksu - uzywane przy usuwaniu
// alertu cenowego, zeby nie zostal po nim slad.
@@ -147,6 +148,15 @@ export function NotificationsProvider({ children }: { children: ReactNode }) {
apiFetch('/notifications/read-all', { method: 'POST' }).catch(() => {});
}, []);
// Kasuje wszystkie powiadomienia uzytkownika. Znikaja od razu z widoku, reszte sprzata backend.
// Czyscimy tez blokade deduplikacji, inaczej te same zdarzenia nie wygenerowalyby juz
// powiadomienia w tej sesji.
const clearAll = useCallback(() => {
setNotifications([]);
sentDedupeKeys.current = new Set();
apiFetch('/notifications/all', { method: 'DELETE' }).catch(() => {});
}, []);
const notify = useCallback((input: NotifyInput) => {
if (!getToken() || !input.title) {
return;
@@ -184,7 +194,7 @@ export function NotificationsProvider({ children }: { children: ReactNode }) {
return (
<NotificationsContext.Provider
value={{ notifications, unreadCount, markRead, markAllRead, notify, dismissByDedupePrefix, refresh }}
value={{ notifications, unreadCount, markRead, markAllRead, clearAll, notify, dismissByDedupePrefix, refresh }}
>
{children}
</NotificationsContext.Provider>