Skip to content

Commit

Permalink
refactor: Category를 정리합니다.
Browse files Browse the repository at this point in the history
  • Loading branch information
Zero-1016 committed Oct 9, 2024
1 parent f21b76f commit f966c35
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 46 deletions.
10 changes: 6 additions & 4 deletions app/(app)/project/[id]/review/create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useCallback, useState } from 'react';
import SolidButton from '@/components/common/button/SolidButton';
import Typography from '@/components/common/typography';
import SelectCategoryChipList from '@/components/questionnaire/SelectCategoryChipList';
import type { EngCategoryType } from '@/enums/categoryEnum';
import { useTabBarEffect } from '@/hooks';
import { flexDirectionColumn } from '@/styles/common';

Expand All @@ -14,23 +15,24 @@ function Review() {
// const { id } = useLocalSearchParams<{ id: string }>();

const [error, setError] = useState<string | null>(null);
const [selectedCategoryList, setSelectedCategoryList] = useState<string[]>([]);
const [selectedCategoryList, setSelectedCategoryList] = useState<EngCategoryType[]>([]);

const addCategory = (category: string) => {
const addCategory = (category: EngCategoryType) => {
if (error) {
setError(null);
}
setSelectedCategoryList([...selectedCategoryList, category]);
};
const removeCategory = (category: string) =>

const removeCategory = (category: EngCategoryType) =>
setSelectedCategoryList(selectedCategoryList.filter((item) => item !== category));

const selectCategory = useCallback(() => {
if (selectedCategoryList.length < MINIMUM_CATEGORY_COUNT) {
setError('5개를 선택해주세요');
return;
}
setError(null);
console.log(selectedCategoryList);
}, [selectedCategoryList]);

return (
Expand Down
4 changes: 2 additions & 2 deletions src/components/questionnaire/QuestionnaireCheckList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { createContext, memo, useContext, useState } from 'react';

import RadioIcon from '@/components/common/icon/radio-icon';
import Typography from '@/components/common/typography';
import type { KorCategoryType } from '@/enums/categoryEnum';
import { color } from '@/styles/theme';
import type { CategoryType } from '@/types/category';

import CategoryChip from '../category-chip';
import * as S from './style';
Expand Down Expand Up @@ -42,7 +42,7 @@ function Item({ children, value }: PropsWithChildren<ItemProps>) {

type QuestionnaireCheckListProps = {
title: string;
category: CategoryType;
category: KorCategoryType;
initialCheckValue?: string | number;
};

Expand Down
74 changes: 42 additions & 32 deletions src/components/questionnaire/SelectCategoryChipList/index.tsx
Original file line number Diff line number Diff line change
@@ -1,67 +1,77 @@
import ErrorText from '@/components/common/error-text';
import Category from '@/components/questionnaire/category';
import type { EngCategoryType } from '@/enums/categoryEnum';
import { CategoryEnum } from '@/enums/categoryEnum';

import * as S from './style';

type Props = {
item: string[];
addItem: (item: string) => void;
removeItem: (item: string) => void;
addItem: (item: EngCategoryType) => void;
removeItem: (item: EngCategoryType) => void;
error: string | null;
};

function SelectCategoryChipList({ item, addItem, removeItem, error }: Props) {
const isActive = (category: string) => item.includes(category);
const isActive = (category: EngCategoryType) => item.includes(category);
return (
<S.Container>
<S.Wrapper>
<Category
category='기술'
isActive={isActive('기술')}
onPress={() => (isActive('기술') ? removeItem('기술') : addItem('기술'))}
category={CategoryEnum.SKILL}
isActive={isActive('SKILL')}
onPress={() => (isActive('SKILL') ? removeItem('SKILL') : addItem('SKILL'))}
/>
<Category
category='성실성'
isActive={isActive('성실성')}
onPress={() => (isActive('성실성') ? removeItem('성실성') : addItem('성실성'))}
category={CategoryEnum.DILIGENCE}
isActive={isActive('DILIGENCE')}
onPress={() => (isActive('DILIGENCE') ? removeItem('DILIGENCE') : addItem('DILIGENCE'))}
/>
<Category
category='배려심'
isActive={isActive('배려심')}
onPress={() => (isActive('배려심') ? removeItem('배려심') : addItem('배려심'))}
/>
<Category
category='아이데이션'
isActive={isActive('아이데이션')}
category={CategoryEnum.CONSIDERATION}
isActive={isActive('CONSIDERATION')}
onPress={() =>
isActive('아이데이션') ? removeItem('아이데이션') : addItem('아이데이션')
isActive('CONSIDERATION') ? removeItem('CONSIDERATION') : addItem('CONSIDERATION')
}
/>
<Category
category='문서화'
isActive={isActive('문서화')}
onPress={() => (isActive('문서화') ? removeItem('문서화') : addItem('문서화'))}
category={CategoryEnum.IDEATION}
isActive={isActive('IDEATION')}
onPress={() => (isActive('IDEATION') ? removeItem('IDEATION') : addItem('IDEATION'))}
/>
<Category
category={CategoryEnum.DOCUMENTATION}
isActive={isActive('DOCUMENTATION')}
onPress={() =>
isActive('DOCUMENTATION') ? removeItem('DOCUMENTATION') : addItem('DOCUMENTATION')
}
/>
<Category
category='문제해결'
isActive={isActive('문제해결')}
onPress={() => (isActive('문제해결') ? removeItem('문제해결') : addItem('문제해결'))}
category={CategoryEnum.PROBLEM_SOLVING}
isActive={isActive('PROBLEM_SOLVING')}
onPress={() =>
isActive('PROBLEM_SOLVING') ? removeItem('PROBLEM_SOLVING') : addItem('PROBLEM_SOLVING')
}
/>
<Category
category='리더십'
isActive={isActive('리더십')}
onPress={() => (isActive('리더십') ? removeItem('리더십') : addItem('리더십'))}
category={CategoryEnum.LEADERSHIP}
isActive={isActive('LEADERSHIP')}
onPress={() =>
isActive('LEADERSHIP') ? removeItem('LEADERSHIP') : addItem('LEADERSHIP')
}
/>
<Category
category='팔로워십'
isActive={isActive('팔로워십')}
onPress={() => (isActive('팔로워십') ? removeItem('팔로워십') : addItem('팔로워십'))}
category={CategoryEnum.FOLLOWERSHIP}
isActive={isActive('FOLLOWERSHIP')}
onPress={() =>
isActive('FOLLOWERSHIP') ? removeItem('FOLLOWERSHIP') : addItem('FOLLOWERSHIP')
}
/>
<Category
category='커뮤니케이션'
isActive={isActive('커뮤니케이션')}
category={CategoryEnum.COMMUNICATION}
isActive={isActive('COMMUNICATION')}
onPress={() =>
isActive('커뮤니케이션') ? removeItem('커뮤니케이션') : addItem('커뮤니케이션')
isActive('COMMUNICATION') ? removeItem('COMMUNICATION') : addItem('COMMUNICATION')
}
/>
</S.Wrapper>
Expand Down
4 changes: 2 additions & 2 deletions src/components/questionnaire/category-chip/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { memo } from 'react';

import Typography from '@/components/common/typography';
import type { KorCategoryType } from '@/enums/categoryEnum';
import { CategoryStyle } from '@/styles/category';
import type { CategoryType } from '@/types/category';

import * as S from './style';

type Props = {
category: CategoryType;
category: KorCategoryType;
};

function CategoryChip({ category }: Props) {
Expand Down
4 changes: 2 additions & 2 deletions src/components/questionnaire/category/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ import type { PressableProps } from 'react-native';

import CategoryIcon from '@/components/common/icon/category-icon';
import Typography from '@/components/common/typography';
import type { KorCategoryType } from '@/enums/categoryEnum';
import { CategoryStyle } from '@/styles/category';
import { shadow } from '@/styles/shadow';
import { color } from '@/styles/theme';
import type { CategoryType } from '@/types/category';

import * as S from './style';

type Props = {
isActive?: boolean;
hasIcon?: boolean;
hasShadow?: boolean;
category: CategoryType;
category: KorCategoryType;
} & PressableProps;

function Category({
Expand Down
8 changes: 6 additions & 2 deletions src/enums/categoryEnum.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
export enum CategoryEnum {
COMMUNICATION = '커뮤니케이션',
SKILL = '기술',
COLLABORATION = '협업',
LEADERSHIP = '리더십',
DOCUMENTATION = '문서화',
TIME_MANAGEMENT = '시간관리',
PROBLEM_SOLVING = '문제해결',
DILIGENCE = '성실성',
IDEATION = '아이데이션',
CONSIDERATION = '배려심',
FOLLOWERSHIP = '팔로워십',
}

export type EngCategoryType = keyof typeof CategoryEnum;
export type KorCategoryType = `${CategoryEnum}`;
3 changes: 1 addition & 2 deletions src/hooks/queries/useAuth.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { useQuery } from '@tanstack/react-query';
import { useEffect } from 'react';

import { getProfile } from '@/apis/auth';
import { getAccessToken } from '@/apis/auth';
import { getAccessToken, getProfile } from '@/apis/member/api';
import { STORAGE_KEYS } from '@/constants';
import { NUMBERS } from '@/constants/numbers';
import { QUERY_KEYS } from '@/constants/queryKeys';
Expand Down

0 comments on commit f966c35

Please sign in to comment.