Fakultas Ilmu Komputer UI

Commit 93eaf3e8 authored by wulanmantiri's avatar wulanmantiri
Browse files

[REFACTOR] Add utils and change routes for weekly report

parent a0b7f332
...@@ -24,9 +24,9 @@ export const paymentResult = `${payment}/result`; ...@@ -24,9 +24,9 @@ export const paymentResult = `${payment}/result`;
const client = 'client'; const client = 'client';
export const clientTabNavigation = `${client}/tab-navigation`; export const clientTabNavigation = `${client}/tab-navigation`;
export const clientProfile = `${client}/profile`; export const clientTabProfile = `${client}/profile`;
export const clientRecommendation = `${client}/recommendation`; export const clientRecommendation = `${client}/recommendation`;
export const clientWeeklyReport = `${client}/report`; export const clientTabWeeklyReport = `${client}/tab-report`;
export const clientChat = `${client}/chat`; export const clientChat = `${client}/chat`;
const nutritionist = 'nutritionist'; const nutritionist = 'nutritionist';
......
...@@ -28,6 +28,8 @@ export { default as ClientListAdmin } from './admin/ClientListAdmin'; ...@@ -28,6 +28,8 @@ export { default as ClientListAdmin } from './admin/ClientListAdmin';
export { default as ClientRecommendation } from './recommendation/ClientRecommendation'; export { default as ClientRecommendation } from './recommendation/ClientRecommendation';
export { default as ClientDietRecommendationForAdmin } from './recommendation/ClientDietRecommendationForAdmin'; export { default as ClientDietRecommendationForAdmin } from './recommendation/ClientDietRecommendationForAdmin';
export { default as ChooseWeekForClient } from './report/ChooseWeekForClient';
export { default as ChooseWeekForNutritionist } from './report/ChooseWeekForNutritionist';
export { default as WeeklyReport } from './report/WeeklyReport'; export { default as WeeklyReport } from './report/WeeklyReport';
export { default as ReadOnlyWeeklyReport } from './report/ReadOnlyWeeklyReport'; export { default as ReadOnlyWeeklyReport } from './report/ReadOnlyWeeklyReport';
......
...@@ -2,9 +2,11 @@ import React, { FC } from 'react'; ...@@ -2,9 +2,11 @@ import React, { FC } from 'react';
import { createStackNavigator } from '@react-navigation/stack'; import { createStackNavigator } from '@react-navigation/stack';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs'; import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { Icon } from 'react-native-elements'; import { Icon } from 'react-native-elements';
import { colors, typography } from 'styles';
import * as ROUTES from 'constants/routes'; import * as ROUTES from 'constants/routes';
import { screenOptions } from 'app/styles';
import { styles, tabBarOptions } from './styles';
import ClientRecommendation from 'scenes/recommendation/ClientRecommendation'; import ClientRecommendation from 'scenes/recommendation/ClientRecommendation';
import WeeklyReport from 'scenes/report/WeeklyReport'; import WeeklyReport from 'scenes/report/WeeklyReport';
import ComingSoonPage from 'scenes/common/ComingSoonPage'; import ComingSoonPage from 'scenes/common/ComingSoonPage';
...@@ -18,9 +20,7 @@ import { ...@@ -18,9 +20,7 @@ import {
Questionnaire5, Questionnaire5,
} from 'scenes/questionnaire/ExtendedQuestionnaire/components'; } from 'scenes/questionnaire/ExtendedQuestionnaire/components';
import ReadOnlyWeeklyReport from 'scenes/report/ReadOnlyWeeklyReport'; import ReadOnlyWeeklyReport from 'scenes/report/ReadOnlyWeeklyReport';
import { screenOptions } from 'app/styles'; import ChooseWeekForClient from 'scenes/report/ChooseWeekForClient';
import { styles } from './styles';
interface NavRoute<T = any> { interface NavRoute<T = any> {
name: string; name: string;
...@@ -75,6 +75,10 @@ export const ExtQuestionnaireStackScreen: FC = () => ( ...@@ -75,6 +75,10 @@ export const ExtQuestionnaireStackScreen: FC = () => (
); );
const reportClientNavigation: NavRoute[] = [ const reportClientNavigation: NavRoute[] = [
{
name: ROUTES.weeklyReportChooseWeek,
component: ChooseWeekForClient,
},
{ {
name: ROUTES.weeklyReportForm, name: ROUTES.weeklyReportForm,
component: WeeklyReport, component: WeeklyReport,
...@@ -83,10 +87,6 @@ const reportClientNavigation: NavRoute[] = [ ...@@ -83,10 +87,6 @@ const reportClientNavigation: NavRoute[] = [
name: ROUTES.weeklyReportReadOnly, name: ROUTES.weeklyReportReadOnly,
component: ReadOnlyWeeklyReport, component: ReadOnlyWeeklyReport,
}, },
{
name: ROUTES.weeklyReportChooseWeek,
component: ComingSoonPage,
},
]; ];
const WeeklyReportStack = createStackNavigator(); const WeeklyReportStack = createStackNavigator();
...@@ -109,24 +109,11 @@ const ClientTab = createBottomTabNavigator(); ...@@ -109,24 +109,11 @@ const ClientTab = createBottomTabNavigator();
const ClientNavigation: FC = () => { const ClientNavigation: FC = () => {
return ( return (
<ClientTab.Navigator <ClientTab.Navigator
initialRouteName={ROUTES.clientProfile} initialRouteName={ROUTES.clientTabProfile}
sceneContainerStyle={styles.sceneStyle} sceneContainerStyle={styles.sceneStyle}
tabBarOptions={{ tabBarOptions={tabBarOptions}>
activeTintColor: colors.primaryVariant,
labelStyle: {
paddingVertical: 0,
marginVertical: 0,
...typography.headingMedium,
fontSize: 14,
},
style: {
height: 66,
paddingTop: 8,
paddingBottom: 8,
},
}}>
<ClientTab.Screen <ClientTab.Screen
name={ROUTES.clientProfile} name={ROUTES.clientTabProfile}
component={ExtQuestionnaireStackScreen} component={ExtQuestionnaireStackScreen}
options={{ options={{
tabBarLabel: 'Profil', tabBarLabel: 'Profil',
...@@ -151,7 +138,7 @@ const ClientNavigation: FC = () => { ...@@ -151,7 +138,7 @@ const ClientNavigation: FC = () => {
}} }}
/> />
<ClientTab.Screen <ClientTab.Screen
name={ROUTES.clientWeeklyReport} name={ROUTES.clientTabWeeklyReport}
component={WeeklyReportStackScreen} component={WeeklyReportStackScreen}
options={{ options={{
tabBarLabel: 'Laporan Diet', tabBarLabel: 'Laporan Diet',
......
import { StyleSheet } from 'react-native'; import { StyleSheet } from 'react-native';
import { colors, typography } from 'styles';
export const styles = StyleSheet.create({ export const styles = StyleSheet.create({
sceneStyle: { sceneStyle: {
backgroundColor: 'transparent', backgroundColor: 'transparent',
}, },
}); });
export const tabBarOptions = {
activeTintColor: colors.primaryVariant,
labelStyle: {
paddingVertical: 0,
marginVertical: 0,
...typography.headingMedium,
fontSize: 14,
},
style: {
height: 66,
paddingTop: 8,
paddingBottom: 8,
},
};
import dayjs from 'dayjs'; import dayjs, { Dayjs } from 'dayjs';
import { API_BASE_URL } from 'env'; import { API_BASE_URL } from 'env';
export const convertDate = (dateString?: string): string => { export const convertDate = (dateString?: string): string => {
...@@ -10,3 +10,15 @@ export const dateToString = (date: Date): string => ...@@ -10,3 +10,15 @@ export const dateToString = (date: Date): string =>
export const getAbsoluteUrl = (path?: string | null) => export const getAbsoluteUrl = (path?: string | null) =>
path ? API_BASE_URL + path : ''; path ? API_BASE_URL + path : '';
export const getDateRange = (
weekDiff: number,
): {
mon: Dayjs;
sun: Dayjs;
} => {
return {
mon: dayjs().day(1).subtract(weekDiff, 'week'),
sun: dayjs().day(7).subtract(weekDiff, 'week'),
};
};
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment