feat: disable delete all themes button when no themes exist

This commit is contained in:
Hachi-R 2025-01-31 23:30:21 -03:00
commit 15746a5598
2 changed files with 4 additions and 2 deletions

View file

@ -7,9 +7,10 @@ import { useState } from "react";
interface ThemeActionsProps { interface ThemeActionsProps {
onListUpdated: () => void; onListUpdated: () => void;
themesCount: number;
} }
export const ThemeActions = ({ onListUpdated }: ThemeActionsProps) => { export const ThemeActions = ({ onListUpdated, themesCount }: ThemeActionsProps) => {
const { t } = useTranslation("settings"); const { t } = useTranslation("settings");
const [addThemeModalVisible, setAddThemeModalVisible] = useState(false); const [addThemeModalVisible, setAddThemeModalVisible] = useState(false);
@ -41,6 +42,7 @@ export const ThemeActions = ({ onListUpdated }: ThemeActionsProps) => {
theme="danger" theme="danger"
className="settings-appearance__button" className="settings-appearance__button"
onClick={() => setDeleteAllThemesModalVisible(true)} onClick={() => setDeleteAllThemesModalVisible(true)}
disabled={themesCount < 1}
> >
<TrashIcon /> <TrashIcon />
{t("clear_themes")} {t("clear_themes")}

View file

@ -19,7 +19,7 @@ export const SettingsAppearance = () => {
<div className="settings-appearance"> <div className="settings-appearance">
<p className="settings-appearance__description">Appearance</p> <p className="settings-appearance__description">Appearance</p>
<ThemeActions onListUpdated={loadThemes} /> <ThemeActions onListUpdated={loadThemes} themesCount={themes.length} />
<div className="settings-appearance__themes"> <div className="settings-appearance__themes">
{!themes.length ? ( {!themes.length ? (