The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/client/components/CreateDiscussion/DefaultParentRoomField.tsx

42 lines
1.0 KiB

import { Skeleton, TextInput, Callout } from '@rocket.chat/fuselage';
import React, { useMemo, ReactElement } from 'react';
import { roomTypes } from '../../../app/utils/client/lib/roomTypes';
import { useTranslation } from '../../contexts/TranslationContext';
import { AsyncStatePhase } from '../../hooks/useAsyncState';
import { useEndpointData } from '../../hooks/useEndpointData';
const DefaultParentRoomField = ({
defaultParentRoom,
}: {
defaultParentRoom: string;
}): ReactElement => {
const t = useTranslation();
const { value, phase } = useEndpointData(
'rooms.info',
useMemo(
() => ({
roomId: defaultParentRoom,
}),
[defaultParentRoom],
),
);
if (phase === AsyncStatePhase.LOADING) {
return <Skeleton width='full' />;
}
if (!value || !value.room) {
return <Callout type={'danger'}>{t('Error')}</Callout>;
}
return (
<TextInput
value={roomTypes.getRoomName(value.room.t, value.room)}
disabled
onChange={(): string => ''}
/>
);
};
export default DefaultParentRoomField;