Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
25 kB
2
Indexable
Never
import React, {useEffect, useState} from 'react';
import {StyleSheet, View, Image, Text, Platform} from 'react-native';
import PushNotificationIOS from '@react-native-community/push-notification-ios';
import messaging from '@react-native-firebase/messaging';

import {
  createStackNavigator,
  createSwitchNavigator,
  createBottomTabNavigator,
} from 'react-navigation';
import {Message} from '../framework/src/Message';
import {runEngine} from '../framework/src/RunEngine';
import MessageEnum, {getName} from '../framework/src/Messages/MessageEnum';
import PushNotification from 'react-native-push-notification';
import Dashboard from '../blocks/dashboard/src/Dashboard';
import HomeScreen from '../components/src/HomeScreen';
import InfoPage from '../blocks/info-page/src/InfoPageBlock';
import BulkUploading from '../blocks/bulkuploading/src/BulkUploading';
import StripePayments from '../blocks/stripepayments/src/StripePayments';
import Audiovideomessenger2 from '../blocks/audiovideomessenger2/src/Audiovideomessenger2';
import Filteritems from '../blocks/filteritems/src/Filteritems';
import Filteroptions from '../blocks/filteritems/src/Filteroptions';
import PhotoLibrary from '../blocks/photolibrary/src/PhotoLibrary';
import SocialMediaAccountLoginScreen from '../blocks/social-media-account-login/src/SocialMediaAccountLoginScreen';
import ForgotPassword from '../blocks/forgot-password/src/ForgotPassword';
import ForgotPasswordOTP from '../blocks/forgot-password/src/ForgotPasswordOTP';
import NewPassword from '../blocks/forgot-password/src/NewPassword';
import VisualAnalytics from '../blocks/visualanalytics/src/VisualAnalytics';
import ICalendarSupport from '../blocks/icalendarsupport/src/ICalendarSupport';
import Catalogue from '../blocks/catalogue/src/Catalogue';
import CarDescription from '../blocks/catalogue/src/CarDescription';
import SocialMediaAccountRegistrationScreen from '../blocks/social-media-account-registration/src/SocialMediaAccountRegistrationScreen';
import Emailnotifications2 from '../blocks/emailnotifications2/src/Emailnotifications2';
import Splitpayments2 from '../blocks/splitpayments2/src/Splitpayments2';
import Onboardingguide from '../blocks/onboardingguide/src/Onboardingguide';
import CountryCodeSelector from '../blocks/country-code-selector/src/CountryCodeSelector';
import CountryCodeSelectorTable from '../blocks/country-code-selector/src/CountryCodeSelectorTable';
import UserProfileBasicBlock from '../blocks/user-profile-basic/src/UserProfileBasicBlock';
import TosAndPrivacyPolicy from '../blocks/user-profile-basic/src/TosAndPrivacyPolicy';
import PaymentInformation from '../blocks/user-profile-basic/src/PaymentInformation';
import AccountInformation from '../blocks/user-profile-basic/src/AccountInformation';
import ApprovalStatus from '../blocks/user-profile-basic/src/ApprovalStatus';
import PhoneNumberInput from '../blocks/mobile-account-registration/src/PhoneNumberInput';
import AdditionalDetailForm from '../blocks/mobile-account-registration/src/AdditionalDetailForm';
import Settings2 from '../blocks/settings2/src/Settings2';
import FormApprovalWorkflow from '../blocks/formapprovalworkflow/src/FormApprovalWorkflow';
import HelpCentre from '../blocks/helpcentre/src/HelpCentre';
import HelpCentreQA from '../blocks/helpcentre/src/HelpCentreQA';
import HelpCentreSub from '../blocks/helpcentre/src/HelpCentreSub';
import Pushnotifications from '../blocks/pushnotifications/src/Pushnotifications';
import Contactus from '../blocks/contactus/src/Contactus';
import AddContactus from '../blocks/contactus/src/AddContactus';
import Notifications from '../blocks/notifications/src/Notifications';
import MobileAccountLoginBlock from '../blocks/mobile-account-login/src/MobileAccountLoginBlock';
import Cfdesignconversion33 from '../blocks/cfdesignconversion33/src/Cfdesignconversion33';
import EmailAccountRegistration from '../blocks/email-account-registration/src/EmailAccountRegistration';
import Categoriessubcategories from '../blocks/categoriessubcategories/src/Categoriessubcategories';
import Adminconsole2 from '../blocks/adminconsole2/src/Adminconsole2';
import Location from '../blocks/location/src/Location';
import Analytics from '../blocks/analytics/src/Analytics';
import Cfdesignconversion23 from '../blocks/cfdesignconversion23/src/Cfdesignconversion23';
import ApplePayIntegration from '../blocks/applepayintegration/src/ApplePayIntegration';
import EmailAccountLoginBlock from '../blocks/email-account-login/src/EmailAccountLoginBlock';
import Cfdesignconversion6 from '../blocks/cfdesignconversion6/src/Cfdesignconversion6';
import NavigationMenu from '../blocks/navigationmenu/src/NavigationMenu';
import AdvancedSearch from '../blocks/advancedsearch/src/AdvancedSearch';
import EducationalUserProfile from '../blocks/educational-user-profile/src/EducationalUserProfile';
import Inventorymanagement3 from '../blocks/inventorymanagement3/src/Inventorymanagement3';
import TransactionBreakdown from '../blocks/inventorymanagement3/src/TransactionBreakdown';
import LocationAndDistance from '../blocks/inventorymanagement3/src/LocationAndDistance';
import CarouselDisplay from '../blocks/carouseldisplay/src/CarouselDisplay';
import Reviews from '../blocks/reviews/src/Reviews';
import AddReview from '../blocks/reviews/src/AddReview';
import Digisureapiintegration3 from '../blocks/digisureapiintegration3/src/Digisureapiintegration3';
import Rolesandpermissions2 from '../blocks/rolesandpermissions2/src/Rolesandpermissions2';
import GoogleCalendarSync from '../blocks/googlecalendarsync/src/GoogleCalendarSync';
import Maps from '../blocks/maps/src/Maps';
import PricingEngine from '../blocks/pricingengine/src/PricingEngine';
import Geofence from '../blocks/geofence/src/Geofence';
import Chat from '../blocks/chat/src/Chat';
import ViewChat from '../blocks/chat/src/ViewChat';
import LinkShare from '../blocks/linkshare/src/LinkShare';
import Scheduling from '../blocks/scheduling/src/Scheduling';
import OrderManagement from '../blocks/ordermanagement/src/OrderManagement';
import OTPInputAuth from '../blocks/otp-input-confirmation/src/OTPInputAuth';
import Reservations from '../blocks/reservations/src/Reservations';
import ReservationHost from '../blocks/reservations/src/ReservationHost';
import ReservationUpcoming from '../blocks/reservations/src/ReservationUpcoming';
import ReservationHistory from '../blocks/reservations/src/ReservationHistory';
import AboutYourCar from '../blocks/catalogue/src/AboutYourCar';
import ListingSetUp from '../blocks/catalogue/src/ListingSetUp';
import AddNewCar from '../blocks/catalogue/src/AddNewCar';
import EnterVIN from '../blocks/catalogue/src/EnterVIN';
import ScanVIN from '../blocks/catalogue/src/ScanVIN';
import ListingSetUpDuration from '../blocks/catalogue/src/ListingSetUpDuration';
import AboutYourCarInfo from '../blocks/catalogue/src/AboutYourCarInfo';
import AddNewHome from '../blocks/catalogue/src/AddNewHome';
import AddNewHomeStep3 from '../blocks/catalogue/src/AddNewHomeStep3';
import AddNewHomeStep2 from '../blocks/catalogue/src/AddNewHomeStep2';
import HomeDetails from '../blocks/catalogue/src/HomeDetails';
import CarPhotos from '../blocks/catalogue/src/CarPhotos';
import AddNewHomeStep4 from '../blocks/catalogue/src/AddNewHomeStep4';
import HomePhotosStep2 from '../blocks/catalogue/src/HomePhotosStep2';
import HomePhotos from '../blocks/catalogue/src/HomePhotos';
import CarPhotosStep2 from '../blocks/catalogue/src/CarPhotosStep2';
import BecomeAHost from '../blocks/user-profile-basic/src/BecomeAHost';
import CarDescriptionTripInfo from '../blocks/reservations/src/CarDescriptionTripInfo';
import BookingConfirmation from '../blocks/reservations/src/BookingConfirmation';
import SetUpPayment from '../blocks/catalogue/src/SetUpPayment';
import Wishlist from '../blocks/wishlist/src/Wishlist';
import ListingSettingsTripPreferences from '../blocks/inventorymanagement3/src/ListingSettingsTripPreferences';
import TripHistory from '../blocks/inventorymanagement3/src/TripHisory';
import CalendarComponent from '../blocks/googlecalendarsync/src/CalendarComponent';
import HostCatalogueSettings from '../blocks/inventorymanagement3/src/HostCatalogueSettings';
import PricingAndDiscounts from '../blocks/inventorymanagement3/src/PricingAndDiscounts';
import CompleteCheckout from '../blocks/reservations/src/CompleteCheckout';
import UpcomingReservationsDetails from '../blocks/reservations/src/UpcomingReservationsDetails';
import SettingsAndNotifications from '../blocks/user-profile-basic/src/SettingsAndNotifications';

