2021-02-15 12:33:47 +00:00
|
|
|
import { Card, Text } from '@ui-kitten/components'
|
|
|
|
import { DateTime } from 'luxon'
|
|
|
|
import React, { useState } from 'react'
|
|
|
|
import { StyleSheet, View } from 'react-native'
|
|
|
|
import { ModalWebView } from './modalWebView.component'
|
2021-01-26 11:02:24 +00:00
|
|
|
|
2021-02-15 12:33:47 +00:00
|
|
|
export const Notification = ({ item }) => {
|
2021-01-26 11:02:24 +00:00
|
|
|
const [isOpen, setIsOpen] = useState(false)
|
|
|
|
const open = () => setIsOpen(true)
|
|
|
|
const close = () => setIsOpen(false)
|
|
|
|
|
2021-02-07 16:14:45 +00:00
|
|
|
const displayDate = DateTime.fromISO(item.dateCreated).toRelative({
|
|
|
|
locale: 'sv',
|
|
|
|
})
|
2021-01-26 12:39:22 +00:00
|
|
|
|
2021-01-26 11:02:24 +00:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<Card
|
|
|
|
style={styles.card}
|
|
|
|
onPress={open}
|
|
|
|
header={(headerProps) => (
|
2021-02-07 16:14:45 +00:00
|
|
|
<View {...headerProps}>
|
2021-01-26 12:39:22 +00:00
|
|
|
<Text category="h6">{item.sender}</Text>
|
|
|
|
<Text category="s1">
|
2021-02-15 11:11:22 +00:00
|
|
|
{item.category ? item.category : ''}
|
|
|
|
{item.category && displayDate ? ' ' : ''}
|
|
|
|
{displayDate ? `(${displayDate})` : ''}
|
2021-01-26 12:39:22 +00:00
|
|
|
</Text>
|
2021-01-26 11:02:24 +00:00
|
|
|
</View>
|
2021-02-15 12:33:47 +00:00
|
|
|
)}
|
|
|
|
>
|
2021-01-26 12:39:22 +00:00
|
|
|
<Text>{item.message}</Text>
|
2021-01-26 11:02:24 +00:00
|
|
|
</Card>
|
2021-02-07 16:14:45 +00:00
|
|
|
{isOpen && <ModalWebView url={item.url} onClose={close} />}
|
2021-01-26 11:02:24 +00:00
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
card: {
|
|
|
|
flex: 1,
|
|
|
|
margin: 2,
|
|
|
|
},
|
|
|
|
})
|