diff --git a/client/src/actions/index.js b/client/src/actions/index.js index 3087c47d..28c2a713 100644 --- a/client/src/actions/index.js +++ b/client/src/actions/index.js @@ -213,6 +213,21 @@ export const getClients = () => async (dispatch) => { } }; +export const getProfileRequest = createAction('GET_PROFILE_REQUEST'); +export const getProfileFailure = createAction('GET_PROFILE_FAILURE'); +export const getProfileSuccess = createAction('GET_PROFILE_SUCCESS'); + +export const getProfile = () => async (dispatch) => { + dispatch(getProfileRequest()); + try { + const profile = await apiClient.getProfile(); + dispatch(getProfileSuccess(profile)); + } catch (error) { + dispatch(addErrorToast({ error })); + dispatch(getProfileFailure()); + } +}; + export const dnsStatusRequest = createAction('DNS_STATUS_REQUEST'); export const dnsStatusFailure = createAction('DNS_STATUS_FAILURE'); export const dnsStatusSuccess = createAction('DNS_STATUS_SUCCESS'); @@ -224,6 +239,7 @@ export const getDnsStatus = () => async (dispatch) => { dispatch(dnsStatusSuccess(dnsStatus)); dispatch(getVersion()); dispatch(getTlsStatus()); + dispatch(getProfile()); } catch (error) { dispatch(addErrorToast({ error })); dispatch(dnsStatusFailure()); diff --git a/client/src/api/Api.js b/client/src/api/Api.js index c5ced2b8..470577a8 100644 --- a/client/src/api/Api.js +++ b/client/src/api/Api.js @@ -525,6 +525,14 @@ class Api { }; return this.makeRequest(path, method, config); } + + // Profile + GET_PROFILE = { path: 'profile', method: 'GET' }; + + getProfile() { + const { path, method } = this.GET_PROFILE; + return this.makeRequest(path, method); + } } const apiClient = new Api(); diff --git a/client/src/components/Header/index.js b/client/src/components/Header/index.js index 28fa0767..8d16e614 100644 --- a/client/src/components/Header/index.js +++ b/client/src/components/Header/index.js @@ -60,9 +60,11 @@ class Header extends Component { />