-
Notifications
You must be signed in to change notification settings - Fork 0
[FEAT/#95] 내가 작성한 리뷰 페이지 구현 #96
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
chunjaemin
wants to merge
3
commits into
feat/#91-proposal-page-detail
Choose a base branch
from
feat/#95-myreview
base: feat/#91-proposal-page-detail
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.
+190
−4
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
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,5 @@ | ||
| import { MyReviewsPage } from "@/pages/student/my-reviews"; | ||
|
|
||
| export default function MyReviewsScreen() { | ||
| return <MyReviewsPage />; | ||
| } |
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 @@ | ||
| export { MyReviewsPage } from "./ui/MyReviewsPage"; |
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,35 @@ | ||
| import type { Review } from "./types"; | ||
|
|
||
| export const mockReviews: Review[] = [ | ||
| { | ||
| id: "1", | ||
| department: "IT대학", | ||
| studentStatus: "재학생", | ||
| rating: 5, | ||
| content: | ||
| "제휴 혜택 덕분에 부담 없이 자주 방문하게 됐어요. 음식도 맛있고 직원분들도 친절해서 매번 만족스러워요.", | ||
| images: [ | ||
| require("@/shared/assets/images/icon.png"), | ||
| require("@/shared/assets/images/icon.png"), | ||
| "skeleton", | ||
| ], | ||
| createdAt: new Date("2025-03-15T18:36:00"), | ||
| }, | ||
| { | ||
| id: "2", | ||
| department: "경영대학", | ||
| studentStatus: "휴학생", | ||
| rating: 3, | ||
| content: "가격 대비 괜찮은 편이에요. 혜택 적용이 간편해서 좋았습니다.", | ||
| createdAt: new Date("2025-03-10T12:20:00"), | ||
| }, | ||
| { | ||
| id: "3", | ||
| department: "사회과학대학", | ||
| studentStatus: "재학생", | ||
| rating: 4, | ||
| content: | ||
| "학생 할인이 적용돼서 자주 이용하고 있어요. 앞으로도 계속 제휴 유지해줬으면 좋겠어요!", | ||
| createdAt: new Date("2025-03-05T09:00:00"), | ||
| }, | ||
| ]; |
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 @@ | ||
| export type { Review, ReviewImage } from "@/entities/review"; |
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,111 @@ | ||
| import { useCallback, useState } from "react"; | ||
| import { FlatList, Pressable, Text, View } from "react-native"; | ||
| import { ReviewCard } from "@/entities/review"; | ||
| import { SortArrowDownIcon } from "@/shared/assets/icons"; | ||
| import { | ||
| type SortOrder, | ||
| useSortedByDate, | ||
| } from "@/shared/lib/hooks/useSortedByDate"; | ||
| import { colorTokens } from "@/shared/styles/tokens"; | ||
| import { AppTopBar } from "@/shared/ui/app-top-bar"; | ||
| import { DarkSelectBottomSheet } from "@/shared/ui/bottom-sheet"; | ||
| import { SmallButton } from "@/shared/ui/buttons/ActionButton"; | ||
| import { PageLayout } from "@/shared/ui/layout"; | ||
| import { mockReviews } from "../model/mockReviews"; | ||
| import type { Review } from "../model/types"; | ||
|
|
||
| const SORT_ITEMS: { label: string; value: SortOrder }[] = [ | ||
| { label: "최신순", value: "latest" }, | ||
| { label: "오래된순", value: "oldest" }, | ||
| ]; | ||
|
|
||
| const listContentStyle = { | ||
| gap: 20, | ||
| paddingHorizontal: 24, | ||
| paddingBottom: 20, | ||
| } as const; | ||
|
|
||
| export function MyReviewsPage() { | ||
| const [isSortSheetVisible, setSortSheetVisible] = useState(false); | ||
| const { | ||
| sort, | ||
| setSort, | ||
| sortedItems: sortedReviews, | ||
| } = useSortedByDate(mockReviews); | ||
|
|
||
| const renderItem = useCallback( | ||
| ({ item }: { item: Review }) => ( | ||
| <ReviewCard | ||
| review={item} | ||
| action={{ label: "삭제하기", onPress: () => {} }} | ||
| /> | ||
| ), | ||
| [], | ||
| ); | ||
|
|
||
| return ( | ||
| <> | ||
| <PageLayout | ||
| className="flex-1 bg-canvas" | ||
| contentContainerClassName="flex-1" | ||
| withBottomInset | ||
| > | ||
| <AppTopBar title="내가 작성한 리뷰" titleAlign="left" /> | ||
|
|
||
| {/* 서브헤더 */} | ||
| <View className="flex-row items-center justify-between px-screen-m pt-[20px] pb-[16px]"> | ||
| <Text className="text-sm font-medium text-content-primary"> | ||
| 작성한 리뷰가{" "} | ||
| <Text className="text-primary">{sortedReviews.length}</Text>건 | ||
| 있어요 | ||
| </Text> | ||
| <Pressable | ||
| onPress={() => setSortSheetVisible(true)} | ||
| hitSlop={8} | ||
| className="flex-row items-center gap-[5px]" | ||
| > | ||
| <Text className="text-sm font-medium text-content-primary"> | ||
| {SORT_ITEMS.find((item) => item.value === sort)?.label} | ||
| </Text> | ||
| <SortArrowDownIcon | ||
| width={20} | ||
| height={20} | ||
| color={colorTokens.contentPrimary} | ||
| /> | ||
| </Pressable> | ||
| </View> | ||
|
|
||
| {/* 리뷰 목록 또는 빈 상태 */} | ||
| {sortedReviews.length === 0 ? ( | ||
| <View className="absolute inset-0 items-center justify-center gap-7"> | ||
| <View className="items-center gap-1.5"> | ||
| <Text className="text-base font-medium text-content-primary"> | ||
| 아직 작성된 리뷰가 없어요! | ||
| </Text> | ||
| <Text className="text-sm text-content-secondary"> | ||
| 제휴 리뷰를 작성하면 혜택을 받을 수 있어요. | ||
| </Text> | ||
| </View> | ||
| <SmallButton onPress={() => {}}>리뷰 작성하기</SmallButton> | ||
| </View> | ||
| ) : ( | ||
| <FlatList<Review> | ||
| style={{ flex: 1 }} | ||
| data={sortedReviews} | ||
| keyExtractor={(item) => item.id} | ||
| renderItem={renderItem} | ||
| contentContainerStyle={listContentStyle} | ||
| /> | ||
| )} | ||
| </PageLayout> | ||
| <DarkSelectBottomSheet | ||
| visible={isSortSheetVisible} | ||
| title="정렬기준" | ||
| items={SORT_ITEMS} | ||
| value={sort} | ||
| onChange={setSort} | ||
| onClose={() => setSortSheetVisible(false)} | ||
| /> | ||
| </> | ||
| ); | ||
| } | ||
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,17 @@ | ||
| import { useMemo, useState } from "react"; | ||
|
|
||
| export type SortOrder = "latest" | "oldest"; | ||
|
|
||
| export function useSortedByDate<T extends { createdAt: Date }>(items: T[]) { | ||
| const [sort, setSort] = useState<SortOrder>("latest"); | ||
|
|
||
| const sortedItems = useMemo(() => { | ||
| return [...items].sort((a, b) => | ||
| sort === "latest" | ||
| ? b.createdAt.getTime() - a.createdAt.getTime() | ||
| : a.createdAt.getTime() - b.createdAt.getTime(), | ||
| ); | ||
| }, [items, sort]); | ||
|
|
||
| return { sort, setSort, sortedItems }; | ||
| } |
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.
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.
빈 상태(Empty State) UI에 absolute inset-0을 사용하면 AppTopBar를 포함한 전체 화면 중앙에 배치되어 헤더와 겹치거나 시각적으로 어색할 수 있습니다. flex-1 items-center justify-center를 사용하여 헤더 아래의 가용 영역 내에서 중앙에 위치하도록 수정하는 것을 권장합니다.