From eeb55832e14bf01518b8ab533ee2f6b627947a74 Mon Sep 17 00:00:00 2001 From: Anton Tranelis Date: Tue, 16 Dec 2025 10:40:24 +0100 Subject: [PATCH] adjust invitepage --- lib/src/Components/AppShell/AppShell.tsx | 1 + lib/src/Components/AppShell/SetAppState.tsx | 6 ++ .../Components/AppShell/hooks/useAppState.tsx | 2 + lib/src/Components/Onboarding/InvitePage.tsx | 53 +++++++++------- .../Profile/Subcomponents/RelationsView.tsx | 60 ++++++++++++------- 5 files changed, 76 insertions(+), 46 deletions(-) diff --git a/lib/src/Components/AppShell/AppShell.tsx b/lib/src/Components/AppShell/AppShell.tsx index 4e2a9c34..8890ab88 100644 --- a/lib/src/Components/AppShell/AppShell.tsx +++ b/lib/src/Components/AppShell/AppShell.tsx @@ -28,6 +28,7 @@ export function AppShell({
{ const setAppState = useSetAppState() + useEffect(() => { + setAppState({ appName }) + }, [appName, setAppState]) + useEffect(() => { setAppState({ assetsApi }) }, [assetsApi, setAppState]) diff --git a/lib/src/Components/AppShell/hooks/useAppState.tsx b/lib/src/Components/AppShell/hooks/useAppState.tsx index c31086ed..c11d4b6d 100644 --- a/lib/src/Components/AppShell/hooks/useAppState.tsx +++ b/lib/src/Components/AppShell/hooks/useAppState.tsx @@ -4,6 +4,7 @@ import { useCallback, useState, createContext, useContext } from 'react' import type { AssetsApi } from '#types/AssetsApi' interface AppState { + appName: string assetsApi: AssetsApi sideBarOpen: boolean sideBarSlim: boolean @@ -16,6 +17,7 @@ interface AppState { type UseAppManagerResult = ReturnType const initialAppState: AppState = { + appName: '', assetsApi: {} as AssetsApi, sideBarOpen: false, sideBarSlim: false, diff --git a/lib/src/Components/Onboarding/InvitePage.tsx b/lib/src/Components/Onboarding/InvitePage.tsx index d0e55ff4..037ea0b1 100644 --- a/lib/src/Components/Onboarding/InvitePage.tsx +++ b/lib/src/Components/Onboarding/InvitePage.tsx @@ -2,6 +2,7 @@ import { useEffect, useState } from 'react' import { useNavigate, useParams } from 'react-router-dom' import { toast } from 'react-toastify' +import { useAppState } from '#components/AppShell/hooks/useAppState' import { useAuth } from '#components/Auth/useAuth' import { useUpdateItem } from '#components/Map/hooks/useItems' import { useMyProfile } from '#components/Map/hooks/useMyProfile' @@ -24,6 +25,7 @@ export function InvitePage({ inviteApi, itemsApi }: Props) { const { id } = useParams<{ id: string }>() const navigate = useNavigate() const updateItem = useUpdateItem() + const { appName } = useAppState() const { myProfile, isUserProfileLayerLoaded, createEmptyProfile } = useMyProfile() @@ -172,23 +174,25 @@ export function InvitePage({ inviteApi, itemsApi }: Props) { if (isAuthenticated) { return ( -

Confirmation

+

Confirmation

{invitingProfile ? ( -
-

+ <> +

Do you want to follow {invitingProfile.name}?

-
- - +
-
+ ) : ( -

Validating invite...

+
+ +
)}
) @@ -196,25 +200,28 @@ export function InvitePage({ inviteApi, itemsApi }: Props) { return ( -

Invitation

{invitingProfile ? ( -
-

Welcome to Utopia!

-

- You have been invited by: {invitingProfile.name} to join the Utopia - community. + <> +

+ Welcome{appName && <> to {appName}}! +

+

+ You have been invited by {invitingProfile.name} to join{' '} + {appName || 'the community'}.

-
- - +
-
+ ) : ( -

Validating invite...

+
+ +
)}
) diff --git a/lib/src/Components/Profile/Subcomponents/RelationsView.tsx b/lib/src/Components/Profile/Subcomponents/RelationsView.tsx index a1fc1f02..c495d013 100644 --- a/lib/src/Components/Profile/Subcomponents/RelationsView.tsx +++ b/lib/src/Components/Profile/Subcomponents/RelationsView.tsx @@ -1,7 +1,9 @@ +import { MapPinIcon } from '@heroicons/react/24/solid' import { Link } from 'react-router-dom' import { useAppState } from '#components/AppShell/hooks/useAppState' import { useItems } from '#components/Map/hooks/useItems' +import { useReverseGeocode } from '#components/Map/hooks/useReverseGeocode' import type { Item } from '#types/Item' @@ -13,6 +15,35 @@ interface Props { hideWhenEmpty?: boolean } +function RelationCard({ item }: { item: Item }) { + const appState = useAppState() + const avatar = item.image ? appState.assetsApi.url + item.image : null + + const { address } = useReverseGeocode( + item.position?.coordinates as [number, number] | undefined, + true, + 'municipality', + ) + + return ( + + {avatar && ( +
+
+ {item.name +
+
+ )} +
+
{item.name}
+
+ + ) +} + export const RelationsView = ({ item, relation, @@ -21,7 +52,6 @@ export const RelationsView = ({ hideWhenEmpty = true, }: Props) => { const items = useItems() - const appState = useAppState() if (!item.relations) return @@ -60,32 +90,16 @@ export const RelationsView = ({ } return ( -
-

{heading}

+
+

{heading}

{hasRelatedItems ? ( -
    +
    {relatedItems.map((relatedItem) => ( -
  • - -
    - {relatedItem.image ? ( - - ) : ( -
    - )} -
    -
    -
    {relatedItem.name}
    -
    - -
  • + ))} -
+
) : ( -

No related items found.

+

No related items found.

)}
)