RocketChat/Rocket.Chat

View on GitHub
apps/meteor/client/sidebarv2/footer/SidebarFooterWatermark.tsx

Summary

Maintainability
C
1 day
Test Coverage
import { Box } from '@rocket.chat/fuselage';
import { useTranslation } from '@rocket.chat/ui-contexts';
import type { ReactElement } from 'react';
import React from 'react';

import { useLicense, useLicenseName } from '../../hooks/useLicense';

export const SidebarFooterWatermark = (): ReactElement | null => {
    const t = useTranslation();

    const response = useLicense();

    const licenseName = useLicenseName();

    if (response.isLoading || response.isError) {
        return null;
    }

    if (licenseName.isError || licenseName.isLoading) {
        return null;
    }

    const license = response.data;

    if (license.activeModules.includes('hide-watermark') && !license.trial) {
        return null;
    }

    return (
        <Box pi={16} pbe={8}>
            <Box is='a' href='https://rocket.chat/' target='_blank' rel='noopener noreferrer'>
                <Box fontScale='micro' color='hint' pbe={4}>
                    {t('Powered_by_RocketChat')}
                </Box>
                <Box fontScale='micro' color='pure-white' pbe={4}>
                    {licenseName.data}
                </Box>
            </Box>
        </Box>
    );
};