-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathReadAccessAssociation.tsx
More file actions
58 lines (53 loc) · 2.41 KB
/
Copy pathReadAccessAssociation.tsx
File metadata and controls
58 lines (53 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import { type ReadAccessRequestAssociationSchema, type Association, type Timeline } from '@concrnt/worldlib'
import { ContentWithCCAvatar } from '../ContentWithCCAvatar'
import { Box, Typography } from '@mui/material'
import { TimeDiff } from '../ui/TimeDiff'
import { type ReactElement, useEffect, useState } from 'react'
import { TimelineChip } from '../ui/TimelineChip'
import { useClient } from '../../context/ClientContext'
import { WatchRequestAcceptButton } from '../WatchRequestAccpetButton'
import { CCLink } from '../ui/CCLink'
import { Trans } from 'react-i18next'
export interface ReadAccessAssociationProps {
association: Association<ReadAccessRequestAssociationSchema>
}
export const ReadAccessAssociation = (props: ReadAccessAssociationProps): ReactElement => {
const { client } = useClient()
const [timeline, setTimeline] = useState<Timeline<any> | null>(null)
useEffect(() => {
client.getTimeline(props.association.target).then(setTimeline)
}, [props.association])
return (
<ContentWithCCAvatar author={props.association.authorUser} profile={props.association.authorProfile}>
<Box display="flex" justifyContent="space-between">
<Typography>
<Trans
i18nKey="pages.associations.readAccessRequest"
components={{
username: (
<CCLink to={`/${props.association.author}`}>
{props.association.authorProfile.username}
</CCLink>
),
timeline: (
<TimelineChip timelineFQID={props.association.target + '@' + props.association.owner} />
)
}}
/>
</Typography>
<TimeDiff date={new Date(props.association.cdate)} />
</Box>
<Box>
{timeline && (
<Box
onClick={(e) => {
e.stopPropagation() // prevent to navigate other page
}}
>
<WatchRequestAcceptButton noAvatar request={props.association} targetTimeline={timeline} />
</Box>
)}
</Box>
</ContentWithCCAvatar>
)
}