generated from the-collab-lab/smart-shopping-list
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from the-collab-lab/ec-hm-issue-13
13. As a user, I want to view a list of my shopping list items in order of how soon I am likely to need to buy each of them again so that it’s clear what I need to buy soon
- Loading branch information
Showing
5 changed files
with
145 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
export function colorPicker(text) { | ||
let color; | ||
switch (text) { | ||
case 'overdue': | ||
color = 'red'; | ||
break; | ||
case 'soon': | ||
color = 'orange'; | ||
break; | ||
case 'kind of soon': | ||
color = 'yellow'; | ||
break; | ||
case 'not so soon': | ||
color = 'green'; | ||
break; | ||
case 'inactive': | ||
color = 'grey'; | ||
break; | ||
default: | ||
color = 'black'; | ||
} | ||
return color; | ||
} | ||
|
||
export function calculateUrgency(daysTillNextPurchase, daysSinceLastPurchase) { | ||
let urgency; | ||
|
||
if ( | ||
daysTillNextPurchase < 0 && | ||
daysSinceLastPurchase > daysTillNextPurchase | ||
) { | ||
urgency = 'overdue'; | ||
} else if (daysTillNextPurchase <= 7) { | ||
urgency = 'soon'; | ||
} else if (daysTillNextPurchase < 30) { | ||
urgency = 'kind of soon'; | ||
} else if (daysTillNextPurchase >= 30) { | ||
urgency = 'not so soon'; | ||
} | ||
|
||
if (daysSinceLastPurchase >= 60) { | ||
urgency = 'inactive'; | ||
} | ||
|
||
return urgency; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters