-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconstants.js
More file actions
36 lines (32 loc) · 1.12 KB
/
Copy pathconstants.js
File metadata and controls
36 lines (32 loc) · 1.12 KB
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
export const BACKEND_URL = 'http://10.0.2.2:5002'
// export const BACKEND_URL = 'https://naughty-outerwear-wasp.cyclic.app' || process.env.REACT_APP_BACKEND_URL || 'http://10.0.2.2:5002'
export const FRONTEND_URL = process.env.REACT_APP_FRONTEND_URL || 'http://10.0.2.2:3000'
export const ErrorMessage = (error) => {
return error.response && error.response?.data?.msg
? error.response.data.msg
: error.message
}
export const getDateString = (date) => {
var seconds = Math.floor((new Date() - date) / 1000)
var interval = seconds / 31536000
if (interval > 1) {
return Math.floor(interval) + ' years ago'
}
interval = seconds / 2592000
if (interval > 1) {
return Math.floor(interval) + ' month ago'
}
interval = seconds / 86400
if (interval > 1) {
return Math.floor(interval) + ' days ago'
}
interval = seconds / 3600
if (interval > 1) {
return Math.floor(interval) + ' hour ago'
}
interval = seconds / 60
if (interval > 1) {
return Math.floor(interval) + ' mins ago'
}
return Math.floor(seconds) + ' secs ago'
}