diff --git a/webapp/src/component/GoToBilling.tsx b/webapp/src/component/GoToBilling.tsx new file mode 100644 index 0000000000..8bc3314eff --- /dev/null +++ b/webapp/src/component/GoToBilling.tsx @@ -0,0 +1,25 @@ +import { Button } from '@mui/material'; +import { LINKS } from 'tg.constants/links'; +import { useGlobalContext } from 'tg.globalContext/GlobalContext'; + +type Props = { + render: (props: { + href: string; + rel: string; + target: string; + }) => React.ReactElement; +}; + +export const GoToBilling = ({ render }: Props) => { + const billingEnabled = useGlobalContext( + (c) => c.serverConfiguration.billing.enabled + ); + if (!billingEnabled) { + return null; + } + return render({ + href: LINKS.GO_TO_CLOUD_BILLING.build(), + rel: 'noopener noreferrer', + target: '_blank', + }); +}; diff --git a/webapp/src/views/projects/translations/TranslationTools/MachineTranslation.tsx b/webapp/src/views/projects/translations/TranslationTools/MachineTranslation.tsx index 67ebbb7394..f3073fc439 100644 --- a/webapp/src/views/projects/translations/TranslationTools/MachineTranslation.tsx +++ b/webapp/src/views/projects/translations/TranslationTools/MachineTranslation.tsx @@ -1,5 +1,5 @@ -import { Skeleton, styled } from '@mui/material'; -import { useTranslate } from '@tolgee/react'; +import { Button, Skeleton, styled } from '@mui/material'; +import { T, useTranslate } from '@tolgee/react'; import { TabMessage } from './TabMessage'; import { useTranslationTools } from './useTranslationTools'; @@ -10,6 +10,7 @@ import { UseQueryResult } from 'react-query'; import { ApiError } from 'tg.service/http/ApiError'; import { TranslatedError } from 'tg.translationTools/TranslatedError'; import clsx from 'clsx'; +import { GoToBilling } from 'tg.component/GoToBilling'; const StyledContainer = styled('div')` display: flex; @@ -71,10 +72,28 @@ export const MachineTranslation: React.FC = ({ const results = data?.servicesTypes.map( (provider) => [provider, data.result[provider]] as const ); + const outOfCredit = Object.values(data?.result || {}).every( + (i) => i?.errorMessage === 'OUT_OF_CREDITS' + ); return ( - {baseIsEmpty ? ( + {outOfCredit ? ( + + + + ( + + )} + /> + + + ) : baseIsEmpty ? ( {t('translation_tools_base_empty')} ) : ( !nothingFetched &&