Front: Play View: Get Score

This commit is contained in:
Arthur Jamet
2023-04-16 14:43:09 +01:00
parent 5a42f098d6
commit 84f91e0d7f
2 changed files with 11 additions and 1 deletions
+3
View File
@@ -43,6 +43,9 @@ services:
build:
context: ./front
dockerfile: Dockerfile.dev
environment:
- SCOROMETER_URL=http://scorometer:6543/
- NGINX_PORT=80
ports:
- "19006:19006"
volumes:
+8 -1
View File
@@ -53,6 +53,7 @@ const PlayView = () => {
const [midiPlayer, setMidiPlayer] = useState<MidiPlayer.Player>();
const [isVirtualPianoVisible, setVirtualPianoVisible] = useState<boolean>(false);
const [time, setTime] = useState(0);
const [score, setScore] = useState(0); // Between 0 and 100
const partitionRessources = useQuery(["partition", songId], () =>
API.getPartitionRessources(songId)
);
@@ -115,6 +116,13 @@ const PlayView = () => {
navigation.navigate('Score', { songId: song.data.id });
return;
}
const points = data.info.score;
const maxPoints = data.info.maxScore;
if (points < 0) {
setScore(0);
} else {
setScore(Math.floor(point / maxPoints) * 100);
}
let formattedMessage = '';
let messageColor: ColorSchemeType | undefined;
@@ -199,7 +207,6 @@ const PlayView = () => {
}
}, [song.data]);
const score = 20;
if (!song.data || !partitionRessources.data) {
return <Center style={{ flexGrow: 1 }}>