aboutsummaryrefslogtreecommitdiffstats
path: root/components/Note.jsx
blob: cc5b1191d4648452ea973e7dac0d71d4493be1b6 (plain) (blame)
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
import { Pressable, StyleSheet, Text } from 'react-native'

const Note = ({ note, setEdit }) => {
  const formatDate = d => d.replace('T',' ').replace(/\..*Z/, '')

  return (
    <Pressable
      style={styles.note}
      onPress={() => setEdit(note)}
    >
      <Text style={styles.title}>{note.title}</Text>
      <Text style={styles.dates}>{`Created at: ${formatDate(note.created_at)}`}</Text>
      <Text style={styles.dates}>{`Updated at: ${formatDate(note.updated_at)}`}</Text>
    </Pressable>
  )
}

const styles = StyleSheet.create({
  note: {
    textAlign: 'left',
    padding: 15,
    width: '100%',
    backgroundColor: 'black',
  },
  title: {
    color: 'white',
    fontSize: 18,
  },
  dates: {
    color: '#bbb',
    fontSize: 10,
  },
});

export default Note