Improve admin ban UX, add product cloning, and enhance auth handling
Refines the admin ban page with better dialog state management and feedback during ban/unban actions. Adds a product cloning feature to the products dashboard and updates the product table to support cloning. Improves error handling in ChatDetail for authentication errors, and enhances middleware to handle auth check timeouts and network errors more gracefully. Also updates BanUserCard to validate user ID and ensure correct request formatting.
This commit is contained in:
@@ -277,9 +277,17 @@ export default function ChatDetail({ chatId }: { chatId: string }) {
|
||||
setTimeout(() => {
|
||||
scrollToBottomHandler();
|
||||
}, 100);
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
console.error("Error fetching chat data:", error);
|
||||
toast.error("Failed to load chat");
|
||||
|
||||
// Don't redirect on auth errors - let the middleware handle it
|
||||
// Only show error toast for non-auth errors
|
||||
if (error?.message?.includes('401') || error?.message?.includes('403')) {
|
||||
// Auth errors will be handled by middleware, don't show toast
|
||||
console.log("Auth error detected, middleware will handle redirect");
|
||||
} else {
|
||||
toast.error("Failed to load chat");
|
||||
}
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@@ -352,8 +360,14 @@ export default function ChatDetail({ chatId }: { chatId: string }) {
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
console.error("Error polling new messages:", error);
|
||||
|
||||
// Silently fail on auth errors during polling - don't disrupt the user
|
||||
if (error?.message?.includes('401') || error?.message?.includes('403')) {
|
||||
console.log("Auth error during polling, stopping poll");
|
||||
return;
|
||||
}
|
||||
} finally {
|
||||
isPollingRef.current = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user