Typscript final
This commit is contained in:
@@ -11,8 +11,8 @@ interface TournamentSettings {
|
||||
type: string;
|
||||
timestamp: string;
|
||||
duration: number;
|
||||
courts: any[];
|
||||
teams: any[];
|
||||
courts: { name?: string }[];
|
||||
teams: { name?: string }[];
|
||||
}
|
||||
|
||||
interface TournamentFormProps {
|
||||
@@ -106,12 +106,13 @@ export default function TournamentForm({ tournamentId, onSuccess, onDelete }: To
|
||||
await api.post('/tournaments', fullPayload);
|
||||
}
|
||||
onSuccess();
|
||||
} catch (err: any) {
|
||||
} catch (err: unknown) {
|
||||
console.error(err);
|
||||
if (Array.isArray(err.detail)) {
|
||||
setError(err.detail.map((e: any) => `${e.loc.join('.')}: ${e.msg}`).join(', '));
|
||||
const error = err as { detail?: string | Array<{ loc: string[]; msg: string }> };
|
||||
if (Array.isArray(error.detail)) {
|
||||
setError(error.detail.map((e) => `${e.loc.join('.')}: ${e.msg}`).join(', '));
|
||||
} else {
|
||||
setError(typeof err.detail === 'string' ? err.detail : "Error saving tournament");
|
||||
setError(typeof error.detail === 'string' ? error.detail : "Error saving tournament");
|
||||
}
|
||||
} finally {
|
||||
setIsSubmitting(false);
|
||||
|
||||
Reference in New Issue
Block a user