-
Notifications
You must be signed in to change notification settings - Fork 0
/
EntryDetails.js
73 lines (62 loc) · 1.46 KB
/
EntryDetails.js
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
61
62
63
64
65
66
67
68
69
70
71
72
73
import React from 'react';
import { styled, View, Text, Button } from 'bappo-components';
import BorderButton from './components/BorderButton';
const EntryDetails = ({
entry,
entryModel,
fetchList,
$popup,
}) => {
const updateEntry = async (data) => {
await entryModel.update(data);
fetchList();
}
const deleteEntry = async () => {
await entryModel.destroyById(entry.id);
fetchList();
}
const openEditForm = () => {
$popup.form({
formKey: 'TimesheetEntryForm',
initialValues: entry,
onSubmit: updateEntry,
});
}
return (
<Container>
<NameContainer>
<FieldName>Notes</FieldName>
</NameContainer>
<ValueContainer>
<Text>{entry.notes}</Text>
<ButtonsContainer>
<MarginedButton onPress={openEditForm}><Text>Edit</Text></MarginedButton>
<BorderButton onPress={deleteEntry}><Text>Delete</Text></BorderButton>
</ButtonsContainer>
</ValueContainer>
</Container>
);
};
export default EntryDetails;
const Container = styled(View)`
margin: 20px;
flex-direction: row;
`;
const NameContainer = styled(View)`
flex-basis: 30%;
align-items: flex-end;
`;
const FieldName = styled(Text)`
font-weight: bold;
margin-right: 20px;
`;
const ValueContainer = styled(View)`
flex-basis: 70%;
`;
const ButtonsContainer = styled(View)`
flex-direction: row;
margin-top: 20px;
`;
const MarginedButton = styled(BorderButton)`
margin-right: 15px;
`;