Skip to content

Commit

Permalink
feat(suiteheader): Running prettier.
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcelo Blechner committed Nov 5, 2020
1 parent a27d2b1 commit 43fcc99
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 13 deletions.
20 changes: 17 additions & 3 deletions src/components/SuiteHeader/hooks/useSuiteHeaderData.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { useState, useEffect, useCallback } from 'react';

// eslint-disable-next-line import/extensions
import getSuiteHeaderData, { calcRoutes, calcSurveyStatus, calcI18N, defaultFetchApi } from '../util/suiteHeaderData';

import getSuiteHeaderData, {
calcRoutes,
calcSurveyStatus,
calcI18N,
defaultFetchApi,
} from '../util/suiteHeaderData';

const useSuiteHeaderData = ({
baseApiUrl,
Expand Down Expand Up @@ -40,7 +44,17 @@ const useSuiteHeaderData = ({
const refreshData = useCallback(async () => {
try {
setIsLoading(true);
const suiteHeaderData = await getSuiteHeaderData({ baseApiUrl, domain, lang, calculateRoutes, calculateSurveyStatus, calculateI18N, fetchApi, surveyConfig, isTest });
const suiteHeaderData = await getSuiteHeaderData({
baseApiUrl,
domain,
lang,
calculateRoutes,
calculateSurveyStatus,
calculateI18N,
fetchApi,
surveyConfig,
isTest,
});
setData(suiteHeaderData);
} catch (err) {
setError(err);
Expand Down
21 changes: 11 additions & 10 deletions src/components/SuiteHeader/util/suiteHeaderData.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,13 @@ export const calcI18N = (i18nData) => ({
.replace('{userName}', userName),
});

export const defaultFetchApi = async (method, url, body, headers, testResponse) =>
export const defaultFetchApi = async (
method,
url,
body,
headers,
testResponse
) =>
testResponse ||
fetch(url, {
method,
Expand Down Expand Up @@ -174,7 +180,6 @@ const getSuiteHeaderData = async ({
surveyConfig = null,
isTest = false,
}) => {

const api = (method, path, body, headers) =>
fetchApi(
method,
Expand All @@ -199,17 +204,13 @@ const getSuiteHeaderData = async ({

// Survey
const showSurvey = surveyConfig?.id
? await calculateSurveyStatus(
profileData.user.username,
surveyConfig,
api
)
? await calculateSurveyStatus(profileData.user.username, surveyConfig, api)
: false;

// i18n
const i18n = i18nData ? calculateI18N(i18nData) : SuiteHeaderI18N.en;

return({
return {
username: profileData.user.username,
userDisplayName: profileData.user.displayName,
email: profileData.user.email,
Expand All @@ -229,7 +230,7 @@ const getSuiteHeaderData = async ({
],
i18n,
showSurvey,
});
}
};
};

export default getSuiteHeaderData;

0 comments on commit 43fcc99

Please sign in to comment.