Commit df5f3b4 1 parent f2262f3 commit df5f3b4 Copy full SHA for df5f3b4
File tree 3 files changed +72
-2
lines changed
3 files changed +72
-2
lines changed Original file line number Diff line number Diff line change 20
20
text-align : right;
21
21
}
22
22
23
- .accounts . add-new {
23
+ .account-actions {
24
24
margin-top : 1.5em ;
25
+ margin-left : 0 ;
26
+ }
27
+
28
+ .account-actions .btn {
29
+ margin-right : 0.5em ;
25
30
}
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import Button from 'react-bootstrap/Button';
8
8
import Col from 'react-bootstrap/Col' ;
9
9
import Container from 'react-bootstrap/Container' ;
10
10
import Crumb from './Breadcrumb' ;
11
+ import ImportAccounts from './ImportAccounts' ;
11
12
import Row from 'react-bootstrap/Row' ;
12
13
13
14
export default function Accounts ( { match } ) {
@@ -67,13 +68,17 @@ export default function Accounts({ match }) {
67
68
</ Row >
68
69
) }
69
70
< Row >
70
- < Col > < Link to = { `${ match . url } /new` } className = "btn btn-primary add-new" > Add new</ Link > </ Col >
71
+ < Col className = "account-actions" >
72
+ < Link to = { `${ match . url } /new` } className = "btn btn-primary add-new" > Add new</ Link >
73
+ < Link to = { `${ match . url } /import` } className = "btn btn-secondary import" > Import</ Link >
74
+ </ Col >
71
75
</ Row >
72
76
</ Container >
73
77
</ >
74
78
} />
75
79
< Route path = { `${ match . path } /edit/:id` } component = { props => < AccountEditor updated = { accountUpdated } { ...props } /> } />
76
80
< Route path = { `${ match . path } /new` } component = { props => < NewAccount created = { accountCreated } { ...props } /> } />
81
+ < Route path = { `${ match . path } /import` } component = { Import } />
77
82
</ >
78
83
)
79
84
}
@@ -108,3 +113,12 @@ function AccountEditor({ updated, match }) {
108
113
</ >
109
114
)
110
115
}
116
+
117
+ function Import ( { match } ) {
118
+ return (
119
+ < >
120
+ < Crumb title = "Import" match = { match } />
121
+ < ImportAccounts />
122
+ </ >
123
+ )
124
+ }
Original file line number Diff line number Diff line change
1
+ import axios from 'axios' ;
2
+ import React from 'react' ;
3
+ import Button from 'react-bootstrap/Button' ;
4
+ import Col from 'react-bootstrap/Col' ;
5
+ import Container from 'react-bootstrap/Container' ;
6
+ import Form from 'react-bootstrap/Form' ;
7
+ import Row from 'react-bootstrap/Row' ;
8
+
9
+ export default function ImportAccounts ( ) {
10
+ return (
11
+ < Container >
12
+ < Row > < Col > < h2 > Import</ h2 > </ Col > </ Row >
13
+ < Row >
14
+ < Col >
15
+ < p > Import OFX or QFX files. Typically, you can download these from your financial institution's "Quicken" or "Microsoft Money" downloads.</ p >
16
+ </ Col >
17
+ </ Row >
18
+ < Form
19
+ noValidate
20
+ onSubmit = { e => {
21
+ e . preventDefault ( )
22
+ e . stopPropagation ( )
23
+ const form = e . currentTarget
24
+ if ( form . checkValidity ( ) !== false ) {
25
+ const formFiles = form . querySelector ( '[type=file]' )
26
+ const files = formFiles . files ;
27
+ if ( files . length !== 1 ) {
28
+ throw Error ( "Must provide one file to import" )
29
+ }
30
+ axios . post ( '/api/v1/import' , files [ 0 ] )
31
+ . then ( ( ) => window . location . reload ( ) )
32
+ . catch ( e => {
33
+ if ( ! e . response . data || ! e . response . data . Error ) {
34
+ throw e
35
+ }
36
+ alert ( e . response . data . Error )
37
+ } )
38
+ }
39
+ } }
40
+ >
41
+ < Form . Row >
42
+ < Form . Control type = "file" required />
43
+ </ Form . Row >
44
+
45
+ < Form . Row >
46
+ < Col > < Button type = "submit" > Import</ Button > </ Col >
47
+ </ Form . Row >
48
+ </ Form >
49
+ </ Container >
50
+ )
51
+ }
You can’t perform that action at this time.
0 commit comments