Add notification history feature with bell icon and history page

- Add notification_history database table for logging all triggered notifications
- Create API endpoints for fetching recent and historical notifications
- Add NotificationBell component in navbar with badge showing recent count
- Dropdown shows 5 most recent notifications with links to products
- Create full NotificationHistory page with filtering by notification type
- Log notifications when sent: price drops, target prices, back-in-stock
- Track which channels (telegram, discord, pushover, ntfy) received each notification
- Update sendNotifications to return which channels succeeded
- Bump version to 1.0.3

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
clucraft 2026-01-23 20:32:24 -05:00
parent 45363e4d97
commit 63fcaebfd8
12 changed files with 1244 additions and 16 deletions

View file

@ -262,6 +262,59 @@ export const profileApi = {
}),
};
// Notification History API
export type NotificationType = 'price_drop' | 'price_target' | 'stock_change';
export interface NotificationHistoryEntry {
id: number;
user_id: number;
product_id: number;
notification_type: NotificationType;
triggered_at: string;
old_price: number | null;
new_price: number | null;
currency: string | null;
price_change_percent: number | null;
target_price: number | null;
old_stock_status: string | null;
new_stock_status: string | null;
channels_notified: string[];
product_name: string | null;
product_url: string | null;
}
export interface NotificationHistoryResponse {
notifications: NotificationHistoryEntry[];
pagination: {
page: number;
limit: number;
totalCount: number;
totalPages: number;
};
}
export interface RecentNotificationsResponse {
notifications: NotificationHistoryEntry[];
recentCount: number;
}
export const notificationsApi = {
getRecent: (limit?: number) =>
api.get<RecentNotificationsResponse>('/notifications/recent', {
params: limit ? { limit } : undefined,
}),
getHistory: (page?: number, limit?: number) =>
api.get<NotificationHistoryResponse>('/notifications/history', {
params: { page: page || 1, limit: limit || 20 },
}),
getCount: (hours?: number) =>
api.get<{ count: number }>('/notifications/count', {
params: hours ? { hours } : undefined,
}),
};
// Admin API
export interface SystemSettings {
registration_enabled: string;