File tree Expand file tree Collapse file tree 3 files changed +27
-3
lines changed
pages/challengeMode/components Expand file tree Collapse file tree 3 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ const ErrorTextMessage = styled.span`
19
19
font-family: "pretendardB";
20
20
font-size: 18px;
21
21
` ;
22
+
22
23
const ErrorText = ( { text } ) => {
23
24
return (
24
25
< ErrorTextContainer >
Original file line number Diff line number Diff line change @@ -5,8 +5,12 @@ import useHover from "../../../hooks/useHover";
5
5
import { useLocation , useNavigate } from "react-router-dom" ;
6
6
import GoToLocationModalContents from "../../modal/modalContents/GoToMainModalContents" ;
7
7
import Modal from "../../modal/Modal" ;
8
- import { useSetAtom } from "jotai" ;
9
- import { timerControlAtom } from "../../../store/atom" ;
8
+ import { useSetAtom , useAtomValue } from "jotai" ;
9
+ import {
10
+ timerControlAtom ,
11
+ userNameAtom ,
12
+ userNameErrorAtom
13
+ } from "../../../store/atom" ;
10
14
11
15
/*네비게이터 전체 */
12
16
const NavBorderBottom = styled . div `
@@ -97,8 +101,14 @@ const Nav = () => {
97
101
const setTimerControl = useSetAtom ( timerControlAtom ) ;
98
102
const path = useLocation ( ) . pathname ;
99
103
const nav = useNavigate ( ) ;
104
+ const userName = useAtomValue ( userNameAtom ) ;
105
+ const setUserNameError = useSetAtom ( userNameErrorAtom ) ;
100
106
101
107
const handleClick = ( ) => {
108
+ if ( userName === "" ) {
109
+ setUserNameError ( true ) ;
110
+ return ;
111
+ }
102
112
setTimerControl ( false ) ;
103
113
if ( path . includes ( "step" ) && ! path . includes ( "step0" ) ) {
104
114
setIsConfirm ( true ) ;
Original file line number Diff line number Diff line change
1
+ import React , { useEffect } from "react" ;
1
2
import styled from "styled-components" ;
2
3
import ErrorText from "../../../components/errorText/ErrorText" ;
3
4
@@ -61,6 +62,13 @@ const AgreeMentMelon = ({
61
62
)
62
63
) ;
63
64
} ;
65
+
66
+ useEffect ( ( ) => {
67
+ // every 함수로 배열의 모든 요소가 조건을 충족하는지 확인
68
+ const allChecked = isAgree . every ( ( item ) => item === true ) ;
69
+ setIsAgreeAll ( allChecked ) ;
70
+ } , [ isAgree , setIsAgreeAll ] ) ;
71
+
64
72
// 전체 동의를 하지 않은 상태에서 다음 단계 버튼을 클릭했을 경우
65
73
const hasError = errorArray . includes ( "checkbox" ) ;
66
74
@@ -72,7 +80,12 @@ const AgreeMentMelon = ({
72
80
{ hasError && < ErrorText text = "체크박스에 모두 동의해 주세요" /> }
73
81
</ TextBox >
74
82
< CheckboxContainer >
75
- < input type = "checkbox" id = "agreeAll" onClick = { handleAgreeAll } />
83
+ < input
84
+ type = "checkbox"
85
+ id = "agreeAll"
86
+ checked = { isAgreeAll } // 모두 체크되면 전체 동의도 체크하기
87
+ onClick = { handleAgreeAll }
88
+ />
76
89
< CheckboxLabel htmlFor = "agreeAll" > 전체동의</ CheckboxLabel >
77
90
< Info > 전체 동의를 누르면 한 번에 동의처리됩니다.</ Info >
78
91
</ CheckboxContainer >
You can’t perform that action at this time.
0 commit comments