Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frontend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
idatt2106-2024-07
frontend
Commits
9c5aac99
Commit
9c5aac99
authored
10 months ago
by
VIktorGrev
Browse files
Options
Downloads
Patches
Plain Diff
style: Adding visual confirmation for sendt reqeust
parent
5e2d0917
No related branches found
No related tags found
1 merge request
!75
style: Adding visual confirmation for sendt reqeust
Pipeline
#282868
passed with warnings
10 months ago
Stage: install
Stage: build
Stage: test
Stage: lint
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/views/User/UserFriendsView.vue
+15
-4
15 additions, 4 deletions
src/views/User/UserFriendsView.vue
with
15 additions
and
4 deletions
src/views/User/UserFriendsView.vue
+
15
−
4
View file @
9c5aac99
...
...
@@ -99,8 +99,11 @@
</h5>
</div>
<div
class=
"col-md-3 col-sm-3"
>
<button
class=
"btn btn-primary pull-right"
@
click=
"addFriend(user.id)"
>
Legg
til venn
</button>
<button
class=
"btn btn-primary pull-right"
@
click=
"addFriend(user.id)"
:disabled=
"friendRequestsSent[user.id]"
v-if=
"!friendRequestsSent[user.id]"
>
Legg til venn
</button>
<button
class=
"btn btn-secondary pull-right"
disabled
v-if=
"friendRequestsSent[user.id]"
>
Forespørsel sendt
</button>
</div>
</div>
</div>
...
...
@@ -117,7 +120,7 @@
<
script
setup
lang=
"ts"
>
import
{
ref
,
onMounted
}
from
'
vue
'
;
import
{
type
Ref
,
ref
,
onMounted
}
from
'
vue
'
;
import
{
useRouter
}
from
'
vue-router
'
;
import
{
FriendService
,
UserService
}
from
'
@/api
'
;
import
type
{
UserDTO
}
from
'
@/api
'
;
...
...
@@ -131,6 +134,8 @@ const friendRequests = ref([] as any);
const
addFriends
=
ref
([]
as
any
);
const
searchedUsers
=
ref
([]
as
any
);
const
friendRequestsSent
:
Ref
<
Record
<
number
,
boolean
>>
=
ref
({});
const
searchWord
=
ref
(
""
);
const
elementsInFriendRequest
=
ref
(
false
);
...
...
@@ -169,7 +174,13 @@ const addNewFriends = async () => {
};
async
function
addFriend
(
friendID
:
number
)
{
const
response
=
await
FriendService
.
addFriendRequest
({
userId
:
friendID
});
try
{
await
FriendService
.
addFriendRequest
({
userId
:
friendID
});
// Use a spread to update the state and keep immutability
friendRequestsSent
.
value
=
{
...
friendRequestsSent
.
value
,
[
friendID
]:
true
};
}
catch
(
error
)
{
console
.
error
(
'
Failed to send friend request
'
,
error
);
}
}
async
function
requestFriend
()
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment