( userId: string, queryClient: QueryClient, )
| 22 | }; |
| 23 | |
| 24 | export const updateUserNotificationPreferences = ( |
| 25 | userId: string, |
| 26 | queryClient: QueryClient, |
| 27 | ) => { |
| 28 | return { |
| 29 | mutationFn: (req) => { |
| 30 | return API.putUserNotificationPreferences(userId, req); |
| 31 | }, |
| 32 | onMutate: (data) => { |
| 33 | queryClient.setQueryData( |
| 34 | userNotificationPreferencesKey(userId), |
| 35 | Object.entries(data.template_disabled_map).map( |
| 36 | ([id, disabled]) => |
| 37 | ({ |
| 38 | id, |
| 39 | disabled, |
| 40 | updated_at: new Date().toISOString(), |
| 41 | }) satisfies NotificationPreference, |
| 42 | ), |
| 43 | ); |
| 44 | }, |
| 45 | } satisfies UseMutationOptions< |
| 46 | NotificationPreference[], |
| 47 | unknown, |
| 48 | UpdateUserNotificationPreferences |
| 49 | >; |
| 50 | }; |
| 51 | |
| 52 | export const systemNotificationTemplatesKey = [ |
| 53 | "notifications", |
no test coverage detected