Skip to content
Open
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
5 changes: 5 additions & 0 deletions src/app/(protected)/student/my-reviews.tsx
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 />;
}
1 change: 1 addition & 0 deletions src/pages/student/my-reviews/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { MyReviewsPage } from "./ui/MyReviewsPage";
35 changes: 35 additions & 0 deletions src/pages/student/my-reviews/model/mockReviews.ts
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"),
},
];
1 change: 1 addition & 0 deletions src/pages/student/my-reviews/model/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type { Review, ReviewImage } from "@/entities/review";
111 changes: 111 additions & 0 deletions src/pages/student/my-reviews/ui/MyReviewsPage.tsx
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">
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

빈 상태(Empty State) UI에 absolute inset-0을 사용하면 AppTopBar를 포함한 전체 화면 중앙에 배치되어 헤더와 겹치거나 시각적으로 어색할 수 있습니다. flex-1 items-center justify-center를 사용하여 헤더 아래의 가용 영역 내에서 중앙에 위치하도록 수정하는 것을 권장합니다.

Suggested change
<View className="absolute inset-0 items-center justify-center gap-7">
<View className="flex-1 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)}
/>
</>
);
}
6 changes: 5 additions & 1 deletion src/pages/student/profile/ui/StudentProfilePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ export function StudentProfilePage() {
const router = useRouter();

const myAccountItems: AccountMenuItemProps[] = [
{ label: "내가 작성한 리뷰", iconName: "writing" },
{
label: "내가 작성한 리뷰",
iconName: "writing",
onPress: () => router.push("../my-reviews"),
},
{ label: "로그아웃", iconName: "exitRight" },
];

Expand Down
1 change: 1 addition & 0 deletions src/shared/assets/icons/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export { default as LoginNoIcon } from "./login-no-icon.svg";
export { default as Logo } from "./logo.svg";
export { default as QRIcon } from "./qr-icon.svg";
export { default as SearchIcon } from "./search-icon.svg";
export { default as SortArrowDownIcon } from "./sort-arrow-down.svg";
export { default as SpeechBubbleIcon } from "./speech-bubble-icon.svg";
export { default as StampActive } from "./stamp-active.svg";
export { default as StampInactive } from "./stamp-inactive.svg";
Expand Down
3 changes: 3 additions & 0 deletions src/shared/assets/icons/sort-arrow-down.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions src/shared/lib/hooks/useSortedByDate.ts
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 };
}
14 changes: 11 additions & 3 deletions src/shared/ui/app-top-bar/AppTopBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@ import { colorTokens } from "@/shared/styles/tokens";
interface AppTopBarProps {
title: string;
onBack?: () => void;
titleAlign?: "left" | "center";
}

export function AppTopBar({ title, onBack }: AppTopBarProps) {
export function AppTopBar({
title,
onBack,
titleAlign = "center",
}: AppTopBarProps) {
const isLeft = titleAlign === "left";
return (
<View className="flex-row items-center px-screen-m pt-7 pb-4">
<Pressable hitSlop={8} onPress={onBack ?? (() => router.back())}>
Expand All @@ -18,10 +24,12 @@ export function AppTopBar({ title, onBack }: AppTopBarProps) {
color={colorTokens.contentPrimary}
/>
</Pressable>
<Text className="flex-1 text-center text-lg font-semibold text-content-primary">
<Text
className={`flex-1 text-xl font-semibold text-content-primary ${isLeft ? "ml-3" : "text-center"}`}
>
{title}
</Text>
<View style={{ width: 24 }} />
{!isLeft && <View style={{ width: 24 }} />}
</View>
);
}
Loading