( templateId: string, queryClient: QueryClient, )
| 112 | }; |
| 113 | |
| 114 | export const updateNotificationTemplateMethod = ( |
| 115 | templateId: string, |
| 116 | queryClient: QueryClient, |
| 117 | ) => { |
| 118 | return { |
| 119 | mutationFn: (req: UpdateNotificationTemplateMethod) => |
| 120 | API.updateNotificationTemplateMethod(templateId, req), |
| 121 | onMutate: (data) => { |
| 122 | const keys = [ |
| 123 | systemNotificationTemplatesKey, |
| 124 | customNotificationTemplatesKey, |
| 125 | ]; |
| 126 | |
| 127 | for (const key of keys) { |
| 128 | const prev = queryClient.getQueryData<NotificationTemplate[]>(key); |
| 129 | if (!prev) { |
| 130 | continue; |
| 131 | } |
| 132 | |
| 133 | queryClient.setQueryData( |
| 134 | key, |
| 135 | prev.map((tpl) => |
| 136 | tpl.id === templateId ? { ...tpl, method: data.method } : tpl, |
| 137 | ), |
| 138 | ); |
| 139 | } |
| 140 | }, |
| 141 | } satisfies UseMutationOptions< |
| 142 | void, |
| 143 | unknown, |
| 144 | UpdateNotificationTemplateMethod |
| 145 | >; |
| 146 | }; |
| 147 | |
| 148 | export const disableNotification = ( |
| 149 | userId: string, |
no test coverage detected