-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #142 from ItRecode/FE-150
[FE-150] feat: λ§μ΄ λ μ½λ(μ€λμ λ μ½λ API μ μ©)
- Loading branch information
Showing
12 changed files
with
179 additions
and
73 deletions.
There are no files selected for viewing
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
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,17 @@ | ||
import React from 'react' | ||
import { ReactComponent as Calendar } from '@assets/myRecordIcon/calendar.svg' | ||
import { useNavigate } from 'react-router-dom' | ||
|
||
export default function MyRecordCalendar() { | ||
const navigate = useNavigate() | ||
|
||
return ( | ||
<div className="mt-7 flex items-center justify-between px-6"> | ||
<h1 className="text-2xl font-semibold">λ§μ΄ λ μ½λ</h1> | ||
<Calendar | ||
className="cursor-pointer" | ||
onClick={() => navigate('/notservice')} | ||
/> | ||
</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 |
---|---|---|
@@ -1,60 +1,81 @@ | ||
import React from 'react' | ||
import { useNavigate } from 'react-router-dom' | ||
// import { ITodayRecord } from 'types/recordData' | ||
// import { getChipIconName } from '@pages/DetailRecord/getChipIconName' | ||
// import Chip from '@components/Chip' | ||
// import recordIcons from '@assets/record_icons' | ||
import { useMyRecord } from '@react-query/hooks/useMyRecord' | ||
import { getChipIconName } from '@pages/DetailRecord/getChipIconName' | ||
import Chip from '@components/Chip' | ||
import recordIcons from '@assets/record_icons' | ||
import { getFormattedDate } from '@utils/getFormattedDate' | ||
import MyRecordCalendar from './MyRecordCalendar' | ||
|
||
export default function TodayRecord() { | ||
const navigate = useNavigate() | ||
// const todayWriteRecord = null | ||
// const background_color = `bg-${todayWriteRecord?.colorName}` | ||
// const RecordIcon = recordIcons[`${todayWriteRecord?.iconName}`] | ||
const { todayRecord, isLoading } = useMyRecord() | ||
const background_color = `bg-${todayRecord?.colorName}` | ||
const RecordIcon = recordIcons[`${todayRecord?.iconName}`] | ||
|
||
if (isLoading) { | ||
return <></> | ||
} | ||
|
||
if (!todayRecord) { | ||
return ( | ||
<> | ||
<MyRecordCalendar /> | ||
<div className="mt-10 mb-[49px] w-full text-center"> | ||
<span className="text-xs leading-5"> | ||
μ€λ μ΄ λ μ½λκ° μμ΄μ! | ||
<br /> | ||
λ μ½λλ₯Ό μ°κ³ μΆμ΅μ 곡μ ν΄λ³΄μΈμ. | ||
</span> | ||
<div | ||
className="mt-4 cursor-pointer text-sm font-semibold leading-5 text-primary-2 underline underline-offset-4" | ||
onClick={() => navigate('/record/add')} | ||
> | ||
λ μ½λ μΆκ°νλ¬ κ°κΈ° | ||
</div> | ||
</div> | ||
</> | ||
) | ||
} | ||
|
||
// if (!todayWriteRecord) { | ||
return ( | ||
<div className="mt-10 mb-[49px] w-full text-center"> | ||
<span className="text-xs leading-5"> | ||
μ€λ μ΄ λ μ½λκ° μμ΄μ! | ||
<br /> | ||
λ μ½λλ₯Ό μ°κ³ μΆμ΅μ 곡μ ν΄λ³΄μΈμ. | ||
</span> | ||
<div | ||
className="mt-4 cursor-pointer text-sm font-semibold leading-5 text-primary-2 underline underline-offset-4" | ||
onClick={() => navigate('/record/add')} | ||
> | ||
λ μ½λ μΆκ°νλ¬ κ°κΈ° | ||
<> | ||
<MyRecordCalendar /> | ||
<div className="mt-4 mb-10 w-full px-6"> | ||
<div | ||
className="cursor-pointer text-xs" | ||
onClick={() => navigate(`/record/${todayRecord.recordId}`)} | ||
> | ||
{getFormattedDate(new Date(todayRecord.createdAt), 'point')} | ||
</div> | ||
<div | ||
className="mt-4 flex w-fit cursor-pointer" | ||
onClick={() => navigate(`/record/${todayRecord.recordId}`)} | ||
> | ||
<div | ||
className={`${background_color} flex h-[86px] w-[86px] items-center rounded-2xl`} | ||
> | ||
<RecordIcon className="flex aspect-square w-full" /> | ||
</div> | ||
<div className="ml-4 flex flex-col"> | ||
<div className="inline"> | ||
<Chip | ||
property="small" | ||
icon={getChipIconName(todayRecord.categoryName)} | ||
message={`${todayRecord.categoryName}`} | ||
active={true} | ||
pointer={false} | ||
/> | ||
</div> | ||
<h2 className="mt-3 text-lg font-semibold leading-[18px]"> | ||
{todayRecord.title} | ||
</h2> | ||
<div className="mt-[14px] text-xs leading-4"> | ||
λκΈ {todayRecord.commentCount}κ° | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</> | ||
) | ||
// } | ||
|
||
// return ( | ||
// <div className="mt-4 mb-10 w-full px-6"> | ||
// {/* TODO: λ μ½λ λ§λ λ μ§ === μ€λ λ μ§ ν¬λ§·ν νκΈ°*/} | ||
// <div className="text-xs">{todayWriteRecord.createdAt}</div> | ||
// <div className="mt-4 flex"> | ||
// <div | ||
// className={`${background_color} flex h-[86px] w-[86px] items-center rounded-2xl`} | ||
// > | ||
// <RecordIcon className="flex aspect-square w-full" /> | ||
// </div> | ||
// <div className="ml-4 flex flex-col"> | ||
// <Chip | ||
// property="small" | ||
// icon={getChipIconName(todayWriteRecord.categoryName)} | ||
// message={`${todayWriteRecord.categoryName}`} | ||
// active={true} | ||
// pointer={false} | ||
// /> | ||
// <h2 className="mt-3 text-lg font-semibold leading-[18px]"> | ||
// {todayWriteRecord.title} | ||
// </h2> | ||
// <div className="mt-[14px] text-xs leading-4"> | ||
// λκΈ {todayWriteRecord.commentCount}κ° | ||
// </div> | ||
// </div> | ||
// </div> | ||
// </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
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,26 @@ | ||
import { QUERY_KEYS } from '@react-query/queryKeys' | ||
import { useQuery } from '@tanstack/react-query' | ||
import { getRecordByDate } from '@apis/record' | ||
import { getFormattedDate } from '@utils/getFormattedDate' | ||
|
||
export const useMyRecord = () => { | ||
const today = new Date() | ||
|
||
const { data: records = null, isLoading } = useQuery( | ||
[QUERY_KEYS.todayRecord], | ||
async () => | ||
await getRecordByDate({ | ||
date: getFormattedDate(today, 'hyphen'), | ||
page: 0, | ||
size: 1, | ||
}), | ||
{ | ||
retry: false, | ||
} | ||
) | ||
|
||
return { | ||
todayRecord: records?.data.recordByDateDtos[0], | ||
isLoading, | ||
} | ||
} |
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,13 @@ | ||
const DATE_JOIN_POINT = 'point' | ||
|
||
export const getFormattedDate = (date: Date, type: string) => { | ||
const year = date.getFullYear() | ||
const month = (date.getMonth() + 1).toString().padStart(2, '0') | ||
const day = date.getDate().toString().padStart(2, '0') | ||
|
||
if (type === DATE_JOIN_POINT) { | ||
return `${year}.${month}.${day}` | ||
} | ||
|
||
return `${year}-${month}-${day}` | ||
} |