RocketChat/Rocket.Chat

View on GitHub
apps/meteor/client/components/message/content/attachments/FileAttachment.tsx

Summary

Maintainability
A
0 mins
Test Coverage
import { type FileAttachmentProps, isFileAudioAttachment, isFileImageAttachment, isFileVideoAttachment } from '@rocket.chat/core-typings';
import React from 'react';

import AudioAttachment from './file/AudioAttachment';
import GenericFileAttachment from './file/GenericFileAttachment';
import ImageAttachment from './file/ImageAttachment';
import VideoAttachment from './file/VideoAttachment';

const FileAttachment = (attachment: FileAttachmentProps) => {
    if (isFileImageAttachment(attachment)) {
        return <ImageAttachment {...attachment} />;
    }

    if (isFileAudioAttachment(attachment)) {
        return <AudioAttachment {...attachment} />;
    }

    if (isFileVideoAttachment(attachment)) {
        return <VideoAttachment {...attachment} />;
    }

    return <GenericFileAttachment {...attachment} />;
};

export default FileAttachment;