fix: TypeScript errors & build fixes for Control Panel Redesign

- Fix unused imports (Trash, Filter, Bell, CategoryAdvanced)
- Fix undefined checks for cleanup settings
- Fix cleanupPreview undefined checks
- Fix useTheme unused parameter
- Fix companyLabels type safety
- Build erfolgreich durchgefuehrt
This commit is contained in:
2026-01-28 17:10:36 +01:00
parent 6da8ce1cbd
commit 904dcd8260
7 changed files with 178 additions and 14 deletions

View File

@@ -98,7 +98,7 @@ export function useTheme() {
// Listen for system preference changes
const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)')
const handleSystemPreferenceChange = (e: MediaQueryListEvent) => {
const handleSystemPreferenceChange = () => {
updateTheme()
}

View File

@@ -39,9 +39,7 @@ import {
Lock,
Copy,
AlertTriangle,
Trash,
Search,
Filter,
Download,
Upload,
ChevronDown,
@@ -52,12 +50,11 @@ import {
Camera,
Globe,
Clock,
Bell,
Palette,
Save,
Edit2,
} from 'lucide-react'
import type { AIControlSettings, CompanyLabel, CategoryInfo, CategoryAdvanced, CleanupStatus } from '@/types/settings'
import type { AIControlSettings, CompanyLabel, CategoryInfo, CleanupStatus } from '@/types/settings'
import { PrivacySecurity } from '@/components/PrivacySecurity'
type TabType = 'profile' | 'accounts' | 'vip' | 'ai-control' | 'subscription' | 'privacy' | 'referrals'
@@ -141,7 +138,6 @@ export function Settings() {
})
const [categories, setCategories] = useState<CategoryInfo[]>([])
const [companyLabels, setCompanyLabels] = useState<CompanyLabel[]>([])
const [newCompanyLabel, setNewCompanyLabel] = useState({ name: '', condition: '', category: 'promotions' })
const [referralData, setReferralData] = useState<{ referralCode: string; referralCount: number } | null>(null)
const [loadingReferral, setLoadingReferral] = useState(false)
@@ -1357,7 +1353,7 @@ export function Settings() {
},
})
}}
className={`w-12 h-6 rounded-full transition-colors flex-shrink-0 ${aiControlSettings.cleanup?.promotions.enabled ? 'bg-primary-500 dark:bg-primary-600' : 'bg-slate-300 dark:bg-slate-600'}`}
className={`w-12 h-6 rounded-full transition-colors flex-shrink-0 ${aiControlSettings.cleanup?.promotions?.enabled ? 'bg-primary-500 dark:bg-primary-600' : 'bg-slate-300 dark:bg-slate-600'}`}
>
<div className={`w-5 h-5 bg-white dark:bg-slate-200 rounded-full transform transition-transform mx-0.5 ${
aiControlSettings.cleanup?.promotions.enabled ? 'translate-x-6' : 'translate-x-0'
@@ -1402,7 +1398,7 @@ export function Settings() {
{[7, 14, 30].map((days) => (
<Button
key={days}
variant={aiControlSettings.cleanup.promotions.deleteAfterDays === days ? 'default' : 'outline'}
variant={aiControlSettings.cleanup?.promotions.deleteAfterDays === days ? 'default' : 'outline'}
size="sm"
onClick={() => {
if (!aiControlSettings.cleanup) return
@@ -1475,7 +1471,7 @@ export function Settings() {
})
}}
className={`px-3 py-1.5 rounded-lg text-sm font-medium transition-colors flex items-center gap-2 ${
aiControlSettings.cleanup.promotions.matchCategoriesOrLabels.includes(category.key)
aiControlSettings.cleanup?.promotions?.matchCategoriesOrLabels?.includes(category.key)
? 'bg-primary-100 dark:bg-primary-900/30 text-primary-700 dark:text-primary-300 border border-primary-300 dark:border-primary-700'
: 'bg-slate-100 dark:bg-slate-800 text-slate-700 dark:text-slate-300 border border-slate-300 dark:border-slate-600 hover:bg-slate-200 dark:hover:bg-slate-700'
}`}
@@ -1505,7 +1501,7 @@ export function Settings() {
</Card>
{/* Preview Section */}
{(cleanupPreview.length > 0 || cleanupStatus) && (
{((cleanupPreview && cleanupPreview.length > 0) || cleanupStatus) && (
<Card className="border-slate-200 dark:border-slate-700">
<CardContent className="p-6">
<div className="flex items-center justify-between mb-4">
@@ -1515,7 +1511,7 @@ export function Settings() {
Preview
</h3>
<p className="text-sm text-slate-600 dark:text-slate-400">
{cleanupPreview.length > 0
{(cleanupPreview && cleanupPreview.length > 0)
? `${cleanupPreview.length} emails affected in the last 7 days`
: cleanupStatus?.lastRun
? `Last run: ${new Date(cleanupStatus.lastRun).toLocaleDateString()}`
@@ -1532,7 +1528,7 @@ export function Settings() {
Refresh
</Button>
</div>
{cleanupPreview.length > 0 && (
{cleanupPreview && cleanupPreview.length > 0 && (
<div className="space-y-2 max-h-64 overflow-y-auto">
{cleanupPreview.slice(0, 10).map((item) => (
<div key={item.id} className="p-3 rounded-lg border border-slate-200 dark:border-slate-700 bg-slate-50 dark:bg-slate-800/50">
@@ -2064,7 +2060,7 @@ export function Settings() {
const saved = await api.saveCompanyLabel(user.$id, editingLabel)
if (saved.data) {
if (editingLabel.id) {
setCompanyLabels(companyLabels.map(l => l.id === editingLabel.id ? saved.data : l))
setCompanyLabels(companyLabels.map(l => l.id === editingLabel.id ? (saved.data || l) : l))
showMessage('success', 'Label updated!')
} else {
setCompanyLabels([...companyLabels, saved.data])