codejax
codejax

Reputation: 112

React Native Conditional Navigation

How to achieve the below scenario in react native.

I have 2 screens (refer image below)

Screen 1 : Alacarte Meal Menu

Screen 2 : Combo Meal Menu

Once user logins for the day, he will be allowed to access 2 seperate screens. Once the user has placed the order from Combo Meal Menu, the same screen should be disabled till next day and should be redirected to alacarte meal menu until the combo meal menu enables.

Any help would be much appreciated

Upvotes: 0

Views: 259

Answers (1)

Gaurav Roy
Gaurav Roy

Reputation: 12215

Okay , so it's a problem of lock timer. Ideally you want to lock one screen for 1 whole day and again make it enable the next day. It would be best to maintain a flag at the backend for the same and unlock it after exact 24 hours. Suppose maintain a flag object called disableFood .

let disableFood = {
locked:false,
time:0
}

and in the main screen where pages are loaded , retrieve that data via backend api call and add the condition , if resultOfApi.disabledFood.locked === true , only show the page you want and when its not locked you can allow user to navigate to both the screen. And in the backend you need to maintain an epoc time whenever the user orders a meal , and assign it to disabledFood.time. And next time when the api is called check for epoc time >24 hours, then make disableFood to again locked :false and time:0,

If you have any doubts ask, coz its quite confusing,

Upvotes: 1

Related Questions