diff --git a/apps/mail/components/context/command-palette-context.tsx b/apps/mail/components/context/command-palette-context.tsx index e6897a9ef6..92f8ef3c1b 100644 --- a/apps/mail/components/context/command-palette-context.tsx +++ b/apps/mail/components/context/command-palette-context.tsx @@ -739,7 +739,7 @@ export function CommandPalette({ children }: { children: React.ReactNode }) { const result: CommandGroup[] = [ { - group: 'Search & Filter', + group: 'Search', items: searchCommands, }, { diff --git a/apps/mail/components/mail/mail.tsx b/apps/mail/components/mail/mail.tsx index e6666e4e2b..b3b4990d0b 100644 --- a/apps/mail/components/mail/mail.tsx +++ b/apps/mail/components/mail/mail.tsx @@ -1,12 +1,12 @@ -import { - Dialog, - DialogContent, - DialogDescription, - DialogFooter, - DialogHeader, - DialogTitle, - DialogTrigger, -} from '@/components/ui/dialog'; +// import { +// Dialog, +// DialogContent, +// DialogDescription, +// DialogFooter, +// DialogHeader, +// DialogTitle, +// DialogTrigger, +// } from '@/components/ui/dialog'; import { DropdownMenu, DropdownMenuItem, @@ -14,17 +14,17 @@ import { DropdownMenuTrigger, } from '../ui/dropdown-menu'; import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip'; -import { Bell, Lightning, Mail, ScanEye, Tag, Trash, User, X, Search } from '../icons/icons'; +import { Bell, Lightning, Mail, ScanEye, Tag, User, X, Search } from '../icons/icons'; import { useCategorySettings, useDefaultCategoryId } from '@/hooks/use-categories'; import { ResizablePanel, ResizablePanelGroup } from '@/components/ui/resizable'; -import React, { useCallback, useEffect, useRef, useState } from 'react'; import { useCommandPalette } from '../context/command-palette-context'; +import { useCallback, useEffect, useRef, useState } from 'react'; import { Check, ChevronDown, RefreshCcw } from 'lucide-react'; import { ThreadDisplay } from '@/components/mail/thread-display'; import { useActiveConnection } from '@/hooks/use-connections'; -import { useMutation, useQuery } from '@tanstack/react-query'; -import { useTRPC } from '@/providers/query-provider'; +// import { useMutation, useQuery } from '@tanstack/react-query'; +// import { useTRPC } from '@/providers/query-provider'; import { useMediaQuery } from '../../hooks/use-media-query'; @@ -33,40 +33,40 @@ import * as CustomIcons from '@/components/icons/icons'; import { isMac } from '@/lib/hotkeys/use-hotkey-utils'; import { MailList } from '@/components/mail/mail-list'; import { useHotkeysContext } from 'react-hotkeys-hook'; -import SelectAllCheckbox from './select-all-checkbox'; +// import SelectAllCheckbox from './select-all-checkbox'; import { useNavigate, useParams } from 'react-router'; import { useMail } from '@/components/mail/use-mail'; import { SidebarToggle } from '../ui/sidebar-toggle'; import { PricingDialog } from '../ui/pricing-dialog'; -import { Textarea } from '@/components/ui/textarea'; -import { useBrainState } from '@/hooks/use-summary'; +// import { Textarea } from '@/components/ui/textarea'; +// import { useBrainState } from '@/hooks/use-summary'; import { clearBulkSelectionAtom } from './use-mail'; import AISidebar from '@/components/ui/ai-sidebar'; import { useThreads } from '@/hooks/use-threads'; -import { useBilling } from '@/hooks/use-billing'; +// import { useBilling } from '@/hooks/use-billing'; import AIToggleButton from '../ai-toggle-button'; import { useIsMobile } from '@/hooks/use-mobile'; -import { Switch } from '@/components/ui/switch'; +// import { Switch } from '@/components/ui/switch'; import { Button } from '@/components/ui/button'; import { useLabels } from '@/hooks/use-labels'; import { useSession } from '@/lib/auth-client'; -import { ScrollArea } from '../ui/scroll-area'; -import { Label } from '@/components/ui/label'; -import { Input } from '@/components/ui/input'; +// import { ScrollArea } from '../ui/scroll-area'; +// import { Label } from '@/components/ui/label'; +// import { Input } from '@/components/ui/input'; import { cn } from '@/lib/utils'; import { m } from '@/paraglide/messages'; import { useQueryState } from 'nuqs'; import { useAtom } from 'jotai'; -import { toast } from 'sonner'; +// import { toast } from 'sonner'; -interface ITag { - id: string; - name: string; - usecase: string; - text: string; -} +// interface ITag { +// id: string; +// name: string; +// usecase: string; +// text: string; +// } export const defaultLabels = [ { @@ -101,282 +101,282 @@ export const defaultLabels = [ }, ]; -const AutoLabelingSettings = () => { - const trpc = useTRPC(); - const [open, setOpen] = useState(false); - const { data: storedLabels, refetch: refetchStoredLabels } = useQuery( - trpc.brain.getLabels.queryOptions(void 0, { - staleTime: 1000 * 60 * 60, // 1 hour - }), - ); - const { mutateAsync: updateLabels, isPending } = useMutation( - trpc.brain.updateLabels.mutationOptions({ - onSuccess: () => { - refetchStoredLabels(); - }, - }), - ); - const [, setPricingDialog] = useQueryState('pricingDialog'); - const [labels, setLabels] = useState([]); - const [newLabel, setNewLabel] = useState({ name: '', usecase: '' }); - const { mutateAsync: EnableBrain, isPending: isEnablingBrain } = useMutation( - trpc.brain.enableBrain.mutationOptions(), - ); - const { mutateAsync: DisableBrain, isPending: isDisablingBrain } = useMutation( - trpc.brain.disableBrain.mutationOptions(), - ); - const { data: brainState, refetch: refetchBrainState } = useBrainState(); - const { isLoading, isPro } = useBilling(); - - useEffect(() => { - if (storedLabels) { - setLabels( - storedLabels.map((label) => ({ - id: label.name, - name: label.name, - text: label.name, - usecase: label.usecase, - })), - ); - } - }, [storedLabels]); - - const handleResetToDefault = useCallback(() => { - setLabels( - defaultLabels.map((label) => ({ - id: label.name, - name: label.name, - text: label.name, - usecase: label.usecase, - })), - ); - }, [storedLabels]); - - const handleAddLabel = () => { - if (!newLabel.name || !newLabel.usecase) return; - setLabels([...labels, { id: newLabel.name, ...newLabel, text: newLabel.name }]); - setNewLabel({ name: '', usecase: '' }); - }; - - const handleDeleteLabel = (id: string) => { - setLabels(labels.filter((label) => label.id !== id)); - }; - - const handleUpdateLabel = (id: string, field: 'name' | 'usecase', value: string) => { - setLabels( - labels.map((label) => - label.id === id - ? { ...label, [field]: value, text: field === 'name' ? value : label.text } - : label, - ), - ); - }; - - const handleSubmit = async () => { - const updatedLabels = labels.map((label) => ({ - name: label.name, - usecase: label.usecase, - })); - - if (newLabel.name.trim() && newLabel.usecase.trim()) { - updatedLabels.push({ - name: newLabel.name, - usecase: newLabel.usecase, - }); - } - await updateLabels({ labels: updatedLabels }); - setOpen(false); - toast.success('Labels updated successfully, Zero will start using them.'); - }; - - const handleEnableBrain = useCallback(async () => { - toast.promise(EnableBrain, { - loading: 'Enabling autolabeling...', - success: 'Autolabeling enabled successfully', - error: 'Failed to enable autolabeling', - finally: async () => { - await refetchBrainState(); - }, - }); - }, []); - - const handleDisableBrain = useCallback(async () => { - toast.promise(DisableBrain, { - loading: 'Disabling autolabeling...', - success: 'Autolabeling disabled successfully', - error: 'Failed to disable autolabeling', - finally: async () => { - await refetchBrainState(); - }, - }); - }, []); - - const handleToggleAutolabeling = useCallback(() => { - if (brainState?.enabled) { - handleDisableBrain(); - } else { - handleEnableBrain(); - } - }, [brainState?.enabled]); - - return ( - { - if (!isPro) { - setPricingDialog('true'); - } else { - setOpen(state); - } - }} - > - -
- - - Auto label - -
-
- - -
- Label Settings - -
- - Configure the labels that Zero uses to automatically organize your emails. - -
- - -
- {labels.map((label, index) => ( -
-
- - -
- ) => - handleUpdateLabel(label.id, 'name', e.target.value) - } - className="h-8" - placeholder="e.g., Important, Follow-up, Archive" - /> -
- -