From 917d83bfb70d863944df62fb3ca254ba74e67e6e Mon Sep 17 00:00:00 2001 From: eug-vs Date: Fri, 14 Aug 2020 04:09:56 +0300 Subject: feat: add EmptyState component --- src/containers/Home/Home.tsx | 50 +++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 24 deletions(-) (limited to 'src/containers/Home/Home.tsx') diff --git a/src/containers/Home/Home.tsx b/src/containers/Home/Home.tsx index 203b380..c0ca00e 100644 --- a/src/containers/Home/Home.tsx +++ b/src/containers/Home/Home.tsx @@ -48,10 +48,10 @@ const Home: React.FC = () => { const theme = useTheme(); const isMobile = useMediaQuery(theme.breakpoints.down('sm')); - const rating = feedbacks.length && feedbacks.reduce( + const rating = feedbacks?.length ? feedbacks.reduce( (acc: number, feedback: Feedback) => acc + feedback.score, 0 - ) / feedbacks.length; + ) / feedbacks.length : 0; const handleLetsGo = () => { history.push('/feed'); @@ -70,36 +70,38 @@ const Home: React.FC = () => { const Reviews = (
- {feedbacks.map((feedback: Feedback) => )} + {feedbacks?.map((feedback: Feedback) => )}
); - const FeedbackSection = feedbacks.findIndex((feedback: Feedback) => feedback.author._id === user?._id) >= 0 ? ( + const FeedbackSection = feedbacks && feedbacks.findIndex( + (feedback: Feedback) => feedback.author._id === user?._id + ) >= 0 ? (

You have already left feedback for this version. If you have more to say, please open GitHub issue or contact us directly via email: {EmailLink}. Alternatively, you can just wait for another application patch to come out.

- ) : ( - <> -

- Here you can share your thougts about Which with us! - Note that you can ony leave feedback once per application version (there will be plenty of them later). -

- {isAuthenticated ? : ( - <> -

You must be authorized to leave feedback.

- - - )} - - ); + ) : ( + <> +

+ Here you can share your thougts about Which with us! + Note that you can ony leave feedback once per application version (there will be plenty of them later). +

+ {isAuthenticated ? : ( + <> +

You must be authorized to leave feedback.

+ + + )} + + ); return (
-- cgit v1.2.3