So now that we have all the logic in place in our back end, let's turn our attention to the front end.
So right now I'm looking at the all sales page and this pages are these page.
When I click on an order, it works really well.
It says refund order.
It calls to correct you URL on the back end.
And I don't want that to change.
In other words, I don't want to have to make any changes or not many changes that will keep this page
working the way that it does.
And we can do that really easily.
So let's go back to our code.
And I'm looking right now at Handler's dutko and I'm looking at the show sale function.
This handler, which displays the show one sale page, and we already have this string map variable.
And if you think about it, the only things that are going to change between this page, the one that
shows a sale and a page like this, you can see I got rid of Diana Prince.
The only thing that's changing are the label of this button and the world that we're calling on the
back end so we can take advantage of this string map and pass that information.
So in the show sale function, I'm going to add a value to the string map string map and I'll give it
an index of refund dash.
You, Earl, what you Earl, do we call to try to issue a refund while it appears admin's refund?
And I'll also put in a string map with the index of refund DTN the label for the button.
I'll make that refund for exactly what it is right now.
And all I have to do now is go to the sales page, mortgage HTML template and find that button, which
is right here, and change this to our story about the appropriate value from our stream map index dot
string map.
And I called this one refund HPN and close my double quotes.
Then I go all the way down to the part where we're calling the refund.
Which is right here and just replace this with index dot string map, and I called that one refund,
dash you out and then close minded or double curly braces and that should actually work.
And of course, that means I can go back to my handlers and did the same thing here.
So I'll just copy these two and fix them.
So refund early becomes AP slash, slash, AP slash admin slash cancel subscription, which is what
we called it in, in the routes file for the hand for the back end and this one becomes cancel subscription.
So let's save that, stop our application, make stop, make a start and make sure it all worked.
So I'll go back to my web browser and I'm looking at a subscription.
So let's reload that.
And now it says cancel subscription.
And if I view the source for this page and then find the fetch statement that calls the cancel subscription,
there it is right there.
Now, as you can see, goes templating, actually puts or escapes the slashes.
But that's fine.
This will absolutely work.
Just trust the text e-mail package and it will do exactly what it's supposed to.
So that looks like that should work.
OK, so we have it all set up and now let's try testing it and see if we have anything else we have
to do.
So I'll open my template or open my JavaScript window and I'll try cancelling a subscription and see
if everything is hooked up properly.
Yes, I want to refund it.
I probably should change that as well.
Yeah, let's do that first.
Let's cancel that and change this in our HTML template.
Where perhaps that information up, so it's in the show cancel button.
Are you sure it's all I have to do here is change this to index that string map and I call it cancel
button like that.
So let's stop our application and make sure that shows up properly.
Maxed out.
OK, let's reload that page, reload and now I should say cancel subscription instead of refunding and
it doesn't.
So I got something wrong.
It wasn't cancel button, it was refund button, save, make, stop, start.
Try this again, so I'll cancel that, reload this page, cancel subscription, that looks better.
Now, let's see if we got it right.
Charge refunded.
OK, so we probably also want to change that message from refunded and change this up here.
Now, those are pretty simple changes.
So what I'm going to do is ask you to change the message that's displayed up here when we cancel a subscription
to something appropriate and leave it as charge refunded when we were refunded subscription.
And also, I want this to change from refunded to canceled.
OK, so that should be pretty simple for you to do.
You give it a whirl and in the next lecture, I'll show you how I did it.