import React, { useState } from 'react' import IconAntDesign from 'react-native-vector-icons/AntDesign' import IconEvilIcons from 'react-native-vector-icons/EvilIcons' import MaterialComIcon from 'react-native-vector-icons/MaterialCommunityIcons'; import { StyleSheet, View, TouchableOpacity } from 'react-native' import { useUtils, useOrder, useLanguage } from 'ordering-components/native' import { OIcon, OText, OModal } from '../shared' import { BusinessBasicInformationParams } from '../../types' import { useTheme } from 'styled-components/native' import { convertHoursToMinutes } from '../../utils' import { BusinessInformation } from '../BusinessInformation' import { BusinessReviews } from '../BusinessReviews' import { BusinessContainer, BusinessHeader, BusinessLogo, BusinessInfo, BusinessInfoItem, WrapReviews, VerticalLine } from './styles' import { Fade, Placeholder, PlaceholderLine } from 'rn-placeholder'; const types = ['food', 'laundry', 'alcohol', 'groceries'] export const BusinessBasicInformation = (props: BusinessBasicInformationParams) => { const { businessState, isBusinessInfoShow, logo, header } = props const { business, loading } = businessState const theme = useTheme() const [orderState] = useOrder() const [, t] = useLanguage() const [{ parsePrice, parseDistance, optimizeImage }] = useUtils() const [openBusinessInformation, setOpenBusinessInformation] = useState(false) const [openBusinessReviews, setOpenBusinessReviews] = useState(false) 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(', ') } return ( {loading ? ( ) : ( !isBusinessInfoShow && ( ) )} {loading ? ( ) : ( {business?.name} )} {business?.reviews?.total} ({business?.reviews?.reviews.length} {t('REVIEWS', 'Reviews')}) {!isBusinessInfoShow && ( setOpenBusinessReviews(true)}> {t('SEE_REVIEWS', 'See reviews')} )} {loading ? ( ) : ( {getBusinessType()} )} {loading ? ( ) : ( <> {orderState?.options?.type === 1 ? ( {convertHoursToMinutes(business?.delivery_time)} ) : ( {convertHoursToMinutes(business?.pickup_time)} )} {parseDistance(business?.distance || 0)} {business && parsePrice(business?.delivery_price || 0)} )} 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: 150 }, headerStyle: { height: 210 }, businessLogo: { width: 60, height: 60, borderRadius: 5, marginLeft: 20, marginBottom: 20, justifyContent: 'flex-start', alignItems: 'flex-start', }, bullet: { flexDirection: 'row', alignItems: 'center' }, metadata: { marginRight: 20, marginLeft: 5, }, reviewStyle: { flexDirection: 'row', alignItems: 'center' }, modalTitleSectionStyle: { position: 'absolute', width: '100%', top: 0, zIndex: 100 } })