Skip to content

Commit aff0807

Browse files
Merge pull request #48 from Team9994/fix/47-home_maintenance
�홈 페이지 유지보수
2 parents 42b5e65 + ef8447f commit aff0807

File tree

9 files changed

+65
-28
lines changed

9 files changed

+65
-28
lines changed

src/app/(home)/components/RoutineList.tsx

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const RoutineList = ({ routineList }: { routineList: RoutineDto[] }) => {
4040
.reverse()
4141
.map((data) => (
4242
<div
43-
className="bg-backgrounds-sub rounded-6 h-[76px] box-border mb-3 mx-5 p-4 text-text-main relative"
43+
className="relative bg-backgrounds-sub rounded-6 h-[76px] box-border mb-3 mx-5 p-4 text-text-main cursor-pointer"
4444
key={data.routineId}
4545
onClick={() => toggleDrawer(data.routineId)}
4646
>
@@ -65,24 +65,32 @@ const RoutineList = ({ routineList }: { routineList: RoutineDto[] }) => {
6565
{activeMenuId === data.routineId && (
6666
<div
6767
ref={menuRef}
68-
className="absolute top-[calc(50%-12px)] z-10 right-5 shadow-main bg-backgrounds-light text-md"
68+
className="absolute top-[calc(50%-12px)] right-5 shadow-main bg-backgrounds-light text-md zIndex"
6969
>
70-
<div className="w-[152px] h-[46px] text-text-main p-3 cursor-pointer border-b border-borders-sub">
70+
{/* <div
71+
onClick={(e: React.MouseEvent<HTMLDivElement>) => {
72+
e.stopPropagation();
73+
}}
74+
className="w-[152px] h-[46px] text-text-main p-3 cursor-pointer border-b border-borders-sub"
75+
>
7176
수정
72-
</div>
77+
</div> */}
7378
<AlertDialog>
7479
<AlertDialogTrigger asChild>
7580
<div
7681
className="w-[152px] h-[46px] text-text-accent p-3 cursor-pointer"
77-
onClick={() => setRoutineToDelete(data.routineId)}
82+
onClick={(e: React.MouseEvent<HTMLDivElement>) => {
83+
e.stopPropagation();
84+
setRoutineToDelete(data.routineId);
85+
}}
7886
>
7987
삭제
8088
</div>
8189
</AlertDialogTrigger>
82-
<AlertDialogOverlay className="bg-[rgba(0, 0, 0, 0.7)]" />
90+
<AlertDialogOverlay className="bg-[rgba(0, 0, 0,0.1)" />
8391
<AlertDialogContent className="w-[296px] h-[148px] bg-backgrounds-sub rounded-6 p-0 flex flex-col items-center text-text-main border-none">
8492
<AlertDialogHeader className="text-center">
85-
<AlertDialogTitle className="text-lg py-[19px] pb-[11px] font-semibold leading-[26px]">
93+
<AlertDialogTitle className="text-lg py-[19px] pb-[11px] font-semibold leading-[26px] text-center">
8694
루틴 삭제
8795
</AlertDialogTitle>
8896
<AlertDialogDescription className="text-sm font-normal leading-5 text-text-main">
@@ -92,14 +100,17 @@ const RoutineList = ({ routineList }: { routineList: RoutineDto[] }) => {
92100
<div className="flex items-center h-12">
93101
<AlertDialogCancel
94102
className="w-[148px] h-full m-0 p-0 text-md font-medium bg-transparent leading-[22px] text-text-light text-center cursor-pointer border-none
95-
focus:outline-none focus:ring-0 active:bg-transparent hover:bg-transparent"
96-
onClick={() => setRoutineToDelete(undefined)}
103+
focus:outline-none focus:ring-0 active:bg-transparent hover:bg-transparent hover:text-text-main"
104+
onClick={(e: React.MouseEvent<HTMLButtonElement>) => {
105+
e.stopPropagation();
106+
setRoutineToDelete(undefined);
107+
}}
97108
>
98109
취소
99110
</AlertDialogCancel>
100111
<AlertDialogAction
101112
className="w-[148px] h-full m-0 p-0 text-md font-medium bg-transparent leading-[22px] text-text-accent text-center cursor-pointer border-none
102-
focus:outline-none focus:ring-0 active:bg-transparent hover:bg-transparent"
113+
focus:outline-none focus:ring-0 active:bg-transparent hover:bg-transparent hover:font-bold"
103114
onClick={confirmDelete}
104115
>
105116
삭제
@@ -129,7 +140,7 @@ const RoutineList = ({ routineList }: { routineList: RoutineDto[] }) => {
129140
</Link>
130141
<Drawer open={drawerToggle} onClose={() => toggleDrawer(selectedId)}>
131142
<div
132-
className={`fixed w-full h-screen inset-0 bg-backgrounds-default opacity-70 z-40 transition-opacity duration-300 ${
143+
className={`fixed w-full h-screen inset-0 bg-backgrounds-default opacity-70 transition-opacity duration-300 ${
133144
drawerToggle ? 'opacity-70 visible' : 'opacity-0 invisible'
134145
}`}
135146
onClick={() => toggleDrawer(selectedId)}

src/app/(home)/hooks/useRoutine.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import React, { useEffect, useRef, useState } from 'react';
22
import { useRouter } from 'next/navigation';
3+
import { useDeleteRoutineMutation } from '@/app/api/routine/query';
34

45
const useRoutine = () => {
6+
const { deleteRoutineMutation } = useDeleteRoutineMutation();
57
const [activeMenuId, setActiveMenuId] = useState<number | undefined>(undefined);
68
const [routineToDelete, setRoutineToDelete] = useState<number | undefined>(undefined);
79
const menuRef = useRef<HTMLDivElement | null>(null);
@@ -28,10 +30,14 @@ const useRoutine = () => {
2830
}
2931
};
3032

31-
const confirmDelete = () => {
32-
console.log(`${routineToDelete}가 삭제되었습니다.`);
33-
setRoutineToDelete(undefined);
34-
setActiveMenuId(undefined);
33+
const confirmDelete = (e: React.MouseEvent<HTMLButtonElement>) => {
34+
e.stopPropagation();
35+
if (routineToDelete) {
36+
deleteRoutineMutation.mutate(String(routineToDelete));
37+
window.location.reload();
38+
setRoutineToDelete(undefined);
39+
setActiveMenuId(undefined);
40+
}
3541
};
3642

3743
const moveRouter = (id: number, type: string) => {

src/app/(home)/layout.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
import Footer from '@/components/layouts/Footer';
22
import Header from '@/components/layouts/Header';
33
import Image from 'next/image';
4+
import Link from 'next/link';
45
import { PropsWithChildren } from 'react';
56

67
export default function HomeLayout({ children }: PropsWithChildren<{}>) {
78
return (
89
<>
910
<Header
1011
left={<Image src={'/assets/logo.svg'} alt={'로고'} width={138} height={24} />}
11-
right={<Image src={'/assets/bell.svg'} alt={'알림'} width={17} height={21} />}
12+
right={
13+
<Link href={'./alarm'}>
14+
<Image src={'/assets/bell.svg'} alt={'알림'} width={17} height={21} />
15+
</Link>
16+
}
1217
className="relative z-20"
1318
/>
1419
{children}

src/app/(home)/page.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,25 @@ import { getRoutineList } from '@/app/api/routine';
99
export const revalidate = 0;
1010
export default async function Home() {
1111
const session = await auth();
12-
console.log(session);
1312
if (!session?.user.name) {
1413
redirect('/sign');
1514
}
1615
if (session?.nickname === undefined) {
1716
redirect('/sign/additional-info');
1817
}
19-
// TODO : 만료된 토큰 재발급 처리 with refresh token
20-
const routineList = (await getRoutineList()) ?? []; // API 호출 실패 시 빈 배열 반환
18+
const routineList = (await getRoutineList()) ?? [];
2119

2220
return (
2321
<div className="relative flex flex-col min-h-[calc(100vh-48px)] bg-backgrounds-default">
2422
<div className="absolute top-[-48px] left-0 w-full h-[228px] bg-gradient-to-b from-[#2B3F58] to-[#212227] z-10"></div>
25-
2623
<div className="z-10">
2724
<div className="w-full h-16 flex items-center mb-2 px-5">
2825
<Link
2926
href="./exercise-list/search"
30-
className="flex items-center w-full h-10 text-sm leading-5 py-2.5 rounded-6 bg-[#324151]"
27+
className="flex items-center w-full h-10 text-sm leading-5 py-2.5 rounded-6 bg-[#324151] hover:opacity-80 active:opacity-80"
3128
>
3229
<Image className="m-2" src={'/assets/search.svg'} width={24} height={24} alt="돋보기" />
33-
<span className="text-text-light">혹시 궁금한 운동이 있으신가요?!</span>
30+
<span className="text-text-light ">혹시 궁금한 운동이 있으신가요?</span>
3431
</Link>
3532
</div>
3633
<h4 className="text-[18px] font-semibold leading-[26px] py-2 pl-5 text-text-main">

src/app/alarm/page.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import React from 'react';
2+
3+
const Alarm = () => {
4+
return <div>알림 페이지</div>;
5+
};
6+
7+
export default Alarm;

src/app/api/routine/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export const putUpdateRoutine = async (id: string, payload: Register_Routine_Pay
6464

6565
export const deleteDeleteRoutine = async (id: string) => {
6666
try {
67-
const res = await api.delete(
67+
const res = await clientApi.delete(
6868
`${process.env.NEXT_PUBLIC_SPRING_BACKEND_URL}${ROUTINE.DELETE_DELETE_ROUTINE(id)}`
6969
);
7070
return res.data;

src/app/api/routine/query/index.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
1-
import { useInfiniteQuery, useMutation, useQueryClient } from '@tanstack/react-query';
2-
import { useRouter } from 'next/navigation';
1+
import { useMutation, useQueryClient } from '@tanstack/react-query';
2+
import { deleteDeleteRoutine } from '..';
3+
4+
export const useDeleteRoutineMutation = () => {
5+
const deleteRoutineMutation = useMutation({
6+
mutationFn: deleteDeleteRoutine,
7+
});
8+
9+
return { deleteRoutineMutation };
10+
};

src/app/globals.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,7 @@
9393
.custom-placeholder::placeholder {
9494
font-size: 18px;
9595
}
96+
.zIndex {
97+
z-index: 9999 !important;
98+
}
9699
}

src/app/profile/[nickname]/components/UserInfo.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@ const UserInfo = ({ userInfo }: { userInfo: UserInfoType }) => {
2121
<div className="flex items-center justify-between h-[104px] px-4 ">
2222
<div className="flex items-center space-x-3">
2323
<Image
24-
src={userInfo.profile}
24+
src={userInfo?.profile}
2525
alt="Profile"
2626
width={64}
2727
height={64}
2828
className="rounded-full"
2929
/>
3030
<div>
31-
<h2 className="text-lg font-semibold text-white">{userInfo.nickname}</h2>
31+
<h2 className="text-lg font-semibold text-white">{userInfo?.nickname}</h2>
3232
<p className="text-sm text-gray-600">
33-
팔로워 {userInfo.followerCount} · 팔로잉 {userInfo.followingCount}
33+
팔로워 {userInfo?.followerCount} · 팔로잉 {userInfo?.followingCount}
3434
</p>
3535
</div>
3636
</div>

0 commit comments

Comments
 (0)