import SearchIcon from '@mui/icons-material/Search';
import IconButton from '@mui/material/IconButton';
import Tooltip from '@mui/material/Tooltip';
import React, { FC } from 'react';
import { Link, useLocation } from 'react-router-dom';

import AppToolbar from 'components/toolbar/AppToolbar';
import globalize from 'scripts/globalize';

import AppTabs from '../tabs/AppTabs';
import { isDrawerPath } from '../drawers/AppDrawer';
import RemotePlayButton from './RemotePlayButton';
import SyncPlayButton from './SyncPlayButton';

interface AppToolbarProps {
    isDrawerOpen: boolean
    onDrawerButtonClick: (event: React.MouseEvent<HTMLElement>) => void
}

const ExperimentalAppToolbar: FC<AppToolbarProps> = ({
    isDrawerOpen,
    onDrawerButtonClick
}) => {
    const location = useLocation();
    const isDrawerAvailable = isDrawerPath(location.pathname);

    return (
        <AppToolbar
            buttons={
                <>
                    <SyncPlayButton />
                    <RemotePlayButton />

                    <Tooltip title={globalize.translate('Search')}>
                        <IconButton
                            size='large'
                            aria-label={globalize.translate('Search')}
                            color='inherit'
                            component={Link}
                            to='/search.html'
                        >
                            <SearchIcon />
                        </IconButton>
                    </Tooltip>
                </>
            }
            isDrawerAvailable={isDrawerAvailable}
            isDrawerOpen={isDrawerOpen}
            onDrawerButtonClick={onDrawerButtonClick}
        >
            <AppTabs isDrawerOpen={isDrawerOpen} />
        </AppToolbar>
    );
};

export default ExperimentalAppToolbar;
