From d57011ee305e4806e5f9d933e314b806f860f82d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cosmin=20P=C3=A2rvulescu?= Date: Wed, 27 Dec 2023 18:06:07 +0200 Subject: [PATCH] chore(passport): Reflect overriden profile in Dashboard --- .../app/components/EditProfileModal/index.tsx | 11 - apps/passport/app/routes/settings.tsx | 21 ++ .../app/routes/settings/dashboard.tsx | 337 ++++++++++-------- 3 files changed, 209 insertions(+), 160 deletions(-) diff --git a/apps/passport/app/components/EditProfileModal/index.tsx b/apps/passport/app/components/EditProfileModal/index.tsx index ca95e3935d..4f7668eaf3 100644 --- a/apps/passport/app/components/EditProfileModal/index.tsx +++ b/apps/passport/app/components/EditProfileModal/index.tsx @@ -9,7 +9,6 @@ import { Input } from '@proofzero/design-system/src/atoms/form/Input' import { captureFormSubmitAndReplaceImages } from '@proofzero/design-system/src/utils/form-cf-images' import { Loader } from '@proofzero/design-system/src/molecules/loader/Loader' import { HiOutlineUpload } from 'react-icons/hi' -import { ToastType, toast } from '@proofzero/design-system/src/atoms/toast' const EditProfileModal: React.FC<{ isOpen: boolean @@ -27,16 +26,6 @@ const EditProfileModal: React.FC<{ useEffect(() => { if (fetcher.state === 'idle' && fetcher.type === 'done') { setIsOpen(false) - - if (!fetcher.data?.error) { - toast(ToastType.Success, { - message: fetcher.data.message, - }) - } else if (fetcher.data?.error) { - toast(ToastType.Error, { - message: fetcher.data.message, - }) - } } }, [fetcher]) diff --git a/apps/passport/app/routes/settings.tsx b/apps/passport/app/routes/settings.tsx index 3bb7ba4994..f2c4bbb91e 100644 --- a/apps/passport/app/routes/settings.tsx +++ b/apps/passport/app/routes/settings.tsx @@ -30,6 +30,7 @@ import { getRollupReqFunctionErrorWrapper } from '@proofzero/utils/errors' import { usePostHog } from 'posthog-js/react' import { useEffect, useState } from 'react' import { InternalServerError } from '@proofzero/errors' +import { ToastType, toast } from '@proofzero/design-system/src/atoms/toast' export type AuthorizedAppsModel = { clientId: string @@ -174,6 +175,22 @@ export default function SettingsLayout() { }, [isIdentified]) const editProfileFetcher = useFetcher() + useEffect(() => { + if ( + editProfileFetcher.state === 'idle' && + editProfileFetcher.type === 'done' + ) { + if (!editProfileFetcher.data?.error) { + toast(ToastType.Success, { + message: editProfileFetcher.data.message, + }) + } else if (editProfileFetcher.data?.error) { + toast(ToastType.Error, { + message: editProfileFetcher.data.message, + }) + } + } + }, [editProfileFetcher]) return ( @@ -212,6 +229,10 @@ export default function SettingsLayout() { connectedProfiles, primaryAccountURN, CONSOLE_URL, + pfpUrl, + displayName, + isProfileCustomized, + editProfileFetcher, }} /> diff --git a/apps/passport/app/routes/settings/dashboard.tsx b/apps/passport/app/routes/settings/dashboard.tsx index 8ca7dbbd44..c76df42732 100644 --- a/apps/passport/app/routes/settings/dashboard.tsx +++ b/apps/passport/app/routes/settings/dashboard.tsx @@ -3,7 +3,7 @@ import { Text } from '@proofzero/design-system' import SectionTitle from '~/components/typography/sectionTitle' import { AccountList } from '~/components/accounts/AccountList' -import { Link, useNavigate } from '@remix-run/react' +import { FetcherWithComponents, Link, useNavigate } from '@remix-run/react' import dashboardChart from '~/assets/dashboard_chart.svg' import type { AccountListItemProps } from '~/components/accounts/AccountListItem' @@ -15,15 +15,28 @@ import { useOutletContext } from '@remix-run/react' import type { AccountURN } from '@proofzero/urns/account' import { AuthorizedAppsModel } from '../settings' import { ToastType, toast } from '@proofzero/design-system/src/atoms/toast' -import { useEffect } from 'react' +import { useEffect, useState } from 'react' +import { TbPencil } from 'react-icons/tb' +import EditProfileModal from '~/components/EditProfileModal' export default function DashboardLayout() { - const { connectedProfiles, authorizedApps, primaryAccountURN } = - useOutletContext<{ - connectedProfiles: any[] - authorizedApps: AuthorizedAppsModel[] - primaryAccountURN: AccountURN - }>() + const { + connectedProfiles, + authorizedApps, + primaryAccountURN, + displayName, + pfpUrl, + isProfileCustomized, + editProfileFetcher, + } = useOutletContext<{ + connectedProfiles: any[] + authorizedApps: AuthorizedAppsModel[] + primaryAccountURN: AccountURN + displayName: string | undefined + pfpUrl: string | undefined + isProfileCustomized: boolean + editProfileFetcher: FetcherWithComponents + }>() const navigate = useNavigate() @@ -52,168 +65,194 @@ export default function DashboardLayout() { } }, []) + const [editProfileModalOpen, setEditProfileModalOpen] = useState(false) + return ( -
-
- - Dashboard - -
- {appErrorExists ? ( - +
+ + Welcome to Passport + + + +
+ {appErrorExists ? ( + { - navigate('/settings/applications') - }} - /> - ) : null} -
{ + navigate('/settings/applications') + }} + /> + ) : null} +
-
-
- -
+
+ +
- - Coming Soon - -
-
- -
-
- - - - - Edit + style={{ + background: `url(${dashboardChart}), #FFFFFF`, + backgroundRepeat: 'no-repeat', + backgroundPosition: 'bottom', + backgroundSize: 'contain', + }} + > + + Coming Soon - +
- -
-
-
- - {authorizedApps.length === 0 ? ( - - ) : ( -
-
- - APPLICATION - - - AUTHORIZED - +
+
+ + + + + Edit + +
-
- {authorizedApps.map((a) => ( -
+
+
+
+ + {authorizedApps.length === 0 ? ( + + ) : ( +
+
+ + APPLICATION + + -
- app icon - {a.title ? ( - - {a.title} - - ) : null} - {a.appDataError || a.appScopeError ? ( - + {authorizedApps.map((a) => ( +
+
+ app icon + {a.title ? ( + + {a.title} + + ) : null} + {a.appDataError || a.appScopeError ? ( + - Data Error - - ) : null} -
+ > + Data Error + + ) : null} +
+ + {new Date(a.timestamp).toLocaleString('default', { + day: '2-digit', + month: 'short', + year: 'numeric', + hour: '2-digit', + minute: '2-digit', + second: '2-digit', + })} + + + ))} +
+ +
+
+
+ +
+ - {new Date(a.timestamp).toLocaleString('default', { - day: '2-digit', - month: 'short', - year: 'numeric', - hour: '2-digit', - minute: '2-digit', - second: '2-digit', - })} + View All - - ))} + +
- -
-
-
- -
- - - View All - - -
-
- )} + )} +
-
+ ) }