Skip to content

Commit

Permalink
SMA-108: fixed the date
Browse files Browse the repository at this point in the history
  • Loading branch information
ivamach committed Apr 29, 2024
1 parent 0e9bd08 commit 501f8c6
Showing 1 changed file with 18 additions and 24 deletions.
42 changes: 18 additions & 24 deletions frontend/sportsmatch-app/src/components/RateGameComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default function RateGameComponent(p: Props) {
console.error(error as ApiError)
}
}
init()
init()

Check failure on line 37 in frontend/sportsmatch-app/src/components/RateGameComponent.tsx

View workflow job for this annotation

GitHub Actions / test

Delete `····`
})

useEffect(() => {
Expand All @@ -53,21 +53,6 @@ export default function RateGameComponent(p: Props) {
init()
}, [])

const dayOfTheWeek = (year: number, month: number, day: number) => {
const daysOfTheWeek = [
'Sunday',
'Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday',
'Saturday',
]
const date = new Date(year, month - 1, day)
const dateIndex = date.getDay()
return daysOfTheWeek[dateIndex]
}

const userProfilePicture = 'pictures/unknown-user-placeholder.png'
const opponentProfilePicture = 'pictures/unknown-user-placeholder.png'

Expand Down Expand Up @@ -106,6 +91,18 @@ export default function RateGameComponent(p: Props) {
const value = parseInt(e.target.value) || 0
setOpponentScore(value)
}

const getDateAndTime = (type: string, date: string) => {
const dateStart: string[] = date.split(' ')
if (type === 'date') {
return dateStart[0]
} else if (type === 'time') {
return dateStart[1]
} else {
return null
}
}

return (
<>
<div className="container-sm rate-game-window-wrapper">
Expand All @@ -117,14 +114,11 @@ export default function RateGameComponent(p: Props) {
{myEvent ? (
<>
<span>
{dayOfTheWeek(
parseInt(myEvent.dateStart[0]),
parseInt(myEvent.dateStart[1]),
parseInt(myEvent.dateStart[2]),
)}
, {myEvent.dateStart[3]}:{myEvent.dateStart[4]}
{' - '}
{myEvent.dateEnd[3]}:{myEvent.dateEnd[4]}
{'on ' + getDateAndTime('date', myEvent.dateStart) +

Check failure on line 117 in frontend/sportsmatch-app/src/components/RateGameComponent.tsx

View workflow job for this annotation

GitHub Actions / test

Insert `⏎···················`
' at ' +
getDateAndTime('time', myEvent.dateStart) +
' - ' +
getDateAndTime('time', myEvent.dateEnd)}
</span>
<br />
<span>{myEvent.placeDTO?.name}</span>{' '}
Expand Down

0 comments on commit 501f8c6

Please sign in to comment.