2024-12-16 21:59:30 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) Contributors to the Suwayomi project
|
|
|
|
|
*
|
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import Button, { ButtonProps } from '@mui/material/Button';
|
|
|
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
|
import RestartAltIcon from '@mui/icons-material/RestartAlt';
|
2024-12-17 16:48:03 +01:00
|
|
|
import IconButton, { IconButtonProps } from '@mui/material/IconButton';
|
2025-02-01 14:24:38 +01:00
|
|
|
import { CustomTooltip } from '@/modules/core/components/CustomTooltip.tsx';
|
2024-12-16 21:59:30 +01:00
|
|
|
|
2024-12-17 16:48:03 +01:00
|
|
|
type PropsIconButton = { asIconButton: true } & IconButtonProps;
|
|
|
|
|
type PropsButton = { asIconButton?: false } & ButtonProps;
|
|
|
|
|
type Props = PropsIconButton | PropsButton;
|
|
|
|
|
|
|
|
|
|
export const ResetButton = ({ asIconButton, ...props }: Props) => {
|
2024-12-16 21:59:30 +01:00
|
|
|
const { t } = useTranslation();
|
|
|
|
|
|
2024-12-17 16:48:03 +01:00
|
|
|
if (asIconButton) {
|
|
|
|
|
return (
|
2025-02-01 14:24:38 +01:00
|
|
|
<CustomTooltip title={t('global.button.reset')}>
|
2024-12-17 16:48:03 +01:00
|
|
|
<IconButton color="inherit" {...props}>
|
|
|
|
|
<RestartAltIcon />
|
|
|
|
|
</IconButton>
|
2025-02-01 14:24:38 +01:00
|
|
|
</CustomTooltip>
|
2024-12-17 16:48:03 +01:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-16 21:59:30 +01:00
|
|
|
return (
|
2024-12-17 16:48:03 +01:00
|
|
|
<Button startIcon={<RestartAltIcon />} {...(props as ButtonProps)}>
|
2024-12-16 21:59:30 +01:00
|
|
|
{t('global.button.reset')}
|
|
|
|
|
</Button>
|
|
|
|
|
);
|
|
|
|
|
};
|