mirror of
https://github.com/utopia-os/utopia-ui.git
synced 2025-12-13 07:46:10 +00:00
Add component to show invite link (WIP)
This commit is contained in:
parent
13612c56aa
commit
3ce71da9ff
29
lib/src/Components/Profile/Subcomponents/InviteLinkView.tsx
Normal file
29
lib/src/Components/Profile/Subcomponents/InviteLinkView.tsx
Normal 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>
|
||||
)
|
||||
}
|
||||
@ -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
|
||||
}
|
||||
|
||||
|
||||
5
lib/src/types/Item.d.ts
vendored
5
lib/src/types/Item.d.ts
vendored
@ -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]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user