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

View File

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