-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into epic/FE-32--search-page
- Loading branch information
Showing
27 changed files
with
678 additions
and
19 deletions.
There are no files selected for viewing
Empty file.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 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 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 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 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,63 @@ | ||
import React, { useState } from 'react'; | ||
import { useRouter } from 'next/router'; | ||
import Image from 'next/image'; | ||
import { useQuery } from '@tanstack/react-query'; | ||
import queries from '@/apis/queries'; | ||
import LOGO_ICON from '../../../public/epigram-icon.png'; | ||
import PROFILE_ICON from '../../../public/icon/user-icon.svg'; | ||
import MENU_ICON from '../../../public/icon/menu-icon.svg'; | ||
import Sidebar from './SideBar'; | ||
|
||
export default function NewHeader() { | ||
const router = useRouter(); | ||
const [isSidebarOpen, setIsSidebarOpen] = useState(false); | ||
|
||
const { data, isLoading, error } = useQuery(queries.user.getMe()); | ||
|
||
const handleNavigateTo = (path: string) => { | ||
router.push(path); | ||
}; | ||
|
||
const getNickName = () => { | ||
if (isLoading) { | ||
return '로딩 중...'; | ||
} | ||
if (error) { | ||
return '에러 발생'; | ||
} | ||
return data?.nickname || '김코드'; | ||
}; | ||
|
||
return ( | ||
<div className='w-full px-6 py-4 bg-white border-b border-line-100 flex items-center gap-2.5 lg:px-[120px] md:px-[72px] md:h-[60px] lg:h-20 md:py-[19px] lg:py-[26px]'> | ||
<div className='flex justify-between items-center w-full md:w-[744px] lg:w-[1920px]'> | ||
<div className='flex items-center gap-3 md:gap-6 lg:gap-9'> | ||
<div className='flex items-center gap-3'> | ||
<button type='button' onClick={() => setIsSidebarOpen(!isSidebarOpen)} className='md:hidden'> | ||
<Image className='w-5 h-5 lg:w-9 lg:h-9' src={MENU_ICON} alt='menu' /> | ||
</button> | ||
<button type='button' onClick={() => handleNavigateTo('/epigrams')} className='flex items-center gap-1'> | ||
<Image className='w-6 h-6 lg:w-9 lg:h-9' src={LOGO_ICON} alt='logo' /> | ||
<span className='text-black-700 text-6 lg:text-[26px] font-montserrat leading-6 font-bold'>Epigram</span> | ||
</button> | ||
</div> | ||
<div className='hidden md:flex items-center gap-6'> | ||
<button type='button' onClick={() => handleNavigateTo('/feed')}> | ||
<div className='text-center text-black-600 text-sm lg:text-base font-semibold font-pretendard leading-normal'>피드</div> | ||
</button> | ||
<button type='button' onClick={() => handleNavigateTo('/search')}> | ||
<div className='text-center text-black-600 text-sm lg:text-base font-semibold font-pretendard leading-normal'>검색</div> | ||
</button> | ||
</div> | ||
</div> | ||
<button type='button' onClick={() => handleNavigateTo('/mypage')} className='flex items-center gap-1.5'> | ||
<div className='w-4 h-4 lg:w-6 lg:h-6 relative'> | ||
<Image src={PROFILE_ICON} alt='프로필 이미지' /> | ||
</div> | ||
<div className='text-gray-300 text-[13px] lg:text-sm font-medium font-pretendard leading-snug'>{getNickName()}</div> | ||
</button> | ||
</div> | ||
<Sidebar isOpen={isSidebarOpen} toggleSidebar={() => setIsSidebarOpen(false)} /> | ||
</div> | ||
); | ||
} |
This file contains 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,42 @@ | ||
import React from 'react'; | ||
import Image from 'next/image'; | ||
import { useRouter } from 'next/router'; | ||
import X_ICON from '../../../public/icon/x-icon.svg'; | ||
|
||
interface SidebarProps { | ||
isOpen: boolean; | ||
toggleSidebar: () => void; | ||
} | ||
|
||
function Sidebar({ isOpen, toggleSidebar }: SidebarProps) { | ||
const router = useRouter(); | ||
|
||
const handleNavigateTo = (path: string) => { | ||
router.push(path); | ||
toggleSidebar(); | ||
}; | ||
|
||
if (!isOpen) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<div className='absolute top-0 left-0 h-full w-[220px] bg-white shadow-lg z-50'> | ||
<div className='h-[54px] px-4 py-2.5 bg-white border-b border-[#f2f2f2] flex items-center justify-end'> | ||
<button type='button' onClick={toggleSidebar}> | ||
<Image className='w-6 h-6' src={X_ICON} alt='사이드바 닫기' /> | ||
</button> | ||
</div> | ||
<div className='flex flex-col'> | ||
<button type='button' className='w-full px-5 py-6 bg-white text-left' onClick={() => handleNavigateTo('/feed')}> | ||
<div className='text-[#373737] text-base font-medium font-pretendard leading-relaxed'>피드</div> | ||
</button> | ||
<button type='button' className='w-full px-5 py-6 bg-white text-left' onClick={() => handleNavigateTo('/search')}> | ||
<div className='text-[#373737] text-base font-medium font-pretendard leading-relaxed'>검색</div> | ||
</button> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default Sidebar; |
This file contains 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,7 @@ | ||
import quries from '@/apis/queries'; | ||
import { CommentRequestType } from '@/schema/comment'; | ||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
const useCommentsHook = (requset: CommentRequestType) => useQuery(quries.epigramComment.getMyComments(requset)); | ||
|
||
export default useCommentsHook; |
This file contains 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,7 @@ | ||
import quries from '@/apis/queries'; | ||
import { GetUserRequestType } from '@/schema/user'; | ||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
const useGetMyContentHook = (requset: GetUserRequestType) => useQuery(quries.user.getMyContentCount(requset)); | ||
|
||
export default useGetMyContentHook; |
This file contains 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 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 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 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 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,40 @@ | ||
import { useMonthlyEmotionLogs } from '@/hooks/useGetEmotion'; | ||
import { Emotion } from '@/types/emotion'; | ||
import { useEffect, useState } from 'react'; | ||
import Calendar from '../../user/ui-calendar/Calendar'; | ||
import Chart from '../../user/ui-chart/Chart'; | ||
|
||
interface EmotionMonthlyLogsProps { | ||
userId: number; | ||
} | ||
|
||
export default function EmotionMonthlyLogs({ userId }: EmotionMonthlyLogsProps) { | ||
// 현재 날짜를 상태로 관리 | ||
const [currentDate, setCurrentDate] = useState<Date>(new Date()); | ||
|
||
// 감정 달력 객체 상태 추가 | ||
const [emotionRequest, setEmotionRequest] = useState<Emotion>({ | ||
userId, | ||
year: currentDate.getFullYear(), | ||
month: currentDate.getMonth() + 1, | ||
}); | ||
|
||
// '월'이 변경될 때마다 request 업데이트 | ||
useEffect(() => { | ||
setEmotionRequest({ | ||
userId, | ||
year: currentDate.getFullYear(), | ||
month: currentDate.getMonth() + 1, | ||
}); | ||
}, [currentDate]); | ||
|
||
// 월별 감정 로그 조회 | ||
const { data: monthlyEmotionLogs = [] } = useMonthlyEmotionLogs(emotionRequest); | ||
|
||
return ( | ||
<div className='pb-[110px]'> | ||
<Calendar currentDate={currentDate} setCurrentDate={setCurrentDate} monthlyEmotionLogs={monthlyEmotionLogs} /> | ||
<Chart monthlyEmotionLogs={monthlyEmotionLogs} /> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.