diff --git a/src/components/RestaurantCard.js b/src/components/RestaurantCard.js index 1b17da1a7..b396f5141 100644 --- a/src/components/RestaurantCard.js +++ b/src/components/RestaurantCard.js @@ -4,6 +4,9 @@ import {TimingBadge} from '../navigation/checkout/components/RestaurantBadges'; import {RestaurantBadge} from './RestaurantBadge'; import {RestaurantTag} from './RestaurantTag'; import React from 'react'; +import {getRestaurantIsAvailable} from '../utils/checkout'; +import i18n from '../i18n'; +import Svg, {Path} from 'react-native-svg'; const logoSize = 64; @@ -16,110 +19,161 @@ const OneLineText = props => ( ); +const styles = StyleSheet.create({ + item: { + marginHorizontal: 16, + marginTop: 16, + borderRadius: 8, + overflow: 'hidden', + marginBottom: 0, + // backgroundColor: backgroundColor, + }, + images: { + width: '100%', + }, + banner: { + aspectRatio: '16/9', + width: '100%', + marginBottom: -50, + }, + overlay: { + position: 'absolute', + width: '100%', + backgroundColor: 'rgba(0,0,0,0.5)', + justifyContent: 'center', + alignItems: 'center', + aspectRatio: '16/9', + color: 'white', + }, + closedLabel: { + fontWeight: 500, + fontSize: 16, + color: 'white', + }, + closedIcon: { + height: 32, + width: 32, + stroke: "white" + }, + logoWrapper: { + borderRadius: 16, + display: 'inline-flex', + marginLeft: 16, + padding: 8, + position: 'relative', + boxSizing: 'border-box', + width: logoSize + 16, + }, + logo: { + width: logoSize, + aspectRatio: '1', + borderRadius: 8, + }, + content: { + width: '100%', + display: 'flex', + flexDirection: 'column', + paddingTop: 8, + paddingRight: 24, + paddingBottom: 24, + paddingLeft: 24, + gap: 12, + }, + name: { + fontWeight: '600', + fontSize: 18, + }, + timing: { + alignItems: 'center', + alignSelf: 'left', + borderRadius: 4, + }, + badgesWrapper: { + display: 'flex', + flexDirection: 'row', + flexWrap: 'wrap', + gap: 8, + left: 0, + padding: 12, + position: 'absolute', + top: 0, + width: '100%', + }, + details: { + overflow: 'hidden', + whiteSpace: 'nowrap', + display: 'flex', + flexDirection: 'row', + gap: 4, + }, + detailsText: { + fontSize: 14, + opacity: 0.75, + }, +}); + export const RestaurantCard = ({restaurant}) => { - const backgroundColor = useColorModeValue('white', '#121212'); + // const backgroundColor = useColorModeValue('white', '#121212'); + // const backgroundColor = useColorModeValue('white', '#222222'); + const backgroundColor = useColorModeValue('white', '#1a1a1a'); + const isClosed = getRestaurantIsAvailable(restaurant); + const overlayBackgroundColor = useColorModeValue( + 'rgba(0,0,0,0.5)', + 'rgba(0,0,0,0.75)', + ); // const backgroundColor = useColorModeValue('white', '#FFFFFF16'); - const styles = StyleSheet.create({ - item: { - marginHorizontal: 16, - marginTop: 16, - borderRadius: 8, - overflow: 'hidden', - marginBottom: 0, - backgroundColor: backgroundColor, - }, - images: { - width: '100%', - }, - banner: { - aspectRatio: '16/9', - width: '100%', - marginBottom: -50, - }, - logoWrapper: { - // backgroundColor: '#fff', - backgroundColor: backgroundColor, - borderRadius: 16, - display: 'inline-flex', - marginLeft: 16, - padding: 8, - position: 'relative', - boxSizing: 'border-box', - width: logoSize + 16, - }, - logo: { - width: logoSize, - aspectRatio: '1', - borderRadius: 8, - }, - content: { - width: '100%', - display: 'flex', - flexDirection: 'column', - paddingTop: 8, - paddingRight: 24, - paddingBottom: 24, - paddingLeft: 24, - gap: 8, - }, - name: { - fontWeight: '600', - fontSize: 18, - }, - timing: { - alignItems: 'center', - alignSelf: 'left', - borderRadius: 4, - }, - badgesWrapper: { - display: 'flex', - flexDirection: 'row', - flexWrap: 'wrap', - gap: 8, - left: 0, - padding: 12, - position: 'absolute', - top: 0, - width: '100%', - }, - details: { - overflow: "hidden", - whiteSpace: 'nowrap', - display: 'flex', - flexDirection: "row", - gap: 4 - }, - detailsText: { - fontSize: 14, - opacity: 0.75, - }, - }); - return ( - + - + {restaurant.badges && ( + + {restaurant.badges.map((badge, i) => ( + + ))} + + )} + {isClosed ? ( + + + + + + + + + + + {i18n.t('NOT_AVAILABLE_ATM')} + + + ) : ( + '' + )} + - { restaurant.badges && - - {restaurant.badges.map((badge, i) => ( - - ))} - - } @@ -129,7 +183,7 @@ export const RestaurantCard = ({restaurant}) => { - { restaurant.tags?.length > 0 ? ( + {restaurant.tags?.length > 0 ? ( restaurant.tags.map((tag, i) => ( )) diff --git a/src/navigation/checkout/components/RestaurantBadges.js b/src/navigation/checkout/components/RestaurantBadges.js index b66f383e5..7f195c7bf 100644 --- a/src/navigation/checkout/components/RestaurantBadges.js +++ b/src/navigation/checkout/components/RestaurantBadges.js @@ -3,6 +3,7 @@ import {Badge, HStack, Icon, Text, useColorModeValue} from 'native-base'; import FontAwesome from 'react-native-vector-icons/FontAwesome'; import { getNextShippingTimeAsText, + getRestaurantIsAvailable, shouldShowPreOrder, } from '../../../utils/checkout'; import React from 'react'; @@ -36,6 +37,7 @@ export const CategoryBadge = ({label}) => { export const TimingBadge = ({restaurant}) => { const color = useColorModeValue('#000', '#fff'); + const isClosed = getRestaurantIsAvailable(restaurant); const shippingTime = getNextShippingTimeAsText(restaurant); const showPreOrder = shouldShowPreOrder(restaurant); @@ -56,7 +58,7 @@ export const TimingBadge = ({restaurant}) => { - ) : ( + ) : !isClosed ? ( { viewBox="0 0 18 11.38"> + ) : ( + + + + + + + + )} - {shippingTime} + + {shippingTime} + ); }; diff --git a/src/utils/checkout.js b/src/utils/checkout.js index eff51aa50..a00af78b9 100644 --- a/src/utils/checkout.js +++ b/src/utils/checkout.js @@ -58,6 +58,14 @@ export function getNextShippingTimeAsText(restaurant, now) { return i18n.t('NOT_AVAILABLE_ATM') } +export function getRestaurantIsAvailable(restaurant) { + if (!restaurant.timing.delivery && !restaurant.timing.collection) { + return true; + } else { + return false; + } +} + export function getRestaurantCaption(restaurant) { return restaurant.description || restaurant.address.streetAddress } @@ -67,7 +75,7 @@ export function shouldShowPreOrder(restaurant) { if (restaurant.timing.delivery.range && Array.isArray(restaurant.timing.delivery.range)) { const duration = moment.duration(moment(restaurant.timing.delivery.range[0]).diff(moment())); - return duration.asHours() > 1; + return duration.asHours() > .75; } }