Skip to content
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

feat(community): 마이 페이지 추가 #38

Merged
merged 17 commits into from
Dec 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const user = {
const myProfile = {
name: '강민하',
phone: '010-0000-0000',
email: '[email protected]',
Expand All @@ -7,4 +7,4 @@ const user = {
id: '201912000',
};

export { user };
export { myProfile };
5 changes: 5 additions & 0 deletions apps/community/src/app/api/mock/my/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { myProfile } from './data';

export function GET() {
return Response.json({ data: myProfile });
}
5 changes: 0 additions & 5 deletions apps/community/src/app/api/mock/users/route.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { MyInfoCard } from '~/components/my/my-info-card';
import { MyInfoField } from '~/components/my/my-info-field';
import { PageHeader } from '~/components/page-header';
import { UserCard } from '~/components/users/user-card';
import { UserList } from '~/components/users/user-list';
import { getUser } from './remotes';
import { getMyProfile } from './remotes';

// TODO: for mocking but will be replaced with a proper solution later
export const dynamic = 'force-dynamic';

export default async function UserPage() {
const { data } = await getUser();
export default async function MyPage() {
const { data } = await getMyProfile();
console.log(data);
gwansikk marked this conversation as resolved.
Show resolved Hide resolved

const userDetails = [
{ title: '이름', value: data.name },
Expand All @@ -24,13 +25,15 @@ export default async function UserPage() {
title="회원 정보"
description="등록한 회원 정보를 확인할 수 있어요."
/>
<UserCard>
<MyInfoCard>
{userDetails.map((detail) => (
<UserList key={detail.title} title={detail.title}>
<UserList.Row>{detail.value}</UserList.Row>
</UserList>
<MyInfoField
key={detail.title}
title={detail.title}
value={detail.value}
/>
))}
</UserCard>
</MyInfoCard>
</>
);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { MOCK_END_POINT } from '~/constants/api';
import { http } from '~/utils/http';

interface User {
interface MyProfile {
id: string;
name: string;
phone: string;
Expand All @@ -10,8 +10,8 @@ interface User {
major: string;
}

function getUser() {
return http.get<User>(MOCK_END_POINT.USERS);
function getMyProfile() {
return http.get<MyProfile>(MOCK_END_POINT.MY_PROFILE);
}

export { type User, getUser };
export { type MyProfile, getMyProfile };
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as style from '~/components/users/user-card.css';
import * as style from '~/components/my/my-info-card.css';

interface Props {
children: React.ReactNode;
}

function UserCard({ children }: Props) {
function MyInfoCard({ children }: Props) {
return (
<div className={style.cardWrapper}>
<h2 className={style.cardTitle}>내 프로필</h2>
Expand All @@ -13,4 +13,4 @@ function UserCard({ children }: Props) {
);
}

export { UserCard };
export { MyInfoCard };
19 changes: 19 additions & 0 deletions apps/community/src/components/my/my-info-field.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import * as styles from '~/components/my/my-info-field.css';

interface Props {
title: string;
value: React.ReactNode;
}

function MyInfoField({ title, value }: Props) {
Copy link
Member

Choose a reason for hiding this comment

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

해당 컴포넌트가 단독으로 사용되는 유즈-케이스가 없다면 MyInfoCard에 컴파운드 패턴으로 묶어도 좋을거 같아요

return (
<div>
<h3 className={styles.listTitle}>{title}</h3>
<ul className={styles.list}>
<li>{value}</li>
</ul>
</div>
);
}

export { MyInfoField };
23 changes: 0 additions & 23 deletions apps/community/src/components/users/user-list.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion apps/community/src/constants/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const MOCK_END_POINT = {
PROFESSORS: `${MOCK_BASE_URL}/professors`,
CLUB: `${MOCK_BASE_URL}/about/club`,
CONTACT: `${MOCK_BASE_URL}/about/contact`,
USERS: `${MOCK_BASE_URL}/users`,
MY_PROFILE: `${MOCK_BASE_URL}/my`,
BOARD: `${MOCK_BASE_URL}/board`,
BOARD_DETAIL: `${MOCK_BASE_URL}/board/detail`,
} as const;
Expand Down
Loading