RocketChat/Rocket.Chat

View on GitHub
apps/meteor/ee/client/sidebar/footer/SidebarFooterWatermark.tsx

Summary

Maintainability
A
25 mins
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 '../../../../client/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>
    );
};