import React from "react";
import { Song } from "../../types/song";
import { GuessType } from "../../types/guess";
import { scoreToEmoji } from "../../helpers";
import { Button } from "../Button";
import { MiniYouTubePlayer } from "../MiniYouTubePlayer";
import * as Styled from "./index.styled";
interface Props {
didGuess: boolean;
currentTry: number;
todaysSolution: Song;
guesses: GuessType[];
}
export function Result({
didGuess,
todaysSolution,
guesses,
currentTry,
}: Props) {
const hoursToNextDay = Math.floor(
(new Date(new Date().setHours(24, 0, 0, 0)).getTime() -
new Date().getTime()) /
1000 /
60 /
60
);
const copyResult = React.useCallback(() => {
navigator.clipboard.writeText(scoreToEmoji(guesses));
}, [guesses]);
if (didGuess) {
const textForTry = ["Perfect!", "Wow!", "Super!", "Congrats!", "Nice!"];
return (
<>
{textForTry[currentTry - 1]}
Today's song is {todaysSolution.artist} - {todaysSolution.name}
You guessed it in {currentTry} {currentTry === 1 ? 'try' : 'tries'}.
Remember to come back in {hoursToNextDay} hours!
>
);
} else {
return (
<>
Unfortunately, thats wrong.
Today's song is {todaysSolution.artist} - {todaysSolution.name}
Try again in {hoursToNextDay} hours.
>
);
}
}