From 55b0b71db4698497ce76a804fcf53cf52cc7ff06 Mon Sep 17 00:00:00 2001 From: hanbin Date: Sat, 22 Jun 2024 15:52:31 +0900 Subject: [PATCH] =?UTF-8?q?[#44]=20Refactor:=20=EB=AF=B8=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=20=ED=8E=98=EC=9D=B4=EC=A7=80=20=EC=82=AD=EC=A0=9C=20(/calenda?= =?UTF-8?q?r/search/results)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/calendar/search/results/index.tsx | 96 ------------------- .../search/results/results.module.scss | 13 --- 2 files changed, 109 deletions(-) delete mode 100644 pages/calendar/search/results/index.tsx delete mode 100644 pages/calendar/search/results/results.module.scss diff --git a/pages/calendar/search/results/index.tsx b/pages/calendar/search/results/index.tsx deleted file mode 100644 index 564e8be1..00000000 --- a/pages/calendar/search/results/index.tsx +++ /dev/null @@ -1,96 +0,0 @@ -import Calendar from '@/components/calendar-compound/calendar'; -import styles from './results.module.scss'; -import CreateTodoButton from '@/components/calendar-monthly/create-todo-button'; -import CalendarTodoDate from '@/components/calendar-monthly/calendar-todo-date'; -import CalendarInstance from '@/utils/date/date.utils'; -import useSelect from '@/hooks/use-select'; -import CalendarTodos from '@/components/calendar-monthly/calendar-todos'; -import { useRouter } from 'next/router'; -import useSearchTodosQuery from '@/hooks/queries/calendar/use-search-todos-query'; -import getQueryString from '@/utils/search/get-query-string'; -import { useEffect, useState } from 'react'; -import countTodosFromSearch from '@/utils/search/count-todos-from-search'; -import { MonthlyTodos, TodoByQueries } from '@/api/calendar/request.type'; -import CalendarMonthly from '@/components/calendar-monthly/calendar-monthly'; - -export default function CalendarPage() { - const router = useRouter(); - const [query, setQuery] = useState('keyword=&petNames=&writerNames='); - - useEffect(() => { - if (!router.isReady) return; - - const keyword = getQueryString('keyword', [router.query.keyword] as string[]); - const petNames = getQueryString('petNames', router.query.petNames as string[]); - const writerNames = getQueryString('writerNames', router.query.writerNames as string[]); - - setQuery([keyword, petNames, writerNames].join('&')); - }, [router.isReady]); - - const searchTodosQuery = useSearchTodosQuery(query); - - const { selectedItem: selectedYear, handleSelectedItem: onSelectedYear } = useSelect( - CalendarInstance.currentYear, - ); - const { selectedItem: selectedMonth, handleSelectedItem: onSelectedMonth } = useSelect( - CalendarInstance.currentMonth, - ); - const { selectedItem: selectedDate, handleSelectedItem: onSelectedDate } = useSelect( - CalendarInstance.currentDate, - ); - - const onResetToday = () => { - onSelectedYear(CalendarInstance.currentYear); - onSelectedMonth(CalendarInstance.currentMonth); - onSelectedDate(CalendarInstance.currentDate); - }; - - const monthlyTodos = countTodosFromSearch(searchTodosQuery.data).reduce((result, todo) => { - if (todo.date.includes(`${selectedYear}-${(selectedMonth + 1).toString().padStart(2, '0')}`)) result.push(todo); - - return result; - }, []); - - const dailyTodos = searchTodosQuery.data.reduce((result, todo) => { - if ( - todo.dateTime.includes( - `${selectedYear}-${(selectedMonth + 1).toString().padStart(2, '0')}-${selectedDate.toString().padStart(2, '0')}`, - ) - ) { - result.push(todo); - } - - return result; - }, []); - - return ( -
-

검색 결과

- -
- -

- 오늘 날짜 -

-
-
- -
- - - - -
-
- ); -} diff --git a/pages/calendar/search/results/results.module.scss b/pages/calendar/search/results/results.module.scss deleted file mode 100644 index 00af5c10..00000000 --- a/pages/calendar/search/results/results.module.scss +++ /dev/null @@ -1,13 +0,0 @@ -.outer { - padding: 19px 24px 100px; -} - -.yearContainer { - display: flex; -} - -.resetToday { - color: var(--main-color); - text-decoration: underline; - cursor: pointer; -}