From a6aa3c29adc44c4b06a3be38fbc0fef4bc4691ec Mon Sep 17 00:00:00 2001 From: Brian Kim Date: Mon, 17 Oct 2022 13:55:48 +0000 Subject: [PATCH 1/3] [Feat] #100 Added profile pic change form in usersettings --- front-end/web-next/pages/settings.js | 28 ++++++++++++++++++- .../web-next/styles/usersettings.module.css | 26 +++++++++++++++-- 2 files changed, 50 insertions(+), 4 deletions(-) diff --git a/front-end/web-next/pages/settings.js b/front-end/web-next/pages/settings.js index af1578e4..57f54c7d 100644 --- a/front-end/web-next/pages/settings.js +++ b/front-end/web-next/pages/settings.js @@ -33,6 +33,11 @@ let submitnewuser = async (event) => { console.log('hi') } +let submituserimg = async (event) => { + console.log('hi') + } + + const Settings = () => { //TreeData1 @@ -111,7 +116,7 @@ const Settings = () => {
-

{error1}fds

+

{error1}fd

{success1}

@@ -120,7 +125,28 @@ const Settings = () => {
+
+

프로필 사진 번경

+
+
+ +
+
+ setuploadedunitlogo(image)}> + 사진을 드레그 해주세요 +

+ +
+ + +

error

+

+ +
+
+
+
diff --git a/front-end/web-next/styles/usersettings.module.css b/front-end/web-next/styles/usersettings.module.css index 0bb016e0..fadbc566 100644 --- a/front-end/web-next/styles/usersettings.module.css +++ b/front-end/web-next/styles/usersettings.module.css @@ -12,17 +12,18 @@ margin-top: 40px; display: flex; justify-content: center; + box-shadow: rgba(0, 0, 0, 0.15) 1.95px 1.95px 2.6px; } .userimagechange { - width: 300px; - height: 300px; + height: 400px; background-color: white; border-radius: 10px; margin-top: 40px; margin-left: 20px; display: flex; justify-content: center; + box-shadow: rgba(0, 0, 0, 0.15) 1.95px 1.95px 2.6px; } .userheader { @@ -46,7 +47,6 @@ color: green; font-size: 14px; line-height: 30px; - margin-left: 15px; margin-top: 3px; } .submitbutton { @@ -58,4 +58,24 @@ color: white; height: 30px; margin-top: 3px; +} + +.submitbutton:hover { + cursor: pointer; + background-color: #005c51; +} + +#error2 { + color: red; + font-size: 14px; + text-align: center; + margin-top: 0px; + margin-bottom: 0px; + line-height: 30px; +} +#success2 { + color: green; + font-size: 14px; + text-align: center; + line-height: 30px; } \ No newline at end of file From 65e53794929a0f1c88edb96dfba3ba37948cfb0a Mon Sep 17 00:00:00 2001 From: Brian Kim Date: Mon, 17 Oct 2022 14:34:29 +0000 Subject: [PATCH 2/3] =?UTF-8?q?[Feat]:=20#100=20=EB=B9=84=EB=B0=80?= =?UTF-8?q?=EB=B2=88=ED=98=B8=20=EB=B3=80=EA=B2=BD=20form=20completed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front-end/web-next/pages/settings.js | 53 +++++++++++++++++-- .../web-next/styles/usersettings.module.css | 22 +++++++- 2 files changed, 70 insertions(+), 5 deletions(-) diff --git a/front-end/web-next/pages/settings.js b/front-end/web-next/pages/settings.js index 57f54c7d..5b92a1d7 100644 --- a/front-end/web-next/pages/settings.js +++ b/front-end/web-next/pages/settings.js @@ -35,7 +35,11 @@ let submitnewuser = async (event) => { let submituserimg = async (event) => { console.log('hi') - } +} + +let submitnewpassword = async (event) => { + console.log('pass') +} @@ -47,9 +51,19 @@ const Settings = () => { const [Armymail, setArmymail] = useState(); const [Armyphone, setArmyphone] = useState(); const [Phone, setPhone] = useState(); + + const [uploadedprofilelogo, setuploadedprofilelogo] = useState("none") + + const [currpassword, setcurrpassword] = useState("none") + const [newpassword1, setnewpassword1] = useState("none") + const [newpassword2, setnewpassword2] = useState("none") + const [error1, seterror1] = useState(); const [success1, setsuccess1] = useState(); - + const [error2, seterror2] = useState(); + const [success2, setsuccess2] = useState(); + const [error3, seterror3] = useState(); + const [success3, setsuccess3] = useState(); const onChange1 = (newValue) => { if (newValue == 'title1' || newValue == 'title2' || newValue == 'title3' || newValue == 'title4') { setRank(); @@ -62,6 +76,7 @@ const Settings = () => { 유저 설정 +
@@ -132,7 +147,7 @@ const Settings = () => {
- setuploadedunitlogo(image)}> + setuploadedprofilelogo(image)}> 사진을 드레그 해주세요

