✨ error handling and new start.sh-file
Co-authored-by: Sindre Kjelsrud <kjelsrudsindre@gmail.com>
This commit is contained in:
parent
faf1de7f44
commit
2270e1c026
4 changed files with 25 additions and 7 deletions
|
@ -1,4 +0,0 @@
|
||||||
docker-compose up -d
|
|
||||||
|
|
||||||
cd cinemateket
|
|
||||||
dotnet run
|
|
|
@ -14,6 +14,7 @@ function App() {
|
||||||
const [totalPages, setTotalPages] = useState(0)
|
const [totalPages, setTotalPages] = useState(0)
|
||||||
const [modalOpen, setModalOpen] = useState(false)
|
const [modalOpen, setModalOpen] = useState(false)
|
||||||
const [modalMovie, setModalMovie] = useState<movieObject | null>(null)
|
const [modalMovie, setModalMovie] = useState<movieObject | null>(null)
|
||||||
|
const [message, setMessage] = useState('Find a list of movies by searching above ☝️')
|
||||||
const navigateToPage = useNavigateToPage()
|
const navigateToPage = useNavigateToPage()
|
||||||
const searchParams = new URLSearchParams(window.location.search)
|
const searchParams = new URLSearchParams(window.location.search)
|
||||||
const [movieTitle, setMovieTitle] = useState(searchParams.get('s') || '')
|
const [movieTitle, setMovieTitle] = useState(searchParams.get('s') || '')
|
||||||
|
@ -26,6 +27,14 @@ function App() {
|
||||||
const handleFetchMovie = async () => {
|
const handleFetchMovie = async () => {
|
||||||
const response = await fetchMovie(title, page, type, year)
|
const response = await fetchMovie(title, page, type, year)
|
||||||
console.log(year)
|
console.log(year)
|
||||||
|
if (response == undefined) {
|
||||||
|
setMovies([])
|
||||||
|
setTotalPages(0)
|
||||||
|
setCurrentPage(1)
|
||||||
|
setLoading(false)
|
||||||
|
setMessage("We unfortunately didn't have any movies matching your search 😭")
|
||||||
|
return
|
||||||
|
}
|
||||||
if (response.response == 'OK') {
|
if (response.response == 'OK') {
|
||||||
setMovies(response.search)
|
setMovies(response.search)
|
||||||
setTotalPages(Number(response.totalResults))
|
setTotalPages(Number(response.totalResults))
|
||||||
|
@ -118,7 +127,7 @@ function App() {
|
||||||
) : movies.length > 0 ? (
|
) : movies.length > 0 ? (
|
||||||
<MovieTable {...{ handleModalOpen, sortHandler, movies }} />
|
<MovieTable {...{ handleModalOpen, sortHandler, movies }} />
|
||||||
) : (
|
) : (
|
||||||
<q.h2>Find a list of movies by searching above ☝️ </q.h2>
|
<q.h2>{message}</q.h2>
|
||||||
)}
|
)}
|
||||||
</q.div>
|
</q.div>
|
||||||
</q.div>
|
</q.div>
|
||||||
|
|
|
@ -7,8 +7,8 @@ export const fetchMovie = async (
|
||||||
page: string = '1',
|
page: string = '1',
|
||||||
type?: string,
|
type?: string,
|
||||||
year?: string
|
year?: string
|
||||||
): Promise<movieResponse> => {
|
): Promise<movieResponse>=> {
|
||||||
let query = `http://localhost:5212/movie?s=${title}&page=${page}`
|
let query = `http://localhost:5212/movie?s=${title}&pageNumber=${page}`
|
||||||
|
|
||||||
if (type) query += `&type=${type}`
|
if (type) query += `&type=${type}`
|
||||||
if (year) query += `&y=${year}`
|
if (year) query += `&y=${year}`
|
||||||
|
|
13
start.sh
Normal file
13
start.sh
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
# backend
|
||||||
|
cd backend
|
||||||
|
docker-compose up -d
|
||||||
|
|
||||||
|
cd cinemateket
|
||||||
|
dotnet run &
|
||||||
|
|
||||||
|
cd ../..
|
||||||
|
|
||||||
|
# frontend
|
||||||
|
cd frontend
|
||||||
|
npm install
|
||||||
|
npm run dev
|
Reference in a new issue