Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyphilemon committed Dec 3, 2024
1 parent 4bbd638 commit a17ab7e
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions components/sidebar-history.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
"use client";
'use client';

import { isToday, isYesterday, subMonths, subWeeks } from "date-fns";
import Link from "next/link";
import { useParams, usePathname, useRouter } from "next/navigation";
import type { User } from "next-auth";
import { memo, useEffect, useState } from "react";
import { toast } from "sonner";
import useSWR from "swr";
import { isToday, isYesterday, subMonths, subWeeks } from 'date-fns';
import Link from 'next/link';
import { useParams, usePathname, useRouter } from 'next/navigation';
import type { User } from 'next-auth';
import { memo, useEffect, useState } from 'react';
import { toast } from 'sonner';
import useSWR from 'swr';

import { MoreHorizontalIcon, TrashIcon } from "@/components/icons";
import { MoreHorizontalIcon, TrashIcon } from '@/components/icons';
import {
AlertDialog,
AlertDialogAction,
Expand All @@ -18,13 +18,13 @@ import {
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
} from "@/components/ui/alert-dialog";
} from '@/components/ui/alert-dialog';
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
} from '@/components/ui/dropdown-menu';
import {
SidebarGroup,
SidebarGroupContent,
Expand All @@ -33,10 +33,10 @@ import {
SidebarMenuButton,
SidebarMenuItem,
useSidebar,
} from "@/components/ui/sidebar";
import type { Chat } from "@/lib/db/schema";
import { fetcher } from "@/lib/utils";
import equal from "fast-deep-equal";
} from '@/components/ui/sidebar';
import type { Chat } from '@/lib/db/schema';
import { fetcher } from '@/lib/utils';
import equal from 'fast-deep-equal';

type GroupedChats = {
today: Chat[];
Expand Down Expand Up @@ -100,7 +100,7 @@ export function SidebarHistory({ user }: { user: User | undefined }) {
data: history,
isLoading,
mutate,
} = useSWR<Array<Chat>>(user ? "/api/history" : null, fetcher, {
} = useSWR<Array<Chat>>(user ? '/api/history' : null, fetcher, {
fallbackData: [],
});

Expand All @@ -113,26 +113,26 @@ export function SidebarHistory({ user }: { user: User | undefined }) {
const router = useRouter();
const handleDelete = async () => {
const deletePromise = fetch(`/api/chat?id=${deleteId}`, {
method: "DELETE",
method: 'DELETE',
});

toast.promise(deletePromise, {
loading: "Deleting chat...",
loading: 'Deleting chat...',
success: () => {
mutate((history) => {
if (history) {
return history.filter((h) => h.id !== id);
}
});
return "Chat deleted successfully";
return 'Chat deleted successfully';
},
error: "Failed to delete chat",
error: 'Failed to delete chat',
});

setShowDeleteDialog(false);

if (deleteId === id) {
router.push("/");
router.push('/');
}
};

Expand Down Expand Up @@ -165,7 +165,7 @@ export function SidebarHistory({ user }: { user: User | undefined }) {
className="h-4 rounded-md flex-1 max-w-[--skeleton-width] bg-sidebar-accent-foreground/10"
style={
{
"--skeleton-width": `${item}%`,
'--skeleton-width': `${item}%`,
} as React.CSSProperties
}
/>
Expand Down

0 comments on commit a17ab7e

Please sign in to comment.