Rimuove i dati dummy della classifica e usa i risultati CSI reali

La classifica e lo storico partite mostravano dati inventati (squadre e
risultati finti) come base, poi sovrascritti dai dati CSI quando
disponibili. Ora classifica, ultimi risultati, storico match e obiettivi
di squadra legati alle vittorie usano solo dati reali (CSI o scout live),
con stati vuoti quando i dati CSI non sono ancora disponibili.

Include anche la correzione di tutti gli errori di formattazione
prettier segnalati da `npm run lint` sul resto del codice sorgente.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-01 13:38:33 +02:00
co-authored by Claude Sonnet 5
parent d813dee282
commit 0a04025fe9
55 changed files with 1038 additions and 879 deletions
+7 -7
View File
@@ -1,15 +1,15 @@
// This file is automatically generated. Do not edit it directly.
import { createMiddleware } from '@tanstack/react-start'
import { supabase } from './client'
import { createMiddleware } from "@tanstack/react-start";
import { supabase } from "./client";
// Must be registered as a global `functionMiddleware` in `src/start.ts`; otherwise
// the browser never attaches the bearer token to serverFn RPCs.
export const attachSupabaseAuth = createMiddleware({ type: 'function' }).client(
export const attachSupabaseAuth = createMiddleware({ type: "function" }).client(
async ({ next }) => {
const { data } = await supabase.auth.getSession()
const token = data.session?.access_token
const { data } = await supabase.auth.getSession();
const token = data.session?.access_token;
return next({
headers: token ? { Authorization: `Bearer ${token}` } : {},
})
});
},
)
);
+42 -46
View File
@@ -1,19 +1,17 @@
// This file is automatically generated. Do not edit it directly.
import { createMiddleware } from '@tanstack/react-start'
import { getRequest } from '@tanstack/react-start/server'
import { createClient } from '@supabase/supabase-js'
import type { Database } from './types'
import { createMiddleware } from "@tanstack/react-start";
import { getRequest } from "@tanstack/react-start/server";
import { createClient } from "@supabase/supabase-js";
import type { Database } from "./types";
function isNewSupabaseApiKey(value: string): boolean {
return value.startsWith('sb_publishable_') || value.startsWith('sb_secret_');
return value.startsWith("sb_publishable_") || value.startsWith("sb_secret_");
}
function createSupabaseFetch(supabaseKey: string): typeof fetch {
return (input, init) => {
const headers = new Headers(
typeof Request !== 'undefined' && input instanceof Request ? input.headers : undefined,
typeof Request !== "undefined" && input instanceof Request ? input.headers : undefined,
);
if (init?.headers) {
@@ -21,81 +19,79 @@ function createSupabaseFetch(supabaseKey: string): typeof fetch {
}
// New Supabase API keys are opaque strings, not bearer JWTs.
if (isNewSupabaseApiKey(supabaseKey) && headers.get('Authorization') === `Bearer ${supabaseKey}`) {
headers.delete('Authorization');
if (
isNewSupabaseApiKey(supabaseKey) &&
headers.get("Authorization") === `Bearer ${supabaseKey}`
) {
headers.delete("Authorization");
}
headers.set('apikey', supabaseKey);
headers.set("apikey", supabaseKey);
return fetch(input, { ...init, headers });
};
}
export const requireSupabaseAuth = createMiddleware({ type: 'function' }).server(
export const requireSupabaseAuth = createMiddleware({ type: "function" }).server(
async ({ next }) => {
const SUPABASE_URL = process.env['SUPABASE_URL'];
const SUPABASE_PUBLISHABLE_KEY = process.env['SUPABASE_PUBLISHABLE_KEY'];
const SUPABASE_URL = process.env["SUPABASE_URL"];
const SUPABASE_PUBLISHABLE_KEY = process.env["SUPABASE_PUBLISHABLE_KEY"];
if (!SUPABASE_URL || !SUPABASE_PUBLISHABLE_KEY) {
const missing = [
...(!SUPABASE_URL ? ['SUPABASE_URL'] : []),
...(!SUPABASE_PUBLISHABLE_KEY ? ['SUPABASE_PUBLISHABLE_KEY'] : []),
...(!SUPABASE_URL ? ["SUPABASE_URL"] : []),
...(!SUPABASE_PUBLISHABLE_KEY ? ["SUPABASE_PUBLISHABLE_KEY"] : []),
];
const message = `Missing Supabase environment variable(s): ${missing.join(', ')}. Connect Supabase in Lovable Cloud.`;
const message = `Missing Supabase environment variable(s): ${missing.join(", ")}. Connect Supabase in Lovable Cloud.`;
console.error(`[Supabase] ${message}`);
throw new Error(message);
}
const request = getRequest();
if (!request?.headers) {
throw new Error('Unauthorized: No request headers available');
throw new Error("Unauthorized: No request headers available");
}
const authHeader = request.headers.get('authorization');
const authHeader = request.headers.get("authorization");
if (!authHeader) {
throw new Error('Unauthorized: No authorization header provided');
throw new Error("Unauthorized: No authorization header provided");
}
if (!authHeader.startsWith('Bearer ')) {
throw new Error('Unauthorized: Only Bearer tokens are supported');
if (!authHeader.startsWith("Bearer ")) {
throw new Error("Unauthorized: Only Bearer tokens are supported");
}
const token = authHeader.replace('Bearer ', '');
const token = authHeader.replace("Bearer ", "");
if (!token) {
throw new Error('Unauthorized: No token provided');
throw new Error("Unauthorized: No token provided");
}
if (token.split('.').length !== 3) {
throw new Error('Unauthorized: Invalid token');
if (token.split(".").length !== 3) {
throw new Error("Unauthorized: Invalid token");
}
const supabase = createClient<Database>(
SUPABASE_URL!,
SUPABASE_PUBLISHABLE_KEY!,
{
global: {
fetch: createSupabaseFetch(SUPABASE_PUBLISHABLE_KEY!),
headers: {
Authorization: `Bearer ${token}`,
},
const supabase = createClient<Database>(SUPABASE_URL!, SUPABASE_PUBLISHABLE_KEY!, {
global: {
fetch: createSupabaseFetch(SUPABASE_PUBLISHABLE_KEY!),
headers: {
Authorization: `Bearer ${token}`,
},
auth: {
storage: undefined,
persistSession: false,
autoRefreshToken: false,
},
}
);
},
auth: {
storage: undefined,
persistSession: false,
autoRefreshToken: false,
},
});
const { data, error } = await supabase.auth.getClaims(token);
if (error || !data?.claims) {
throw new Error('Unauthorized: Invalid token');
throw new Error("Unauthorized: Invalid token");
}
if (!data.claims.sub) {
throw new Error('Unauthorized: No user ID found in token');
throw new Error("Unauthorized: No user ID found in token");
}
return next({
+16 -13
View File
@@ -2,17 +2,17 @@
// Server-side Supabase client with service role key - bypasses RLS.
// Use this for admin operations in server functions and server routes only.
// For user-authenticated queries (with RLS), use the auth middleware instead.
import { createClient } from '@supabase/supabase-js';
import type { Database } from './types';
import { createClient } from "@supabase/supabase-js";
import type { Database } from "./types";
function isNewSupabaseApiKey(value: string): boolean {
return value.startsWith('sb_publishable_') || value.startsWith('sb_secret_');
return value.startsWith("sb_publishable_") || value.startsWith("sb_secret_");
}
function createSupabaseFetch(supabaseKey: string): typeof fetch {
return (input, init) => {
const headers = new Headers(
typeof Request !== 'undefined' && input instanceof Request ? input.headers : undefined,
typeof Request !== "undefined" && input instanceof Request ? input.headers : undefined,
);
if (init?.headers) {
@@ -20,25 +20,28 @@ function createSupabaseFetch(supabaseKey: string): typeof fetch {
}
// New Supabase API keys are opaque strings, not bearer JWTs.
if (isNewSupabaseApiKey(supabaseKey) && headers.get('Authorization') === `Bearer ${supabaseKey}`) {
headers.delete('Authorization');
if (
isNewSupabaseApiKey(supabaseKey) &&
headers.get("Authorization") === `Bearer ${supabaseKey}`
) {
headers.delete("Authorization");
}
headers.set('apikey', supabaseKey);
headers.set("apikey", supabaseKey);
return fetch(input, { ...init, headers });
};
}
function createSupabaseAdminClient() {
const SUPABASE_URL = process.env['SUPABASE_URL'];
const SUPABASE_SERVICE_ROLE_KEY = process.env['SUPABASE_SERVICE_ROLE_KEY'];
const SUPABASE_URL = process.env["SUPABASE_URL"];
const SUPABASE_SERVICE_ROLE_KEY = process.env["SUPABASE_SERVICE_ROLE_KEY"];
if (!SUPABASE_URL || !SUPABASE_SERVICE_ROLE_KEY) {
const missing = [
...(!SUPABASE_URL ? ['SUPABASE_URL'] : []),
...(!SUPABASE_SERVICE_ROLE_KEY ? ['SUPABASE_SERVICE_ROLE_KEY'] : []),
...(!SUPABASE_URL ? ["SUPABASE_URL"] : []),
...(!SUPABASE_SERVICE_ROLE_KEY ? ["SUPABASE_SERVICE_ROLE_KEY"] : []),
];
const message = `Missing Supabase environment variable(s): ${missing.join(', ')}. Connect Supabase in Lovable Cloud.`;
const message = `Missing Supabase environment variable(s): ${missing.join(", ")}. Connect Supabase in Lovable Cloud.`;
console.error(`[Supabase] ${message}`);
throw new Error(message);
}
@@ -51,7 +54,7 @@ function createSupabaseAdminClient() {
storage: undefined,
persistSession: false,
autoRefreshToken: false,
}
},
});
}
+18 -16
View File
@@ -1,15 +1,15 @@
// This file is automatically generated. Do not edit it directly.
import { createClient } from '@supabase/supabase-js';
import type { Database } from './types';
import { createClient } from "@supabase/supabase-js";
import type { Database } from "./types";
function isNewSupabaseApiKey(value: string): boolean {
return value.startsWith('sb_publishable_') || value.startsWith('sb_secret_');
return value.startsWith("sb_publishable_") || value.startsWith("sb_secret_");
}
function createSupabaseFetch(supabaseKey: string): typeof fetch {
return (input, init) => {
const headers = new Headers(
typeof Request !== 'undefined' && input instanceof Request ? input.headers : undefined,
typeof Request !== "undefined" && input instanceof Request ? input.headers : undefined,
);
if (init?.headers) {
@@ -17,28 +17,31 @@ function createSupabaseFetch(supabaseKey: string): typeof fetch {
}
// New Supabase API keys are opaque strings, not bearer JWTs.
if (isNewSupabaseApiKey(supabaseKey) && headers.get('Authorization') === `Bearer ${supabaseKey}`) {
headers.delete('Authorization');
if (
isNewSupabaseApiKey(supabaseKey) &&
headers.get("Authorization") === `Bearer ${supabaseKey}`
) {
headers.delete("Authorization");
}
headers.set('apikey', supabaseKey);
headers.set("apikey", supabaseKey);
return fetch(input, { ...init, headers });
};
}
function createSupabaseClient() {
// Use import.meta.env for client-side (Vite build-time replacement)
// Fall back to process.env for SSR (server-side rendering)
const SUPABASE_URL = import.meta.env['VITE_SUPABASE_URL'] || process.env['SUPABASE_URL'];
const SUPABASE_PUBLISHABLE_KEY = import.meta.env['VITE_SUPABASE_PUBLISHABLE_KEY'] || process.env['SUPABASE_PUBLISHABLE_KEY'];
const SUPABASE_URL = import.meta.env["VITE_SUPABASE_URL"] || process.env["SUPABASE_URL"];
const SUPABASE_PUBLISHABLE_KEY =
import.meta.env["VITE_SUPABASE_PUBLISHABLE_KEY"] || process.env["SUPABASE_PUBLISHABLE_KEY"];
if (!SUPABASE_URL || !SUPABASE_PUBLISHABLE_KEY) {
const missing = [
...(!SUPABASE_URL ? ['SUPABASE_URL'] : []),
...(!SUPABASE_PUBLISHABLE_KEY ? ['SUPABASE_PUBLISHABLE_KEY'] : []),
...(!SUPABASE_URL ? ["SUPABASE_URL"] : []),
...(!SUPABASE_PUBLISHABLE_KEY ? ["SUPABASE_PUBLISHABLE_KEY"] : []),
];
const message = `Missing Supabase environment variable(s): ${missing.join(', ')}. Connect Supabase in Lovable Cloud.`;
const message = `Missing Supabase environment variable(s): ${missing.join(", ")}. Connect Supabase in Lovable Cloud.`;
console.error(`[Supabase] ${message}`);
throw new Error(message);
}
@@ -48,10 +51,10 @@ function createSupabaseClient() {
fetch: createSupabaseFetch(SUPABASE_PUBLISHABLE_KEY),
},
auth: {
storage: typeof window !== 'undefined' ? localStorage : undefined,
storage: typeof window !== "undefined" ? localStorage : undefined,
persistSession: true,
autoRefreshToken: true,
}
},
});
}
@@ -65,4 +68,3 @@ export const supabase = new Proxy({} as ReturnType<typeof createSupabaseClient>,
return Reflect.get(_supabase, prop, receiver);
},
});
File diff suppressed because it is too large Load Diff