Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FE] refactor: 카테고리 로직 수정 #637

Merged
merged 5 commits into from
Sep 15, 2023
Merged

[FE] refactor: 카테고리 로직 수정 #637

merged 5 commits into from
Sep 15, 2023

Conversation

hae-on
Copy link
Collaborator

@hae-on hae-on commented Sep 15, 2023

Issue

✨ 구현한 기능

카테고리 api에 이미지가 추가되어 그에 맞게 로직을 수정하였습니다.

📢 논의하고 싶은 내용

x

🎸 기타

x

⏰ 일정

  • 추정 시간 : 2시간
  • 걸린 시간 : 15분

@github-actions
Copy link

github-actions bot commented Sep 15, 2023

Unit Test Results

8 tests   8 ✔️  9s ⏱️
3 suites  0 💤
1 files    0

Results for commit 3a91362.

♻️ This comment has been updated with latest results.

Copy link
Collaborator

@xodms0309 xodms0309 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

굿굿 해온 코멘트 확인해주세요~~

Comment on lines 10 to 29
const CategoryList = () => {
const { data: foodCategories } = useCategoryQuery(CATEGORY_TYPE['FOOD']);
const { data: storeCategories } = useCategoryQuery(CATEGORY_TYPE['STORE']);

return (
<CategoryListContainer>
<MenuListWrapper>
{menuList.map((menu, index) => (
<Link key={`menuItem-${index}`} as={RouterLink} to={`products/food?category=${index + 1}`}>
{foodCategories.map((menu) => (
<Link key={`menuItem-${menu.id}`} as={RouterLink} to={`products/food?category=${menu.id}`}>
<CategoryItem name={menu.name} image={menu.image} />
</Link>
))}
</MenuListWrapper>
<StoreListWrapper>
{storeList.map((menu, index) => (
<Link key={`menuItem-${index}`} as={RouterLink} to={`products/store?category=${index + 6}`}>
<CategoryItem key={`storeItem-${index}`} name={menu.name} image={menu.image} />
{storeCategories.map((menu) => (
<Link key={`menuItem-${menu.id}`} as={RouterLink} to={`products/store?category=${menu.id}`}>
<CategoryItem name={menu.name} image={menu.image} />
</Link>
))}
</StoreListWrapper>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

근데 아까는 이게 최선일 것 같았는데 코드 보니까 밖에서 menuVariant 값을 받고 얘는 뿌려주는 역할만 하게끔 하면 어떨까 싶어요

const CategoryList = ({menuVariant}) => {
  const { data: categories } = useCategoryQuery(CATEGORY_TYPE[menuVariant]);

  return (
      <ListWrapper>
        {categories.map((menu) => (
          <Link key={`menuItem-${menu.id}`} as={RouterLink} to={`products/${menuVariant}?category=${menu.id}`}>
            <CategoryItem name={menu.name} image={menu.image} />
          </Link>
        ))}
      </ListWrapper>
  )

이런식으로?? 그리고 밖에서는

<CategoryList menuVariant="FOOD"/>
<CategoryList menuVariant="STORE"/>

이렇게 쓰는걸로

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저도 동의!

Copy link
Collaborator

@Leejin-Yang Leejin-Yang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생했어요 해온!
타미 의견만 확인해주세요~

Copy link
Collaborator

@xodms0309 xodms0309 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

굿굿입니다~~~ 해옹

@hae-on hae-on merged commit 26825ff into develop Sep 15, 2023
3 checks passed
@hae-on hae-on deleted the feat/issue-635 branch September 15, 2023 07:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FE] 카테고리 로직 수정
3 participants