Skip to content

Commit d81afc1

Browse files
committed
Merge remote-tracking branch 'origin/dev' into feat/login#108
2 parents bc43755 + f3a82f0 commit d81afc1

File tree

23 files changed

+468
-74
lines changed

23 files changed

+468
-74
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// import CommentList from '@/domains/shared/components/comment/CommentList';
1+
import MyComment from '@/domains/mypage/components/pages/my-active/MyComment';
22
import { Metadata } from 'next';
33

44
export const metadata: Metadata = {
@@ -7,6 +7,6 @@ export const metadata: Metadata = {
77
};
88

99
function Page() {
10-
return <>{/* <CommentList /> */}</>;
10+
return <MyComment />;
1111
}
1212
export default Page;
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// import PostCard from '@/domains/community/main/PostCard';
2+
import MyLike from '@/domains/mypage/components/pages/my-active/MyLike';
23
import { Metadata } from 'next';
34

45
export const metadata: Metadata = {
@@ -7,6 +8,6 @@ export const metadata: Metadata = {
78
};
89

910
function Page() {
10-
return <section>{/* <PostCard posts={posts} isLoading={isLoading} /> */}</section>;
11+
// return <MyLike />;
1112
}
1213
export default Page;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// import PostCard from '@/domains/community/main/PostCard';
1+
import MyPost from '@/domains/mypage/components/pages/my-active/MyPost';
22
import { Metadata } from 'next';
33

44
export const metadata: Metadata = {
@@ -7,6 +7,6 @@ export const metadata: Metadata = {
77
};
88

99
function Page() {
10-
return <div>{/* <PostCard posts={posts} isLoading={isLoading} /> */}</div>;
10+
return <MyPost />;
1111
}
1212
export default Page;

src/app/mypage/my-alarm/page.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Alarm from '@/domains/mypage/components/Alarm';
1+
import MyAlarm from '@/domains/mypage/components/pages/my-alarm/MyAlarm';
22

33
import { Metadata } from 'next';
44

@@ -10,10 +10,7 @@ export const metadata: Metadata = {
1010
function Page() {
1111
return (
1212
<div className="flex flex-col gap-3">
13-
<Alarm></Alarm>
14-
<Alarm></Alarm>
15-
<Alarm></Alarm>
16-
<Alarm></Alarm>
13+
<MyAlarm />
1714
</div>
1815
);
1916
}

src/app/mypage/my-bar/page.tsx

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import CocktailCard from '@/domains/shared/components/cocktail-card/CocktailCard';
1+
import MyBar from '@/domains/mypage/components/pages/my-bar/MyBar';
22
import { Metadata } from 'next';
33

44
export const metadata: Metadata = {
@@ -7,19 +7,6 @@ export const metadata: Metadata = {
77
};
88

99
function Page() {
10-
return (
11-
<div
12-
className="grid grid-cols-1 justify-items-center mt-10 gap-8 sm:[grid-template-columns:repeat(2,minmax(0,320px))] sm:justify-evenly md:[grid-template-columns:repeat(3,minmax(0,250px))]
13-
"
14-
>
15-
<CocktailCard
16-
src=""
17-
textSize1="text-xl"
18-
name="Old Pashioned"
19-
nameKo="올드 패션드"
20-
keep={false}
21-
></CocktailCard>
22-
</div>
23-
);
10+
return <MyBar />;
2411
}
2512
export default Page;
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
'use client';
2+
import { getApi } from '@/app/api/config/appConfig';
3+
import { useEffect, useState } from 'react';
4+
5+
interface Profile {
6+
abvDegree: number;
7+
abvLabel: string;
8+
abvLevel: number;
9+
email?: string;
10+
id: number;
11+
myCommentCount: number;
12+
myKeepCount: number;
13+
myLikedPostCount: number;
14+
myPostCount: number;
15+
nickname: string;
16+
}
17+
18+
function useFetchProfile() {
19+
const [profile, setProfile] = useState<Profile | null>(null);
20+
21+
const fetchProfile = async () => {
22+
const res = await fetch(`${getApi}/me/profile`, {
23+
method: 'GET',
24+
credentials: 'include',
25+
});
26+
const json = await res.json();
27+
setProfile(json.data);
28+
};
29+
30+
useEffect(() => {
31+
fetchProfile();
32+
}, []);
33+
34+
return { profile, fetchProfile };
35+
}
36+
export default useFetchProfile;

src/domains/mypage/components/Alarm.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@ import clsx from 'clsx';
44
import Image from 'next/image';
55
import { useState } from 'react';
66

7-
function Alarm() {
7+
interface Props {
8+
title: string;
9+
content: string;
10+
}
11+
12+
function Alarm({ title, content }: Props) {
813
const [isClick, setIsClick] = useState(false);
914

1015
const handleClick = () => {
@@ -27,8 +32,8 @@ function Alarm() {
2732
<p className="text-sm text-white/80">10분 전</p>
2833
</div>
2934
<div className="flex flex-col">
30-
<h2 className="text-lg font-bold">새로운 좋아요 알림</h2>
31-
<p className="text-sm text-white/80">User님이 내 글에 좋아요를 누르셨습니다.</p>
35+
<h2 className="text-lg font-bold">{title}</h2>
36+
<p className="text-sm text-white/80">{content}</p>
3237
</div>
3338
</div>
3439
</div>

src/domains/mypage/components/EditNickName.tsx

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,76 @@
1+
import { getApi } from '@/app/api/config/appConfig';
12
import Button from '@/shared/components/button/Button';
23
import TextButton from '@/shared/components/button/TextButton';
34
import Input from '@/shared/components/Input-box/Input';
45
import ModalLayout from '@/shared/components/modal-pop/ModalLayout';
6+
import { useToast } from '@/shared/hook/useToast';
7+
import { Dispatch, SetStateAction } from 'react';
58

69
interface Props {
710
open: boolean;
811
onClose: () => void;
12+
setNickName: (v: string) => void;
13+
setIsOpen: Dispatch<SetStateAction<boolean>>;
14+
editNickName: string;
15+
setEditNickName: Dispatch<SetStateAction<string>>;
916
}
1017

11-
function EditNickName({ open, onClose }: Props) {
18+
function EditNickName({
19+
open,
20+
onClose,
21+
setNickName,
22+
setIsOpen,
23+
editNickName,
24+
setEditNickName,
25+
}: Props) {
26+
const { toastError } = useToast();
27+
const handlesave = async () => {
28+
if (editNickName.length <= 1) {
29+
toastError('닉네임은 2글자 이상 입력해야합니다');
30+
return;
31+
}
32+
33+
await setNickName(editNickName);
34+
35+
await fetch(`${getApi}/me/profile`, {
36+
method: 'PATCH',
37+
credentials: 'include',
38+
headers: {
39+
'Content-Type': 'application/json',
40+
},
41+
body: JSON.stringify({
42+
nickname: editNickName,
43+
}),
44+
});
45+
await setIsOpen(false);
46+
};
47+
48+
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
49+
setEditNickName(e.target.value);
50+
};
51+
1252
return (
1353
<ModalLayout
1454
title="닉네임 수정"
1555
description="닉네임을 수정해주세요."
1656
open={open}
1757
onClose={onClose}
18-
buttons={<Button>저장</Button>}
58+
buttons={
59+
<Button type="submit" onClick={handlesave}>
60+
저장
61+
</Button>
62+
}
1963
>
2064
<div className="flex flex-col gap-3 items-end">
2165
<label htmlFor="editNickName" className="sr-only">
2266
닉네임변경
2367
</label>
24-
<Input placeholder="8글자 이내로 입력해주세요" id="editNicName" className="w-full" />
68+
<Input
69+
onChange={(e) => handleChange(e)}
70+
placeholder="8글자 이내로 입력해주세요"
71+
id="editNickName"
72+
className="w-full"
73+
/>
2574
<TextButton onClick={onClose}>기존 이름으로 돌아가기</TextButton>
2675
</div>
2776
</ModalLayout>

src/domains/mypage/components/ToggleBtn.tsx

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,45 @@
11
'use client';
2+
import { getApi } from '@/app/api/config/appConfig';
3+
import { useToast } from '@/shared/hook/useToast';
24
import clsx from 'clsx';
3-
import { useState } from 'react';
5+
import { useEffect, useState } from 'react';
46

57
function ToggleBtn() {
6-
const [isClick, setIsClick] = useState(false);
8+
const [isClick, setIsClick] = useState<boolean | null>(null);
9+
const { toastSuccess } = useToast();
710

8-
const handleClick = () => {
9-
setIsClick(!isClick);
11+
useEffect(() => {
12+
const fetchToggle = async () => {
13+
try {
14+
const res = await fetch(`${getApi}/me/notification-setting`, {
15+
method: 'GET',
16+
credentials: 'include',
17+
});
18+
const json = await res.json();
19+
setIsClick(json.data.enabled);
20+
} catch {
21+
console.error();
22+
}
23+
};
24+
fetchToggle();
25+
}, []);
26+
27+
const handleClick = async () => {
28+
if (isClick === null) return;
29+
const next = !isClick;
30+
setIsClick(next);
31+
32+
await fetch(`${getApi}/me/notification-setting`, {
33+
method: 'PATCH',
34+
credentials: 'include',
35+
headers: { 'Content-Type': 'application/json' },
36+
body: JSON.stringify({
37+
enabled: next,
38+
}),
39+
});
40+
next ? toastSuccess('알림이 설정되었습니다.') : toastSuccess('알림이 해제되었습니다');
1041
};
42+
1143
return (
1244
<button
1345
className={clsx(

src/domains/mypage/components/WithdrawModal.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
'use client';
2+
13
import CrySsury from '@/shared/assets/ssury/ssury_cry.webp';
24
import Image from 'next/image';
35
import ModalLayout from '@/shared/components/modal-pop/ModalLayout';
46
import Button from '@/shared/components/button/Button';
7+
58
interface Props {
69
open: boolean;
710
onClose: () => void;

0 commit comments

Comments
 (0)