Okay.
In this video, we'll come back to our edit screen here.
And what we will do is we will reuse whatever we have here for actually creating a new movie as well.
What we have so far is we have rating the the the movie.
We have a list of movies here.
So list of movies here and then the details about the movie rate, movie, edit, movie.
So what we need to do is we need to also create a new movie.
And what I will do is I will create create it here.
So I will have a button here to add a new movie and then we will like it will be bring to the edit.
And from there we can come back to this list.
So what we can we do, I will go into the details here.
And as you remember, we had the title navigation.
So what I could do is I can copy that and inside our list JS I can also reuse it.
So in this case it's not going to be detail.
Our component is movie list.
So I will have movie list here and then we can have a title which is going to be fixed, a list of movies
like this, and then we can have it orange, the same style.
It doesn't really matter.
We are interested more in the header, right, which is the button.
So this will be add, add new and we can have it color.
And then on press we will do navigate, edit and this we are not going to pass the movie from the params
as we did there.
What we can actually do is we can pass an object and we can pass a title of none and then we can pass
a description.
Of none.
So basically what I'm passing is title and description.
This is what we will need to have in the edit so we can find variable button.
And what we need to do is we need to copy that and we need to also include it here, import it.
Okay, we have this.
We have a list of movies that's a new title and then we have Add new.
So if I click here I am in the list of movies here, and then we have a title and then we have a description
here.
So the reason why you see a list of movies because when you click back here, you will be here.
So this is the last screen that you were on clicking on that button.
So we have Add new and we now have a title here because we are at the moment, we don't have a title
yet and this is empty and this is empty because we pass that.
Empty objects here.
So our movie is title and description.
So this is what we are passing there.
So what we can actually do if we go back here, what we are using is we are using here a movie ID and
this is for Save Movie A This time it's not going to be a ID because we don't want to.
We first we don't have an ID yet and first we don't want to do a put.
We would like to do a post so we can actually use this movie ID for differentiate our call.
So what I can do is I can say if and then I can do movie ID If we have movie ID, then we can I will
cut this here and put it there and then I will indent that a little bit so I can indent that part.
And then else that means we don't have an ID and this will be our case.
When we do add new, then we can have another call similar.
We can actually make it more reusable.
At the moment I just copy and paste, but this could be extracted to our variable somewhere, somewhere
else.
And a lot of this stuff is just repeated so we could just put it outside.
But you, uh, you already know how to do it.
So do it yourself.
And I will just make it clean here so you will see exactly what what is happening.
So I will do post here and then this.
We are not we don't want to pass any ID here because we will pass the new post, a new movie there token
and that stays the same.
We will also pass title and description here and then we can do something wherever we have the movie.
So basically, if we go if we get back the movie, we would like to come back to the homepage, which
is if you remember, movie list, that's where we need to go.
So here and we don't need to pass any params there.
So let's, uh, test it now how it works.
If I go here, add new and I will say Terminator and then sci fi.
Oh, that's supposed to be.
Sci fi movie, and I will save it here.
I'm actually here.
I don't see the list of movies here, but what I'm assuming is that if I will refresh it, I will have
a new video here.
So let me do some changes here.
I will save it.
And you can see Terminator is here, so I will double check if actually we have, uh, that movie.
So it's has zero now ratings and I can edit and I can say sci fi movie from 80s like this if I will
save it.
You can see this has been saved.
And so our edit and our post, it's working fine using the same component.
So in this case we are updating that and we can actually update this put on a field as well if you like.
So what we could do is.
We can use the same kind of if movie ID so I can go here and we can find our button on press save movie
title, save.
So what we can do is this title is static now, but I could make it dynamic, so I will put it like
this and then we can do movie ID.
If it's movie ID, then it's going to be safe.
Otherwise it's going to be so we can do edit and then otherwise we'll do add.
So if I click here, I can see ad if I will select a specific movie here, I will have.
Edit So you can see based on the conditional, if we have the ID of the movie or not, we can actually
change the user interface as well.
So that's it for updating and posting movies.