@@ -152,7 +167,39 @@ const Settings = () => {
+
+
+

비밀번호 변경

+

현재 비밀번호

+ + { setcurrpassword(event.target.value) }} /> + +

새 비밀번호

+ + { setnewpassword1(event.target.value) }} /> + +

새 비밀번호 확인

+ ({ + validator(_, value) { + if (!value || getFieldValue('새 비밀번호') === value) { + return Promise.resolve(); + } + return Promise.reject(new Error('비밀번호가 일치하지 않습니다!')); + }, + })]}> + { setnewpassword2(event.target.value) }} /> + + +
+ +

{error3}fd

+

{success3}

+
+
+
+
+ diff --git a/front-end/web-next/styles/usersettings.module.css b/front-end/web-next/styles/usersettings.module.css index fadbc566..b0e46f63 100644 --- a/front-end/web-next/styles/usersettings.module.css +++ b/front-end/web-next/styles/usersettings.module.css @@ -1,3 +1,11 @@ +.background { + height: 100%; + display: block; + min-width: 1100px; + overflow-x: scroll; +} + + .lastitem { color: grey; } @@ -5,7 +13,7 @@ .userdatachange { width: 700px; min-width: 650px; - height: 570px; + height: 563px; background-color: white; border-radius: 10px; margin-left: 30px; @@ -34,7 +42,17 @@ margin-bottom: 10px; } - +.resetpassword { + width: 700px; + height: 350px; + background-color: white; + border-radius: 10px; + box-shadow: rgba(0, 0, 0, 0.15) 1.95px 1.95px 2.6px; + margin-left: 30px; + margin-top: 20px; + display: flex; + justify-content: center; +} #error1 { color: red; From 3ceffeadaa42dd98d813c6bac9c8f2834ed46dfd Mon Sep 17 00:00:00 2001 From: Brian Kim Date: Mon, 17 Oct 2022 15:43:47 +0000 Subject: [PATCH 3/3] [Fix]: Made changes to /api/user/register function to accommodate the register form --- back-end/controllers/userControllers.js | 9 +---- front-end/web-next/pages/home.js | 10 +++-- front-end/web-next/pages/register.js | 40 +++++++++++++------ front-end/web-next/styles/register.module.css | 12 ++++++ 4 files changed, 47 insertions(+), 24 deletions(-) diff --git a/back-end/controllers/userControllers.js b/back-end/controllers/userControllers.js index 29a4e991..8f2ad10a 100644 --- a/back-end/controllers/userControllers.js +++ b/back-end/controllers/userControllers.js @@ -120,16 +120,13 @@ const addUser = asyncHandler(async (req, res) => { //@access Public const registerUser = asyncHandler(async (req, res) => { const { - Rank, - Name, DoDID, - email, password, pic, Invcode } = req.body; //049opo6a - if (!Rank || !Name || !email || !password || !DoDID || !Invcode) { + if (!password || !DoDID || !Invcode) { res.status(400); throw new Error("모든 정보를 입력하세요."); } @@ -155,7 +152,6 @@ const registerUser = asyncHandler(async (req, res) => { const updatedUser = await User.findByIdAndUpdate( userDb._id, { - email: email, password: await bcrypt.hash(password, await bcrypt.genSalt(10)), pic: pic, is_registered: true @@ -170,10 +166,7 @@ const registerUser = asyncHandler(async (req, res) => { } else { res.status(201).json({ _id: updatedUser._id, - Name: updatedUser.Name, - Rank: updatedUser.Rank, DoDID: updatedUser.DoDID, - email: updatedUser.email, Type: updatedUser.Type, pic: updatedUser.pic, token: generateToken(updatedUser._id), diff --git a/front-end/web-next/pages/home.js b/front-end/web-next/pages/home.js index 0e64f37f..19f2f874 100644 --- a/front-end/web-next/pages/home.js +++ b/front-end/web-next/pages/home.js @@ -107,14 +107,16 @@ const Home = () => { } +const backendroot = process.env.NEXT_PUBLIC_BACKEND_ROOT +let endpoint = backendroot + 'api/user/login' //export async function getServerSideProps() { -// Fetch data from external API -//const res = await fetch(`https://.../data`) -//const data = await res.json() + //Fetch data from external API +// const res = await fetch(`https://.../data`) +// const data = await res.json() // Pass data to the page via props -// return { props: 'data' } + //return { props: 'data' } //} export default Home; diff --git a/front-end/web-next/pages/register.js b/front-end/web-next/pages/register.js index 6c23de0d..981d4691 100644 --- a/front-end/web-next/pages/register.js +++ b/front-end/web-next/pages/register.js @@ -15,13 +15,20 @@ const Register = () => { const [Invcode, setInvcode] = useState(); const [Password, setPassword] = useState(); const [ConfPassword, setConfPassword] = useState(); - const [error, setError] = useState(''); + const [error, seterror] = useState(''); + const [success, setsuccess] = useState(''); + + const backendroot = process.env.NEXT_PUBLIC_BACKEND_ROOT + let endpoint = backendroot + 'api/user/register' let registeruser = async (event) => { console.log("hi") const data = { DoDID: DoDID, - password: Password + password: Password, + pic: "https://camo.githubusercontent.com/3c2bd3f35721dc332ebf2b11ace89722c37a0f60b94eac42b2a0462fdeb2d420/68747470733a2f2f63646e2d69636f6e732d706e672e666c617469636f6e2e636f6d2f3531322f363134322f363134323232362e706e67", + Invcode: Invcode + } const JSONdata = JSON.stringify(data) const options = { @@ -37,6 +44,13 @@ const Register = () => { const response = await fetch(endpoint, options) const result = await response.json() console.log(result) + if (result['DoDID']) { + seterror("") + setsuccess("계정이 성공적으로 만들어젔습니다. 가입해주세요!") + } else { + setsuccess("") + seterror(result['message']) + } } return ( <> @@ -46,26 +60,26 @@ const Register = () => {

