feat(delete-chat): use `window.location` to refresh page
This commit is contained in:
parent
b33e5fefba
commit
f1c0b5435b
|
@ -11,7 +11,6 @@ import {
|
||||||
import { Fragment, useState } from 'react';
|
import { Fragment, useState } from 'react';
|
||||||
import { toast } from 'sonner';
|
import { toast } from 'sonner';
|
||||||
import { Chat } from '@/app/library/page';
|
import { Chat } from '@/app/library/page';
|
||||||
import { useRouter } from 'next/navigation';
|
|
||||||
|
|
||||||
const DeleteChat = ({
|
const DeleteChat = ({
|
||||||
chatId,
|
chatId,
|
||||||
|
@ -27,8 +26,6 @@ const DeleteChat = ({
|
||||||
const [confirmationDialogOpen, setConfirmationDialogOpen] = useState(false);
|
const [confirmationDialogOpen, setConfirmationDialogOpen] = useState(false);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
|
|
||||||
const router = useRouter();
|
|
||||||
|
|
||||||
const handleDelete = async () => {
|
const handleDelete = async () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
try {
|
||||||
|
@ -51,7 +48,7 @@ const DeleteChat = ({
|
||||||
setChats(newChats);
|
setChats(newChats);
|
||||||
|
|
||||||
if (redirect) {
|
if (redirect) {
|
||||||
router.push('/');
|
window.location.href = '/';
|
||||||
}
|
}
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
toast.error(err.message);
|
toast.error(err.message);
|
||||||
|
|
Loading…
Reference in New Issue