Skip to content

Commit

Permalink
feat: profile, edit profile page에서 url에 유효하지 않은 uid 입력시 404page 로 이동
Browse files Browse the repository at this point in the history
  • Loading branch information
seonjo1 committed Aug 26, 2024
1 parent 56c5092 commit 12bb599
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
18 changes: 10 additions & 8 deletions frontend/src/components/Edit-Profile.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import { Component } from "../core/Component.js";
import { changeUrl } from "../core/router.js";
import { parseJWT } from "../core/jwt.js";

export class EditProfile extends Component {

translate() {
const payload = parseJWT();

if (parseInt(this.props.uid) !== payload.id)
changeUrl("/404", false);

const languages = {
0: {
headText: "Edit Profile",
Expand Down Expand Up @@ -147,7 +153,7 @@ export class EditProfile extends Component {
}

setEvent() {
this.addEvent('click', '#goBack', (event) => {
this.addEvent('click', '#goBack', () => {
window.history.back();
});

Expand All @@ -158,15 +164,15 @@ export class EditProfile extends Component {
}
});

this.addEvent('click', '#deleteButton', (event) => {
this.addEvent('click', '#deleteButton', () => {
document.getElementById('deleteDoubleCheck').style.display = 'flex';
});

this.addEvent('click', '#deleteNoButton', (event) => {
this.addEvent('click', '#deleteNoButton', () => {
document.getElementById('deleteDoubleCheck').style.display = 'none';
});

this.addEvent('click', '#deleteYesButton', (event) => {
this.addEvent('click', '#deleteYesButton', () => {
//API!! ME DELETE
fetch("https://localhost:443/api/me/", {
method: 'DELETE',
Expand All @@ -187,10 +193,6 @@ export class EditProfile extends Component {
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 Down
5 changes: 4 additions & 1 deletion frontend/src/components/Profile-Info.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ export class ProfileInfo extends Component {
this.state.rate = data.user.lose == 0 ? (data.user.win == 0 ? 0 : 100) :
Math.round((data.user.win / (data.user.lose + data.user.win)) * 100);
})
.catch(error => console.error('Fetch error:', error));
.catch(error => {
console.error('Fetch error:', error);
changeUrl("/404", false);
});
return { user: this.user, rate: this.rate, games: this.games };
}

Expand Down
1 change: 0 additions & 1 deletion frontend/src/core/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ export async function parsePath(path) {
keys.forEach((key, index) => {
props[key.substring(1)] = values[index];
});
console.log(props);
route.component(props);
return;
}
Expand Down

0 comments on commit 12bb599

Please sign in to comment.