1
- import React , { useEffect } from " react" ;
2
- import { useDispatch } from " react-redux" ;
3
- import { BrowserRouter as Router , Switch , Route } from " react-router-dom" ;
4
- import { RxChangeEvent } from " rxdb" ;
1
+ import React , { useEffect } from ' react'
2
+ import { useDispatch } from ' react-redux'
3
+ import { BrowserRouter as Router , Switch , Route } from ' react-router-dom'
4
+ import { RxChangeEvent } from ' rxdb'
5
5
6
- import Background from " ./components/Background" ;
7
- import Nav from " ./components/Nav" ;
8
- import Dashboard from " ./routes/Dashboard" ;
6
+ import Background from ' ./components/Background'
7
+ import Nav from ' ./components/Nav'
8
+ import Dashboard from ' ./routes/Dashboard'
9
9
10
- import DBSchema from " ./db/schema" ;
11
- import * as DBModel from " ./db/model" ;
12
- import * as WorkActions from " ./features/work/actions" ;
13
- import { createDB , createSchema , populateDB } from " ./db" ;
10
+ import DBSchema from ' ./db/schema'
11
+ import * as DBModel from ' ./db/model'
12
+ import * as WorkActions from ' ./features/work/actions'
13
+ import { createDB , createSchema , populateDB } from ' ./db'
14
14
15
- import workExperienceData from " ./assets/data/db/WorkExperience.model" ;
16
- import companyData from " ./assets/data/db/Company.model" ;
17
- import locationData from " ./assets/data/db/Location.model" ;
18
- import positionData from " ./assets/data/db/Position.model" ;
19
- import technologyData from " ./assets/data/db/Technology.model" ;
20
- import contractTypeData from " ./assets/data/db/ContractType.model" ;
21
- import projectData from " ./assets/data/db/Project.model" ;
22
- import " ./App.scss" ;
15
+ import workExperienceData from ' ./assets/data/db/WorkExperience.model'
16
+ import companyData from ' ./assets/data/db/Company.model'
17
+ import locationData from ' ./assets/data/db/Location.model'
18
+ import positionData from ' ./assets/data/db/Position.model'
19
+ import technologyData from ' ./assets/data/db/Technology.model'
20
+ import contractTypeData from ' ./assets/data/db/ContractType.model'
21
+ import projectData from ' ./assets/data/db/Project.model'
22
+ import ' ./App.scss'
23
23
24
- function App ( ) {
25
- const dispatch = useDispatch ( ) ;
24
+ function App ( ) {
25
+ const dispatch = useDispatch ( )
26
26
27
27
useEffect ( ( ) => {
28
- const dbP : Promise < DBModel . TPortfolioDatabase > = createDB ( ) ;
29
- let dbRef : DBModel . TPortfolioDatabase ;
28
+ const dbP : Promise < DBModel . TPortfolioDatabase > = createDB ( )
29
+ let dbRef : DBModel . TPortfolioDatabase
30
30
31
31
dbP . then (
32
32
( db : DBModel . TPortfolioDatabase ) => {
33
- dbRef = db ;
34
- const schemaP : Promise < DBModel . TPortfolioCollection > = createSchema ( db ) ;
33
+ dbRef = db
34
+ const schemaP : Promise < DBModel . TPortfolioCollection > = createSchema ( db )
35
35
36
36
schemaP . then (
37
37
( dbSchema : DBModel . TPortfolioCollection ) => {
@@ -45,45 +45,45 @@ function App() {
45
45
position : WorkActions . updatePosition ,
46
46
technology : WorkActions . updateTechnology ,
47
47
contract_type : WorkActions . updateContractType ,
48
- project : WorkActions . updateProject ,
49
- } ;
48
+ project : WorkActions . updateProject
49
+ }
50
50
51
51
dbSchema [ schema ] . $ . subscribe ( ( changeEvent : RxChangeEvent ) => {
52
- const payload = changeEvent . rxDocument . toJSON ( ) ;
52
+ const payload = changeEvent . rxDocument . toJSON ( )
53
53
54
54
dispatch (
55
55
actions [
56
56
changeEvent . collectionName as DBModel . TPortfolioCollectionKey
57
57
] ( payload )
58
- ) ;
59
- } ) ;
58
+ )
59
+ } )
60
60
populateDB ( dbSchema , {
61
61
workExperienceData,
62
62
companyData,
63
63
locationData,
64
64
positionData,
65
65
technologyData,
66
66
contractTypeData,
67
- projectData,
68
- } ) ;
69
- } ) ;
67
+ projectData
68
+ } )
69
+ } )
70
70
} ,
71
71
( err : any ) => {
72
- console . dir ( err ) ;
72
+ console . dir ( err )
73
73
}
74
- ) ;
74
+ )
75
75
} ,
76
76
( { code } ) => {
77
- console . dir ( code ) ;
77
+ console . dir ( code )
78
78
}
79
- ) ;
79
+ )
80
80
81
81
return ( ) => {
82
- dbRef ?. remove ( ) ;
82
+ dbRef ?. remove ( )
83
83
84
- return void null ;
85
- } ;
86
- } , [ dispatch ] ) ;
84
+ return void null
85
+ }
86
+ } , [ dispatch ] )
87
87
88
88
return (
89
89
< Router >
@@ -96,7 +96,7 @@ function App() {
96
96
</ Route >
97
97
</ Switch >
98
98
</ Router >
99
- ) ;
99
+ )
100
100
}
101
101
102
- export default App ;
102
+ export default App
0 commit comments