diff --git a/src/api/basicApi.ts b/src/api/basicApi.ts index 739fe6d..de489e3 100644 --- a/src/api/basicApi.ts +++ b/src/api/basicApi.ts @@ -1,6 +1,6 @@ import { getData, BASE_BACKEND } from "./api-base"; import settings from "../settings"; -import { IApiResponseBase, ICategory, IUser, QueryParams } from "../types"; +import { IApiResponseBase, ICategory, QueryParams } from "../types"; export const fetchDataBase = ( url: string, @@ -30,11 +30,3 @@ export const fetchCategories = ( groupId, `${BASE_BACKEND}${settings.url.categories}`, ); - -export const fetchUsers = ( - groupId: string, -): Promise> => - fetchGroupedDataBase( - groupId, - `${BASE_BACKEND}${settings.url.users}`, - ); diff --git a/src/features/calendars/controller.tsx b/src/features/calendars/controller.tsx index be9ed10..11ff6f7 100644 --- a/src/features/calendars/controller.tsx +++ b/src/features/calendars/controller.tsx @@ -3,20 +3,21 @@ import { useDispatch, useSelector } from "react-redux"; import { groupBy, isArray, isEmpty } from "lodash"; import CalendarForm from "./CalendarForm"; import { setProgress, setSnackState } from "../feedback/feedbackSlice"; -import { selectCurrentGroup } from "../group/groupSlice"; +import { + selectCurrentGroup, + selectCurrentGroupUser, +} from "../group/groupSlice"; import { createCalendar, deleteCalendar, fetchCalendars, updateCalendar, - fetchUsers, } from "../../api"; import { IApiResponseBase, ICalendar, ICalendarBase, ICalendarResponse, - IUser, } from "../../types"; import { isApiError, createSnackState } from "../../utils"; // FIXME: @@ -35,9 +36,10 @@ const calendarGroupBy = (calendars: ICalendarResponse[]) => { const CalendarController = (): JSX.Element => { const currentGroup = useSelector(selectCurrentGroup); + const users = useSelector(selectCurrentGroupUser); const dispatch = useDispatch(); const [calendars, setCalendars] = useState([]); - const [users, setUsers] = useState([]); + // const [users, setUsers] = useState([]); const [refresh, setRefresh] = useState(false); useEffect(() => { @@ -60,21 +62,6 @@ const CalendarController = (): JSX.Element => { getDatas(); }, [refresh, currentGroup]); - useEffect(() => { - const getDatas = async () => { - const data = await fetchUsers(currentGroup.id); - const { error } = isApiError(data, true); - if (!error) - setUsers( - data.body && !isEmpty(data.body) && isArray(data.body) - ? data.body - : [], - ); - // setUsers(usersData); - }; - getDatas(); - }, [currentGroup]); - const responseHandler = useCallback( (res: IApiResponseBase, withBody?: boolean) => { const { error, message } = isApiError(res, withBody);