-
Notifications
You must be signed in to change notification settings - Fork 1
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 #21 from ApptiveDev/develop/register-page-contents
Feat: Develop/register page contents
- Loading branch information
Showing
21 changed files
with
736 additions
and
49 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,45 @@ | ||
import {useSelector} from 'react-redux'; | ||
import {RootState} from '@/modules'; | ||
import Button from '@components/button/Button.tsx'; | ||
import {getRequiredInfo} from '@modules/registerReducer.ts'; | ||
import {useEffect, useState} from 'react'; | ||
import {useNavigate} from 'react-router-dom'; | ||
import Constants from '@/constants'; | ||
|
||
type RegisterStepButtonProps = { | ||
currentProgress: number; | ||
}; | ||
|
||
const RegisterStepButton = ({currentProgress}: RegisterStepButtonProps) => { | ||
const navigate = useNavigate(); | ||
const registerState = | ||
useSelector((state: RootState) => state.register); | ||
const [disabled, setDisabled] = useState(true); | ||
|
||
const constant = Constants.register; | ||
useEffect(() => { | ||
if (Object.keys(registerState).length === 0) { | ||
return; | ||
} | ||
const requiredInfo = getRequiredInfo(currentProgress); | ||
|
||
let disabledChange = false; | ||
for (const key of requiredInfo) { | ||
if (typeof registerState[key] === 'undefined' || registerState[key] === | ||
null) { | ||
disabledChange = true; | ||
} | ||
} | ||
if (currentProgress === constant.page_nums.PAGE_USER_AGREEMENT && | ||
!registerState.tos_agreed) { | ||
disabledChange = true; | ||
} | ||
setDisabled(disabledChange); | ||
}, [currentProgress, registerState]); | ||
return <Button label={'다음'} disabled={disabled} onClick={() => { | ||
if (!disabled) { | ||
navigate(constant.getNextUrlHash(currentProgress)); | ||
} | ||
}} />; | ||
}; | ||
export default RegisterStepButton; |
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
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,38 @@ | ||
import React from 'react'; | ||
|
||
import checkIcon from '@assets/icons/check.svg'; | ||
|
||
interface CheckboxProps { | ||
checked: boolean; | ||
label?: string; | ||
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void; | ||
} | ||
|
||
const LoginCheckbox = ({checked, onChange, label}: CheckboxProps) => { | ||
return ( | ||
<> | ||
<label className='flex'> | ||
|
||
<input type='checkbox' | ||
className='appearance-none w-[24px] h-[24px] | ||
border rounded-full border-gray-400 | ||
checked:bg-blue-600 checked:border-transparent | ||
focus:outline-none' | ||
style={{ | ||
backgroundImage: 'url("' + checkIcon + '")', | ||
backgroundSize: '70%', | ||
backgroundRepeat: 'no-repeat', | ||
backgroundPosition: '50% 55%', | ||
}} | ||
checked={checked} | ||
onChange={onChange} | ||
/> | ||
|
||
<p className='text-primary font-bold font-apple ml-[4px]'> | ||
{label && label}</p> | ||
</label> | ||
</> | ||
); | ||
}; | ||
|
||
export default LoginCheckbox; |
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 |
---|---|---|
@@ -1,9 +1,12 @@ | ||
import {configureStore} from '@reduxjs/toolkit'; | ||
import authReducer from '@modules/authReducer.ts'; | ||
import registerReducer from '@modules/registerReducer.ts'; | ||
|
||
export const rootStore = configureStore({ | ||
reducer: { | ||
auth: authReducer, | ||
register: registerReducer, | ||
}, | ||
devTools: true, | ||
}); | ||
export type RootState = ReturnType<typeof rootStore.getState>; |
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,89 @@ | ||
import Constants from '@/constants'; | ||
|
||
const REGISTER_SET_INFO = 'register/SET_INFO'; | ||
const REGISTER_CLEAR_INFO = 'register/CLEAR_INFO'; | ||
|
||
interface SetInfoAction { | ||
type: typeof REGISTER_SET_INFO; | ||
payload: RegisterState; | ||
} | ||
|
||
interface ClearInfoAction { | ||
type: typeof REGISTER_CLEAR_INFO; | ||
} | ||
|
||
type RegisterState = { | ||
register_type?: number; | ||
tos_agreed?: boolean; | ||
name?: string; | ||
email?: string; | ||
authorized?: boolean; | ||
nickname?: string; | ||
loginid?: string; | ||
password?: string; | ||
passwordConfirm?: string; | ||
gender?: number; | ||
}; | ||
|
||
const registerFields: (keyof RegisterState)[] = [ | ||
'register_type', | ||
'tos_agreed', | ||
'name', | ||
'email', | ||
'authorized', | ||
'nickname', | ||
'loginid', | ||
'password', | ||
'passwordConfirm', | ||
'gender', | ||
]; | ||
|
||
const pageNums = Constants.register.page_nums; | ||
|
||
export const getRequiredInfo = (progress: number): (keyof RegisterState)[] => { | ||
switch (progress) { | ||
case pageNums.PAGE_REGISTER_SELECTION: | ||
return registerFields.slice(0, 1); | ||
case pageNums.PAGE_USER_AGREEMENT: | ||
return registerFields.slice(0, 2); | ||
case pageNums.PAGE_AUTHORIZATION: | ||
return registerFields.slice(0, 5); | ||
case pageNums.PAGE_INPUT_INFORMATION: | ||
return registerFields; | ||
} | ||
return []; | ||
}; | ||
|
||
// 모두 undefined | ||
const initialState: RegisterState = {}; | ||
|
||
export const setRegisterInfo = (info: RegisterState): SetInfoAction => ({ | ||
type: REGISTER_SET_INFO, | ||
payload: info, | ||
}); | ||
|
||
export const clearRegisterInfo = (): ClearInfoAction => ({ | ||
type: REGISTER_CLEAR_INFO, | ||
}); | ||
|
||
// Reducer | ||
const registerReducer = ( | ||
state = initialState, | ||
action: SetInfoAction | ClearInfoAction, | ||
): RegisterState => { | ||
switch (action.type) { | ||
case REGISTER_SET_INFO: | ||
return { | ||
...state, | ||
...action.payload, | ||
}; | ||
case REGISTER_CLEAR_INFO: | ||
return { | ||
...initialState, | ||
}; | ||
default: | ||
return state; | ||
} | ||
}; | ||
|
||
export default registerReducer; |
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
Oops, something went wrong.