import DeatilsAndPhotos from '../blocks/catalogue/src/DeatilsAndPhotos';
import ProtectionPlan from '../blocks/catalogue/src/ProtectionPlan';
import GuestInstructions from '../blocks/catalogue/src/GuestInstructions';
import ExtraAddons from '../blocks/catalogue/src/ExtraAddons';
import Checkout from '../blocks/reservations/src/Checkout';
import ProductDescription from '../blocks/productdescription/src/ProductDescription';
import AddPhotos from '../blocks/reservations/src/AddPhotos';
import CarPriceEngine from '../blocks/catalogue/src/CarPriceEngine';
// import StorageProvider from 'packages/framework/src/StorageProvider';

import StorageProvider from '../../packages/framework/src/StorageProvider';
import {setStorageData} from 'framework/src/Utilities';

const styles = StyleSheet.create({
  Images: {
    height: 25,
    width: 25,
    resizeMode: 'contain',
    marginTop: 15,
  },
  screenName: {
    color: '#5481CB',
    fontFamily: 'Montserrat',
    fontSize: 10,
    fontWeight: '700',
    marginTop: 5,
  },
});

if (!HomeScreen.instance) {
  const defaultProps = {
    navigation: null,
    id: 'HomeScreen',
  };
  const homeScreen = new HomeScreen(defaultProps);
}

