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, ScrollView } from 'react-native' import { useUtils, useOrder, useLanguage } 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 } 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 ( {!isBusinessInfoShow && ( )} {loading ? ( ) : ( {business?.name} )} {!isBusinessInfoShow && ( setOpenBusinessInformation(true)} > )} {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)} {!loading && ( {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: 150 }, headerStyle: { height: 260 }, businessLogo: { width: 75, height: 75, borderRadius: 20, marginLeft: 20, marginBottom: 40, justifyContent: 'flex-start', alignItems: 'flex-start', }, businessInfo: { paddingHorizontal: 20, paddingTop: 20, borderTopRightRadius: 20, borderTopLeftRadius: 20, transform: [{ translateY: -20 }], }, 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 } })