-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from ddok-ddak/feature/DD-19-회원가입
Feature/dd 19 회원가입
- Loading branch information
Showing
18 changed files
with
1,084 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { UserData } from '@/store/userData'; | ||
import { callAPI } from './common/api'; | ||
import CommonResponse from './http'; | ||
|
||
/** | ||
* check duplicated email | ||
* @param email email | ||
* @returns response | ||
*/ | ||
export const checkDuplicatedEmail = async (email: string) => { | ||
const response = await callAPI({ | ||
url: '/api/v1/members/duplicatedEmail', | ||
method: 'GET', | ||
params: { | ||
}, | ||
}); | ||
|
||
return response as CommonResponse; | ||
}; | ||
|
||
/** | ||
* check duplicated nickname | ||
* @param nickname nickname | ||
* @returns response | ||
*/ | ||
export const checkDuplicatedNickname = async (nickname: string) => { | ||
const response = await callAPI({ | ||
url: '/api/v1/members/duplicateNickname', | ||
method: 'GET', | ||
params: { | ||
nickname | ||
} | ||
}); | ||
|
||
return response as CommonResponse; | ||
}; | ||
|
||
/** | ||
* user sign up | ||
* @param request: UserData | ||
* @returns response | ||
*/ | ||
export const addUser = async (request: UserData) => { | ||
const response = await callAPI({ | ||
url: '/api/v1/auth/signup', | ||
method: 'POST', | ||
body: request, | ||
}); | ||
|
||
return response as CommonResponse; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { ReactElement } from 'react'; | ||
import { useRecoilState } from 'recoil'; | ||
import { SignUpStepState } from '@/store/signUp'; | ||
|
||
export function useSignUpStepForm(steps: ReactElement[]) { | ||
|
||
const [currentStepIndex, setCurrentStepIndex] = useRecoilState(SignUpStepState); | ||
|
||
/** | ||
* handle next button | ||
*/ | ||
function handleNextButton() { | ||
const currIdx = currentStepIndex; | ||
setCurrentStepIndex(() => (currIdx < steps.length - 1) ? (currIdx + 1) : currIdx); | ||
} | ||
|
||
/** | ||
* handle prev button | ||
*/ | ||
function handlePrevButton() { | ||
const currIdx = currentStepIndex; | ||
setCurrentStepIndex(() => (currIdx <= 0) ? currIdx : currIdx - 1); | ||
} | ||
|
||
return { | ||
currentStepIndex, | ||
step: steps[currentStepIndex], | ||
steps, | ||
handleNextButton, | ||
handlePrevButton | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
import React, { useState, useEffect } from 'react'; | ||
import { useRecoilState, useSetRecoilState, useRecoilValue } from 'recoil'; | ||
import { | ||
Box, | ||
List, | ||
ListItem, | ||
ListItemButton, | ||
ListItemIcon, | ||
ListItemText, | ||
Checkbox, | ||
Divider, | ||
} from '@mui/material'; | ||
import { SignUpNextButtonState, SignUpStepInstruction, SignUpStepNextButton } from '@/store/signUp'; | ||
|
||
import FormWrapper from './FormWrapper'; | ||
|
||
type ItemType = { | ||
required: boolean, | ||
desc: string, | ||
checked: boolean, | ||
} | ||
|
||
const termsAndConditionsArray: ItemType[] = [ | ||
{ | ||
required: false, | ||
desc: '모두 동의합니다.', | ||
checked: false, | ||
}, | ||
{ | ||
required: true, | ||
desc: '만 14세 이상입니다', | ||
checked: false, | ||
}, | ||
{ | ||
required: true, | ||
desc: '[필수] 이용 약관 동의', | ||
checked: false, | ||
}, | ||
{ | ||
required: true, | ||
desc: '[필수] 개인정보 수집 및 이용 동의', | ||
checked: false, | ||
}, | ||
{ | ||
required: false, | ||
desc: '[선택] 광고, 마케팅 활용 정보수신 동의', | ||
checked: false, | ||
} | ||
]; | ||
|
||
const CheckTermsAndConditions = (props: any) => { | ||
const [signUpNextButtonProps, setSignUpNextButtonProps] = useRecoilState(SignUpNextButtonState); | ||
const setSignUpStepInstruction = useSetRecoilState(SignUpStepInstruction); | ||
const signUpStepNextButton = useRecoilValue(SignUpStepNextButton); | ||
|
||
const [checked, setChecked] = useState([false, false, false, false, false]); | ||
const [isNextButtonDisabled, setIsNextButtonDisabled] = useState(true); | ||
|
||
const handleCheckboxToggle = (idx: number) => () => { | ||
const currentIndex = idx; | ||
const newChecked: boolean[] = [...checked]; | ||
let newValue = !newChecked[idx]; | ||
let isRequiredCheck = false; | ||
|
||
if (currentIndex === 0) { | ||
// 모두 동의 | ||
newChecked.fill(newValue); | ||
} else { | ||
newChecked[idx] = newValue; | ||
} | ||
setChecked(newChecked); | ||
isRequiredCheck = !(newChecked[1] && newChecked[2] && newChecked[3]); | ||
setIsNextButtonDisabled(isRequiredCheck); | ||
setSignUpNextButtonProps({ | ||
...signUpNextButtonProps, | ||
isDisabled: isRequiredCheck, | ||
}); | ||
}; | ||
const CheckboxItem = (item: ItemType, idx: number) => { | ||
const labelId = `checkbox-list-label-${idx}`; | ||
return ( | ||
<ListItem disablePadding> | ||
<ListItemButton | ||
role={undefined} | ||
onClick={handleCheckboxToggle(idx)} | ||
dense | ||
> | ||
<ListItemIcon> | ||
<Checkbox | ||
required={item.required} | ||
edge="start" | ||
sx={{ width: '21px', height: '21px' }} | ||
checked={checked[idx]} | ||
tabIndex={-1} | ||
disableRipple | ||
inputProps={{ 'aria-labelledby': labelId }} | ||
/> | ||
</ListItemIcon> | ||
<ListItemText id={labelId} primary={item.desc} /> | ||
</ListItemButton> | ||
</ListItem> | ||
); | ||
}; | ||
|
||
useEffect(() => { | ||
setSignUpStepInstruction('서비스를 이용하기 위해 약관에 동의 해주세요.'); | ||
setSignUpNextButtonProps({ | ||
...signUpNextButtonProps, | ||
isDisabled: true, | ||
clickHandler: props.handleNextButton | ||
}) | ||
}, []); | ||
|
||
return ( | ||
<FormWrapper> | ||
<List | ||
sx={{ | ||
width: '100%', | ||
maxWidth: 360, | ||
bgcolor: 'background.paper', | ||
}} | ||
> | ||
{Object.values(termsAndConditionsArray).map((item: ItemType, idx: number) => { | ||
return ( | ||
<Box key={idx}> | ||
{idx === 1 && ( | ||
<Divider | ||
variant="middle" | ||
sx={{ | ||
backgroundColor: '#DDDDDD', | ||
height: '3px', | ||
border: 'none', | ||
margin: '10px 0 10px 5px', | ||
width: '95%', | ||
}} | ||
/> | ||
)} | ||
{CheckboxItem(item, idx)} | ||
</Box> | ||
); | ||
})} | ||
</List> | ||
</FormWrapper> | ||
); | ||
}; | ||
|
||
export default CheckTermsAndConditions; |
Oops, something went wrong.