-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEventRegisterLayout.tsx
More file actions
89 lines (82 loc) · 2.83 KB
/
EventRegisterLayout.tsx
File metadata and controls
89 lines (82 loc) · 2.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import { ReactNode, useState, Children, isValidElement, cloneElement } from 'react';
import Button from '../../../../design-system/ui/Button';
import Header from '../../../../design-system/ui/Header';
import IconButton from '../../../../design-system/ui/buttons/IconButton';
import { useNavigate } from 'react-router-dom';
import HomeButton from '../../../../public/assets/menu/HomeButton.svg';
interface EventRegisterLayoutProps {
children: ReactNode;
title?: string;
className?: string;
onNext: () => void;
onPrev: () => void;
requireValidation?: boolean;
goHome?: boolean;
}
interface ValidationChildProps {
onValidationChange: (isValid: boolean) => void;
}
const EventRegisterLayout = ({
children,
title,
className = '',
onNext,
onPrev,
requireValidation = false,
goHome = false,
}: EventRegisterLayoutProps) => {
const [isFormValid, setIsFormValid] = useState(false);
const handleValidationChange = (isValid: boolean) => {
setIsFormValid(isValid);
};
const childrenWithValidation = Children.map(children, child => {
if (requireValidation && isValidElement<ValidationChildProps>(child)) {
return cloneElement(child, { onValidationChange: handleValidationChange });
}
return child;
});
const navigate = useNavigate();
return (
<div className="relative flex">
{/* 헤더 영역 */}
<div className="absolute top-0 w-full h-36 md:h-40 bg-gradient-to-br from-[#FF5593] to-[rgb(255,117,119)] rounded-b-[60px] z-10">
<Header
centerContent="이벤트 등록"
leftButtonLabel={goHome ? (<IconButton
iconPath={<img src={HomeButton} />}
onClick={() => navigate('/')}
iconClassName="cursor-pointer z-30 ml-auto"
/>) : '<'}
leftButtonClick={goHome ? () => navigate('/') : onPrev}
color="white"
leftButtonClassName="text-xl z-30"
rightContent={
goHome ? null : (
<IconButton
iconPath={<img src={HomeButton} />}
onClick={() => navigate('/')}
iconClassName="cursor-pointer z-30 ml-auto"
/>
)
}
/>
</div>
{/* 레이아웃 내용 */}
<div className="flex flex-col justify-between w-[85%] min-h-[calc(100vh-6rem)] bg-white rounded-[20px] mt-24 mx-auto z-20">
<div>
<div className="text-center w-full my-5 md:my-8 text-lg md:text-2xl font-bold">{title}</div>
<div className={`${className}`}>{childrenWithValidation}</div>
</div>
<div className="w-full p-5">
<Button
label="다음"
onClick={onNext}
className="w-full h-12 rounded-full"
disabled={requireValidation && !isFormValid}
/>
</div>
</div>
</div>
);
};
export default EventRegisterLayout;