Skip to content

Commit

Permalink
feat : reset user info
Browse files Browse the repository at this point in the history
  • Loading branch information
YGwan committed Aug 16, 2023
1 parent 4f9166f commit ab1d1ee
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/main/java/se/ton/t210/controller/MemberController.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public ResponseEntity<Void> sendEmailAuthMail(@Valid @Email String email) {
}

@PostMapping("/api/reset/userInfo")
public ResponseEntity<Void> resetUserInfo(@RequestBody ResetPersonalInfoRequest request) {
final Member member = new Member(1L, "홍길동", "[email protected]", "password", ApplicationType.PoliceOfficerMale);
public ResponseEntity<Void> resetUserInfo(@LoginMember LoginMemberInfo member,
@RequestBody ResetPersonalInfoRequest request) {
memberService.resetUserInfo(member, request);
return ResponseEntity.ok().build();
}
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/se/ton/t210/service/MemberService.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,11 @@ public MemberPersonalInfoResponse getPersonalInfo(String accessToken) {
return memberRepository.getMemberByEmail(email);
}

public void resetUserInfo(Member member, ResetPersonalInfoRequest request) {
public void resetUserInfo(LoginMemberInfo memberInfo, ResetPersonalInfoRequest request) {
Member member = memberRepository.findById(memberInfo.getId()).orElseThrow(() -> {
throw new AuthException(HttpStatus.CONFLICT, "Email is not exists");
}
);
member.resetPersonalInfo(request);
memberRepository.save(member);
}
}
50 changes: 36 additions & 14 deletions src/main/resources/static/js/setting-account.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ document.addEventListener("DOMContentLoaded", function () {
console.log(event.target.textContent);

if (event.target.textContent === "경찰직공무원(남)" || event.target.textContent === "경찰직공무원(여)") {
imgElement.src ="../files/type_icon4.png"; // 경찰직 이미지 경로로 변경
imgElement.src = "../files/type_icon4.png"; // 경찰직 이미지 경로로 변경
} else if (event.target.textContent === "소방직공무원(남)" || event.target.textContent === "소방직공무원(여)") {
imgElement.src ="../files/type_icon2.jpeg"; // 소방직 이미지 경로로 변경
imgElement.src = "../files/type_icon2.jpeg"; // 소방직 이미지 경로로 변경
} else if (event.target.textContent === "교정직공무원(남)" || event.target.textContent === "교정직공무원(여)") {
imgElement.src ="../files/type_icon3.png";// 교정직 이미지 경로로 변경
}
imgElement.src = "../files/type_icon3.png";// 교정직 이미지 경로로 변경
}
dropdownText.id = event.target.id;
dropdown.classList.remove("active");
}
Expand Down Expand Up @@ -138,18 +138,40 @@ document.addEventListener("DOMContentLoaded", function () {
passwordInput2.addEventListener("input", checkPasswordMatch)

const signUpBtn = document.querySelector(".button2");
signUpBtn.addEventListener("click", function () {
signUpBtn.addEventListener("click", async function () {
if (!passwordMachResult) {
sAlert("비밀번호가 일치하지 않습니다.")
// alert("Passwords must match.");
return;
} else {
console.log(passwordMachResult);
// Call API to save password 여기서 저장 api 호출~~!!
const restPassword = passwordInput.value
const resetApplicationTypeKey = dropdownText.id

// 회원가입 - 서버에 요청
const userData = {
password: restPassword,
applicationType: resetApplicationTypeKey
};
try {
const response = await fetch(currentDomain + "/api/reset/userInfo", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(userData),
});
if (!response.ok) {
const data = await response.text();
throw new Error(data || "회원 정보 수정 실패");
}
sAlert("회원정보 수정이 완료되었습니다.");
} catch (error) {
sAlert("수정에 실패했습니다.");
}
}
});


});

// Password toggle
Expand Down Expand Up @@ -206,16 +228,16 @@ async function fetchMemberInfo() {
console.log("applicationTypeStandardName:", applicationTypeStandardName);


dropdownText.textContent=applicationTypeStandardName;
nameInput.textContent=name;
emailInput.textContent=email;
dropdownText.textContent = applicationTypeStandardName;
nameInput.textContent = name;
emailInput.textContent = email;
if (applicationTypeStandardName === "경찰직공무원(남)" || applicationTypeStandardName === "경찰직공무원(여)") {
imgElement.src ="../files/type_icon4.png"; // 경찰직 이미지 경로로 변경
imgElement.src = "../files/type_icon4.png"; // 경찰직 이미지 경로로 변경
} else if (applicationTypeStandardName === "소방직공무원(남)" || applicationTypeSta쇼ndardName === "소방직공무원(여)") {
imgElement.src ="../files/type_icon2.jpeg"; // 소방직 이미지 경로로 변경
imgElement.src = "../files/type_icon2.jpeg"; // 소방직 이미지 경로로 변경
} else if (applicationTypeStandardName === "교정직공무원(남)" || applicationTypeStandardName === "교정직공무원(여)") {
imgElement.src ="../files/type_icon3.png";// 교정직 이미지 경로로 변경
}
imgElement.src = "../files/type_icon3.png";// 교정직 이미지 경로로 변경
}
}

async function fetchApplicationTypeName() {
Expand Down

0 comments on commit ab1d1ee

Please sign in to comment.