-
Notifications
You must be signed in to change notification settings - Fork 22
/
Notifications.tsx
60 lines (54 loc) · 1.47 KB
/
Notifications.tsx
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
59
60
import { DoneAll } from '@mui/icons-material'
import clsx from 'clsx'
import { useTranslation } from 'react-i18next'
import { NotificationsProps } from '@dao-dao/types'
import { NoContent, PageLoader, useAppContext } from '../components'
/**
* A component to render notifications in the inbox.
*/
export const Notifications = ({
inbox: { checked, onCheck },
InboxMainItemRenderer,
compact,
className,
}: NotificationsProps) => {
const { t } = useTranslation()
const { inbox } = useAppContext()
// Type-check, should always be loaded for dapp.
if (!inbox) {
throw new Error(t('error.loadingData'))
}
const { loading, items } = inbox
return (
<div
className={clsx('relative flex flex-col items-stretch gap-4', className)}
>
{loading ? (
<PageLoader className="mt-10" />
) : items.length === 0 ? (
<NoContent
Icon={DoneAll}
body={t('info.emptyInboxCaughtUp')}
noBorder
/>
) : (
<div className="flex grow flex-col">
{items.map((item) => (
<div
key={item.id}
className="animate-fade-in border-b border-border-secondary"
>
<InboxMainItemRenderer
key={item.id}
checked={!!checked[item.id]}
compact={compact}
item={item}
onCheck={onCheck}
/>
</div>
))}
</div>
)}
</div>
)
}