This commit is contained in:
parent
65c09abd06
commit
f41fa8c3c9
11
src/App.tsx
11
src/App.tsx
@ -1,8 +1,9 @@
|
|||||||
import {useEffect, useState} from 'react'
|
import {useEffect, useState} from 'react'
|
||||||
import './App.css'
|
import './App.css'
|
||||||
|
import {Movie} from "./Models.ts";
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const [movies, setMovies] = useState([])
|
const [movies, setMovies] = useState<Movie[]>([])
|
||||||
const [selectedMovie, setSelectedMovie] = useState("")
|
const [selectedMovie, setSelectedMovie] = useState("")
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetch('http://localhost:8080/movies')
|
fetch('http://localhost:8080/movies')
|
||||||
@ -13,15 +14,15 @@ function App() {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
function sortByYear(a, b): number {
|
function sortByYear(a: Movie, b: Movie): number {
|
||||||
return a.releaseYear < b.releaseYear ? -1 : 1
|
return a.releaseYear < b.releaseYear ? -1 : 1
|
||||||
}
|
}
|
||||||
|
|
||||||
function sortByScreenedDate(a, b): number {
|
function sortByScreenedDate(a: Movie, b: Movie): number {
|
||||||
return a.screenedDate < b.screenedDate ? -1 : 1
|
return a.screenedDate < b.screenedDate ? -1 : 1
|
||||||
}
|
}
|
||||||
|
|
||||||
function sortByTitle(a, b): number {
|
function sortByTitle(a: Movie, b: Movie): number {
|
||||||
return a.title < b.title ? -1 : 1
|
return a.title < b.title ? -1 : 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,7 +46,7 @@ function App() {
|
|||||||
);
|
);
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className={"screened"}>{screenedFormatted}</div><div onClick={} className={"title"}>{movie.title} ({movie.releaseYear})</div>
|
<div className={"screened"}>{screenedFormatted}</div><div onClick={handleMovieSelectionClick} className={"title"}>{movie.title} ({movie.releaseYear})</div>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
interface Movie{
|
export interface Movie {
|
||||||
id: string,
|
id: string,
|
||||||
title: string,
|
title: string,
|
||||||
screenedDate: string,
|
screenedDate: string,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user