import { notifyApiError } from "../lib/apiErrors" import React, { useEffect, useState } from "react"; import { Eye, EyeOff, Globe, Lock, Moon, Palette, Shield, Sun, User, CreditCard, Smartphone, } from "lucide-react"; import { Card, CardContent, CardHeader, CardTitle, } from "../components/ui/card"; import { Input } from "../components/ui/input"; import { Button } from "../components/ui/button"; import { cn } from "../lib/utils"; import { SpinnerIcon } from "../components/ui/spinner-icon"; import { changeTeamMemberPassword } from "../api/team.api"; import { logoutToLogin } from "../lib/auth"; import { getMyProfile } from "../api/users.api"; import type { TeamMeProfile } from "../types/team.types"; import { toast } from "sonner"; import { AppVersionsTab } from "./settings/AppVersionsTab"; import { SubscriptionPlansTab } from "./settings/SubscriptionPlansTab"; import { ThemeModePreview } from "./settings/components/ThemeModePreview"; import { useTheme } from "../contexts/ThemeContext"; type SettingsTab = | "subscription" | "app-versions" | "security" | "appearance"; const tabs: { id: SettingsTab; label: string; icon: typeof Shield }[] = [ { id: "subscription", label: "Subscription packages", icon: CreditCard }, { id: "app-versions", label: "App versions", icon: Smartphone }, { id: "security", label: "Security", icon: Shield }, { id: "appearance", label: "Appearance", icon: Palette }, ]; function SecurityTab({ memberId }: { memberId: number }) { const [currentPassword, setCurrentPassword] = useState(""); const [newPassword, setNewPassword] = useState(""); const [confirmPassword, setConfirmPassword] = useState(""); const [showCurrent, setShowCurrent] = useState(false); const [showNew, setShowNew] = useState(false); const [showConfirm, setShowConfirm] = useState(false); const [saving, setSaving] = useState(false); const handleChangePassword = async () => { if (!currentPassword.trim()) { toast.error("Enter your current password."); return; } if (newPassword.length < 8) { toast.error("New password must be at least 8 characters."); return; } if (newPassword !== confirmPassword) { toast.error("New password and confirmation do not match."); return; } if (currentPassword === newPassword) { toast.error("New password must be different from your current password."); return; } setSaving(true); try { await changeTeamMemberPassword(memberId, { current_password: currentPassword, new_password: newPassword, }); logoutToLogin({ passwordChanged: true }); return; } catch (e: unknown) { notifyApiError(e, "Failed to update password."); } finally { setSaving(false); } }; return (
Active appearance:{" "} {resolvedTheme} {theme === "system" ? " (from your device setting)" : null} {theme === "light" ? " (fixed — not tied to device)" : null}
Light vs System: Light always stays bright. System copies your Windows/macOS theme — if your device is in light mode, System will match Light; switch your device to dark to see System use the dark admin theme.
{error || "Settings not available"}
Please check your connection and try again.
Manage your account preferences, subscriptions, and system configurations with ease