Skip to content

Commit

Permalink
client: default language
Browse files Browse the repository at this point in the history
  • Loading branch information
Mizzick committed Jan 18, 2023
1 parent 01a057a commit ca9abc1
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions client/src/api/Api.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import axios from 'axios';

import { getPathWithQueryString } from '../helpers/helpers';
import { QUERY_LOGS_PAGE_LIMIT, HTML_PAGES, R_PATH_LAST_PART } from '../helpers/constants';
import {
QUERY_LOGS_PAGE_LIMIT, HTML_PAGES, R_PATH_LAST_PART, THEMES,
} from '../helpers/constants';
import { BASE_URL } from '../../constants';
import i18n from '../i18n';
import { LANGUAGES } from '../helpers/twosky';

class Api {
baseUrl = BASE_URL;
Expand Down Expand Up @@ -236,7 +240,7 @@ class Api {

async changeTheme(config) {
const profile = await this.getProfile();
profile.theme = config.theme ? config.theme : 'auto';
profile.theme = config.theme;

return this.setProfile(profile);
}
Expand Down Expand Up @@ -579,10 +583,12 @@ class Api {
}

setProfile(data) {
const theme = data.theme ? data.theme : THEMES.auto;
const defaultLanguage = i18n.language ? i18n.language : LANGUAGES.en;
const language = data.language ? data.language : defaultLanguage;

const { path, method } = this.UPDATE_PROFILE;
const config = {
data,
};
const config = { data: { theme, language } };

return this.makeRequest(path, method, config);
}
Expand Down

0 comments on commit ca9abc1

Please sign in to comment.