diff --git a/packages/openchs-android/src/views/customDashboard/CustomDashboardView.js b/packages/openchs-android/src/views/customDashboard/CustomDashboardView.js index aa7a9fadf..71829bd78 100644 --- a/packages/openchs-android/src/views/customDashboard/CustomDashboardView.js +++ b/packages/openchs-android/src/views/customDashboard/CustomDashboardView.js @@ -8,7 +8,15 @@ import { performCustomDashboardActionAndClearRefresh, performCustomDashboardActionAndRefresh } from "../../action/customDashboard/CustomDashboardActions"; -import {SafeAreaView, ScrollView, StyleSheet, Text, TouchableNativeFeedback, View} from "react-native"; +import { + SafeAreaView, + ScrollView, + StyleSheet, + Text, + TouchableNativeFeedback, + TouchableOpacity, + View +} from "react-native"; import _ from "lodash"; import CustomDashboardTab from "./CustomDashboardTab"; import {DashboardSection} from 'openchs-models'; @@ -39,6 +47,7 @@ import {CardListView} from './CardListView'; import UserInfoService from "../../service/UserInfoService"; import DashboardFilterService from '../../service/reports/DashboardFilterService'; import DatePicker from '../primitives/DatePicker'; +import moment from 'moment'; const viewNameMap = { 'ApprovalListingView': ApprovalListingView, @@ -79,18 +88,21 @@ function FilterSection({dispatcher, asOnDateValue, asOnDateFilter, I18n, onFilte performCustomDashboardActionAndClearRefresh(dispatcher, Actions.FILTER_APPLIED); } - // const renderQuickDateOptions = (label, value, isFilled) => { - // const backgroundColor = {backgroundColor: isFilled ? Colors.ActionButtonColor : Colors.DisabledButtonColor}; - // const textColor = {color: isFilled ? Colors.TextOnPrimaryColor : Colors.InputNormal}; - // return ( - // isFilled ? _.noop() : dispatchAction(Actions.ON_DATE, {value})} - // > - // {I18n.t(label)} - // - // ) - // } + const renderQuickDateOptions = (label, value, isFilled) => { + const backgroundColor = {backgroundColor: isFilled ? Colors.ActionButtonColor : Colors.FilterButtonColor}; + const textColor = {color: isFilled ? Colors.TextOnPrimaryColor : Styles.accentColor}; + return ( + isFilled ? _.noop() : onAsOnDateChange(value)} + > + {I18n.t(label)} + + ) + } + + const isToday = moment(asOnDateValue).isSame(moment(), "day"); + const isTomorrow = moment(asOnDateValue).isSame(moment().add(1, "day"), "day"); return ( @@ -108,15 +120,15 @@ function FilterSection({dispatcher, asOnDateValue, asOnDateFilter, I18n, onFilte alignItems: 'center', justifyContent: 'flex-start', flexWrap: 'wrap', - gap: 2, + gap: 5, flex: 0.6 }}> {I18n.t('asOnDate')}: - {/*{this.renderQuickDateOptions('Today', new Date(), isToday)}*/} - {/*{this.renderQuickDateOptions('Tomorrow', moment().add(1, "day").toDate(), isTomorrow)}*/} + {renderQuickDateOptions('Today', new Date(), isToday)} + {renderQuickDateOptions('Tomorrow', moment().add(1, "day").toDate(), isTomorrow)} }