Skip to content
This repository was archived by the owner on Jan 16, 2022. It is now read-only.

Commit 52c00ff

Browse files
committed
chore: apply suggestions
1 parent cbcada8 commit 52c00ff

File tree

3 files changed

+11
-18
lines changed

3 files changed

+11
-18
lines changed

src/App/Header/LoginDialog/LoginDialog.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ const LoginDialog: React.FC<Props> = ({ onClose, open = false }) => {
2525
const appContext = useContext(AppContext);
2626
const { doLogin } = useAPI();
2727

28-
// eslint-disable-next-line react-hooks/exhaustive-deps
2928
const makeLogin = useCallback(
3029
async (username?: string, password?: string): Promise<LoginBody> => {
3130
// checks isEmpty

src/design-tokens/ThemeProvider.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ThemeProvider as MuiThemeProvider } from '@material-ui/core/styles';
22
import { ThemeProvider as EmotionThemeProvider } from 'emotion-theming';
33
import i18next from 'i18next';
4-
import React, { useEffect } from 'react';
4+
import React, { useEffect, useCallback } from 'react';
55

66
import { useConfig } from 'verdaccio-ui/providers/config';
77

@@ -21,18 +21,21 @@ const ThemeProvider: React.FC = ({ children }) => {
2121

2222
const themeMode: ThemeMode = isDarkMode ? 'dark' : 'light';
2323

24-
const changeLanguage = async () => {
24+
const changeLanguage = useCallback(async () => {
2525
await i18next.changeLanguage(language);
26-
};
26+
}, [language]);
27+
28+
const currentTheme = getTheme(themeMode, configOptions?.primaryColor);
2729

2830
useEffect(() => {
2931
changeLanguage();
3032
loadDayJSLocale();
3133
}, [language, changeLanguage]);
34+
3235
return (
3336
<ThemeContext.Provider value={{ isDarkMode, setIsDarkMode, language, setLanguage }}>
34-
<EmotionThemeProvider theme={getTheme(themeMode, configOptions?.primaryColor)}>
35-
<MuiThemeProvider theme={getTheme(themeMode, configOptions?.primaryColor)}>{children}</MuiThemeProvider>
37+
<EmotionThemeProvider theme={currentTheme}>
38+
<MuiThemeProvider theme={currentTheme}>{children}</MuiThemeProvider>
3639
</EmotionThemeProvider>
3740
</ThemeContext.Provider>
3841
);

src/providers/API/APIProvider.tsx

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,30 +65,23 @@ const APIProvider: FunctionComponent = ({ children }) => {
6565
};
6666

6767
const doLogin = async (username: string, password: string): Promise<LoginBody> => {
68-
const response: LoginBody = await API.request(buildURL('login'), 'POST', {
68+
return await API.request(buildURL('login'), 'POST', {
6969
body: JSON.stringify({ username, password }),
7070
headers: {
7171
Accept: HEADERS.JSON,
7272
'Content-Type': HEADERS.JSON,
7373
},
7474
});
75-
const result: LoginBody = {
76-
username: response.username,
77-
token: response.token,
78-
};
79-
return result;
8075
};
8176

8277
const getResource = async (link: string): Promise<Blob> => {
83-
const fileStream: Blob = await API.request(link, 'GET', {
78+
return await API.request(link, 'GET', {
8479
headers: {
8580
['accept']:
8681
'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3',
8782
},
8883
credentials: 'include',
8984
});
90-
91-
return fileStream;
9285
};
9386

9487
const value = useMemo(
@@ -108,6 +101,4 @@ const APIProvider: FunctionComponent = ({ children }) => {
108101

109102
export default APIProvider;
110103

111-
const useAPI = () => useContext(AppAPIContext);
112-
113-
export { useAPI };
104+
export const useAPI = () => useContext(AppAPIContext);

0 commit comments

Comments
 (0)