import React, { useEffect, useState } from 'react'; import { BusinessReviews as BusinessReviewController, useLanguage, useOrder, useUtils } 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'; import { setLocalMoment } from '../../utils'; const BusinessReviewsUI = (props: BusinessReviewsParams) => { const { businessState, reviewsList } = props; const [, t] = useLanguage(); const theme = useTheme(); const [searchReview, setSearchReview] = useState('') const [orderState] = useOrder(); const [{ parseDate }] = useUtils() 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 }: any) => ( {parseDate(created_at, { outputFormat: 'MMMM D, YYYY • hh:mm A' })} {comment} ); useEffect(() => { setLocalMoment(moment, t) }, []) 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', )})`} setSearchReview(txt)} /> {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 .filter((review: any) => searchReview !== '' ? review.comment?.toLowerCase()?.includes(searchReview?.toLowerCase()) : true) .map((review: any) => ( ))} )} {reviewsList?.reviews .filter((review: any) => searchReview !== '' ? review.comment?.toLowerCase()?.includes(searchReview?.toLowerCase()) : true).length === 0 && ( {t('REVIEWS_NOT_FOUND', 'Reviews Not Found')} )} ); }; export const BusinessReviews = (props: any) => { const BusinessReviewProps = { ...props, UIComponent: BusinessReviewsUI, }; return ; };