So now we want to be able to delete users and this should be pretty easy.
We already have the back end all set.
So let's first go to our slice, our user user API slice and then under get users, we're going to add
delete user.
Which is going to be a mutation and we're going to have a query with the ID, although I want to call
it user, we'll say user sorry, user ID, I've been writing Python lately.
We use underscores quite a bit.
All right.
So inside here we're going to have our URL, which is just going to be the user's URL, slash the user
ID, and then the method is going to be delete.
And then we're just going to.
Use.
Use our delete mutation.
And then let's go over to our user list and we're going to bring in up here, in addition to the get
users query, we want the use.
Delete user mutation.
And then I'm also going to bring in toast from.
From Reactos to Fi.
And let's see, we're going to initialize this.
Let's go right here.
And we're going to get delete user and then is loading.
Actually we don't even really need.
Well, yeah, I guess we can.
We'll just rename it to loading.
Loading, delete.
Okay.
And then let's see.
We're going to.
Add that.
Where should we put this loading?
What do they put it in the product list?
Above is loading.
All right.
So we'll just kind of.
Do what we did here.
Did I bring Loader in?
Yeah, I did.
All right, so now we need to delete.
We have our delete handler.
We just need to add the functionality in here.
So let's do a quick confirm.
So if window Dot confirm.
Are you sure?
And if they're sure, then we're going to try.
We're going to try and then we want to await on the delete user.
Which we need to make this asynchronous.
Oops, let's delete handler here.
Let's make this async.
Okay.
And then we're going to delete user and then pass in the ID.
And then we're going to just refetch.
And then let's do a toast down here.
Dot error.
And let's do.
What do we want here?
Error dot data.
Dot message.
Our.
All right.
And we can do a success toast if you want.
Like that.
So let's try it out.
We're going to go back over here and we are, of course, logged in as an admin.
So if I don't want Steve Rogers here anymore, let's click Delete and there we go.
User deleted.
So now.
In the next video, I want to be able to update a user.
So we're going to actually create a new screen called the User edit screen, because if we click on
this edit, it's going to take us to a page where we can see the user data, but it'll be in a form
so that if we want to update it, we can.