blob: c61c2aa72b51dcc9c9e6a1d69a4a1ef8eaa81830 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
import supabase from './supabase';
export interface UserNotifications {
created_at: string;
updated_at: string;
user_id: number;
subscription: JSON;
}
export const getUserSubscription = async (userId: number) =>
await supabase.from('user_notifications').select('*').eq('user_id', userId);
export const getUserSubscriptions = async () => {
const { data, error } = await supabase.from('user_notifications').select('*');
if (error) return [];
return data as UserNotifications[];
};
export const setUserSubscription = async (userId: number, subscription: JSON) =>
await supabase.from('user_notifications').upsert(
{
user_id: userId,
updated_at: new Date().toISOString(),
subscription: subscription
},
{ onConflict: 'user_id' }
);
|