fixed an error related to requesting the state.wizard.wizardCompleted key in PublicRoute. Fixed translation and layout

This commit is contained in:
Artem Tarasov 2020-08-06 00:01:41 +03:00
parent 5c8efbd7c5
commit c4ba6adee2
9 changed files with 53 additions and 69 deletions

View File

@ -8,7 +8,7 @@
},
"AllowedHosts": "*",
"core": {
"base-domain": "localhost",
"base-domain": "",
"machinekey": "1123askdasjklasbnd",
"notify": {
"postman": "log"
@ -99,7 +99,7 @@
"internal": "http://localhost:9999/"
},
"controlpanel": {
"url": "controlpanel"
"url": ""
}
},
"ConnectionStrings": {

View File

@ -1,54 +1,37 @@
import i18n from "i18next";
import Backend from "i18next-xhr-backend";
import { constants } from 'asc-web-common';
const { LANGUAGE } = constants;
import en from "./locales/en/translation.json";
import ru from "./locales/ru/translation.json";
import { constants } from "asc-web-common";
const { LANGUAGE } = constants;
const newInstance = i18n.createInstance();
if (process.env.NODE_ENV === "production") {
newInstance
.use(Backend)
.init({
lng: localStorage.getItem(LANGUAGE) || 'en',
fallbackLng: "en",
const resources = {
en: {
translation: en//require("./locales/en/translation.json")
},
ru: {
translation: ru//require("./locales/ru/translation.json")
}
};
interpolation: {
escapeValue: false, // not needed for react as it escapes by default
},
newInstance.init({
resources: resources,
lng: localStorage.getItem(LANGUAGE) || 'en',
fallbackLng: "en",
react: {
useSuspense: true
},
backend: {
loadPath: `/locales/About/{{lng}}/{{ns}}.json`
}
});
} else if (process.env.NODE_ENV === "development") {
const resources = {
en: {
translation: require("./locales/en/translation.json")
},
ru: {
translation: require("./locales/ru/translation.json")
interpolation: {
escapeValue: false, // not needed for react as it escapes by default
format: function (value, format) {
if (format === 'lowercase') return value.toLowerCase();
return value;
}
};
},
newInstance.init({
resources: resources,
lng: localStorage.getItem(LANGUAGE) || 'en',
fallbackLng: "en",
debug: true,
interpolation: {
escapeValue: false, // not needed for react as it escapes by default
},
react: {
useSuspense: false
}
});
}
react: {
useSuspense: false
}
});
export default newInstance;

View File

@ -404,7 +404,7 @@ const WizardWrapper = withTranslation()(Body);
const WizardPage = props => {
const { language, isLoaded } = props;
//i18n.changeLanguage(language);
i18n.changeLanguage(language);
return (
<>
{ isLoaded && <PageLayout

View File

@ -16,10 +16,14 @@ const StyledContainer = styled(Box)`
width: 311px;
margin: 0 auto;
display: grid;
grid-template-columns: 66px auto;
grid-template-columns: min-content auto;
grid-auto-columns: min-content;
grid-row-gap: 12px;
.title {
white-space: nowrap;
}
.machine-name-value,
.email-value {
margin-left: 16px;
@ -88,7 +92,7 @@ const SettingsContainer = ({
onSelect={onSelectLanguageHandler}
/>
<Text fontSize="13px">{t('timezone')}</Text>
<Text className="title" fontSize="13px">{t('timezone')}</Text>
<ComboBox
className="drop-down"
options={timezones}

View File

@ -3,12 +3,12 @@ const {
setPasswordSettings,
setTimezones,
setPortalCultures,
getPortalSettings
getPortalSettings,
setWizardComplete
} = store.auth.actions;
export const SET_IS_WIZARD_LOADED = 'SET_IS_WIZARD_LOADED';
export const SET_IS_MACHINE_NAME = 'SET_IS_MACHINE_NAME';
export const SET_COMPLETE = 'SET_COMPLETE';
export const SET_IS_LICENSE_REQUIRED = "SET_IS_LICENSE_REQUIRED";
export const SET_LICENSE_UPLOAD = "SET_LICENSE_UPLOAD";
@ -26,13 +26,6 @@ export function setMachineName(machineName) {
};
}
export function setComplete(res) {
return {
type: SET_COMPLETE,
res
}
}
export function setIsRequiredLicense(isRequired) {
return {
type: SET_IS_LICENSE_REQUIRED,
@ -82,8 +75,9 @@ export function getMachineName(token) {
export function setPortalOwner(email, pwd, lng, timeZone, confirmKey, analytics) {
return dispatch => {
return api.settings.setPortalOwner(email, pwd, lng, timeZone, confirmKey, analytics)
.then((res) => dispatch(setComplete(res)))
.then(() => dispatch(setWizardComplete()))
.then(() => getPortalSettings(dispatch))
}
}

View File

@ -1,7 +1,6 @@
import {
SET_IS_WIZARD_LOADED,
SET_IS_MACHINE_NAME,
SET_COMPLETE,
SET_IS_LICENSE_REQUIRED,
SET_LICENSE_UPLOAD
} from "./actions";
@ -11,7 +10,6 @@ const initState = {
isLicenseRequired: false,
machineName: 'unknown',
response: null,
wizardCompleted: false,
licenseUpload: null
};
@ -28,12 +26,6 @@ const ownerReducer = ( state = initState, action) => {
machineName: action.machineName
});
case SET_COMPLETE:
return Object.assign({}, state, {
response: action.res,
wizardCompleted: true
});
case SET_IS_LICENSE_REQUIRED:
return Object.assign({}, state, {
isLicenseRequired: action.isRequired

View File

@ -46,7 +46,7 @@ export const PublicRoute = ({ component: Component, ...rest }) => {
function mapStateToProps(state) {
return {
wizardToken: state.auth.settings.wizardToken,
wizardCompleted: state.wizard.wizardCompleted
wizardCompleted: state.auth.settings.wizardCompleted
};
}

View File

@ -15,6 +15,7 @@ export const SET_CURRENT_PRODUCT_ID = "SET_CURRENT_PRODUCT_ID";
export const SET_CURRENT_PRODUCT_HOME_PAGE = "SET_CURRENT_PRODUCT_HOME_PAGE";
export const SET_GREETING_SETTINGS = "SET_GREETING_SETTINGS";
export const SET_CUSTOM_NAMES = "SET_CUSTOM_NAMES";
export const SET_WIZARD_COMPLETED ="SET_WIZARD_COMPLETED";
export function setCurrentUser(user) {
return {
@ -114,6 +115,12 @@ export function setCustomNames(customNames) {
};
}
export function setWizardComplete() {
return {
type: SET_WIZARD_COMPLETED
}
}
export function getUser(dispatch) {
return api.people.getUser()
.then(user => dispatch(setCurrentUser(user)))

View File

@ -1,7 +1,7 @@
import {
SET_CURRENT_USER, SET_MODULES, SET_SETTINGS, SET_IS_LOADED, LOGOUT, SET_PASSWORD_SETTINGS, SET_NEW_EMAIL,
SET_PORTAL_CULTURES, SET_PORTAL_LANGUAGE_AND_TIME, SET_TIMEZONES, SET_CURRENT_PRODUCT_ID, SET_CURRENT_PRODUCT_HOME_PAGE, SET_GREETING_SETTINGS,
SET_CUSTOM_NAMES } from './actions';
SET_CUSTOM_NAMES, SET_WIZARD_COMPLETED } from './actions';
import isEmpty from "lodash/isEmpty";
import { LANGUAGE, AUTH_KEY } from '../../constants';
@ -30,7 +30,7 @@ const initialState = {
timePattern: "h:mm tt"
},
greetingSettings: 'Web Office Applications',
enableAdmMess: false
enableAdmMess: false,
}
}
@ -102,6 +102,10 @@ const authReducer = (state = initialState, action) => {
return Object.assign({}, initialState, {
settings: state.settings
});
case SET_WIZARD_COMPLETED:
return Object.assign({}, state, {
settings: { ...state.settings, wizardCompleted: true}
})
default: