Skip to content

Commit

Permalink
add small Add additional add friend button
Browse files Browse the repository at this point in the history
  • Loading branch information
Likqez committed Dec 13, 2024
1 parent 68da8d6 commit e24bae8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
18 changes: 15 additions & 3 deletions components/UsersView.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import {type GetFriendsResponse, FriendshipStatus} from "@/types/api/user.friends";
import {FriendshipStatus, type GetFriendsResponse} from "@/types/api/user.friends";
import {UserViewType} from "@/types/components/users.view";
import type {GetUserResponse} from "@/types/api/users";
Expand All @@ -12,6 +12,14 @@ const props = defineProps({
users: {
type: Array as PropType<GetFriendsResponse[] | GetUserResponse[]>,
required: true,
},
onAction: {

Check warning on line 16 in components/UsersView.vue

View workflow job for this annotation

GitHub Actions / eslint

Prop 'onAction' requires default value to be set

Check warning on line 16 in components/UsersView.vue

View workflow job for this annotation

GitHub Actions / eslint

Prop 'onAction' requires default value to be set
type: Function as PropType<() => void>,
required: false
},
actionLabel: {

Check warning on line 20 in components/UsersView.vue

View workflow job for this annotation

GitHub Actions / eslint

Prop 'actionLabel' requires default value to be set

Check warning on line 20 in components/UsersView.vue

View workflow job for this annotation

GitHub Actions / eslint

Prop 'actionLabel' requires default value to be set
type: String,
required: false
}
});
Expand Down Expand Up @@ -48,7 +56,7 @@ function isUserInformation(user: GetFriendsResponse | GetUserResponse): user is
// Map users conditionally depending on their type
const mappedUsers: Array<GetUserResponse> = computed(() => {
if(!props.users || props.users.length < 1) return [];
if (!props.users || props.users.length < 1) return [];
return props.users.map(user => {
if (isGetFriendsResponse(user)) {
Expand All @@ -69,7 +77,7 @@ const mappedUsers: Array<GetUserResponse> = computed(() => {
]"
>
<!-- Fixed Conditional Header -->
<div class="mb-1 text-xs md:text-base bg-gray-200 mt-2">
<div class="mb-1 text-xs md:text-base bg-gray-200 mt-2 flex justify-between">
<p v-if="viewType === UserViewType.USERTURN">
Your Turn
</p>
Expand All @@ -85,6 +93,10 @@ const mappedUsers: Array<GetUserResponse> = computed(() => {
<p v-else-if="viewType === UserViewType.SENTREQUESTS">
Sent Friend Requests
</p>
<button v-if="props.onAction && props.actionLabel" class="flex items-center text-gray-700" @click="props.onAction()">
<Icon name="mdi:plus"/>
{{ props.actionLabel }}
</button>
</div>

<!-- Scrollable User Boxes -->
Expand Down
2 changes: 1 addition & 1 deletion components/profile/FriendRequestModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const addFriend = async () => {
</script>

<template>
<div class="modal-overlay">
<div class="modal-overlay z-50">
<div class="modal">
<p class="text-3xl font-bold">New friend</p>
<p class="mb-3">Enter your friends name:</p>
Expand Down
4 changes: 2 additions & 2 deletions components/profile/Friendlist.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ async function getFriendships() {
<div class="flex flex-col">
<!-- Buttons Section -->
<div class="flex justify-center mb-3">
<button class="p-2 bg-blue-500 text-white rounded-3xl ml-2" @click="showModal = true">Add new friend</button>
<button v-if="friends.length < 1" class="p-2 bg-blue-500 text-white rounded-3xl ml-2" @click="showModal = true">Add new friend</button>
<ProfileFriendRequestModal v-show="showModal" @close-modal="showModal = false" @refresh="getFriendships" />
</div>

<!-- Responsive Size Content Section -->
<div class="overflow-y-auto" style="max-height: 43vh;">
<UsersView v-if="friends.length > 0" :view-type="UserViewType.FRIENDS" :users="friends"

Check warning on line 40 in components/profile/Friendlist.vue

View workflow job for this annotation

GitHub Actions / eslint

Expected a linebreak before this attribute

Check warning on line 40 in components/profile/Friendlist.vue

View workflow job for this annotation

GitHub Actions / eslint

Expected a linebreak before this attribute
@refresh="getFriendships" />
action-label="Add Friend" :on-action="() => {showModal = true}" @refresh="getFriendships" />
<UsersView v-if="requests.length > 0" :view-type="UserViewType.REQUESTS" :users="requests"

Check warning on line 42 in components/profile/Friendlist.vue

View workflow job for this annotation

GitHub Actions / eslint

Expected a linebreak before this attribute

Check warning on line 42 in components/profile/Friendlist.vue

View workflow job for this annotation

GitHub Actions / eslint

Expected a linebreak before this attribute
@refresh="getFriendships" />
<UsersView v-if="sentRequests.length > 0" :view-type="UserViewType.SENTREQUESTS" :users="sentRequests"

Check warning on line 44 in components/profile/Friendlist.vue

View workflow job for this annotation

GitHub Actions / eslint

Expected a linebreak before this attribute

Check warning on line 44 in components/profile/Friendlist.vue

View workflow job for this annotation

GitHub Actions / eslint

Expected a linebreak before this attribute
Expand Down

0 comments on commit e24bae8

Please sign in to comment.