File size: 1,069 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
import { IconButton, Dialog } from '@mui/material';
import Translate from '@mui/icons-material/Translate';
import React, { useState } from 'react';
import SelectLang from './SelectLang';
import I18nDialog from './I18nDialog';
import { useOption } from '../../core/components/hooks';
export const I18nTools: React.FC<{
nodeId: string;
}> = React.memo(({ nodeId }) => {
const languages = useOption('languages');
const [showI18nDialog, setShowI18nDialog] = useState(false);
const hasI18n = languages && languages?.length > 0;
const onClose = () => setShowI18nDialog(false);
if (!hasI18n) {
return null;
}
return (
<>
<Dialog open={showI18nDialog} onClose={onClose}>
<I18nDialog nodeId={nodeId} onClose={onClose} />
</Dialog>
<div style={{ display: 'flex', alignItems: 'center' }}>
<IconButton
onClick={() => setShowI18nDialog(true)}
aria-label="i18n"
color="secondary"
>
<Translate />
</IconButton>
<SelectLang />
</div>
</>
);
});
|