bulk cart
This commit is contained in:
@@ -5,9 +5,13 @@ import { useAuthStore } from '@/zustand/authStore';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import React from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { removeToken, removeRefreshToken } from '@/lib/api/func';
|
||||
|
||||
export type LogoutPromptProps = Omit<PromptProps, 'onConfirm' | 'onCancel' | 'children'> & {
|
||||
slug?: string;
|
||||
};
|
||||
|
||||
function LogoutPrompt({ ...rest }: Omit<PromptProps, 'onConfirm' | 'onCancel' | 'children'>) {
|
||||
function LogoutPrompt({ slug, ...rest }: LogoutPromptProps) {
|
||||
const { t } = useTranslation('common', {
|
||||
keyPrefix: 'LogoutModal'
|
||||
});
|
||||
@@ -15,12 +19,15 @@ function LogoutPrompt({ ...rest }: Omit<PromptProps, 'onConfirm' | 'onCancel' |
|
||||
const router = useRouter();
|
||||
const userIsAuthenticated = useAuthStore((state) => state.isAuthenticated);
|
||||
|
||||
const onConfirmLogout = (e: React.MouseEvent) => {
|
||||
const onConfirmLogout = async (e: React.MouseEvent) => {
|
||||
if (!e) return;
|
||||
if (userIsAuthenticated) {
|
||||
authLogout();
|
||||
await removeToken();
|
||||
await removeRefreshToken();
|
||||
}
|
||||
router.replace('/');
|
||||
const redirectPath = slug ? `/${slug}` : '/';
|
||||
router.replace(redirectPath);
|
||||
};
|
||||
|
||||
const toggleShareModalVisiblity = (e: React.MouseEvent) => {
|
||||
|
||||
Reference in New Issue
Block a user