import AsyncStorage from '@react-native-async-storage/async-storage'; const VIEWED_NOTIFICATIONS_KEY = '@viewed_notifications'; interface ViewedNotification { id: string; type: 'reservation' | 'promotion'; viewedAt: string; } export const notificationStorage = { async markAsViewed(id: string, type: 'reservation' | 'promotion'): Promise { try { const existing = await this.getViewedNotifications(); const newViewed: ViewedNotification = { id, type, viewedAt: new Date().toISOString() }; const updated = [...existing, newViewed]; await AsyncStorage.setItem(VIEWED_NOTIFICATIONS_KEY, JSON.stringify(updated)); } catch (error) { console.error('Error marking notification as viewed:', error); } }, async getViewedNotifications(): Promise { try { const viewed = await AsyncStorage.getItem(VIEWED_NOTIFICATIONS_KEY); return viewed ? JSON.parse(viewed) : []; } catch (error) { console.error('Error getting viewed notifications:', error); return []; } }, async isNotificationViewed(id: string): Promise { const viewed = await this.getViewedNotifications(); return viewed.some((notification) => notification.id === id); }, async seeAllCurrentStorage() { const viewed = await this.getViewedNotifications(); return viewed; }, async clearStorage() { await AsyncStorage.removeItem(VIEWED_NOTIFICATIONS_KEY); } };