-
Notifications
You must be signed in to change notification settings - Fork 1
feat(dog-walk): 산책 코스 차단 기능 및 로딩/빈 상태 UI 개선 #159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Lim-Ji-Hyeon
wants to merge
12
commits into
main
Choose a base branch
from
feature/dog-walk-block
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
c1dc767
feat: ✨ 산책 코스 게시물을 차단하는 훅 추가
Lim-Ji-Hyeon 609b592
feat: ✨ OptionsActionsheet 추가
Lim-Ji-Hyeon 1286b58
feat: ✨ 산책 코스 게시글 차단 관련 Actionsheet 추가
Lim-Ji-Hyeon f3c9a50
feat: ✨ DetailHeaderBar에 산책 코스 차단 Actionsheet 추가
Lim-Ji-Hyeon 79adb1e
refactor: ♻️ DetailHeaderBar props 수정
Lim-Ji-Hyeon 7cd9f7e
fix: 🐛 handleBlock 함수에 예외 처리 추가
Lim-Ji-Hyeon 046c2e8
feat: ✨ 스켈레톤 UI 추가
Lim-Ji-Hyeon ec88c78
feat: ✨ 산책 코스 데이터가 없을 때의 UI 개발
Lim-Ji-Hyeon a33f9b0
feat: ✨ 차단된 산책 코스 필터링 기능 구현
Lim-Ji-Hyeon 69e2852
feat: ✨ 검색 화면 차단 반영 및 빈 상태 UI 개선
Lim-Ji-Hyeon f6dc1a4
feat: ✨ 홈 화면 차단 반영 및 로딩/빈 상태 UI 개선
Lim-Ji-Hyeon 01f1ca0
feat: ✨ 산책 코스 조회시 userId 파라미터 추가
Lim-Ji-Hyeon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
apps/dog-walk/api/reactQuery/block/useInsertBlockCourse.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import { useMutation } from "@tanstack/react-query"; | ||
| import { supabase } from "@/api/supabaseClient"; | ||
|
|
||
| interface BlockCoursePayload { | ||
| userId: string; | ||
| courseId: number; | ||
| } | ||
|
|
||
| const insertBlockCourse = async ({ userId, courseId }: BlockCoursePayload) => { | ||
| const { data, error } = await supabase | ||
| .from("blocked_courses") | ||
| .insert({ | ||
| created_at: new Date(), | ||
| user_id: userId, | ||
| course_id: courseId, | ||
| }) | ||
| .select("id") | ||
| .single(); | ||
|
|
||
| if (error) throw error; | ||
|
|
||
| return data?.id ?? null; | ||
| }; | ||
|
|
||
| export const useInsertBlockCourse = () => { | ||
| return useMutation({ | ||
| mutationFn: (payload: BlockCoursePayload) => insertBlockCourse(payload), | ||
| }); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,24 +1,33 @@ | ||
| import { useQuery } from "@tanstack/react-query"; | ||
| import { supabase } from "@/api/supabaseClient"; | ||
| import { getBlockedCourseIds } from "@/api/utils/applyBlockFilter"; | ||
| import { queryKeys } from "../queryKeys"; | ||
|
|
||
| const fetchCourse = async (id: number) => { | ||
| const fetchCourse = async (id: number, userId?: string) => { | ||
| if (!id) throw new Error("Course ID 없음"); | ||
|
|
||
| const { data, error } = await supabase | ||
| .from("walking_courses") | ||
| .select("*") | ||
| .eq("id", id) | ||
| .single(); | ||
| const blockedIds = await getBlockedCourseIds(userId); | ||
|
|
||
| let query = supabase.from("walking_courses").select("*").eq("id", id); | ||
|
|
||
| if (blockedIds.length > 0) { | ||
| query = query.not("id", "in", `(${blockedIds.join(",")})`); | ||
| } | ||
|
|
||
| const { data, error } = await query.single(); | ||
|
|
||
| if (error) throw error; | ||
| return data; | ||
| }; | ||
|
|
||
| export const useFindCourse = (id: number) => { | ||
| export const useFindCourse = (id: number, userId?: string) => { | ||
| return useQuery({ | ||
| queryKey: [queryKeys.course.findCourse, id], | ||
| queryFn: () => fetchCourse(id), | ||
| queryKey: [queryKeys.course.findCourse, id, userId], | ||
| queryFn: () => fetchCourse(id, userId), | ||
| enabled: !!id, | ||
| staleTime: 0, | ||
| gcTime: 0, | ||
| refetchOnMount: "always", | ||
| refetchOnWindowFocus: true, | ||
| }); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import { supabase } from "../supabaseClient"; | ||
|
|
||
| export const getBlockedCourseIds = async ( | ||
| userId?: string, | ||
| ): Promise<number[]> => { | ||
| if (!userId) return []; | ||
|
|
||
| const { data, error } = await supabase | ||
| .from("blocked_courses") | ||
| .select("course_id") | ||
| .eq("user_id", userId); | ||
|
|
||
| if (error) { | ||
| console.error("Failed to fetch blocked courses:", error); | ||
| return []; | ||
| } | ||
|
|
||
| return data.map((item) => item.course_id); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
요거 다 들어가는거면 쿼리클라이언트에 들어가는게 나으려나요?!