import React from 'react'; import { BusinessReviews as BusinessReviewController, useLanguage, useOrder, } from 'ordering-components/native'; import { useTheme } from 'styled-components/native'; import IconAntDesign from 'react-native-vector-icons/AntDesign'; import { View, StyleSheet } from 'react-native'; import { OIcon, OInput, OText } from '../shared'; import { BusinessReviewsContainer, ScoreView, BusinessReviewContent, WrapCustomerReview, WrapCustomerReviewTotal, StarPointsView, ReviewSearchView, ReviewProgressView, PrincipalWrapView, } from './styles'; import { BusinessReviewsParams } from '../../types'; import { ProgressBar, TouchableRipple } from 'react-native-paper'; import moment from 'moment'; const BusinessReviewsUI = (props: BusinessReviewsParams) => { const { reviewsList, businessState, handleChangeSearch, } = props; const [, t] = useLanguage(); const theme = useTheme(); const [orderState] = useOrder(); const styles = StyleSheet.create({ starIcon: { marginRight: 5, }, reviewScoreStyle: { flexDirection: 'row', alignItems: 'center', justifyContent: 'center', }, wrapTotalScoresStyle: { maxHeight: 80, height: 80, marginBottom: 20, }, progress: { borderRadius: 5, height: 4, backgroundColor: theme.colors.backgroundGray200, marginVertical: 9, }, progressLabel: { flexDirection: 'row', justifyContent: 'space-between', }, }); const Score = ({ star, text }: any) => ( {star} {text} ); const PrincipalComments = ({ comments }: any) => ( {comments.map((txt: string, idx: number) => ( {txt} ))} ); const ReviewItem = ({ comment, created_at, total, customer }: any) => ( {customer?.name || 'Jane Cooper'} {moment(created_at).format('MMMM d, yyyy • hh:mm')} {comment} ); return ( {reviewsList.error ? ( {t('ERROR_UNKNOWN', 'An error has ocurred')} ) : ( <> 0 ? theme.colors.primary : theme.colors.disabled } /> {`${businessState?.business?.reviews?.total || 0 } (${reviewsList?.reviews?.length || 0} ${t( 'REVIEWS', 'reviews', )})`} {t('REVIEW_ORDER', 'Review order')} {t('REVIEW_TERRIBLE', 'Terrible')} {t('REVIEW_BAD', 'Bad')} {t('REVIEW_OKAY', 'Okay')} {t('REVIEW_GOOD', 'Good')} = 4.5 ? theme.colors.textNormal : theme.colors.backgroundGray400 }> {t('REVIEW_GREAT', 'Great')} {/* {t('PRINCIPAL_COMMENTS', 'Principal comments')} */} {reviewsList?.reviews.map((review: any) => ( ))} )} {!reviewsList.loading && reviewsList?.reviews.length === 0 && ( {t('REVIEWS_NOT_FOUND', 'Reviews Not Found')} )} ); }; export const BusinessReviews = (props: any) => { const BusinessReviewProps = { ...props, UIComponent: BusinessReviewsUI, }; return ; };