Small refactor
This commit is contained in:
commit
34d7f9a14e
@ -4,8 +4,8 @@ import { Input } from "@material-ui/core";
|
||||
import "./index.scss";
|
||||
import ClickAwayListener from "@material-ui/core/ClickAwayListener";
|
||||
import { LecturesContext } from "../../../businesslogic/LecturesProvider";
|
||||
import {LectureInit} from "../../../businesslogic/types/lectureInit";
|
||||
|
||||
import { Lecture } from "../../../businesslogic/types/lecture";
|
||||
import { LectureInit } from "../../../businesslogic/types/lectureInit";
|
||||
|
||||
export const Results: React.FC = () => {
|
||||
const [input, setInput] = useState<string>("");
|
||||
@ -27,10 +27,13 @@ export const Results: React.FC = () => {
|
||||
|
||||
useEffect(() => {
|
||||
const fetchData = async () => {
|
||||
const { data } = await axios.get(
|
||||
`http://localhost:1287/getCourses?name=""`
|
||||
const results = await axios.get(`http://localhost:1287/getCourses?name=`);
|
||||
const lecturesData = results.data.map(
|
||||
(result: { id: number; name: string }) => ({
|
||||
id: result.id,
|
||||
name: result.name,
|
||||
})
|
||||
);
|
||||
const lecturesData = data.map((data: { name: any; id: any; })=> {name: data.name, id: data.id})
|
||||
|
||||
setLecturesData(lecturesData);
|
||||
};
|
||||
@ -39,7 +42,11 @@ export const Results: React.FC = () => {
|
||||
|
||||
useEffect(() => {
|
||||
const filterLectures = (value: string) => {
|
||||
return lecturesData.filter((lecture) => lecture.name.includes(value));
|
||||
const zmienna = lecturesData.filter((lecture) =>
|
||||
lecture.name.toLowerCase().includes(value.toLowerCase())
|
||||
);
|
||||
console.log(zmienna);
|
||||
return zmienna;
|
||||
};
|
||||
filterLectures(input);
|
||||
}, [input]);
|
||||
|
Loading…
Reference in New Issue
Block a user