회원가입

- + { setName(event.target.value) }} />

- + { setDoDID(event.target.value) }} /> + 22-xxxxxxxx 양식으로 입력 - 22-xxxxxxxx 양식으로 입력

- + { setInvcode(event.target.value) }} /> + 부대에서 받은 초대코드 이용 - 부대에서 받은 초대코드 이용

- - { setPassword(event.target.value) }} /> + + { setPassword(event.target.value) }} /> + 8자리 이상 비밀번호 사용 - 8자리 이상 비밀번호 사용

- ({ + ({ validator(_, value) { if (!value || getFieldValue('비밀번호') === value) { return Promise.resolve(); @@ -73,12 +87,14 @@ const Register = () => { return Promise.reject(new Error('비밀번호가 일치하지 않습니다!')); }, }),] }> - { setConfPassword(event.target.value) }} /> + { setConfPassword(event.target.value) }} />

{error}

+

{success}

+
diff --git a/front-end/web-next/styles/register.module.css b/front-end/web-next/styles/register.module.css index a53c5a34..0a85c177 100644 --- a/front-end/web-next/styles/register.module.css +++ b/front-end/web-next/styles/register.module.css @@ -60,4 +60,16 @@ line-height: 33px; margin-top: 4px; margin-bottom: 0px; +} + +#success { + color: green; + font-size: 14px; + line-height: 33px; + margin-top: 4px; + margin-bottom: 0px; +} + +.inputfield { + margin-bottom: 7px; } \ No newline at end of file