From 77014f0d36b6f1041cf098b3cfc8e1e5fe615cf8 Mon Sep 17 00:00:00 2001 From: Frank Johnson Date: Wed, 13 Oct 2021 17:03:44 -0400 Subject: [PATCH] Added recent projects list to logged-in nav --- .../ProfileSlashLogin/ProfileSlashLogin.tsx | 33 ++++++++++++++----- app/web/src/components/Projects/Projects.tsx | 23 +++++++++++-- .../components/ProjectsCell/ProjectsCell.tsx | 8 +++-- .../ProjectsOfUserCell/ProjectsOfUserCell.tsx | 16 +++++++-- app/web/src/layouts/MainLayout/MainLayout.js | 19 ++++++++--- 5 files changed, 78 insertions(+), 21 deletions(-) diff --git a/app/web/src/components/ProfileSlashLogin/ProfileSlashLogin.tsx b/app/web/src/components/ProfileSlashLogin/ProfileSlashLogin.tsx index 055eeed..f4102a4 100644 --- a/app/web/src/components/ProfileSlashLogin/ProfileSlashLogin.tsx +++ b/app/web/src/components/ProfileSlashLogin/ProfileSlashLogin.tsx @@ -8,6 +8,7 @@ import { ImageFallback } from 'src/components/ImageUploader' import useUser from 'src/helpers/hooks/useUser' import LoginModal from 'src/components/LoginModal' import Gravatar from 'src/components/Gravatar/Gravatar' +import ProjectsOfUserCell from 'src/components/ProjectsOfUserCell' const ProfileSlashLogin = () => { const { logOut, isAuthenticated, currentUser, client } = useAuth() @@ -58,25 +59,39 @@ const ProfileSlashLogin = () => { {currentUser && ( - -

- Hello {user?.name} -

- -
+

+ Hello {user?.name} +

+ +
View Your Profile
Logout +
+

+ Recent Projects +

+
)} diff --git a/app/web/src/components/Projects/Projects.tsx b/app/web/src/components/Projects/Projects.tsx index 22e216a..14d541e 100644 --- a/app/web/src/components/Projects/Projects.tsx +++ b/app/web/src/components/Projects/Projects.tsx @@ -11,6 +11,7 @@ const ProjectsList = ({ projects, shouldFilterProjectsWithoutImage = false, projectLimit = 80, + isMinimal = false, }) => { // temporary filtering projects that don't have images until some kind of search is added and there are more things on the website // it helps avoid the look of the website just being filled with dumby data. @@ -23,7 +24,7 @@ const ProjectsList = ({ ? projects .filter(({ mainImage }) => mainImage) .slice(0, projectLimit || 80) - : [...projects] + : [...projects].slice(0, projectLimit || 80) ) // sort should probably be done on the service, but the filtering is temp too .sort( @@ -33,7 +34,7 @@ const ProjectsList = ({ [projects, shouldFilterProjectsWithoutImage] ) - return ( + return !isMinimal ? (
+ ) : ( +
+ +
) } diff --git a/app/web/src/components/ProjectsCell/ProjectsCell.tsx b/app/web/src/components/ProjectsCell/ProjectsCell.tsx index 4acb694..cccc6fe 100644 --- a/app/web/src/components/ProjectsCell/ProjectsCell.tsx +++ b/app/web/src/components/ProjectsCell/ProjectsCell.tsx @@ -27,26 +27,30 @@ export const QUERY = gql` export const Loading = () =>
Loading...
-export const Empty = () => { - return ( +export const Empty = ({ isMinimal = false }) => { + return !isMinimal ? (
{'No projects yet. '} {'Create one?'}
+ ) : ( +

None yet!

) } export const Success = ({ projects, variables: { shouldFilterProjectsWithoutImage, projectLimit }, + isMinimal = false, }) => { return ( ) } diff --git a/app/web/src/components/ProjectsOfUserCell/ProjectsOfUserCell.tsx b/app/web/src/components/ProjectsOfUserCell/ProjectsOfUserCell.tsx index b3a7b22..bddd1c2 100644 --- a/app/web/src/components/ProjectsOfUserCell/ProjectsOfUserCell.tsx +++ b/app/web/src/components/ProjectsOfUserCell/ProjectsOfUserCell.tsx @@ -15,6 +15,7 @@ export const QUERY = gql` createdAt updatedAt user { + id image userName } @@ -27,18 +28,27 @@ export const QUERY = gql` export const Loading = () =>
Loading...
-export const Empty = () => { - return
No projects yet.
+export const Empty = ({ isMinimal = false }) => { + return ( +

+ No projects yet. +

+ ) } export const Success = ({ projects, - variables: { shouldFilterProjectsWithoutImage }, + variables: { userName }, + shouldFilterProjectsWithoutImage = false, + projectLimit = 80, + isMinimal = false, }) => { return ( ) } diff --git a/app/web/src/layouts/MainLayout/MainLayout.js b/app/web/src/layouts/MainLayout/MainLayout.js index 5dfaeea..d4c65e1 100644 --- a/app/web/src/layouts/MainLayout/MainLayout.js +++ b/app/web/src/layouts/MainLayout/MainLayout.js @@ -16,6 +16,7 @@ import Svg from 'src/components/Svg' import { ImageFallback } from 'src/components/ImageUploader' import useUser from 'src/helpers/hooks/useUser' import './MainLayout.css' +import ProjectsOfUserCell from 'src/components/ProjectsOfUserCell' let previousSubmission = '' @@ -130,13 +131,12 @@ const MainLayout = ({ children, shouldRemoveFooterInIde }) => { {currentUser && ( -

+

Hello {user?.name} -

+

-
View Your Profile
@@ -144,10 +144,19 @@ const MainLayout = ({ children, shouldRemoveFooterInIde }) => { Logout +
+

+ Recent Projects +

+
)}