From c6e5a9535a118de9b0595906da892a3db4a727f9 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 23 Nov 2025 08:05:41 +0000 Subject: [PATCH] fix: update NotificationPreferences to use new API structure - Update endpoint path from /notification-preferences to /member/notification-preferences - Change PUT request body to use preferences array format - Update types to use Item schema instead of UpdateNotificationPreferencesInputBody --- src/pages/repair/NotificationPreferences.tsx | 21 ++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/pages/repair/NotificationPreferences.tsx b/src/pages/repair/NotificationPreferences.tsx index 852cc6c..aa7e89c 100644 --- a/src/pages/repair/NotificationPreferences.tsx +++ b/src/pages/repair/NotificationPreferences.tsx @@ -4,7 +4,7 @@ import { saturdayClient } from "../../utils/client" import type { components } from "../../types/saturday" type NotificationPreferenceItem = components["schemas"]["NotificationPreferenceItem"] -type UpdateNotificationPreferencesInputBody = components["schemas"]["UpdateNotificationPreferencesInputBody"] +type Item = components["schemas"]["Item"] interface NotificationPreferencesProps { token: string @@ -28,7 +28,7 @@ export default function NotificationPreferences({ token }: NotificationPreferenc setErrorMessage("") try { - const { data, error } = await saturdayClient.GET("/notification-preferences", { + const { data, error } = await saturdayClient.GET("/member/notification-preferences", { params: { header: { Authorization: `Bearer ${token}`, @@ -63,20 +63,21 @@ export default function NotificationPreferences({ token }: NotificationPreferenc )) try { - // Create the request body with all preferences - const requestBody: UpdateNotificationPreferencesInputBody = preferences.reduce((acc, pref) => { - const enabled = pref.notificationType === notificationType ? newValue : pref.enabled - acc[pref.notificationType] = enabled - return acc - }, {} as UpdateNotificationPreferencesInputBody) + // Create the request body with all preferences as an array of Item objects + const preferencesArray: Item[] = preferences.map(pref => ({ + notificationType: pref.notificationType, + enabled: pref.notificationType === notificationType ? newValue : pref.enabled, + })) - const { error } = await saturdayClient.PUT("/notification-preferences", { + const { error } = await saturdayClient.PUT("/member/notification-preferences", { params: { header: { Authorization: `Bearer ${token}`, }, }, - body: requestBody, + body: { + preferences: preferencesArray, + }, }) if (error) {