Skip to content

Commit

Permalink
fix: edit profile 페이지 오류메시지 보여주는거 삭제
Browse files Browse the repository at this point in the history
  • Loading branch information
seonjo1 committed Aug 17, 2024
1 parent 44d0160 commit 16d02fa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 44 deletions.
30 changes: 8 additions & 22 deletions frontend/src/components/Edit-Profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ export class EditProfile extends Component {
</div>
<div id="url-upload-wrapper">
<label for="image-url">Present Image URL</label>
<input type="text" id="image-url" value="${this.state.img_url}" placeholder="Enter image URL" readonly>
<input type="text" class="profile-image-url" value="${this.state.img_url}" placeholder="Enter image URL" readonly>
</div>
</div>
<div id="edit-2FA">
<label for="2fa-toggle">Enable 2FA:</label>
${this.state.is_2FA ? `<input type="checkbox" id="2fa-toggle" checked disabled>` : `<input type="checkbox" id="2fa-toggle" disabled>`}
${this.state.is_2FA ? `<input type="checkbox" checked disabled>` : `<input type="checkbox" disabled>`}
</div>
</div>
<div id="Arrow">
Expand All @@ -72,17 +72,15 @@ export class EditProfile extends Component {
<div class="edit" id="edit-nick">
<label for="nickname">Nickname:</label>
<input type="text" id="nickname" value="${this.state.nickname}" autocomplete="off" maxlength="10">
<div id="nickname-error" class="error-message"></div>
</div>
<div class="edit" id="edit-img">
<div id="image-preview">
<img id="profile-image" src="${this.state.img_url}" alt="Profile Image"></img>
</div>
<div id="url-upload-wrapper">
<label for="image-url">Enter Image URL</label>
<input type="text" id="image-url" value="${this.state.img_url}" placeholder="Enter image URL">
<input type="text" class="profile-image-url" id="image-url" value="${this.state.img_url}" placeholder="Enter image URL">
</div>
<div id="image-error" class="error-message"></div>
</div>
<div id="edit-2FA">
<label for="2fa-toggle">Enable 2FA:</label>
Expand Down Expand Up @@ -131,15 +129,15 @@ export class EditProfile extends Component {
this.addEvent('click', '#profileChange', async (event) => {
event.preventDefault();

// Clear any previous error messages
document.getElementById('nickname-error').textContent = '';
document.getElementById('image-error').textContent = '';

// Fetch the values
const nickname = document.getElementById('nickname').value;
const imageUrl = document.getElementById('image-url').value;
const is_2FA = document.getElementById('2fa-toggle').checked;

console.log(nickname);
console.log(imageUrl);
console.log(is_2FA);

// Create FormData object to send file and other data
const formData = new FormData();
formData.append('nickname', nickname);
Expand All @@ -161,19 +159,7 @@ export class EditProfile extends Component {
}
})
.then(result => {
// nickname이 유효하지 않으면 경고문 띄움
if (!result.is_valid_nick) {
document.getElementById('nickname-error').textContent = "nickname is invalid!";
}

// image가 유효하지 않으면 경고문 띄움
if (!result.is_valid_img) {
document.getElementById('image-error').textContent = "image is invalid!";
}

if (result.is_valid_nick && result.is_valid_img) {
changeUrl(`/main/profile/${this.props.uid}/edit`);
}
changeUrl(`/main/profile/${this.props.uid}/edit`);
})
.catch(error => {
console.error('Error updating profile:', error);
Expand Down
23 changes: 1 addition & 22 deletions frontend/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -1216,20 +1216,6 @@ div#edit-nick{
justify-content: center;
}

div.edit{
position: relative;
}

div#nickname-error {
position: absolute;
bottom: 3px;
}

div#image-error {
position: absolute;
bottom: 10px;
}

#edit-nick label {
display: block;
margin-right: 20px;
Expand All @@ -1239,7 +1225,6 @@ div#image-error {
color: #333;
}


#edit-nick input[type="text"] {
width: 30%;
padding: 10px;
Expand Down Expand Up @@ -1292,7 +1277,7 @@ div#edit-img {
color: #333;
}

#image-url {
.profile-image-url {
margin-top: 10px;
width: 80%;
height: 80%;
Expand Down Expand Up @@ -1355,9 +1340,3 @@ button#profileChange {
button#profileChange:hover {
background-color: #357ABD;
}

.error-message {
color: red;
font-size: 12px;
margin-top: 5px;
}

0 comments on commit 16d02fa

Please sign in to comment.