Add component to show invite link (WIP)

This commit is contained in:
Maximilian Harz 2025-06-23 23:45:55 +02:00
parent 13612c56aa
commit 3ce71da9ff
3 changed files with 36 additions and 0 deletions

View File

@ -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 (
<div className='tw:my-10 tw:mt-2 tw:px-6'>
<h2 className='tw:text-lg tw:font-semibold'>Invite</h2>
<div className='tw:mt-2 tw:text-sm'>
<input
type='text'
value={link}
readOnly
className='tw:w-full tw:mb-2 tw:p-2 tw:border tw:rounded'
/>
</div>
</div>
)
}

View File

@ -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
}

View File

@ -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]