From 3665a9467da52a455919b7705be1ba57f453f883 Mon Sep 17 00:00:00 2001 From: psyeon1120 Date: Sat, 28 Oct 2023 20:30:08 +0900 Subject: [PATCH] =?UTF-8?q?[PDW-45]=20feat:=20=EC=A7=81=EC=9B=90=20?= =?UTF-8?q?=EB=93=B1=EB=A1=9D=20API=20=EC=97=B0=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/button/BigSquareButton.js | 17 ++++- src/components/capsule/SelectToggle.js | 2 +- src/components/modal/Modal.js | 2 +- src/pages/manager/userManage/UserModal.js | 80 +++++++++++++++++------ 4 files changed, 78 insertions(+), 23 deletions(-) diff --git a/src/components/button/BigSquareButton.js b/src/components/button/BigSquareButton.js index eb497f3..2e9e406 100644 --- a/src/components/button/BigSquareButton.js +++ b/src/components/button/BigSquareButton.js @@ -8,7 +8,7 @@ const Button = styled.button` border: none; border-radius: 8px; background: #8741CB; - box-shadow: 0px 4px 4px 0px #00000040; + box-shadow: 0 4px 4px 0 #00000040; cursor: pointer; color: white; font-size: 17px; @@ -21,6 +21,21 @@ const WhiteButton = styled(Button)` border: 1px solid #8741CB; ` +export const InputPurpleButton = styled.input.attrs({type: 'submit'})` + width: 130px; + height: 100%; + padding: 10px; + border: none; + border-radius: 8px; + background: #8741CB; + box-shadow: 0 4px 4px 0 #00000040; + cursor: pointer; + color: white; + font-size: 17px; + font-family: NanumSquare_ac; + +` + function BigSquareButton(props) { return ( diff --git a/src/components/capsule/SelectToggle.js b/src/components/capsule/SelectToggle.js index 0a91a6a..3024462 100644 --- a/src/components/capsule/SelectToggle.js +++ b/src/components/capsule/SelectToggle.js @@ -29,7 +29,7 @@ const ModalSelect = styled(Select)` export function SelectToggleInModal(props) { return ( - + {props.items} ); diff --git a/src/components/modal/Modal.js b/src/components/modal/Modal.js index 57732a6..c7c61d6 100644 --- a/src/components/modal/Modal.js +++ b/src/components/modal/Modal.js @@ -53,7 +53,7 @@ export const ExitBtn = styled.button` align-items : center; ` -export const AttrsContainer = styled.div` +export const AttrsForm = styled.form` width: 100%; ` diff --git a/src/pages/manager/userManage/UserModal.js b/src/pages/manager/userManage/UserModal.js index dc8c5c0..592672a 100644 --- a/src/pages/manager/userManage/UserModal.js +++ b/src/pages/manager/userManage/UserModal.js @@ -7,9 +7,8 @@ import { AttrContainer, AttrInput, AttrLabel, - AttrsContainer, + AttrsForm, BottomBtnContainer, - ExitBtn, ModalBackdrop, ModalTitle, ModalView, @@ -21,11 +20,12 @@ import { BasicCapsuleBtnF, BasicRadioInput } from 'components/capsule/RoleCapsule'; -import BigSquareButton from 'components/button/BigSquareButton'; +import BigSquareButton, {InputPurpleButton} from 'components/button/BigSquareButton'; export function UserModal(props) { const [departmentOptionList, setDepartmentOptionList] = useState([]); const [currentRole, setCurrentRole] = useState("일반"); + const [currentDepartment, setCurrentDepartment] = useState(""); let departments; function getDpNPsList() { @@ -36,7 +36,7 @@ export function UserModal(props) { }) .then((response) => { departments = response.data.data.departmentList - setDepartmentOptionList(departments.map((department) => ())) + setDepartmentOptionList(departments.map((department) => ())) }) .catch((error) => { basicError(error) @@ -47,12 +47,52 @@ export function UserModal(props) { getDpNPsList() }, []) - const handleChange = (e) => { - console.log(`선택한 값 : ${e.target.value}`); - + const handleRoleChange = (e) => { setCurrentRole(e.target.value); }; + const handleDepartmentChange = (e) => { + setCurrentDepartment(e.target.value); + }; + + // 전화번호 자동 하이픈 + const autoHyphen = (e) => { + e.target.value = e.target.value + .replace(/[^0-9]/g, '') + .replace(/^(\d{2,3})(\d{3,4})(\d{4})$/, `$1-$2-$3`); + } + + const registerUser = (e) => { + e.preventDefault() + const inputName = e.target.name.value + const inputEmail = e.target.email.value + const inputPassword = e.target.password.value + const inputPhone = e.target.phone.value + const inputDepartment = e.target.department.value + const inputRole = e.target.role.value + // todo: 입력값 정규식 확인 + + AdminUsersAxios.post("", { + name: inputName, + email: inputEmail, + password: inputPassword, + phone: inputPhone, + department: inputDepartment, + role: inputRole + }, { + headers: { + Authorization: getToken() + } + }) + .then((response) => { + alert("등록되었습니다.") + window.location.reload(); + }) + .catch((error) => { + basicError(error) + }) + }; + return ( @@ -60,26 +100,26 @@ export function UserModal(props) { 신규 직원 등록 - + 성명 - + 이메일 - + 비밀번호 - + 연락처 - + 부서 - + 권한 @@ -87,20 +127,20 @@ export function UserModal(props) { name="role" value="일반" checked={currentRole === "일반"} - onChange={handleChange}/> + onChange={handleRoleChange}/> 일반 + onChange={handleRoleChange}/> 관리자 - - - - - + + + + + );