-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(toks-main): 카테고리 기능 리팩토링 및 Bug Fixed (#402)
* refactor: 카테고리 기능 리팩토링 및 Bug Fixed * fix: order lint fix * fix: template.tsx에서 RecoilRoot 리렌더링되어 상태 초기화되는 이슈 fixed * fix: category 가나다라 순으로 프론트에서 처리 * fix: image url public 안들어가는 이슈 fix * fix: category flow 주석 추가
- Loading branch information
Showing
14 changed files
with
227 additions
and
112 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
'use client'; | ||
|
||
import React from 'react'; | ||
import { RecoilRoot } from 'recoil'; | ||
|
||
const Provider = ({ children }: StrictPropsWithChildren) => { | ||
return <RecoilRoot>{children}</RecoilRoot>; | ||
}; | ||
|
||
export default Provider; |
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
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,55 @@ | ||
'use client'; | ||
|
||
import { getCookie } from 'cookies-next'; | ||
import React, { memo } from 'react'; | ||
import { useRecoilValue, useSetRecoilState } from 'recoil'; | ||
|
||
import { Categories } from '@/common/components/Categories'; | ||
import { useSelectedCategoriesQuery } from '@/queries'; | ||
import { useCategoriesQuery } from '@/queries/useCategoriesQuery'; | ||
import { | ||
isVisibleCategoryBottomSheetAtom, | ||
selectedTemporaryCategoryAtom, | ||
} from '@/store'; | ||
|
||
import { isSameCategory } from '../utils'; | ||
|
||
const QuizCategory = () => { | ||
const accessToken = getCookie('accessToken'); | ||
const { data: categoryQuery } = useCategoriesQuery(); | ||
const { data: selectedLoginCategory } = useSelectedCategoriesQuery(); | ||
const selectedTemporaryCategory = useRecoilValue( | ||
selectedTemporaryCategoryAtom | ||
); | ||
|
||
const setIsOpenCategoryBottomSheet = useSetRecoilState( | ||
isVisibleCategoryBottomSheetAtom | ||
); | ||
|
||
const selectedCategory = Boolean(accessToken) | ||
? selectedLoginCategory | ||
: selectedTemporaryCategory; | ||
|
||
const categories = categoryQuery?.tabs.map(({ name, id }) => { | ||
const isSelected = | ||
selectedCategory?.filter((categoryId) => | ||
isSameCategory(categoryId, id) | ||
) ?? []; | ||
|
||
return { | ||
categoryName: `${name} ${isSelected.length}`, | ||
isSelected: isSelected.length > 0, | ||
}; | ||
}); | ||
|
||
return ( | ||
<Categories | ||
categories={categories ?? []} | ||
onClick={() => { | ||
setIsOpenCategoryBottomSheet(true); | ||
}} | ||
/> | ||
); | ||
}; | ||
|
||
export default memo(QuizCategory); |
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,3 @@ | ||
export const isSameCategory = (a: string, b: string) => { | ||
return a.slice(0, 2) === b.slice(0, 2); | ||
}; |
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.