Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/features/minihome/post/list/PostList.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useEffect, useState } from "react";

import BevelScrollContainer from "@/components/Container/BevelScrollContainer";
import { useAuthUser } from "@/hooks/useAuthUser";
import type { PostWithCounts } from "@/types/post.types";
import supabase from "@/utils/supabase";

Expand All @@ -15,8 +14,7 @@ interface PostListProps {
export default function PostList({ onPostClick, ownerId }: PostListProps) {
const [posts, setPosts] = useState<PostWithCounts[]>([]);
const [isLoading, setIsLoading] = useState(true);

const { nickname: authorName } = useAuthUser();
const [ownerNickname, setOwnerNickname] = useState<string>("주인장");

useEffect(() => {
async function fetchPosts() {
Expand All @@ -29,7 +27,7 @@ export default function PostList({ onPostClick, ownerId }: PostListProps) {

const { data: homepage, error: homepageError } = await supabase
.from("homepages")
.select("id")
.select("id, owner:profiles!homepages_owner_id_fkey(nickname)")
.eq("owner_id", ownerId)
.single();

Expand All @@ -40,6 +38,7 @@ export default function PostList({ onPostClick, ownerId }: PostListProps) {
}

const homepageIdToFetch = homepage.id;
setOwnerNickname(homepage.owner?.nickname ?? "주인장");

const { data, error } = await supabase
.from("homepage_posts")
Expand Down Expand Up @@ -77,7 +76,7 @@ export default function PostList({ onPostClick, ownerId }: PostListProps) {
<PostItem
key={post.id}
post={post}
authorName={authorName || "주인장"}
authorName={ownerNickname}
onPostClick={onPostClick}
/>
))
Expand Down
Loading