Skip to content

Commit 554a51b

Browse files
committed
moved readable to common
1 parent dce4f2a commit 554a51b

File tree

3 files changed

+24
-11
lines changed

3 files changed

+24
-11
lines changed

packages/common/src/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { ServicesProvider, useServices } from './contexts/ServicesContext.js'
1616
// utils
1717
import { getUrl } from './utils/urls'
1818
import timeUtils from './utils/time'
19+
import errorUtils from './utils/errors'
1920

2021
// components
2122
import AutocompleteInput from './components/AutocompleteInput'
@@ -33,7 +34,7 @@ import linesVector from './assets/images/lines.png'
3334
export {
3435
jwtService, rpcClient,
3536
ServicesProvider, useServices,
36-
getUrl, timeUtils,
37+
getUrl, timeUtils, errorUtils,
3738
AutocompleteInput, Login, Footer, FooterLink, Navbar, NavbarLink, Alert, Loading,
3839
linesVector
3940
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
/**
3+
* Copyright (c) Kernel
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*
8+
*/
9+
10+
const readable = (error) => {
11+
if (error.toLowerCase().indexOf('consent') > 0) {
12+
return 'You need to share your profile data in order to view recommendations.'
13+
}
14+
if (error.toLowerCase().indexOf('profile') > 0) {
15+
return 'You need to create your profile first in order to view recommendations.'
16+
}
17+
return 'You need to refresh your auth token by reloading this page.'
18+
}
19+
20+
export default { readable }

packages/explorer/src/views/Browse.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import { useEffect, useReducer } from 'react'
1010
import { useNavigate } from 'react-router-dom'
11-
import { useServices, timeUtils, Navbar, Footer } from '@kernel/common'
11+
import { useServices, timeUtils, errorUtils, Navbar, Footer } from '@kernel/common'
1212

1313
import AppConfig from 'App.config'
1414

@@ -33,15 +33,7 @@ const reducer = (state, action) => {
3333

3434
const { humanize } = timeUtils
3535

36-
const readable = (error) => {
37-
if (error.toLowerCase().indexOf('consent') > 0) {
38-
return 'You need to share your profile data in order to view recommendations.'
39-
}
40-
if (error.toLowerCase().indexOf('profile') > 0) {
41-
return 'You need to create your profile first in order to view recommendations.'
42-
}
43-
return 'You need to refresh your auth token by reloading this page.'
44-
}
36+
const { readable } = errorUtils
4537

4638
const Page = () => {
4739
const [state, dispatch] = useReducer(reducer, INITIAL_STATE)

0 commit comments

Comments
 (0)