Skip to content

Commit

Permalink
Refactor: global store type category interface
Browse files Browse the repository at this point in the history
  • Loading branch information
swgvenghy committed Aug 22, 2024
1 parent 57ff79f commit 4c7f88c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/store/type-category-store.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { create } from 'zustand';

interface TypeCategoryState {
export interface TypeCategoryState {
type: undefined | 'SUSI' | 'PYEONIP' | 'JEONGSI';
category: undefined | 'ADMISSION_GUIDELINE' | 'PASSING_RESULT' | 'PAST_QUESTIONS' | 'INTERVIEW_PRACTICAL_TEST';
setSelectedType: (button: TypeCategoryState['type']) => void;
Expand Down
16 changes: 5 additions & 11 deletions src/ui/components/molecule/chat-section/chat-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,21 @@
import React from 'react';
import ChatCard from '../../atom/chat-card/chat-card';
import PresetButton from '../../atom/preset/preset-button';
import useTypeStore from '../../../../store/type-category-store';
import useTypeStore, { TypeCategoryState } from '../../../../store/type-category-store';
import useChatStore from '../../../../store/chat-store';

const ChatSection: React.FC = () => {
const { setSelectedType, type, setSelectedCategory, category } = useTypeStore();
const { messages } = useChatStore();
const [selectedTypeButton, setSelectedTypeButton] = React.useState<'SUSI' | 'PYEONIP' | 'JEONGSI' | undefined>(
undefined,
);
const [selectedCategoryButton, setSelectedCategoryButton] = React.useState<
undefined | 'ADMISSION_GUIDELINE' | 'PASSING_RESULT' | 'PAST_QUESTIONS' | 'INTERVIEW_PRACTICAL_TEST'
>(undefined);
const [selectedTypeButton, setSelectedTypeButton] = React.useState<TypeCategoryState['type']>(undefined);
const [selectedCategoryButton, setSelectedCategoryButton] = React.useState<TypeCategoryState['category']>(undefined);

const handleTypeButtonClick = (selectedType: 'SUSI' | 'PYEONIP' | 'JEONGSI') => {
const handleTypeButtonClick = (selectedType: TypeCategoryState['type']) => {
setSelectedType(selectedType);
setSelectedTypeButton(selectedType);
};

const handleCategoryButtonClick = (
selectedCategory: 'ADMISSION_GUIDELINE' | 'PASSING_RESULT' | 'PAST_QUESTIONS' | 'INTERVIEW_PRACTICAL_TEST',
) => {
const handleCategoryButtonClick = (selectedCategory: TypeCategoryState['category']) => {
setSelectedCategory(selectedCategory);
setSelectedCategoryButton(selectedCategory);
};
Expand Down

0 comments on commit 4c7f88c

Please sign in to comment.