project-icp / bee-pollinator-app

The web application front end for the ICP Pollinator Decision Support Tool 🐝
Apache License 2.0
6 stars 1 forks source link

List Surveys Based on User Contribution Level #406

Closed rajadain closed 5 years ago

rajadain commented 5 years ago

Overview

Updates the Survey Listing for each apiary to list November, April, and Monthly surveys separately, with explicit marking. Pro users see all three kinds of listings, and Light users see only November and April listings. We begin counting from November 2018 for November and April surveys, and from the date of the apiary's creation for the Monthly surveys.

We still show the four most recent survey listings in a survey card, with the rest hidden behind a "View full history" button. Clicking that button opens a popup that lists all the surveys for that apiary.

Connects #398 Connects #378

Demo

For Pro Users:

image

2019-01-04 13 44 08

For Light Users:

image

Notes

The Survey Detail dialog needs styling. I've made a note in #393.

Testing Instructions

rajadain commented 5 years ago

Alright, that took a while, but I've managed to switch to a Prop Type corresponding to our survey model in the back-end:

export const Survey = shape({
    id: number,
    month_year: string.isRequired,
    num_colonies: number,
    created_at: string,
    survey_type: string.isRequired,
    apiary: number.isRequired,
    completed: bool.isRequired,
});

id, num_colonies, and created_at are optional fields, because they'll only have values for submitted surveys. Now, when compiling the list of surveys, we go over every calculated month_year value, and if a corresponding survey is found we use that (after settings its completed=true). Otherwise, we make a new one with month_year, survey_type, apiary, and completed = false. The various commits have been rebased and fixed up to reflect this.

Ready for another review.

rajadain commented 5 years ago

Thanks for reviewing again. Will merge when green.