export function App() {
  const [userAuthtoken, setUserAuthtoken] = useState('');
  const [onBoardingShown, setonBoardingShown] = useState(false);
  const [userType, setUserType] = useState({});

  useEffect(() => {
    fcmtoken();
  }, []);

  const fcmtoken = async () => {
    getToken();
    const authStatus = await messaging().requestPermission();
    console.log(authStatus, 'authstatu');
    const fcmToken = await messaging().getToken();
    await setStorageData('pushnotification', fcmToken);

    await messaging().onMessage(async (remoteMessage: any) => {
      console.log(
        '@@@ FCM SERVICE A NEW FCM MESSAGE IS ARRIVED FOREGROUND ===========',
        remoteMessage,
      );
      if (remoteMessage) {
        let notification: any = null;
        if (Platform.OS === 'ios') {
          notification = remoteMessage;
        }
        notification['title'] = remoteMessage.notification.title;
        notification['message'] = remoteMessage.notification.body;
      }
    });
  };

  const getToken = async () => {
    try {
      const onBoardingtoken = await StorageProvider.get('onBoarding');
      const usertoken = await StorageProvider.get('usertoken');
      const userType = await StorageProvider.get('userType');

      if (onBoardingtoken) {
        setonBoardingShown(onBoardingtoken);
      }
      if (usertoken) {
        setUserAuthtoken(usertoken);
      }
      if (usertoken) {
        setUserType(userType);
      }
    } catch (error) {
      console.error('Error retrieving token:', error);
    }
  };

  const initialRouteName = !onBoardingShown ? 'onBoarding' : 'App';
  const tabInitialRoute = userAuthtoken ? 'Search' : 'Profile';
  const profileInitialRoute = userAuthtoken
    ? 'UserProfileBasicBlock'
    : 'EmailAccountLoginBlock';
  const HostInitialRoute =
    userType === 'host' ? 'Inventorymanagement3' : 'BecomeAHost';

  const BoardingStack = createStackNavigator({
    Onboardingguide: {
      screen: Onboardingguide,
      navigationOptions: {header: null, title: 'Onboardingguide'},
    },
  });

  const Profile = createStackNavigator(
    {
      EmailAccountLoginBlock: {
        screen: EmailAccountLoginBlock,
        navigationOptions: {header: null, title: 'EmailAccountLoginBlock'},
      },
      UserProfileBasicBlock: {
        screen: UserProfileBasicBlock,
        navigationOptions: {header: null, title: 'UserProfileBasicBlock'},
      },
      AccountInformation: {
        screen: AccountInformation,
        navigationOptions: {header: null, title: 'AccountInformation'},
      },
      ApprovalStatus: {
        screen: ApprovalStatus,
        navigationOptions: {header: null, title: 'ApprovalStatus'},
      },
      PaymentInformation: {
        screen: PaymentInformation,
        navigationOptions: {header: null, title: 'PaymentInformation'},
      },
      ApplePayIntegration: {
        screen: ApplePayIntegration,
        navigationOptions: {header: null, title: 'ApplePayIntegration'},
      },
      ApplePayIntegration: {
        screen: ApplePayIntegration,
        navigationOptions: {header: null, title: 'ApplePayIntegration'},
      },
      SettingsAndNotifications: {
        screen: SettingsAndNotifications,
        navigationOptions: {header: null, title: 'SettingsAndNotifications'},
      },
      Splitpayments2: {
        screen: Splitpayments2,
        navigationOptions: {header: null, title: 'Splitpayments2'},
      },
      TosAndPrivacyPolicy: {
        screen: TosAndPrivacyPolicy,
        navigationOptions: {
          header: null,
          title: 'TosAndPrivacyPolicy',
          useNativeAnimations: true,
        },
      },
    },
    {
      initialRouteName: profileInitialRoute,
    },
  );

  const Reservation = createStackNavigator(
    {
      ReservationHost: {
        screen: ReservationHost,
        navigationOptions: {
          header: null,
          title: 'Reservations',
          animation: 'none',
        },
      },
      ReservationHistory: {
        screen: ReservationHistory,
        navigationOptions: {
          header: null,
          title: 'Reservations',
          animation: 'none',
        },
      },
      ReservationUpcoming: {
        screen: ReservationUpcoming,
        navigationOptions: {
          header: null,
          title: 'Reservations',
          animation: 'none',
        },
      },
      CompleteCheckout: {
        screen: CompleteCheckout,
        navigationOptions: {
          header: null,
          title: 'CompleteCheckout',
          animation: 'none',
          tabBarVisible: false,
        },
      },
      UpcomingReservationsDetails: {
        screen: UpcomingReservationsDetails,
        navigationOptions: {header: null, title: 'UpcomingReservationsDetails'},
      },
      AddPhotos: {
        screen: AddPhotos,
        navigationOptions: {header: null, title: 'AddPhotos'},
      },
    },
    {
      // Disable animations globally for the entire navigator
      animationEnabled: false,
    },
  );

  const Host = createStackNavigator(
    {
      BecomeAHost: {
        screen: BecomeAHost,
        navigationOptions: {header: null, title: 'BecomeAHost'},
      },
      Inventorymanagement3: {
        screen: Inventorymanagement3,
        navigationOptions: {header: null, title: 'Inventorymanagement3'},
      },
      TransactionBreakdown: {
        screen: TransactionBreakdown,
        navigationOptions: {header: null, title: 'Inventorymanagement3'},
      },
      TripHistory: {
        screen: TripHistory,
        navigationOptions: {header: null, title: 'TripHistory'},
      },
      ListingSettingsTripPreferences: {
        screen: ListingSettingsTripPreferences,
        navigationOptions: {
          header: null,
          title: 'ListingSettingsTripPreferences',
        },
      },

      LocationAndDistance: {
        screen: LocationAndDistance,

        navigationOptions: {header: null},
      },
      HostCatalogueSettings: {
        screen: HostCatalogueSettings,

        navigationOptions: {header: null},
      },
      PricingAndDiscounts: {
        screen: PricingAndDiscounts,
        navigationOptions: {header: null},
      },
      DeatilsAndPhotos: {
        screen: DeatilsAndPhotos,
        navigationOptions: {header: null, title: 'DeatilsAndPhotos'},
      },
      ProtectionPlan: {
        screen: ProtectionPlan,
        navigationOptions: {header: null, title: 'ProtectionPlan'},
      },
      GuestInstructions: {
        screen: GuestInstructions,
        navigationOptions: {header: null, title: 'GuestInstructions'},
      },
      ExtraAddons: {
        screen: ExtraAddons,
        navigationOptions: {header: null, title: 'ExtraAddons'},
      },
      Checkout: {
        screen: Checkout,
        navigationOptions: {header: null, title: 'Checkout'},
      },
    },
    {initialRouteName: HostInitialRoute},
  );

  const Save = createStackNavigator({
    Wishlist: {
      screen: Wishlist,
      navigationOptions: {header: null, title: 'Wishlist'},
    },
    PhotoLibrary: {
      screen: PhotoLibrary,
      navigationOptions: {header: null, title: 'PhotoLibrary'},
    },
  });

  const Home = createStackNavigator({
    Dashboard: {
      screen: Dashboard,
      navigationOptions: {header: null, title: 'Dashboard'},
    },
    Catalogue: {
      screen: Catalogue,
      navigationOptions: {header: null, title: 'Catalogue'},
    },
    ProductDescription: {
      screen: ProductDescription,
      navigationOptions: {header: null, title: 'ProductDescription'},
    },

    Wishlist: {
      screen: Wishlist,
      navigationOptions: {header: null, title: 'Wishlist'},
    },
    CarDescription: {
      screen: CarDescription,
      navigationOptions: {header: null, title: 'CarDescription'},
    },
    CarDescriptionTripInfo: {
      screen: CarDescriptionTripInfo,
      navigationOptions: {header: null, title: 'CarDescriptionTripInfo'},
    },
    Checkout: {
      screen: Checkout,
      navigationOptions: {header: null, title: 'Checkout'},
    },
    BookingConfirmation: {
      screen: BookingConfirmation,
      navigationOptions: {header: null, title: 'BookingConfirmation'},
    },

    AdvancedSearch: {
      screen: AdvancedSearch,
      navigationOptions: {header: null, title: 'AdvancedSearch'},
    },
    CalendarComponent: {
      screen: CalendarComponent,
      navigationOptions: {header: null, title: 'CalendarComponent'},
    },
  });

  const signUpStack = createStackNavigator({
    EmailAccountRegistration: {
      screen: EmailAccountRegistration,
      navigationOptions: {header: null, title: 'EmailAccountRegistration'},
    },
    OTPInputAuth: {
      screen: OTPInputAuth,
      navigationOptions: {header: null, title: 'OTPInputAuth'},
    },
    Digisureapiintegration3: {
      screen: Digisureapiintegration3,
      navigationOptions: {header: null, title: 'Digisureapiintegration3'},
    },
    Splitpayments2: {
      screen: Splitpayments2,
      navigationOptions: {header: null, title: 'Splitpayments2'},
    },
    TosAndPrivacyPolicy: {
      screen: TosAndPrivacyPolicy,
      navigationOptions: {
        header: null,
        title: 'TosAndPrivacyPolicy',
        useNativeAnimations: true,
      },
    },
    AddNewCar: {
      screen: AddNewCar,
      navigationOptions: {header: null, title: 'AddNewCar'},
    },
    EnterVIN: {
      screen: EnterVIN,
      navigationOptions: {header: null, title: 'EnterVIN'},
    },
    ScanVIN: {
      screen: ScanVIN,
      navigationOptions: {header: null, title: 'ScanVIN'},
    },
    ListingSetUpDuration: {
      screen: ListingSetUpDuration,
      navigationOptions: {header: null, title: 'ListingSetUpDuration'},
    },
    ListingSetUp: {
      screen: ListingSetUp,
      navigationOptions: {header: null, title: 'ListingSetUp'},
    },
    AboutYourCarInfo: {
      screen: AboutYourCarInfo,
      navigationOptions: {header: null, title: 'AboutYourCarInfo'},
    },
    AboutYourCar: {
      screen: AboutYourCar,
      navigationOptions: {header: null, title: 'AboutYourCar'},
    },
    AddNewHome: {
      screen: AddNewHome,
      navigationOptions: {header: null, title: 'AddNewHome'},
    },
    AddNewHomeStep2: {
      screen: AddNewHomeStep2,
      navigationOptions: {header: null, title: 'AddNewHomeStep2'},
    },
    AddNewHomeStep3: {
      screen: AddNewHomeStep3,
      navigationOptions: {header: null, title: 'AddNewHomeStep3'},
    },
    CarPhotos: {
      screen: CarPhotos,
      navigationOptions: {header: null, title: 'CarPhotos'},
    },
    CarPhotosStep2: {
      screen: CarPhotosStep2,
      navigationOptions: {header: null, title: 'CarPhotosStep2'},
    },
    CarPriceEngine: {
      screen: CarPriceEngine,
      navigationOptions: {header: null, title: 'CarPriceEngine'},
    },
    SetUpPayment: {
      screen: SetUpPayment,
      navigationOptions: {header: null, title: 'SetUpPayment'},
    },
    AddNewHomeStep4: {
      screen: AddNewHomeStep4,
      navigationOptions: {header: null, title: 'AddNewHomeStep4'},
    },
    HomePhotos: {
      screen: HomePhotos,
      navigationOptions: {title: 'HomePhotos', header: null},
    },
    HomeDetails: {
      screen: HomeDetails,
      navigationOptions: {header: null, title: 'HomeDetails'},
    },
    HomePhotosStep2: {
      screen: HomePhotosStep2,
      navigationOptions: {header: null, title: 'HomePhotosStep2'},
    },
  });

  const Tab = createBottomTabNavigator(
    {
      Search: Home,
      Reservations: Reservation,
      Host: Host,
      Save: Save,
      Profile: Profile,
    },
    {
      initialRouteName: tabInitialRoute,
      navigationOptions: ({navigation}) => ({
        tabBarIcon: ({focused, horizontal, tintColor}) => {
          const {routeName} = navigation.state;
          if (routeName === 'Search') {
            return (
              <>
                <Image
                  source={require('../components/src/home.png')}
                  style={
                    focused
                      ? [styles.Images, {tintColor: '#5481CB'}]
                      : styles.Images
                  }
                />
                <Text style={styles.screenName}>{focused && routeName}</Text>
              </>
            );
          }
          if (routeName === 'Reservations') {
            return (
              <>
                <Image
                  source={require('../components/src/calendar.png')}
                  style={
                    focused
                      ? [styles.Images, {tintColor: '#5481CB'}]
                      : styles.Images
                  }
                />
                <Text style={styles.screenName}>{focused && routeName}</Text>
              </>
            );
          }

          if (routeName === 'Host') {
            return (
              <>
                <Image
                  source={require('../components/src/host.png')}
                  style={
                    focused
                      ? [styles.Images, {tintColor: '#5481CB'}]
                      : styles.Images
                  }
                />
                <Text style={styles.screenName}>{focused && routeName}</Text>
              </>
            );
          }

          if (routeName === 'Save') {
            return (
              <>
                <Image
                  source={require('../components/src/saved.png')}
                  style={
                    focused
                      ? [styles.Images, {tintColor: '#5481CB'}]
                      : styles.Images
                  }
                />
                <Text style={styles.screenName}>{focused && routeName}</Text>
              </>
            );
          }

          if (routeName === 'Profile') {
            return (
              <>
                <Image
                  source={require('../components/src/profile.png')}
                  style={
                    focused
                      ? [styles.Images, {tintColor: '#5481CB'}]
                      : styles.Images
                  }
                />
                <Text style={styles.screenName}>{focused && routeName}</Text>
              </>
            );
          }
        },
      }),
      tabBarOptions: {
        showLabel: false,
        keyboardHidesTabBar: true,
        style: {
          backgroundColor: '#fff',
          // height: 70,
          borderRadius: 12,
          shadowColor: '#B0B0B0',
          shadowOffset: {width: 0, height: -3},
          shadowOpacity: 0.1,
          shadowRadius: 0,
          elevation: 5,
        },
        safeAreaInset: {
          bottom: 20,
          top: 'never',
        },
      },
    },
  );

  const AppNavigator = createSwitchNavigator(
    {
      App: Tab,
      onBoarding: BoardingStack,
      signUpStack: signUpStack,
    },
    {
      initialRouteName,
    },
  );

  return <AppNavigator />;
}
Leave a Comment