import React, { useState } from 'react'; import { BusinessInformation as BusinessInformationController, useLanguage, useUtils } from 'ordering-components/native'; import { useTheme } from 'styled-components/native'; import { SliderBox } from 'react-native-image-slider-box'; import { OIcon, OText, OModal } from '../shared'; import { BusinessInformationContainer, WrapMainContent, GrayBackground, WrapScheduleBlock, ScheduleBlock, WrapBusinessMap, InnerContent, DivideView, MediaWrapper, } from './styles'; import { Platform, StyleSheet, TouchableOpacity, View } from 'react-native'; import { BusinessInformationParams } from '../../types'; import { GoogleMap } from '../GoogleMap'; import { WebView } from 'react-native-webview'; import NavBar from '../../../../../src/components/NavBar' const BusinessInformationUI = (props: BusinessInformationParams) => { const { businessState, business, businessSchedule, businessLocation } = props; const theme = useTheme(); const [, t] = useLanguage(); const [{ optimizeImage }] = useUtils(); const [openImages, setOpenImages] = useState(false) const daysOfWeek = [ t('SUNDAY_ABBREVIATION', 'Sun'), t('MONDAY_ABBREVIATION', 'Mon'), t('TUESDAY_ABBREVIATION', 'Tues'), t('WEDNESDAY_ABBREVIATION', 'Wed'), t('THURSDAY_ABBREVIATION', 'Thur'), t('FRIDAY_ABBREVIATION', 'Fri'), t('SATURDAY_ABBREVIATION', 'Sat'), ]; const scheduleFormatted = ({ hour, minute, }: { hour: number | string; minute: number | string; }) => { const checkTime = (val: number | string) => (val < 10 ? `0${val}` : val); const zz = hour > 12 ? 'PM' : 'AM'; const h = parseInt(`${hour}`); return `${h > 12 ? h - 12 : h}:${checkTime(minute)} ${zz}`; }; const businessCoordinate = { lat: businessState?.business?.location?.lat, lng: businessState?.business?.location?.lng, }; const businessImage = { uri: businessState?.business?.logo, }; const businessMarker = { latlng: businessCoordinate, image: businessImage, }; const bVideos = () => { const len = businessState?.business?.gallery?.length | 0; if (len == 0) return []; const vAry = businessState?.business?.gallery.filter( ({ type, file }: any) => type == 2 && file == null, ); return vAry; }; const bImages: any = () => { const len = businessState?.business?.gallery?.length ?? 0; if (len == 0) return []; const iAry = businessState?.business?.gallery.filter( ({ type, video }: any) => type == 1 && video == null, ); return iAry; }; return ( props.navigation?.canGoBack() && props.navigation.goBack()} /> {businessState?.business?.name} {t('BUSINESS_LOCATION', 'Business Location')} {!!businessLocation.location && ( )} {businessState?.business?.address} {t('OPENING_TIME', 'Opening Time')} {!!businessSchedule && businessSchedule?.length > 0 && ( {businessSchedule.map((schedule: any, i: number) => ( {daysOfWeek[i].toUpperCase()} {schedule.enabled ? ( {scheduleFormatted(schedule.lapses[0].open) + ' - ' + scheduleFormatted(schedule.lapses[0].close)} ) : ( {t('CLOSED', 'Closed')} )} ))} )} <> {bVideos().length > 0 && ( <> {t('VIDEOS', 'Videos')} {bVideos().map((v: any) => ( ))} )} {bImages().length > 0 && ( <> {t('IMAGES', 'Images')} {bImages().map((i: any) => ( i.file != null && ( setOpenImages(true)}> )))} )} setOpenImages(false)} isNotDecoration > optimizeImage(image?.file, 'h_300,c_limit'))} dotColor={theme.colors.primary} inactiveDotColor={theme.colors.backgroundGray} dotStyle={styles.dotStyle} activeOpacity={1} /> ); }; const styles = StyleSheet.create({ wrapMapStyle: { overflow: 'hidden', marginTop: 15, marginBottom: 10, }, dotStyle: { width: 15, height: 15, borderRadius: 15, marginHorizontal: 10, padding: 0, margin: 0 }, modalTitleSectionStyle: { position: 'absolute', width: '100%', top: 0, zIndex: 100, left: 40 }, }); export const BusinessInformation = (props: BusinessInformationParams) => { const BusinessInformationProps = { ...props, UIComponent: BusinessInformationUI, }; return ; };