add last week logic

This commit is contained in:
feruz 2021-08-07 12:50:11 +03:00
parent 4fad20126c
commit 99ca9606b5
3 changed files with 20 additions and 4 deletions

View File

@ -1,6 +1,6 @@
/* eslint-disable react/jsx-wrap-multilines */ /* eslint-disable react/jsx-wrap-multilines */
import React, { PureComponent } from 'react'; import React, { PureComponent } from 'react';
import { View, FlatList, ActivityIndicator, RefreshControl, Text, SectionList } from 'react-native'; import { View, FlatList, ActivityIndicator, RefreshControl, Text } from 'react-native';
import { injectIntl } from 'react-intl'; import { injectIntl } from 'react-intl';
// Constants // Constants
@ -13,7 +13,7 @@ import { ListPlaceHolder } from '../../basicUIElements';
import { ThemeContainer } from '../../../containers'; import { ThemeContainer } from '../../../containers';
// Utils // Utils
import { isToday, isYesterday, isThisWeek, isThisMonth } from '../../../utils/time'; import { isToday, isYesterday, isThisWeek, isLastWeek, isThisMonth } from '../../../utils/time';
// Styles // Styles
import styles from './notificationStyles'; import styles from './notificationStyles';
@ -109,6 +109,12 @@ class NotificationView extends PureComponent {
}), }),
data: [], data: [],
}, },
{
title: intl.formatMessage({
id: 'notification.last_week',
}),
data: [],
},
{ {
title: intl.formatMessage({ title: intl.formatMessage({
id: 'notification.this_month', id: 'notification.this_month',
@ -152,11 +158,15 @@ class NotificationView extends PureComponent {
return 2; return 2;
} }
if (isThisMonth(timestamp)) { if (isLastWeek(timestamp)) {
return 3; return 3;
} }
return 4; if (isThisMonth(timestamp)) {
return 4;
}
return 5;
}; };

View File

@ -128,6 +128,7 @@
"recent": "Recent", "recent": "Recent",
"yesterday": "Yesterday", "yesterday": "Yesterday",
"this_week": "This Week", "this_week": "This Week",
"last_week": "Last Week",
"this_month": "This Month", "this_month": "This Month",
"older_then": "Older Than A Month", "older_then": "Older Than A Month",
"activities": "All", "activities": "All",

View File

@ -93,6 +93,11 @@ export const isThisWeek = (value) => {
return day < TODAY.getTime() && day > SEVEN_DAY.getTime(); return day < TODAY.getTime() && day > SEVEN_DAY.getTime();
}; };
export const isLastWeek = (value) => {
const day = new Date(value).getTime();
return day < SEVEN_DAY.getTime() && day > 2 * SEVEN_DAY.getTime();
};
export const isThisMonth = (value) => { export const isThisMonth = (value) => {
const day = new Date(value); const day = new Date(value);
return TODAY.getMonth() === day.getMonth() && TODAY.getFullYear() === day.getFullYear() ? 1 : 0; return TODAY.getMonth() === day.getMonth() && TODAY.getFullYear() === day.getFullYear() ? 1 : 0;