Skip to content
Snippets Groups Projects
Commit 7fc5ca10 authored by Lukáš Kratochvíl's avatar Lukáš Kratochvíl
Browse files

fix: SearchPage - more efficient inititial fetching of categories and directors

parent 40ba824a
No related branches found
No related tags found
No related merge requests found
......@@ -65,11 +65,11 @@ export const SearchPage = () => {
useEffect(() => {
const fetchData = async () => {
try {
const response = await axiosConfig.get<CategoryIO[]>('/categories');
setCategories([ ...response.data ]);
const catResponsePromise = axiosConfig.get<CategoryIO[]>('/categories');
const dirResponsePromise = axiosConfig.get<DirectorIO[]>('/directors');
const dirResponse = await axiosConfig.get<DirectorIO[]>('/directors');
setDirectors([ ...dirResponse.data ]);
setCategories([ ...((await catResponsePromise).data) ]);
setDirectors([ ...((await dirResponsePromise).data) ]);
} catch {
}
......@@ -78,7 +78,6 @@ export const SearchPage = () => {
void fetchData();
}, []);
// here will be API call for search on BE, everything needed is in values
const onSubmit = async (values: IFormProps) => {
try {
const response = await axiosConfig.get<MovieIO[]>(
......@@ -116,6 +115,7 @@ export const SearchPage = () => {
const onReset = () => {
form.resetFields();
};
//columns stays the same
const columns = [
{
......@@ -345,9 +345,9 @@ export const SearchPage = () => {
onRow={(record, rowIndex) => {
return {
onClick: (event) => {
console.log(record.id); //remove later
console.log(record.id); // TODO: remove later
},
}; //here change to view movie
}; // TODO: here change to view movie
}}
columns={columns}
dataSource={resultMovies}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment