Skip to content

Commit fc50db2

Browse files
mchestrclaude
andcommitted
fix: address PR feedback - accessibility and centralized logging
- Add aria-label to toggle buttons for screen reader accessibility - Replace console.error with centralized logger in watchlist actions Co-Authored-By: Claude <[email protected]>
1 parent a9f5475 commit fc50db2

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

actions/admin/watchlist.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
import { authOptions } from "@/lib/auth"
44
import { prisma } from "@/lib/prisma"
55
import { requireAdmin } from "@/lib/admin"
6+
import { createLogger } from "@/lib/utils/logger"
67
import { globalWatchlistSyncSettingsSchema } from "@/lib/validations/watchlist"
78
import { syncUserWatchlist } from "@/lib/watchlist/sync-service"
89
import { getServerSession } from "next-auth"
910

11+
const logger = createLogger("ADMIN_WATCHLIST_ACTIONS")
12+
1013
/**
1114
* Get global watchlist sync settings (admin only)
1215
*/
@@ -33,7 +36,7 @@ export async function getGlobalWatchlistSyncSettings() {
3336
},
3437
}
3538
} catch (error) {
36-
console.error("Error fetching global watchlist sync settings:", error)
39+
logger.error("Error fetching global watchlist sync settings", error)
3740
return { success: false as const, error: "Failed to fetch settings" }
3841
}
3942
}
@@ -86,7 +89,7 @@ export async function updateGlobalWatchlistSyncSettings(data: unknown) {
8689

8790
return { success: true as const }
8891
} catch (error) {
89-
console.error("Error updating global watchlist sync settings:", error)
92+
logger.error("Error updating global watchlist sync settings", error)
9093
return { success: false as const, error: "Failed to update settings" }
9194
}
9295
}
@@ -136,7 +139,7 @@ export async function getWatchlistSyncStats() {
136139
},
137140
}
138141
} catch (error) {
139-
console.error("Error fetching watchlist sync stats:", error)
142+
logger.error("Error fetching watchlist sync stats", error)
140143
return { success: false as const, error: "Failed to fetch stats" }
141144
}
142145
}
@@ -173,7 +176,7 @@ export async function forceUserWatchlistSync(userId: string) {
173176
data: result.data,
174177
}
175178
} catch (error) {
176-
console.error("Error forcing user watchlist sync:", error)
179+
logger.error("Error forcing user watchlist sync", error)
177180
return { success: false as const, error: "Failed to sync" }
178181
}
179182
}

actions/watchlist.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22

33
import { WatchlistSyncStatus } from "@/lib/generated/prisma/client"
44
import { prisma } from "@/lib/prisma"
5+
import { createLogger } from "@/lib/utils/logger"
56
import { updateWatchlistSyncSettingsSchema } from "@/lib/validations/watchlist"
67
import { syncUserWatchlist } from "@/lib/watchlist/sync-service"
78
import { getServerSession } from "next-auth"
89
import { authOptions } from "@/lib/auth"
910

11+
const logger = createLogger("WATCHLIST_ACTIONS")
12+
1013
/**
1114
* Get current user's watchlist sync settings and status
1215
*/
@@ -86,7 +89,7 @@ export async function getWatchlistSyncSettings() {
8689
},
8790
}
8891
} catch (error) {
89-
console.error("Error fetching watchlist sync settings:", error)
92+
logger.error("Error fetching watchlist sync settings", error)
9093
return { success: false as const, error: "Failed to fetch settings" }
9194
}
9295
}
@@ -159,7 +162,7 @@ export async function updateWatchlistSyncSettings(data: unknown) {
159162

160163
return { success: true as const }
161164
} catch (error) {
162-
console.error("Error updating watchlist sync settings:", error)
165+
logger.error("Error updating watchlist sync settings", error)
163166
return { success: false as const, error: "Failed to update settings" }
164167
}
165168
}
@@ -195,7 +198,7 @@ export async function triggerWatchlistSync() {
195198
data: result.data,
196199
}
197200
} catch (error) {
198-
console.error("Error triggering watchlist sync:", error)
201+
logger.error("Error triggering watchlist sync", error)
199202
return { success: false as const, error: "Failed to trigger sync" }
200203
}
201204
}
@@ -251,7 +254,7 @@ export async function getWatchlistSyncHistory(options?: {
251254
},
252255
}
253256
} catch (error) {
254-
console.error("Error fetching watchlist sync history:", error)
257+
logger.error("Error fetching watchlist sync history", error)
255258
return { success: false as const, error: "Failed to fetch history" }
256259
}
257260
}

components/admin/settings/watchlist-sync-settings.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ export function WatchlistSyncSettings() {
157157
`}
158158
role="switch"
159159
aria-checked={settings.watchlistSyncEnabled}
160+
aria-label={settings.watchlistSyncEnabled ? "Disable watchlist sync" : "Enable watchlist sync"}
160161
data-testid="watchlist-sync-global-toggle"
161162
>
162163
<span

components/watchlist/sync-settings-card.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ export function WatchlistSyncCard() {
202202
`}
203203
role="switch"
204204
aria-checked={isEnabled}
205+
aria-label={isEnabled ? "Disable watchlist sync" : "Enable watchlist sync"}
205206
data-testid="watchlist-sync-toggle"
206207
>
207208
<span

0 commit comments

Comments
 (0)