better bracket, player stats in pb
This commit is contained in:
@@ -30,7 +30,12 @@ export const MatchCard: React.FC<MatchCardProps> = ({
|
||||
from_loser: match.home_from_loser,
|
||||
team: match.home,
|
||||
seed: match.home_seed,
|
||||
cups: match.status === "ended" ? match.home_cups : undefined
|
||||
cups: match.status === "ended" ? match.home_cups : undefined,
|
||||
isWinner:
|
||||
match.status === "ended" &&
|
||||
match.home_cups !== undefined &&
|
||||
match.away_cups !== undefined &&
|
||||
match.home_cups > match.away_cups,
|
||||
}),
|
||||
[match]
|
||||
);
|
||||
@@ -40,7 +45,12 @@ export const MatchCard: React.FC<MatchCardProps> = ({
|
||||
from_loser: match.away_from_loser,
|
||||
team: match.away,
|
||||
seed: match.away_seed,
|
||||
cups: match.status === "ended" ? match.away_cups : undefined
|
||||
cups: match.status === "ended" ? match.away_cups : undefined,
|
||||
isWinner:
|
||||
match.status === "ended" &&
|
||||
match.away_cups !== undefined &&
|
||||
match.home_cups !== undefined &&
|
||||
match.away_cups > match.home_cups,
|
||||
}),
|
||||
[match]
|
||||
);
|
||||
@@ -81,37 +91,45 @@ export const MatchCard: React.FC<MatchCardProps> = ({
|
||||
}, [match]);
|
||||
|
||||
const handleFormSubmit = useCallback(
|
||||
async (data: { home_cups: number; away_cups: number; ot_count: number }) => {
|
||||
await end.mutate({ data: {
|
||||
...data,
|
||||
matchId: match.id
|
||||
}});
|
||||
async (data: {
|
||||
home_cups: number;
|
||||
away_cups: number;
|
||||
ot_count: number;
|
||||
}) => {
|
||||
await end.mutate({
|
||||
data: {
|
||||
...data,
|
||||
matchId: match.id,
|
||||
},
|
||||
});
|
||||
editSheet.close();
|
||||
},
|
||||
[match.id, editSheet]
|
||||
);
|
||||
|
||||
const handleSpeakerClick = useCallback(() => {
|
||||
if ('speechSynthesis' in window && match.home?.name && match.away?.name) {
|
||||
if ("speechSynthesis" in window && match.home?.name && match.away?.name) {
|
||||
const utterance = new SpeechSynthesisUtterance(
|
||||
`${match.home.name} vs. ${match.away.name}`
|
||||
);
|
||||
|
||||
|
||||
const voices = window.speechSynthesis.getVoices();
|
||||
|
||||
const preferredVoice = voices.find(voice =>
|
||||
voice.lang.startsWith('en') &&
|
||||
voice.name.includes('Daniel')
|
||||
) || voices.find(voice => voice.lang.startsWith('en') && voice.default);
|
||||
|
||||
|
||||
const preferredVoice =
|
||||
voices.find(
|
||||
(voice) =>
|
||||
voice.lang.startsWith("en") && voice.name.includes("Daniel")
|
||||
) ||
|
||||
voices.find((voice) => voice.lang.startsWith("en") && voice.default);
|
||||
|
||||
if (preferredVoice) {
|
||||
utterance.voice = preferredVoice;
|
||||
}
|
||||
|
||||
|
||||
utterance.rate = 0.9;
|
||||
utterance.volume = 0.8;
|
||||
utterance.pitch = 1.0;
|
||||
|
||||
|
||||
window.speechSynthesis.speak(utterance);
|
||||
}
|
||||
}, [match.home?.name, match.away?.name]);
|
||||
@@ -157,17 +175,19 @@ export const MatchCard: React.FC<MatchCardProps> = ({
|
||||
</Text>
|
||||
)}
|
||||
|
||||
<ActionIcon
|
||||
pos="absolute"
|
||||
bottom={-2}
|
||||
left={-26}
|
||||
size="sm"
|
||||
variant="subtle"
|
||||
color="gray"
|
||||
onClick={handleSpeakerClick}
|
||||
>
|
||||
<SpeakerHighIcon size={12} />
|
||||
</ActionIcon>
|
||||
{showControls && (
|
||||
<ActionIcon
|
||||
pos="absolute"
|
||||
bottom={-2}
|
||||
left={-26}
|
||||
size="sm"
|
||||
variant="subtle"
|
||||
color="gray"
|
||||
onClick={handleSpeakerClick}
|
||||
>
|
||||
<SpeakerHighIcon size={12} />
|
||||
</ActionIcon>
|
||||
)}
|
||||
</Card>
|
||||
</Indicator>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user