fix: use correct icon in ConditionalIconButton

This commit is contained in:
Ali BARIN
2021-12-14 12:42:23 +01:00
committed by Ömer Faruk Aydın
parent 6da8557219
commit fdfad28c2e
2 changed files with 21 additions and 10 deletions

View File

@@ -6,7 +6,7 @@ import Button from '@mui/material/Button';
import { IconButton } from './style'; import { IconButton } from './style';
export default function ConditionalIconButton(props: any) { export default function ConditionalIconButton(props: any) {
const { Icon, ...buttonProps } = props; const { icon, ...buttonProps } = props;
const theme = useTheme(); const theme = useTheme();
const matchSmallScreens = useMediaQuery(theme.breakpoints.down('md'), { noSsr: true }); const matchSmallScreens = useMediaQuery(theme.breakpoints.down('md'), { noSsr: true });
@@ -17,9 +17,8 @@ export default function ConditionalIconButton(props: any) {
type={buttonProps.type} type={buttonProps.type}
size={buttonProps.size} size={buttonProps.size}
component={buttonProps.component} component={buttonProps.component}
to={buttonProps.to}
> >
<Icon /> {icon}
</IconButton> </IconButton>
) )
} }

View File

@@ -1,10 +1,12 @@
import { useCallback, useState } from 'react'; import * as React from 'react';
import { Link, Routes, Route, useNavigate } from 'react-router-dom'; import { Link, Routes, Route, useNavigate } from 'react-router-dom';
import type { LinkProps } from 'react-router-dom';
import { useQuery } from '@apollo/client'; import { useQuery } from '@apollo/client';
import Box from '@mui/material/Box'; import Box from '@mui/material/Box';
import Grid from '@mui/material/Grid'; import Grid from '@mui/material/Grid';
import AddIcon from '@mui/icons-material/Add'; import AddIcon from '@mui/icons-material/Add';
import ConditionalIconButton from 'components/ConditionalIconButton'; import ConditionalIconButton from 'components/ConditionalIconButton';
import Container from 'components/Container'; import Container from 'components/Container';
import AddNewAppConnection from 'components/AddNewAppConnection'; import AddNewAppConnection from 'components/AddNewAppConnection';
@@ -19,17 +21,28 @@ import type { App } from 'types/app';
export default function Applications() { export default function Applications() {
const navigate = useNavigate(); const navigate = useNavigate();
const formatMessage = useFormatMessage(); const formatMessage = useFormatMessage();
const [appName, setAppName] = useState(null); const [appName, setAppName] = React.useState(null);
const { data } = useQuery(GET_CONNECTED_APPS, { variables: {name: appName } }); const { data } = useQuery(GET_CONNECTED_APPS, { variables: {name: appName } });
const onSearchChange = useCallback((event) => { const onSearchChange = React.useCallback((event) => {
setAppName(event.target.value); setAppName(event.target.value);
}, []); }, []);
const goToApps = useCallback(() => { const goToApps = React.useCallback(() => {
navigate(URLS.APPS); navigate(URLS.APPS);
}, [navigate]); }, [navigate]);
const NewAppConnectionLink = React.useMemo(
() =>
React.forwardRef<HTMLAnchorElement, Omit<LinkProps, 'to'>>(function InlineLink(
linkProps,
ref,
) {
return <Link ref={ref} to={URLS.NEW_APP_CONNECTION} {...linkProps} />;
}),
[],
);
return ( return (
<Box sx={{ py: 3 }}> <Box sx={{ py: 3 }}>
<Container> <Container>
@@ -48,10 +61,9 @@ export default function Applications() {
variant="contained" variant="contained"
color="primary" color="primary"
size="large" size="large"
component={Link} component={NewAppConnectionLink}
to={URLS.NEW_APP_CONNECTION}
fullWidth fullWidth
Icon={<AddIcon />} icon={<AddIcon />}
> >
{formatMessage('apps.addConnection')} {formatMessage('apps.addConnection')}
</ConditionalIconButton> </ConditionalIconButton>