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/views/admin/apps/APIsDisplay.tsx

40 lines
1.1 KiB

import { Box, Divider } from '@rocket.chat/fuselage';
import React, { FC } from 'react';
import { useTranslation } from '../../../contexts/TranslationContext';
import { useAbsoluteUrl } from '../../../contexts/ServerContext';
import { apiCurlGetter } from './helpers';
type APIsDisplayProps = {
apis: {
path: string;
computedPath: string;
methods: unknown[];
examples: Record<string, unknown>;
}[];
};
const APIsDisplay: FC<APIsDisplayProps> = ({ apis }) => {
const t = useTranslation();
const absoluteUrl = useAbsoluteUrl();
const getApiCurl = apiCurlGetter(absoluteUrl);
return <>
<Divider />
<Box display='flex' flexDirection='column'>
<Box fontScale='s2' mb='x12'>{t('APIs')}</Box>
{apis.map((api) => <Box key={api.path} mb='x8'>
<Box fontScale='p2'>{api.methods.join(' | ').toUpperCase()} {api.path}</Box>
{api.methods.map((method) => <Box>
<Box withRichContent><pre><code>
{getApiCurl(method, api).map((curlAddress) => <>{curlAddress}<br /></>)}
</code></pre></Box>
</Box>)}
</Box>)}
</Box>
</>;
};
export default APIsDisplay;