-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[혜수] - 비즈니스 로직 분리
- Loading branch information
Showing
38 changed files
with
433 additions
and
381 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
53 changes: 0 additions & 53 deletions
53
src/app/(header)/_components/LinkIconText/LinkIconText.tsx
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,2 @@ | ||
export { default as useTab } from './useTab'; | ||
export { default as useExplorePlans } from './useExplorePlans'; |
31 changes: 31 additions & 0 deletions
31
src/app/(header)/explore/_components/hooks/useExplorePlans.ts
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,31 @@ | ||
import { useAllPlansQuery } from '@/hooks/apis/useAllPlansQuery'; | ||
import { SortType } from '@/types/apis/plan/GetAllPlans'; | ||
import { useMemo, useState } from 'react'; | ||
|
||
export default function useExplorePlans() { | ||
const [sort, setSort] = useState<SortType>('latest'); | ||
const [current, setCurrent] = useState(true); | ||
const { loadedPlans, fetchNextPage, hasNextPage } = useAllPlansQuery({ | ||
sort, | ||
current, | ||
}); | ||
const flatLoadedPlans = useMemo(() => loadedPlans.flat(), [loadedPlans]); | ||
const handleSort = (condition: SortType) => { | ||
setSort(condition); | ||
}; | ||
const handleYear = (isNewYear: boolean) => { | ||
setCurrent(isNewYear); | ||
}; | ||
return { | ||
sort, | ||
setSort, | ||
current, | ||
setCurrent, | ||
loadedPlans, | ||
fetchNextPage, | ||
hasNextPage, | ||
flatLoadedPlans, | ||
handleSort, | ||
handleYear, | ||
}; | ||
} |
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,23 @@ | ||
import { TabProps } from '@/types/Tab'; | ||
import { useState } from 'react'; | ||
|
||
export default function useTab({ handleSort, handleYear }: TabProps) { | ||
const [currentYearTab, setCurrentYearTab] = useState(0); | ||
const [currentSortTab, setCurrentSortTab] = useState(0); | ||
const selectYearMenuHandler = (index: number) => { | ||
setCurrentYearTab(index); | ||
handleYear(index === 0 ? true : false); | ||
}; | ||
const selectSortMenuHandler = (index: number) => { | ||
setCurrentSortTab(index); | ||
handleSort(index === 0 ? 'latest' : 'ajaja'); | ||
}; | ||
return { | ||
currentYearTab, | ||
setCurrentYearTab, | ||
currentSortTab, | ||
setCurrentSortTab, | ||
selectYearMenuHandler, | ||
selectSortMenuHandler, | ||
}; | ||
} |
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
Oops, something went wrong.