checking someone's plan in progress
This commit is contained in:
parent
c7dc37c827
commit
68667e55de
@ -50,7 +50,7 @@ interface DropdownProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const Dropdown = ({ open, input, handleCloseDropdown, selectedOption }: DropdownProps) => {
|
export const Dropdown = ({ open, input, handleCloseDropdown, selectedOption }: DropdownProps) => {
|
||||||
const { courses, selectBasketNames, addCourseToBasket } = useContext(coursesContext)!;
|
const { courses, selectBasketNames, addCourseToBasket,getUserTimetable } = useContext(coursesContext)!;
|
||||||
const { users } = useContext(usersContext)!;
|
const { users } = useContext(usersContext)!;
|
||||||
const basketNames = useMemo(() => selectBasketNames(), [selectBasketNames]);
|
const basketNames = useMemo(() => selectBasketNames(), [selectBasketNames]);
|
||||||
const [filteredCourses, setFilteredCourses] = useState<Array<Course>>([]);
|
const [filteredCourses, setFilteredCourses] = useState<Array<Course>>([]);
|
||||||
@ -65,6 +65,15 @@ export const Dropdown = ({ open, input, handleCloseDropdown, selectedOption }: D
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onUserClick = (event: MouseEvent) => {
|
||||||
|
const target = event.currentTarget;
|
||||||
|
if (target.id && target.textContent) {
|
||||||
|
console.log(target.id,target.textContent);
|
||||||
|
getUserTimetable(target.id);
|
||||||
|
handleCloseDropdown();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const filterCourses = (input: string) => {
|
const filterCourses = (input: string) => {
|
||||||
const filteredCourses = courses.filter(
|
const filteredCourses = courses.filter(
|
||||||
@ -111,7 +120,7 @@ export const Dropdown = ({ open, input, handleCloseDropdown, selectedOption }: D
|
|||||||
{selectedOption === 'studenci' ? (
|
{selectedOption === 'studenci' ? (
|
||||||
<div>
|
<div>
|
||||||
{filteredUsers.map(({ name, surname, id }, index) => (
|
{filteredUsers.map(({ name, surname, id }, index) => (
|
||||||
<CourseContainer key={index} id={id.toString()}>
|
<CourseContainer key={index} id={id.toString()} onClick={onUserClick}>
|
||||||
<p>
|
<p>
|
||||||
{name} {surname}{' '}
|
{name} {surname}{' '}
|
||||||
</p>
|
</p>
|
||||||
|
@ -28,6 +28,7 @@ interface CourseContext {
|
|||||||
selectBasketNames: () => Array<string>;
|
selectBasketNames: () => Array<string>;
|
||||||
selectBasketCourses: () => Array<Course>;
|
selectBasketCourses: () => Array<Course>;
|
||||||
selectBasketCourseGroups: (courseId: number) => { lecture: Group | undefined; classes: Group | undefined };
|
selectBasketCourseGroups: (courseId: number) => { lecture: Group | undefined; classes: Group | undefined };
|
||||||
|
getUserTimetable: (userID: string) => Promise<void>;
|
||||||
}
|
}
|
||||||
export const coursesContext = createContext<CourseContext | undefined>(undefined);
|
export const coursesContext = createContext<CourseContext | undefined>(undefined);
|
||||||
|
|
||||||
@ -165,6 +166,17 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getUserTimetable = async (userID:string) => {
|
||||||
|
try {
|
||||||
|
const {data} = await axiosInstance.get(
|
||||||
|
`${process.env.REACT_APP_API_URL}/api/v1/commisions/user/${userID}`,
|
||||||
|
);
|
||||||
|
console.log(data);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const fetchCourses = async () => {
|
const fetchCourses = async () => {
|
||||||
try {
|
try {
|
||||||
const { data: courses } = await axiosInstance.get<Array<Course>>(
|
const { data: courses } = await axiosInstance.get<Array<Course>>(
|
||||||
@ -200,6 +212,7 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => {
|
|||||||
selectBasketNames,
|
selectBasketNames,
|
||||||
selectBasketCourses,
|
selectBasketCourses,
|
||||||
selectBasketCourseGroups,
|
selectBasketCourseGroups,
|
||||||
|
getUserTimetable,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
|
Loading…
Reference in New Issue
Block a user