forked from CSID-DGU/2024-2-OSSProj-Osori-FE-01
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/CSID-DGU/2024-2-OSSProj-Osoโฆ
- Loading branch information
Showing
17 changed files
with
1,051 additions
and
225 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,116 @@ | ||
<template> | ||
<div class="comment-input"> | ||
<select v-model="selectedEmoji"> | ||
<option value="" disabled selected hidden><img src="../../../assets/images/smile.svg"></option> | ||
<option value="" disabled selected hidden>#๏ธโฃ</option> | ||
<option value="๐">๐</option> | ||
<option value="๐">๐</option> | ||
<option value="โค๏ธ">โค๏ธ</option> | ||
<option value="๐">๐</option> | ||
<option value="๐">๐</option> | ||
</select> | ||
<input type="text" v-model="comment" placeholder="๋๊ธ ์ ๋ ฅ" /> | ||
<button @click="submitComment"><img src="../../../assets/images/add.svg"></button> | ||
<input | ||
class="realinput" | ||
type="text" | ||
v-model="comment" | ||
placeholder="๋๊ธ ์ ๋ ฅ" | ||
/> | ||
<button @click="submitComment"> | ||
<img src="../../../assets/images/add.svg" /> | ||
</button> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
import { ref } from 'vue' | ||
import { ref, onMounted } from 'vue' | ||
const selectedEmoji = ref('') | ||
const comment = ref('') | ||
const goalId = '123' | ||
const submitComment = () => { | ||
/* ๋๊ธ ์ ์ถ */ | ||
const emojiMap = { | ||
'๐': 0, | ||
'๐': 1, | ||
'โค๏ธ': 2, | ||
'๐': 3, | ||
'๐': 4 | ||
} | ||
const submitComment = async () => { | ||
if (!comment.value.trim()) { | ||
alert('๋๊ธ์ ์ ๋ ฅํ์ธ์.') | ||
return | ||
} | ||
try { | ||
const emojiNumber = emojiMap[selectedEmoji.value] ?? -1 | ||
const payload = { | ||
emoji: emojiNumber, | ||
content: comment.value, | ||
} | ||
console.log("์์ฒญํ Payload:", payload) | ||
const response = await fetch( | ||
`${process.env.VUE_APP_BE_API_URL}/api/goals/${goalId}/comments`, | ||
{ | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
credentials: 'include', | ||
body: JSON.stringify(payload), | ||
} | ||
) | ||
if (response.ok) { | ||
alert('๋๊ธ์ด ์ฑ๊ณต์ ์ผ๋ก ์ถ๊ฐ๋์์ต๋๋ค!') | ||
selectedEmoji.value = '' | ||
comment.value = '' | ||
} else { | ||
alert('๋๊ธ ์ถ๊ฐ ์ค ๋ฌธ์ ๊ฐ ๋ฐ์ํ์ต๋๋ค. ๋ค์ ์๋ํด์ฃผ์ธ์.') | ||
} | ||
} catch (error) { | ||
console.error('๋๊ธ ์ ์ก ์ค ์ค๋ฅ:', error) | ||
alert('๋๊ธ ์ถ๊ฐ ์ค ๋ฌธ์ ๊ฐ ๋ฐ์ํ์ต๋๋ค. ๋ค์ ์๋ํด์ฃผ์ธ์.') | ||
} | ||
} | ||
</script> | ||
<style scoped> | ||
.comment-input { | ||
display: flex; | ||
gap: 8px; | ||
margin-top: 8px; | ||
width: 98%; | ||
} | ||
.comment-input select:focus { | ||
outline: none; | ||
border: none; | ||
box-shadow: none; | ||
} | ||
.realinput::placeholder { | ||
color: #b3b3b3; | ||
font-family: 'NaL'; | ||
font-size: 14px; | ||
font-style: normal; | ||
font-weight: 300; | ||
line-height: normal; | ||
} | ||
.realinput { | ||
outline: none; | ||
border: none; | ||
background-color: transparent; | ||
border-radius: 0; | ||
font-family: 'NaL'; | ||
font-size: 16px; | ||
margin-left: 4px; | ||
} | ||
.realinput:focus { | ||
outline: none; | ||
border: none; | ||
box-shadow: none; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.