Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion app/posts/[id]/ContentTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ export default function ContentTab({ post }: ContentTabProps) {
/>
</button>
))}
이미지
</div>
</div>
</div>
Expand Down
1 change: 0 additions & 1 deletion app/posts/[id]/PlaceDetailModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ export default function PlaceDetailModal({ place, onClose }: PlaceDetailModalPro
/>
</button>
))}
이미지
</div>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions hooks/usePlace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const usePlace = () => {
return [];
}
},
[]
[user]
);

/** μ—¬ν–‰μ§€ 단일 쑰회 */
Expand All @@ -84,7 +84,7 @@ export const usePlace = () => {
return null;
}
},
[]
[user]
);

/** μ—¬ν–‰μ§€ 리뷰 쑰회 */
Expand Down
15 changes: 11 additions & 4 deletions hooks/usePost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@ import { SortOption } from '@/components/posts/SortButton';
import { supabase } from '@/lib/supabaseClient';
import { PostWithUserAction, PostReview, PostInputType, FilterOption } from '@/types/post.type';
import { useCallback } from 'react';
import { useAuth } from './useAuth';

export const usePost = () => {
const { user } = useAuth();

const getAllPostsWithUserAction = useCallback(
async (sortBy?: SortOption, filter?: FilterOption): Promise<PostWithUserAction[]> => {
try {
let query = supabase.rpc('get_posts_with_user_action');
let query = supabase.rpc('get_posts_with_user_action', {
_user_id: user?.id ?? null,
});

if (sortBy) {
switch (sortBy) {
Expand Down Expand Up @@ -48,14 +53,16 @@ export const usePost = () => {
return [];
}
},
[]
[user]
);

const getPostWithUserAction = useCallback(
async (postId: string): Promise<PostWithUserAction | null> => {
try {
const { data, error } = await supabase
.rpc('get_posts_with_user_action')
.rpc('get_posts_with_user_action', {
_user_id: user?.id ?? null,
})
.eq('id', postId)
.single();
if (error) {
Expand All @@ -70,7 +77,7 @@ export const usePost = () => {
return null;
}
},
[]
[user]
);

const getPostReviews = useCallback(async (postId: string): Promise<PostReview[]> => {
Expand Down