Skip to content

Commit

Permalink
Merge pull request #63 from Minn-Choi/feature/#6
Browse files Browse the repository at this point in the history
[feat/#6] api μ—°κ²°
  • Loading branch information
Minn-Choi authored Dec 2, 2024
2 parents d285b18 + 0161c63 commit f39d097
Show file tree
Hide file tree
Showing 15 changed files with 1,047 additions and 223 deletions.
392 changes: 373 additions & 19 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"express": "^4.21.1",
"http-proxy-middleware": "^3.0.3",
"register-service-worker": "^1.7.2",
"styled-components": "^6.1.13",
"v-calendar": "^3.1.2",
"vue": "^3.2.13",
"vue-cal": "^4.10.0",
Expand Down
12 changes: 12 additions & 0 deletions src/assets/images/plusBtn.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/assets/images/plusBtn2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
101 changes: 93 additions & 8 deletions src/components/common/feed/CommentInput.vue
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>
40 changes: 34 additions & 6 deletions src/components/common/feed/CommentList.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<template>
<div class="comment-list">
<div v-for="comment in comments" :key="comment.id" class="comment">
<span>{{ comment.nickname }}</span>
<span>{{ comment.emoji }}</span>
<p>{{ comment.content }}</p>
<div class="nick">{{ comment.nickname }}</div>
<div>{{ comment.emoji }}</div>
<div class="comment">{{ comment.content }}</div>
</div>
</div>
</template>
Expand All @@ -18,10 +18,38 @@ const comments = ref([
</script>

<style scoped>
.comment-list .comment {
.comment-list{
display: flex;
flex-direction: column;
gap:5px;
margin-bottom: 5px;
}
.comment{
display: flex;
gap:10px;
margin-left: 5px;
}
.nick{
font-family: 'NaB';
font-size: 15px;
color:#FF7F00;
font-style: normal;
font-weight: 300;
line-height: normal;
display: flex;
align-items: center;
}
.comment{
font-family: 'NaL';
font-size: 14px;
color:#000000;
font-style: normal;
font-weight: 300;
line-height: normal;
display: flex;
gap: 8px;
align-items: center;
margin-bottom: 8px;
}
</style>
51 changes: 43 additions & 8 deletions src/components/common/feed/FollowStats.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,67 @@
<span class="follower-count">{{ followerCount }}λͺ…</span>
<span class="following-text">νŒ”λ‘œμž‰</span>
<span class="following-count">{{ followingCount }}λͺ…</span>
<img src="../../../assets/images/next.svg">
<img class='na' src="../../../assets/images/next.svg" alt="Next" />
</div>
</div>
</template>

<script setup>
import { ref, computed } from 'vue'
import { ref, computed, onMounted } from 'vue'
import { useRouter } from 'vue-router'
const followerCount = ref(0) // APIμ—μ„œ λ°›μ•„μ˜€λŠ” νŒ”λ‘œμ›Œ 수
const followingCount = ref(0) // APIμ—μ„œ λ°›μ•„μ˜€λŠ” νŒ”λ‘œμž‰ 수
const followerCount = ref(0)
const followingCount = ref(0)
// ν˜„μž¬ λ‚ μ§œλ₯Ό ν¬λ§·νŒ…
const formattedDate = computed(() => {
const date = new Date();
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0'); // 월은 0λΆ€ν„° μ‹œμž‘ν•˜λ―€λ‘œ +1
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
return `${year} . ${month} . ${day}`;
});
const API_URL = `${process.env.VUE_APP_BE_API_URL}/api`;
const fetchFollowCounts = async () => {
try {
const followerResponse = await fetch(`${API_URL}/followers`, {
method: 'GET',
credentials: 'include',
});
const followerData = await followerResponse.json();
followerCount.value = Array.isArray(followerData) ? followerData.length : 0;
const followingResponse = await fetch(`${API_URL}/following`, {
method: 'GET',
credentials: 'include',
});
const followingData = await followingResponse.json();
followingCount.value = Array.isArray(followingData) ? followingData.length : 0;
} catch (error) {
console.error('νŒ”λ‘œμ›Œ 및 νŒ”λ‘œμž‰ 수 κ°€μ Έμ˜€κΈ° μ‹€νŒ¨:', error);
followerCount.value = 0;
followingCount.value = 0;
}
};
const router = useRouter()
const goToFollowPage = () => {
// νŒ”λ‘œμš° 관리 νŽ˜μ΄μ§€λ‘œ μ΄λ™ν•˜λŠ” ν•¨μˆ˜
router.push('/feed/ako-stamp-follow')
}
onMounted(() => {
fetchFollowCounts();
});
</script>

<style scoped>
.follow-stats {
display: flex;
align-items: center;
width: 100%;
height: 37px;
padding: 8px;
border-radius: 10px;
Expand All @@ -45,7 +76,7 @@ const goToFollowPage = () => {
.date-info {
flex: 1;
text-align: left;
color: #FF7F00; /* λ‚ μ§œ 색상 */
color: #FF7F00;
font-family: 'NaR';
font-size: 0.9rem;
padding-left: 5px;
Expand Down Expand Up @@ -84,4 +115,8 @@ const goToFollowPage = () => {
font-weight: 400;
line-height: normal;
}
.na{
cursor: pointer;
}
</style>
3 changes: 2 additions & 1 deletion src/components/common/feed/FriendGoal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import CommentInput from './CommentInput.vue'
import CommentList from './CommentList.vue'
const friendNickname = ref('ν† λ‹ˆ')
const friendGoalContent = ref('이따 μƒλ‘μ›μ—μ„œ λ°₯λ¨Ήμ„μ‚¬λžŒ? κΉ€μΉ˜μ² νŒμ–΄μ©Œκ³ μ €μ©Œκ³ ')
const friendGoalContent = ref('이따 μƒλ‘μ›μ—μ„œ λ°₯λ¨Ήμ„μ‚¬λžŒμžˆλ‚˜μš”? 같이 λ¨Ήμ–΄μš”')
const showCommentSection = ref(false)
const toggleCommentSection = () => {
Expand Down Expand Up @@ -72,5 +72,6 @@ const toggleCommentSection = () => {
.btn button:hover {
background: none;
outline: none;
}
</style>
Loading

0 comments on commit f39d097

Please sign in to comment.