Filters

May 21st, 2020
react

Complexity

I finally got one of the APIs I needed, and just in time. I spent the majority of the morning working on the map portion of the application, and it is a doozy. I was able to get the native portion of it totally working with no issues, but getting it to work for the web is a totally different story. Getting the coordinates of the address from the lead wasn't much of an issue; in fact, I found a package I could use across platforms and swapped it out for the one I had for the native portion of the application. This was pretty easy to work with, so now on the native side, I have one package to get the coordinates from the address given, one package for getting the coordinates of the user's current location, and another package to transfer them over to whatever mapping application they have installed on their device. This took some configuration, but I was able to get it done fairly easily. However, for the web version, I had all kinds of issues. I think, actually, that if you're on the web, like on a computer, you probably don't even want to open up a map application and get directions. You may want to see where it is on a map or get a text or email with the address to open it up on a phone or tablet, but I don't think you would want to open up Google maps on a desktop. So, my thoughts are, if you are using the web version, I want to display a map on the page using Leaflet, and maybe have a button where the address is texted or emailed to the representative.

react

I was really stuck on this, so I decided to step outside for a quick second. Sometimes, the best thing to do is step away and come back to it after giving it some thought. This seems to work way too often, so I took a stroll. As I was walking, I heard a whoosh, looked up and noticed a bird had just flown really close to me. I thought that was weird, but then I noticed it was hovering over me and squawking at me. Suddenly, it dove down at me, I walked away quickly, looked up, and it was hovering over at me, right to swipe me again. I walked faster, but it wouldn't leave me alone. To paint the picture, I'm right outside of the office and there are windows all over the place. There is a good chance at least one person was watching this all go down. Before I knew it, I was running away from this bird swooping down at me. I got about 50 yards or so away, and it finally perched up on a light post, trying to intimidate me. I sheepishly walked away, chuckling to myself over how that must have looked. On my breaks, I park right by where this all went down, watched several people walking by the same spot, waiting for the same thing to happen. Apparently, that bird just didn't like the looks of me, because he didn't bother anyone else.

react

When I got back in, my cohort had some news that he had completed the filters API for the search page. This filter will allow the representative to choose from a list of cities, counties, and states they have active leads in, they can filter by the type of lead it is, and whether they have provided emails. The first step was to create the fetch call to the API. We've created a really nice custom hook to handle any kinds of calls to APIs. This takes in the endpoint string and, optionally, a body object. This API is a post call, so it does have a body. We pass in the filters and then it brings back the leads that match the fields. However, it ended up being a lot more complicated than that. If the user doesn't choose any cities, then we pass in the full list of cities to the API, same thing with counties, states, and types of leads. This meant I had to create all kinds of ternaries to make it work correctly. It was complicated, but for the most part, it works. I have something strange going on with it right now, where if you select one filter and then unselect it, leaving everything unselected, it's not sending back the full list. For some reason, about a fifth of the results are not coming back, so something is wrong. I also have an issue with the types of leads where, if you close the filters tab, the leads that were checked go to unchecked. This is definitely due to an issue with the names from the API for these fields being different than the ones I used in the application. I'm pretty confident I can solve that problem, but the first issue, I have no idea what's going on.

Until tomorrow!

Created by Sam Thoyre, © 2019