fix ts errors

This commit is contained in:
Ramón Souza 2024-08-05 14:21:23 -03:00
parent 8689a0d961
commit 1b0e84ebc0
4 changed files with 36 additions and 5 deletions

View File

@ -230,10 +230,10 @@ const BreakoutRoomUserAssignment: React.FC<ChildComponentProps> = ({
return Object.values(rooms).filter((r) => r.name === roomName).length > 1;
};
const changeRoomPresentation = (position) => (ev) => {
const changeRoomPresentation = (position: number) => (ev: React.ChangeEvent<HTMLSelectElement>) => {
// @ts-ignore-next-line
const newRoomsPresentations = [...roomPresentations];
newRoomsPresentations[position] = ev.target.value;
setRoomPresentations(newRoomsPresentations);
};

View File

@ -24,6 +24,8 @@ import {
RoomToWithSettings,
BreakoutUser,
moveUserRegistery,
Presentation,
RoomPresentations,
} from './room-managment-state/types';
import { BREAKOUT_ROOM_CREATE, BREAKOUT_ROOM_MOVE_USER } from '../mutations';
import useDeduplicatedSubscription from '/imports/ui/core/hooks/useDeduplicatedSubscription';
@ -44,6 +46,8 @@ interface CreateBreakoutRoomProps extends CreateBreakoutRoomContainerProps {
isBreakoutRecordable: boolean,
users: Array<BreakoutUser>,
runningRooms: getBreakoutsResponse['breakoutRoom'],
presentations: Array<Presentation>,
currentPresentation: string,
}
const intlMessages = defineMessages({
@ -239,7 +243,7 @@ const CreateBreakoutRoom: React.FC<CreateBreakoutRoomProps> = ({
const [durationTime, setDurationTime] = React.useState(DEFAULT_BREAKOUT_TIME);
const isImportPresentationWithAnnotationsEnabled = useIsImportPresentationWithAnnotationsFromBreakoutRoomsEnabled();
const isImportSharedNotesEnabled = useIsImportSharedNotesFromBreakoutRoomsEnabled();
const [roomPresentations, setRoomPresentations] = React.useState([]);
const [roomPresentations, setRoomPresentations] = React.useState<RoomPresentations>([]);
const [createBreakoutRoom] = useMutation(BREAKOUT_ROOM_CREATE);
const [moveUser] = useMutation(BREAKOUT_ROOM_MOVE_USER);
@ -261,7 +265,8 @@ const CreateBreakoutRoom: React.FC<CreateBreakoutRoomProps> = ({
};
const getRoomPresentation = (position: number) => {
return roomPresentations[position] || `${CURRENT_SLIDE_PREFIX}${currentPresentation}`;
if (roomPresentations[position]) return roomPresentations[position];
return `${CURRENT_SLIDE_PREFIX}${currentPresentation}`;
};
const createRoom = () => {
@ -572,7 +577,7 @@ const CreateBreakoutRoomContainer: React.FC<CreateBreakoutRoomContainerProps> =
const { data: presentationData } = useDeduplicatedSubscription(PRESENTATIONS_SUBSCRIPTION);
const presentations = presentationData?.pres_presentation || [];
const currentPresentation = presentations.find((p) => p.current)?.presentationId || '';
const currentPresentation = presentations.find((p: Presentation) => p.current)?.presentationId || '';
if (usersLoading || breakoutsLoading || !currentMeeting) {
return null;

View File

@ -6,6 +6,8 @@ import {
ChildComponentProps,
Room,
moveUserRegistery,
Presentation,
RoomPresentations,
} from './types';
import { breakoutRoom, getBreakoutsResponse } from '../queries';
@ -28,6 +30,13 @@ interface RoomManagmentStateProps {
setFormIsValid: (isValid: boolean) => void;
setRoomsRef: (rooms: Rooms) => void;
setMoveRegisterRef: (moveRegister: moveUserRegistery) => void;
presentations: Presentation[];
roomPresentations: RoomPresentations;
setRoomPresentations: React.Dispatch<React.SetStateAction<RoomPresentations>>;
currentPresentation: string;
currentSlidePrefix: string;
getRoomPresentation: (roomId: number) => string;
isUpdate: boolean;
}
const RoomManagmentState: React.FC<RoomManagmentStateProps> = ({

View File

@ -47,4 +47,21 @@ export type ChildComponentProps = {
randomlyAssign: () => void;
resetRooms: (cap: number) => void;
users: BreakoutUser[];
currentSlidePrefix: string;
presentations: Presentation[];
getRoomPresentation: (roomId: number) => string;
setRoomPresentations: React.Dispatch<React.SetStateAction<RoomPresentations>>;
currentPresentation: string;
roomPresentations: RoomPresentations;
isUpdate: boolean;
}
export interface Presentation {
presentationId: string;
name: string;
current: boolean;
}
export interface RoomPresentations {
[roomId: number]: string;
}