"use client"; import { useState, useCallback } from "react"; import { useTranslations } from "next-intl"; import { Upload, Download } from "lucide-react"; import { Button } from "@/components/ui/button"; import { SettingsSection, SettingItem, ToggleSwitch } from "./settings-section"; import { ContactImportDialog } from "@/components/contacts/contact-import-dialog"; import { exportContacts } from "@/components/contacts/contact-export"; import { useContactStore } from "@/stores/contact-store"; import { useAuthStore } from "@/stores/auth-store"; import { useSettingsStore } from "@/stores/settings-store"; import { toast } from "@/stores/toast-store"; export function ContactsSettings() { const t = useTranslations("contacts"); const tSettings = useTranslations("settings.contacts"); const { client } = useAuthStore(); const { contacts, supportsSync, importContacts, } = useContactStore(); const groupContactsByLetter = useSettingsStore((s) => s.groupContactsByLetter); const updateSetting = useSettingsStore((s) => s.updateSetting); const [showImport, setShowImport] = useState(false); const individuals = contacts.filter(c => c.kind !== "group"); const handleImport = useCallback(async (importedContacts: import("@/lib/jmap/types").ContactCard[]) => { return importContacts( supportsSync && client ? client : null, importedContacts ); }, [supportsSync, client, importContacts]); const handleExport = () => { if (individuals.length > 0) { exportContacts(individuals); toast.success(t("export.success", { count: individuals.length })); } }; if (showImport) { return (