Fakultas Ilmu Komputer UI

Commit d5965d09 authored by wulanmantiri's avatar wulanmantiri
Browse files

[GREEN] Add and fix navigation for returning users

parent 1d5ded97
......@@ -5,6 +5,8 @@ import {
adminNavigation,
unpaidClientNavigation,
paidClientNavigation,
cartsExpireClientNavigation,
takeQuizClientNavigation,
} from 'constants/navigation';
import { UserRole, AuthUserResponse } from 'services/auth/models';
import { TransactionStatus } from 'services/payment/models';
......@@ -18,20 +20,28 @@ export const getNavigation = (
if (!user.cart_id) {
return {
initialRoute: ROUTES.allAccessQuestionnaire,
navigation: unpaidClientNavigation,
navigation: takeQuizClientNavigation,
};
}
if ([TransactionStatus.UNPAID, null].includes(user.transaction_status)) {
if (user.all_carts_are_expired) {
return {
initialRoute: ROUTES.checkout,
navigation: unpaidClientNavigation,
initialRoute: ROUTES.allCartsExpired,
navigation: cartsExpireClientNavigation,
};
} else {
}
if (user.transaction_status === TransactionStatus.UNPAID) {
return {
initialRoute: ROUTES.clientTabNavigation,
navigation: paidClientNavigation,
initialRoute: ROUTES.checkout,
navigation: unpaidClientNavigation,
};
}
return {
initialRoute: ROUTES.clientTabNavigation,
navigation: paidClientNavigation,
};
}
if (user.role === UserRole.NUTRITIONIST) {
......
......@@ -24,6 +24,7 @@ import {
LoginChoosePlan,
ClientNavigation,
ChooseWeekForNutritionist,
AllCartsExpiredPage,
} from 'scenes';
import { FC } from 'react';
import DietReportForNutritionist from 'scenes/nutritionist/DietReportForNutritionist';
......@@ -90,6 +91,62 @@ export const publicNavigation: NavRoute[] = [
},
];
export const takeQuizClientNavigation: NavRoute[] = [
...navigation,
{
name: ROUTES.allCartsExpired,
component: AllCartsExpiredPage,
header: 'Dietela',
},
{
name: ROUTES.checkout,
component: Checkout,
header: 'Checkout',
},
{
name: ROUTES.payment,
component: PaymentWebView,
header: 'Pembayaran',
},
{
name: ROUTES.paymentResult,
component: PaymentResult,
},
{
name: ROUTES.clientTabNavigation,
component: ClientNavigation,
header: 'Dietela',
},
];
export const cartsExpireClientNavigation: NavRoute[] = [
{
name: ROUTES.allCartsExpired,
component: AllCartsExpiredPage,
header: 'Dietela',
},
{
name: ROUTES.checkout,
component: Checkout,
header: 'Checkout',
},
{
name: ROUTES.payment,
component: PaymentWebView,
header: 'Pembayaran',
},
{
name: ROUTES.paymentResult,
component: PaymentResult,
},
...navigation,
{
name: ROUTES.clientTabNavigation,
component: ClientNavigation,
header: 'Dietela',
},
];
export const unpaidClientNavigation: NavRoute[] = [
{
name: ROUTES.checkout,
......
export const initial = 'initial-page';
export const allCartsExpired = 'all-carts-expired';
export const comingSoon = '*';
const questionnaire = 'questionnaire';
......
......@@ -31,6 +31,7 @@ export const initialUser = {
is_finished_onboarding: false,
cart_id: null,
nutritionist: null,
all_carts_are_expired: false,
};
export const UserContext = createContext<iUserContext>({
......
import React, { FC } from 'react';
import { View } from 'react-native';
import { useNavigation } from '@react-navigation/native';
import * as ROUTES from 'constants/routes';
import { EmptyDataPage, BigButton } from 'components/core';
import { styles } from './styles';
const AllCartsExpiredPage: FC = () => {
const navigation = useNavigation();
return (
<View style={styles.center}>
<EmptyDataPage text="Program diet Anda telah selesai!" />
<BigButton
title="konsultasi lagi"
onPress={() => navigation.navigate(ROUTES.allAccessQuestionnaire)}
/>
</View>
);
};
export default AllCartsExpiredPage;
import { StyleSheet } from 'react-native';
import { typography, layoutStyles } from 'styles';
export const styles = StyleSheet.create({
center: {
flex: 1,
...layoutStyles,
},
noRecomText: {
...typography.headingMedium,
textAlign: 'center',
marginTop: 10,
},
});
......@@ -5,6 +5,7 @@ export { default as ManualRegistrationPage } from './auth/ManualRegistrationPage
export { default as InitialPage } from './common/InitialPage';
export { default as ComingSoonPage } from './common/ComingSoonPage';
export { default as AllCartsExpiredPage } from './common/AllCartsExpiredPage';
export { default as AllAccessQuestionnaire } from './questionnaire/AllAccessQuestionnaire';
export { default as DietelaQuizResult } from './questionnaire/DietelaQuizResult';
......
......@@ -31,6 +31,7 @@ export interface AuthUserResponse extends User {
transaction_status: TransactionStatus | null;
is_finished_onboarding: boolean;
cart_id: number | null;
all_carts_are_expired: boolean;
nutritionist: {
full_name_and_degree: string;
phone_number: string | null;
......
Markdown is supported
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