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) => {
|
||||
const { courses, selectBasketNames, addCourseToBasket } = useContext(coursesContext)!;
|
||||
const { courses, selectBasketNames, addCourseToBasket,getUserTimetable } = useContext(coursesContext)!;
|
||||
const { users } = useContext(usersContext)!;
|
||||
const basketNames = useMemo(() => selectBasketNames(), [selectBasketNames]);
|
||||
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(() => {
|
||||
const filterCourses = (input: string) => {
|
||||
const filteredCourses = courses.filter(
|
||||
@ -111,7 +120,7 @@ export const Dropdown = ({ open, input, handleCloseDropdown, selectedOption }: D
|
||||
{selectedOption === 'studenci' ? (
|
||||
<div>
|
||||
{filteredUsers.map(({ name, surname, id }, index) => (
|
||||
<CourseContainer key={index} id={id.toString()}>
|
||||
<CourseContainer key={index} id={id.toString()} onClick={onUserClick}>
|
||||
<p>
|
||||
{name} {surname}{' '}
|
||||
</p>
|
||||
|
@ -28,6 +28,7 @@ interface CourseContext {
|
||||
selectBasketNames: () => Array<string>;
|
||||
selectBasketCourses: () => Array<Course>;
|
||||
selectBasketCourseGroups: (courseId: number) => { lecture: Group | undefined; classes: Group | undefined };
|
||||
getUserTimetable: (userID: string) => Promise<void>;
|
||||
}
|
||||
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 () => {
|
||||
try {
|
||||
const { data: courses } = await axiosInstance.get<Array<Course>>(
|
||||
@ -200,6 +212,7 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => {
|
||||
selectBasketNames,
|
||||
selectBasketCourses,
|
||||
selectBasketCourseGroups,
|
||||
getUserTimetable,
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
|
Loading…
Reference in New Issue
Block a user