diff --git a/lib/src/Components/Profile/Subcomponents/InviteLinkView.tsx b/lib/src/Components/Profile/Subcomponents/InviteLinkView.tsx new file mode 100644 index 00000000..4f5cb8e2 --- /dev/null +++ b/lib/src/Components/Profile/Subcomponents/InviteLinkView.tsx @@ -0,0 +1,29 @@ +import { TextView } from '#components/Map/Subcomponents/ItemPopupComponents' + +import type { Item } from '#types/Item' + +export const InviteLinkView = ({ item }: { item: Item }) => { + // TODO Only show if user has permission to view secrets. + // usePermission() seems to be useful. + + if (!item.secrets || item.secrets.length === 0) { + console.log('No secrets found for item', item.id) + // Generate a new secret if none exists? + return + } + const link = `${window.location.origin}/invite/${item.secrets[0].secret}` + + return ( +
+

Invite

+
+ +
+
+ ) +} diff --git a/lib/src/Components/Profile/Templates/FlexView.tsx b/lib/src/Components/Profile/Templates/FlexView.tsx index 845898c3..4a32f53f 100644 --- a/lib/src/Components/Profile/Templates/FlexView.tsx +++ b/lib/src/Components/Profile/Templates/FlexView.tsx @@ -4,6 +4,7 @@ import { ContactInfoView } from '#components/Profile/Subcomponents/ContactInfoVi import { CrowdfundingView } from '#components/Profile/Subcomponents/CrowdfundingView' import { GalleryView } from '#components/Profile/Subcomponents/GalleryView' import { GroupSubHeaderView } from '#components/Profile/Subcomponents/GroupSubHeaderView' +import { InviteLinkView } from '#components/Profile/Subcomponents/InviteLinkView' import { ProfileStartEndView } from '#components/Profile/Subcomponents/ProfileStartEndView' import { ProfileTextView } from '#components/Profile/Subcomponents/ProfileTextView' @@ -17,6 +18,7 @@ const componentMap = { startEnd: ProfileStartEndView, gallery: GalleryView, crowdfundings: CrowdfundingView, + inviteLinks: InviteLinkView, // weitere Komponenten hier } diff --git a/lib/src/types/Item.d.ts b/lib/src/types/Item.d.ts index be3d6194..bcf5026e 100644 --- a/lib/src/types/Item.d.ts +++ b/lib/src/types/Item.d.ts @@ -16,6 +16,10 @@ interface GalleryItem { } } +interface ItemSecret { + secret: string +} + /** * @category Types */ @@ -53,6 +57,7 @@ export interface Item { next_appointment?: string gallery?: GalleryItem[] openCollectiveSlug?: string + secrets?: ItemSecret[] // { // coordinates: [number, number]