Skip to content

Commit

Permalink
feat: allow ability to count since being a volunteer
Browse files Browse the repository at this point in the history
  • Loading branch information
hopetambala committed Oct 18, 2020
1 parent 6b15b0e commit 1d75dd6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
11 changes: 10 additions & 1 deletion components/Header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,18 @@ const Header = ({ logOut }) => {

const [drawerOpen, setDrawerOpen] = useState(false);
const [surveyCount, setSurveyCount] = useState(0);
const [volunteerDate, setVolunteerDate] = useState('');

const volunteerLength = (object) => {
const date = new Date(object.createdAt);
const convertedDate = date.toDateString();
return convertedDate;
};

const count = async () => {
getData('currentUser').then((user) => {
const userName = `${user.firstname || ''} ${user.lastname || ''}`;
setVolunteerDate(volunteerLength(user));
countService('SurveyData', 'surveyingUser', userName).then((counts) => {
setSurveyCount(counts);
});
Expand Down Expand Up @@ -49,7 +57,8 @@ const Header = ({ logOut }) => {
</View>
{drawerOpen === true
&& (
<View>
<View style={{ flexDirection: 'row', alignSelf: 'center' }}>
<Text style={styles.calculationText}>{`Volunteer Since\n${volunteerDate}`}</Text>
<Text style={styles.calculationText}>{`Surveys Collected\n${surveyCount}`}</Text>
</View>
)}
Expand Down
1 change: 0 additions & 1 deletion components/Header/index.styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ const styles = StyleSheet.create({
},
calculationText: {
fontWeight: 'bold',
alignSelf: 'flex-end',
textAlign: 'center',
padding: 20
}
Expand Down

0 comments on commit 1d75dd6

Please sign in to comment.