import React from 'react'; import { StyleSheet, useWindowDimensions, View } from 'react-native'; import { BusinessController as BusinessSingleCard, useUtils, useOrder, useLanguage, } from 'ordering-components/native'; import { useTheme } from 'styled-components/native'; import FastImage from 'react-native-fast-image' import { OText } from '../shared'; import { BusinessControllerParams } from '../../types'; import { convertHoursToMinutes, lightenDarkenColor, shape } from '../../utils'; import { Card, BusinessHero, BusinessContent, BusinessInfo, Metadata, BusinessLogo, RibbonBox } from './styles'; export const BusinessFeaturedCtrlUI = (props: BusinessControllerParams) => { const { business, handleClick, isBusinessOpen } = props; const [{ parsePrice, parseDistance, optimizeImage }] = useUtils(); const [orderState] = useOrder(); const [, t] = useLanguage(); const theme = useTheme(); const styles = StyleSheet.create({ headerStyle: { borderTopLeftRadius: 25, borderTopRightRadius: 25, }, businessLogo: { alignSelf: 'center', }, businessStateView: { backgroundColor: '#6C6C6C', borderRadius: 10, }, businessStateText: { color: theme.colors.white, textAlign: 'center', padding: 8, }, metadata: { marginRight: 20, marginLeft: 5, }, metaField: { paddingEnd: 3, marginEnd: 2, }, starIcon: { marginTop: 1.5, marginHorizontal: 5, }, featured: { position: 'absolute', padding: 8, backgroundColor: theme.colors.backgroundDark, opacity: 0.8, borderRadius: 10, left: 20, top: 10, }, closed: { }, bullet: { flexDirection: 'row', justifyContent: 'flex-start', width: '100%', }, productStyle: { height: 40, width: 40 } }); const { width } = useWindowDimensions(); return ( handleClick(business)}> {business?.ribbon?.enabled && ( {business?.ribbon?.text} )} {business?.name} {!isBusinessOpen ? ( {t('CLOSED', 'Closed')} ) : ( {t('DELIVERY_FEE', 'Delivery Fee')} {parsePrice(business?.delivery_price) + ' \u2022'} {convertHoursToMinutes( orderState?.options?.type === 1 ? business?.delivery_time : business?.pickup_time, ) + ' \u2022'} {parseDistance(business?.distance)} )} ); }; export const BusinessFeaturedController = (props: BusinessControllerParams) => { const BusinessControllerProps = { ...props, UIComponent: BusinessFeaturedCtrlUI, }; return ; };