Portfolio 2 Week 15: Redeem, Reward & Retrieving Information Everywhere Sprint 4
- Goh Qi Xun

- Feb 1, 2021
- 2 min read
Last sprint and last week. I need to get everything settled and validated before presentation. For me, I left with Redeem and reward page (back-end) where it store user's voucher into the database and retrieve to use it.
Just like any other data structure I've done. It is very straight forward and easy.

Whenever user purchase a voucher, it will stored inside the database. Once they redeem their vouchers, their points will be deducted automatically and updated points will be shown on their phone page. Storing of data into Firebase wasn't quite an issue for me since the start but retrieving this time is a bit troublesome. There are some challenges I faced when doing this.

Issue #1
After redeem, it's not showing when back button was press from redeem page. It only show after user re-login to this app. I was able to fix this by adding to viewWillAppear() function that will refresh the data every time it reloads, but this will lead me to the next issue
Issue #2
Since I added to viewWillAppear() function, data will be reloaded and re-append into the array, creating a duplicate of everything each time they do so. This then fixed by removing loading in viewDidLoad() function where it loads the vouchers of user whenever they visit this page. This, unfortunately also caused another issue.
Issue #3
Loading data in viewDidLoad() function removed will not display anything whenever they load this page. So after some thinking, I found out a solution by checking if list is empty in viewDidLoad(). Retrieving of data only happened if list is empty, which means that it has yet to initialise. Every time viewDidAppear() function is called, it will first empty the data before adding the data back in. This will prevent duplicate of data but also help to refresh their data into latest one.

Get Essential, Designed by Jun Wei
After all this is completed, I went to retrieve all the database information whenever Jun Wei needed, like his "Get Essential" page where he needs to get the user's allergy, dietary, etc to help filter out what their needs. I also make sure that retrieve data of everywhere is right.
With bit of spare time, I went to make validation for most of the parts. Some of it includes like if user doesn't finish their profile or quiz and they re-login, I will bring them to their past visit quiz so that they will complete it. This is done so that it doesn't crash the program behind where we cannot retrieve any of their allergy or dietary because it's not there.

Ensure that password format, email and all the stuff are properly done with proper alert message everywhere when needed. Properly alert message to give user feedback.

Lastly, we combined our storyboards together into the main one as it is one of the issue at the start where one touch another one couldn't. I also made a logout button for user to logout account, although this is not a essential function but I feel that it is good to have 1.
Once everything is done, we've officially complete our Portfolio 2 project.



Comments