|
1
|
import axios from "axios"; |
|
2
|
import Firebase from "../components/Firebase"; |
|
3
|
import { Path } from "./routes"; |
|
4
|
|
|
5
|
axios.defaults.baseURL = 'https://api.musik88.com/api/v1/'; |
|
6
|
|
|
7
|
export const getHome = (path: Path, firebase: Firebase) => { |
|
8
|
return Promise.all([ |
|
9
|
firebase.whoAmIRef().once('value'), |
|
10
|
axios.get(`/carousel`), |
|
11
|
]).then((values) => { |
|
12
|
const whoAmI = values[0].val(); |
|
13
|
const files = values[1].data.audio_files; |
|
14
|
const obj = { |
|
15
|
path: path, |
|
16
|
data: { |
|
17
|
whoAmI: whoAmI, |
|
18
|
carousel: files |
|
19
|
} |
|
20
|
}; |
|
21
|
return obj; |
|
22
|
}); |
|
23
|
} |
|
24
|
|
|
25
|
export const getAbout = (path: Path, firebase: Firebase) => { |
|
26
|
return firebase |
|
27
|
.aboutRef() |
|
28
|
.once('value') |
|
29
|
.then((snapshot) => { |
|
30
|
return { |
|
31
|
path: path, |
|
32
|
data: snapshot.val() |
|
33
|
} |
|
34
|
}); |
|
35
|
} |
|
36
|
|
|
37
|
export const getContact = (path: Path, firebase: Firebase) => { |
|
38
|
return firebase |
|
39
|
.contactRef() |
|
40
|
.once('value') |
|
41
|
.then((snapshot) => { |
|
42
|
return { |
|
43
|
path: path, |
|
44
|
data: snapshot.val() |
|
45
|
} |
|
46
|
}); |
|
47
|
} |
|
48
|
|
|
49
|
export const getCv = (path: Path, firebase: Firebase) => { |
|
50
|
return firebase |
|
51
|
.cvRef() |
|
52
|
.once('value') |
|
53
|
.then((snapshot) => { |
|
54
|
return { |
|
55
|
path: path, |
|
56
|
data: snapshot.val() |
|
57
|
} |
|
58
|
}); |
|
59
|
} |