import React, { useState } from 'react' import IconAntDesign from 'react-native-vector-icons/AntDesign' import { StyleSheet, View, TouchableOpacity } from 'react-native' import { useUtils, useOrder, useLanguage, useSession, useConfig } from 'ordering-components/native' import { useTheme } from 'styled-components/native'; import { OIcon, OText, OModal } from '../shared' import { BusinessBasicInformationParams } from '../../types' import { convertHoursToMinutes } from '../../utils' import { BusinessInformation } from '../BusinessInformation' import { BusinessReviews } from '../BusinessReviews' import { BusinessContainer, BusinessHeader, BusinessLogo, BusinessInfo, BusinessInfoItem, WrapReviews, WrapBusinessInfo, WrapSearch } from './styles' import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder'; import { SearchBar } from '../SearchBar'; import { useSafeAreaInsets } from 'react-native-safe-area-context'; import moment from 'moment'; const types = ['food', 'laundry', 'alcohol', 'groceries'] export const BusinessBasicInformation = (props: BusinessBasicInformationParams) => { const { navigation, businessState, isBusinessInfoShow, logo, header, handleChangeSearch, showReview } = props const { business, loading } = businessState const theme = useTheme() const [orderState] = useOrder() const [, t] = useLanguage() const [{ auth }] = useSession() const [{ configs }] = useConfig() const [{ parsePrice, parseDistance, optimizeImage, parseDate }] = useUtils() const [openBusinessInformation, setOpenBusinessInformation] = useState(false) const [openBusinessReviews, setOpenBusinessReviews] = useState(false) const [searchVal, setSearchVal] = useState('') const getBusinessType = () => { if (Object.keys(business).length <= 0) return t('GENERAL', 'General') const _types: any = [] types.forEach(type => business[type] && _types.push( t(`BUSINESS_TYPE_${type?.replace(/\s/g, '_')?.toUpperCase()}`, type) )) return _types.join(', ') } const handleSearchCancel = () => { setSearchVal(''); handleChangeSearch(''); console.log('clicked clear button!'); } const onRedirect = (route: string, params?: any) => { navigation.navigate(route, params) } return ( {loading ? ( ) : ( !isBusinessInfoShow && ( ) )} {!isBusinessInfoShow && setOpenBusinessInformation(true)} style={{ alignSelf: 'center', marginBottom: 8 }}> {t('MORE_INFO', 'More Info')} } {handleChangeSearch && ( handleSearchCancel()} searchValue={searchVal} isCancelXButtonShow noBorderShow placeholder={t('SEARCH_PRODUCTS', 'Search Products')} lazyLoad={businessState?.business?.lazy_load_products_recommended} inputStyle={{ height: 40, textAlign: 'center' }} /> )} {loading ? ( ) : ( {t('DELIVERY_TO', 'Delivery to')} )} {loading ? ( ) : <> {orderState?.options?.address?.address} {!isBusinessInfoShow && ( auth ? onRedirect('AddressList', { isGoBack: true, isFromProductsList: true }) : onRedirect('AddressForm', { address: orderState.options?.address })} > )} {orderState.options?.moment ? moment(orderState.options?.moment).format('dddd, MMM.DD.yyyy hh:mm A') : t('ASAP_ABBREVIATION', 'ASAP')} {!isBusinessInfoShow && ( navigation.navigate('MomentOption')} > )} } {showReview && ( {business?.reviews?.total} {!isBusinessInfoShow && ( setOpenBusinessReviews(true)}> {t('SEE_REVIEWS', 'See reviews')} )} )} setOpenBusinessInformation(false)} styleCloseButton={{ color: theme.colors.white, backgroundColor: 'rgba(0,0,0,0.3)' }} isNotDecoration > setOpenBusinessReviews(false)} styleCloseButton={{ color: theme.colors.white, backgroundColor: 'rgba(0,0,0,0.3)' }} isNotDecoration > ) } const styles = StyleSheet.create({ businesInfoheaderStyle: { height: 260 }, headerStyle: { height: 260 }, businessLogo: { width: 103, height: 103, borderRadius: 100, marginBottom: 19, overflow: 'hidden', }, businessInfo: { paddingHorizontal: 40, }, bullet: { flexDirection: 'row', alignItems: 'center' }, metadata: { marginRight: 20, marginLeft: 5, }, starIcon: { marginHorizontal: 5, }, reviewStyle: { flexDirection: 'row', alignItems: 'center' }, modalTitleSectionStyle: { position: 'absolute', width: '100%', top: 0, zIndex: 100 }, infoItem: { flexBasis: '50%', flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' } })