Shoraky commited on
Commit
7bc8a26
·
1 Parent(s): 2e69b0d

Clarify missing player error for admins

Browse files
Files changed (1) hide show
  1. src/analysis.ts +3 -1
src/analysis.ts CHANGED
@@ -69,7 +69,9 @@ export function analysisRouter(db: SupabaseClient, secret: string, onCompleted?:
69
  if (!isAdmin) playerQuery = playerQuery.eq("user_id", userId);
70
  const { data: player, error: playerError } = await playerQuery.maybeSingle();
71
  if (playerError) return res.status(503).json({ error: "Unable to verify the selected player." });
72
- if (!player) return res.status(404).json({ error: "Choose a player from your own roster before starting analysis." });
 
 
73
  if (isAdmin) {
74
  const { error } = await db.rpc("admin_create_analysis_session", {
75
  p_session_id: input.clientId,
 
69
  if (!isAdmin) playerQuery = playerQuery.eq("user_id", userId);
70
  const { data: player, error: playerError } = await playerQuery.maybeSingle();
71
  if (playerError) return res.status(503).json({ error: "Unable to verify the selected player." });
72
+ if (!player) return res.status(404).json({ error: isAdmin
73
+ ? "The selected player was not found. Refresh the player list and try again."
74
+ : "Choose a player from your own roster before starting analysis." });
75
  if (isAdmin) {
76
  const { error } = await db.rpc("admin_create_analysis_session", {
77
  p_session_id: input.clientId,