Skip to content

Commit

Permalink
Merge pull request #106 from study2895:main
Browse files Browse the repository at this point in the history
[Feat] ๋น„๋ฐ€๋ฒˆํ˜ธ ์ž…๋ ฅ๋œ ๋ฐ์ดํ„ฐ๊ฐ€ ์—†์„ ๋•Œ ๋ฒ„ํŠผ ๋น„ํ™œ์„ฑํ™” ๋ถ„๊ธฐ ๋กœ์ง ์ž‘์„ฑ
  • Loading branch information
study2895 authored Dec 10, 2024
2 parents 8a17b1a + 93490b7 commit 20969cf
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 deletions.
22 changes: 10 additions & 12 deletions src/views/login/mypage/MypageScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,50 +106,48 @@ export async function verifyCurrentPassword() {

// ๋น„๋ฐ€๋ฒˆํ˜ธ ๋ณ€๊ฒฝ
export async function updatePassword() {
// ํ˜„์žฌ ๋น„๋ฐ€๋ฒˆํ˜ธ ํ™•์ธ ์—ฌ๋ถ€
if (!passwordVerified.value) {
alert('ํ˜„์žฌ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ๋จผ์ € ํ™•์ธํ•ด์ฃผ์„ธ์š”.')
return
}

// ์ƒˆ ๋น„๋ฐ€๋ฒˆํ˜ธ์™€ ํ™•์ธ ๋น„๋ฐ€๋ฒˆํ˜ธ ์ผ์น˜ ์—ฌ๋ถ€ ํ™•์ธ
if (password.value !== confirmPassword.value) {
alert('์ƒˆ ๋น„๋ฐ€๋ฒˆํ˜ธ๊ฐ€ ์ผ์น˜ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.')
return
}

if (!password.value || !confirmPassword.value) {
alert('์ƒˆ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.')
return
}

try {
// API ์š”์ฒญ
const response = await fetch(
`${process.env.VUE_APP_BE_API_URL}/api/users/password`,
{
method: 'PATCH',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
currentPassword: currentPassword.value, // ํ˜„์žฌ ๋น„๋ฐ€๋ฒˆํ˜ธ
newPassword: password.value // ์ƒˆ ๋น„๋ฐ€๋ฒˆํ˜ธ
currentPassword: currentPassword.value,
newPassword: password.value
}),
credentials: 'include' // ์„ธ์…˜ ํฌํ•จ
credentials: 'include'
}
)

// ์‘๋‹ต ์ฒ˜๋ฆฌ
if (response.ok) {
const message = await response.json() // ์„ฑ๊ณต ๋ฉ”์‹œ์ง€
alert(message) // "๋น„๋ฐ€๋ฒˆํ˜ธ๊ฐ€ ์„ฑ๊ณต์ ์œผ๋กœ ๋ณ€๊ฒฝ๋˜์—ˆ์Šต๋‹ˆ๋‹ค."
alert('๋น„๋ฐ€๋ฒˆํ˜ธ๊ฐ€ ์„ฑ๊ณต์ ์œผ๋กœ ๋ณ€๊ฒฝ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.')
password.value = ''
confirmPassword.value = ''
currentPassword.value = ''
passwordVerified.value = false // ๋น„๋ฐ€๋ฒˆํ˜ธ ํ™•์ธ ์ƒํƒœ ์ดˆ๊ธฐํ™”
passwordVerified.value = false
} else if (response.status === 400) {
alert('ํ˜„์žฌ ๋น„๋ฐ€๋ฒˆํ˜ธ๊ฐ€ ์ผ์น˜ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.')
} else {
console.error('๋น„๋ฐ€๋ฒˆํ˜ธ ์ˆ˜์ • ์‹คํŒจ:', response.status, response.statusText)
}
} catch (error) {
console.error('๋น„๋ฐ€๋ฒˆํ˜ธ ์ˆ˜์ • ์˜ค๋ฅ˜:', error)
} finally {
alert('๋น„๋ฐ€๋ฒˆํ˜ธ๊ฐ€ ๋ณ€๊ฒฝ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.')
}
}

Expand Down
7 changes: 6 additions & 1 deletion src/views/login/mypage/MypageView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,12 @@
placeholder="์ƒˆ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ๋‹ค์‹œ ์ž…๋ ฅํ•˜์„ธ์š”"
class="form-input"
/>
<button @click="updatePassword" class="update-button">
<!-- ๋น„๋ฐ€๋ฒˆํ˜ธ ์ˆ˜์ • ๋ฒ„ํŠผ์— :disabled ์†์„ฑ ์ถ”๊ฐ€ -->
<button
@click="updatePassword"
class="update-button"
:disabled="!password || !confirmPassword"
>
์ˆ˜์ •ํ•˜๊ธฐ
</button>
</div>
Expand Down
8 changes: 2 additions & 6 deletions src/views/mainpage/MainpageView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,13 @@ import commentIcon from '@/assets/Icons/akoming/todo/comment.svg'
import akofolioIcon from '@/assets/Icons/akoming/todo/akofolio.svg'
import SkeletonMainPage from './SkeletonMainPage.vue'
// Tasks for the to-do list
const tasks = ref([
{ name: '์•„์ฝ”๋ฐ ์ถœ์„', completed: false },
{ name: '์•„์ฝ”์ž๊ตญ', completed: false },
{ name: '๋Œ“๊ธ€ ๋‚จ๊ธฐ๊ธฐ', completed: false },
{ name: '์•„์ฝ”ํด๋ฆฌ์˜ค', completed: false }
])
// ์Šคํƒฌํ”„ ์ƒํƒœ ์ •์˜
const stamps = ref([
{
label: 'A',
Expand Down Expand Up @@ -193,7 +191,6 @@ const fetchQuestStatus = async () => {
}
}
// Functions to get icons based on task name and completion status
const getCompletedStampIcon = (label) => {
return require(`@/assets/Icons/akoming/stamp/color/color${label.toLowerCase()}.svg`)
}
Expand All @@ -217,7 +214,6 @@ const getTaskIcon = (taskName) => {
}
}
// onMounted์—์„œ ํ˜ธ์ถœํ•˜์—ฌ ์ดˆ๊ธฐ ๋ฐ์ดํ„ฐ ๋กœ๋“œ
onMounted(() => {
fetchQuestStatus()
})
Expand All @@ -230,11 +226,11 @@ onMounted(() => {
font-family: 'NanumSquareRound', sans-serif;
display: flex;
justify-content: center;
overflow-x: hidden; /* ์ขŒ์šฐ ์Šคํฌ๋กค ์ œ๊ฑฐ */
overflow-x: hidden;
}
.mobile-container {
width: 100%; /* ํ™”๋ฉด ํฌ๊ธฐ์— ๋งž๊ฒŒ ์กฐ์ • */
width: 100%;
max-width: 395px;
min-width: 340px;
background-color: #fae8da;
Expand Down

0 comments on commit 20969cf

Please sign in to comment.