Skip to content

Commit

Permalink
#187 refactor: 변수명 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
namdaeun committed Jul 31, 2024
1 parent ab7b7e4 commit fb86287
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
23 changes: 11 additions & 12 deletions src/page/archiving/index/ArchivingPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { alignBlocks, getLastDayOfMonth } from '@/page/archiving/index/util/bloc

import { useState } from 'react';

import AddIc from '@/common/asset/svg/add_btn.svg?react';
import Add from '@/common/asset/svg/add_btn.svg?react';
import Button from '@/common/component/Button/Button';
import Flex from '@/common/component/Flex/Flex';
import Modal from '@/common/component/Modal/Modal';
Expand Down Expand Up @@ -54,16 +54,15 @@ const ArchivingPage = () => {

const sideBarRef = useOutsideClick(handleClose, 'TimeBlock');

const { currentDate, currentYear, selectedMonth, setSelectedMonth, handlePrevYear, handleNextYear, endDay } =
useDate();
const { currentYear, selectedMonthType, setSelectedMonthType, handlePrevYear, handleNextYear, endDay } = useDate();

const selectedMonthNumber = parseInt(selectedMonth.split('월')[0]);
const selectedMonth = parseInt(selectedMonthType.split('월')[0]);

const { data } = useGetTimeBlockQuery(+teamId, 'executive', currentYear, selectedMonthNumber);
const { data } = useGetTimeBlockQuery(+teamId, 'executive', currentYear, selectedMonth);

const [selectedBlock, setSelectedBlock] = useState<Block>();
const timeBlocks: Block[] = data?.timeBlocks || [];
const blockFloors = alignBlocks(timeBlocks, endDay, selectedMonth, currentYear);
const blockFloors = alignBlocks(timeBlocks, endDay, selectedMonthType, currentYear);

// 블록 생성 모달 관련 코드
const { isOpen, openModal, closeModal, setCurrentContent, currentContent } = useModal();
Expand Down Expand Up @@ -91,8 +90,8 @@ const ArchivingPage = () => {
<YearHeader handlePrevYear={handlePrevYear} handleNextYear={handleNextYear} currentYear={currentYear} />
<Flex css={contentStyle}>
<MonthHeader
currentMonth={selectedMonth}
onMonthClick={(month) => setSelectedMonth(month)}
currentMonth={selectedMonthType}
onMonthClick={(month) => setSelectedMonthType(month)}
selectedBlock={selectedBlock}
/>
<div id="block_area" css={daySectionStyle}>
Expand All @@ -104,14 +103,14 @@ const ArchivingPage = () => {
const startMonth = blockStartDate.getUTCMonth() + 1;
const endMonth = blockEndDate.getUTCMonth() + 1;

const firstDayOfMonth = new Date(Date.UTC(currentYear, selectedMonthNumber - 1, 1));
const firstDayOfMonth = new Date(Date.UTC(currentYear, selectedMonth - 1, 1));
const lastDayOfMonth = getLastDayOfMonth(firstDayOfMonth);

if (blockStartDate.getFullYear() !== currentYear || startMonth !== selectedMonthNumber) {
if (blockStartDate.getFullYear() !== currentYear || startMonth !== selectedMonth) {
startDate = firstDayOfMonth;
}

if (blockEndDate.getFullYear() !== currentYear || endMonth !== selectedMonthNumber) {
if (blockEndDate.getFullYear() !== currentYear || endMonth !== selectedMonth) {
endDate = lastDayOfMonth;
}

Expand All @@ -137,7 +136,7 @@ const ArchivingPage = () => {
variant="action"
css={buttonStyle(selectedBlock)}
onClick={() => openModal(<BlockModal onNext={handleNext} />)}>
<AddIc width={24} height={24} />
<Add width={24} height={24} />
블록 생성
</Button>
</Flex>
Expand Down
8 changes: 4 additions & 4 deletions src/page/archiving/index/hook/common/useDate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export const useDate = () => {
const currentDate = new Date();

const [currentYear, setCurrentYear] = useState(currentDate.getFullYear());
const [selectedMonth, setSelectedMonth] = useState<MonthType>(`${currentDate.getMonth() + 1}월` as MonthType);
const dateOfMonth = getMonthDate(selectedMonth, currentYear);
const [selectedMonthType, setSelectedMonthType] = useState<MonthType>(`${currentDate.getMonth() + 1}월` as MonthType);
const dateOfMonth = getMonthDate(selectedMonthType, currentYear);
const endDay = endOfMonth(dateOfMonth);

const handlePrevYear = () => {
Expand All @@ -23,8 +23,8 @@ export const useDate = () => {
return {
currentDate,
currentYear,
selectedMonth,
setSelectedMonth,
selectedMonthType,
setSelectedMonthType,
handlePrevYear,
handleNextYear,
dateOfMonth,
Expand Down

0 comments on commit fb86287

Please sign in to comment.