From 3a15a2b2892fe91bc65f8a40be89d8be01af8bd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Kratochv=C3=ADl?= <xkrato10@fi.muni.cz> Date: Fri, 24 Jun 2022 16:04:55 +0200 Subject: [PATCH] feat: SearchPage - fetch result from the API - only non-relational attributes for now --- frontend/src/components/SearchPage.tsx | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/SearchPage.tsx b/frontend/src/components/SearchPage.tsx index 99cc473..31ead7a 100644 --- a/frontend/src/components/SearchPage.tsx +++ b/frontend/src/components/SearchPage.tsx @@ -80,7 +80,28 @@ export const SearchPage = () => { // here will be API call for search on BE, everything needed is in values const onSubmit = async (values: IFormProps) => { - alert(JSON.stringify(values)); + try { + const response = await axiosConfig.get<MovieIO[]>( + `/movies`, + { + params: { + name: values.name, + origName: values.originalName, + runtime: { + gte: values.runTimeMinutes[0], + lte: values.runTimeMinutes[1], + }, + published: { + gte: values.publishedAt[0], + lte: values.publishedAt[1], + }, + } + } + ); + setResultMovies([ ...response.data ]); + } catch { + // TODO: on error + } }; //function that happens when search button is pressed -- GitLab