diff --git a/frontend/src/components/blog/comments/Comments.tsx b/frontend/src/components/blog/comments/Comments.tsx index 21836ad..5e12b68 100644 --- a/frontend/src/components/blog/comments/Comments.tsx +++ b/frontend/src/components/blog/comments/Comments.tsx @@ -14,8 +14,10 @@ interface CommentsProps { } export default function Comments(props: CommentsProps) { + console.log('[Comments] SSR isAuthorized:', props.isAuthorized); const [isAuthenticated, setIsAuthenticated] = createSignal(props.isAuthorized ?? false); - const [currentUser, setCurrentUser] = createSignal<{ + console.log('[Comments] Initial isAuthenticated:', isAuthenticated()); +const [currentUser, setCurrentUser] = createSignal<{ id: string; name: string; email: string; @@ -52,6 +54,7 @@ export default function Comments(props: CommentsProps) { const data = await response.json(); if (data.authenticated && data.user) { + setIsAuthenticated(true); setCurrentUser({ id: data.user.id, name: data.user.name || "Пользователь", @@ -67,6 +70,7 @@ export default function Comments(props: CommentsProps) { const loadComments = async () => { try { + setIsLoading(true); const response = await fetch( `/api/comments?post_slug=${encodeURIComponent(props.postSlug)}&parent=null`, { @@ -101,6 +105,8 @@ export default function Comments(props: CommentsProps) { setComments(commentsWithReplies); } catch (error) { console.error("[Comments] Ошибка загрузки комментариев:", error); + } finally { + setIsLoading(false); } }; @@ -299,6 +305,11 @@ export default function Comments(props: CommentsProps) { )} + {/* DEBUG */} +