Skip to content

Commit

Permalink
refactor: buttons 배열을 통해 버튼 생성
Browse files Browse the repository at this point in the history
  • Loading branch information
soosoo22 committed Jul 31, 2024
1 parent 500d721 commit eaaaf4c
Showing 1 changed file with 33 additions and 10 deletions.
43 changes: 33 additions & 10 deletions frontend/src/pages/ErrorPage/components/ErrorSection/index.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,53 @@
import AlertTriangle from '@/assets/alertTriangle.svg';
import Home from '@/assets/home.svg';
import ReLoad from '@/assets/reload.svg';
import HomeIcon from '@/assets/home.svg';
import ReloadIcon from '@/assets/reload.svg';
import { Button } from '@/components';
import { ButtonType } from '@/types/styles';

import * as S from './styles';

interface ErrorSectionProps {
errorMessage: string;
handleReLoad: () => void;
handleReload: () => void;
handleGoHome: () => void;
}

const ErrorSection = ({ errorMessage, handleReLoad, handleGoHome }: ErrorSectionProps) => {
const ErrorSection = ({ errorMessage, handleReload, handleGoHome }: ErrorSectionProps) => {
const buttons = [
{
buttonType: 'primary' as ButtonType,
text: '새로고침하기',
image: ReloadIcon,
imageDescription: '새로고침 이미지',
onClick: handleReload,
},
{
buttonType: 'secondary' as ButtonType,
text: '홈으로 이동하기',
image: HomeIcon,
imageDescription: '홈 이미지',
onClick: handleGoHome,
},
];

return (
<S.Layout>
<S.ErrorLogoWrapper>
<img src={AlertTriangle} alt="에러 로고" />
</S.ErrorLogoWrapper>
<S.ErrorMessage>{errorMessage}</S.ErrorMessage>
<S.Container>
<S.ButtonContainer>
<Button buttonType="primary" text="새로고침하기" icon={ReLoad} onClick={handleReLoad} />
</S.ButtonContainer>
<S.ButtonContainer>
<Button buttonType="secondary" text="홈으로 이동하기" icon={Home} onClick={handleGoHome} />
</S.ButtonContainer>
{buttons.map((button, index) => (
<S.ButtonContainer key={index}>
<Button
buttonType={button.buttonType}
text={button.text}
image={button.image}
imageDescription={button.imageDescription}
onClick={button.onClick}
/>
</S.ButtonContainer>
))}
</S.Container>
</S.Layout>
);
Expand Down

0 comments on commit eaaaf4c

Please sign in to comment.