import React, { useState } from 'react' import { StyleSheet, View, TouchableOpacity, Text, TextStyle, Platform } from 'react-native' import { useUtils, useOrder, useLanguage } from 'ordering-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 { useTheme } from 'styled-components/native' 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, noImage } = props const { business, loading } = businessState const theme = useTheme(); 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: 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 }, deliveryInfo: { flexDirection: 'row', minHeight: 55, borderRadius: 7.6, borderWidth: 1, borderColor: theme.colors.border, marginVertical: 11, justifyContent: 'space-around', alignItems: 'center', }, dInfoItem: { alignItems: 'center' } }) 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 ( {!noImage && ( {loading ? ( ) : ( !isBusinessInfoShow && ( ) )} )} {loading ? ( ) : ( {business?.name} )} {loading ? ( ) : ( {getBusinessType()} )} {loading ? ( ) : ( {business?.reviews?.total} setOpenBusinessReviews(true)}> {business?.reviews?.reviews?.length + ' ' + t('REVIEWS', 'reviews')} {' \u2022 ' + parseDistance(business?.distance || 0)} )} {business && parsePrice(business?.delivery_price || 0)} {t('DELIVERY_FEE', 'Delivery fee').toLowerCase()} {orderState?.options?.type === 1 ? convertHoursToMinutes(business?.delivery_time) : convertHoursToMinutes(business?.pickup_time) } {t('DELIVERY_TIME', 'Delivery time').toLowerCase()} setOpenBusinessInformation(false)} styleCloseButton={{ color: theme.colors.white, backgroundColor: 'rgba(0,0,0,0.3)' }} isNotDecoration overScreen > setOpenBusinessReviews(false)} styleCloseButton={{ color: theme.colors.white, backgroundColor: 'rgba(0,0,0,0.3)' }} isNotDecoration overScreen > ) }