-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddGuideFirstKr.tsx
More file actions
118 lines (102 loc) · 3.26 KB
/
AddGuideFirstKr.tsx
File metadata and controls
118 lines (102 loc) · 3.26 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import { css } from '@emotion/react';
import styled from '@emotion/styled';
import React, { useEffect } from 'react';
import { AddOkrCardWrapper } from '../../styles/KeyResultCardStyle';
import { IAddKrFlowProps } from '../../types/KrInfoTypes';
import GuideFirstKeyResultCard from '../addKr/GuideFirstKeyResultCard';
import KeyResultPlusCard from '../addKr/KeyResultPlusCard';
const MAX_KR_LENGTH = 3;
const AddGuideFirstKr = ({
objInfo,
clickedCard,
handleClickPlusCard,
handleClickCloseBtn,
krListInfo,
setKrListInfo,
onValidateNextStep,
}: IAddKrFlowProps) => {
const { objTitle } = objInfo;
const plusCardLength = Array.from({ length: MAX_KR_LENGTH - 1 }, (_, i) => i + 1);
useEffect(() => {
const isValid =
krListInfo.filter((kr) => {
return clickedCard.includes(kr.krIdx);
}).length ===
krListInfo.filter((kr) => {
const { krTitle, krStartAt, krExpireAt } = kr;
return krTitle && krStartAt && krExpireAt;
}).length;
onValidateNextStep(isValid);
}, [krListInfo, clickedCard]);
return (
<section css={AddGuideKrContainer}>
<StFirstAddGuideKrTxt>
{
'목표를 이루기 위한 측정 가능한 이정표를 설정해볼거예요\n먼저, 목표를 달성하기 위해 어떤 성과들이 필요할까요?'
}
</StFirstAddGuideKrTxt>
<StObjTitleBox>
<p>{objTitle}</p>
</StObjTitleBox>
<AddOkrCardWrapper>
<GuideFirstKeyResultCard
cardIdx={0}
objInfo={objInfo}
krListInfo={krListInfo}
setKrListInfo={setKrListInfo}
/>
{plusCardLength.map((item) => {
return (
<React.Fragment key={item}>
{clickedCard.find((el) => el === item) ? (
<GuideFirstKeyResultCard
key={item}
cardIdx={item}
objInfo={objInfo}
krListInfo={krListInfo}
setKrListInfo={setKrListInfo}
handleClickCloseBtn={handleClickCloseBtn}
/>
) : (
<div
key={item}
onClick={() => handleClickPlusCard(item)}
onKeyDown={() => handleClickPlusCard(item)}
role="presentation"
>
<KeyResultPlusCard key={item} />
</div>
)}
</React.Fragment>
);
})}
</AddOkrCardWrapper>
</section>
);
};
export default AddGuideFirstKr;
const AddGuideKrContainer = css`
display: flex;
flex-direction: column;
align-items: center;
`;
const StAddGuideKrTxt = styled.h1`
color: ${({ theme }) => theme.colors.gray_000};
text-align: center;
white-space: pre-line;
${({ theme }) => theme.fonts.title_20_semibold};
`;
const StFirstAddGuideKrTxt = styled(StAddGuideKrTxt)`
margin: 1rem 0 0.6rem;
`;
const StObjTitleBox = styled.div`
display: flex;
align-items: center;
width: fit-content;
height: 4.2rem;
padding: 0.7rem 0.5rem ${({ theme }) => theme.fonts.title_16_semibold};
margin-bottom: 3rem;
color: ${({ theme }) => theme.colors.main_purple};
border-bottom: 1px solid ${({ theme }) => theme.colors.main_purple};
${({ theme }) => theme.fonts.title_16_semibold};
`;