Account.source default values
This commit is contained in:
parent
45c4c1fa3f
commit
23ff2f1568
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
const { createSlice } = require("@reduxjs/toolkit");
|
const { createSlice } = require("@reduxjs/toolkit");
|
||||||
const d = require("dotty");
|
const d = require("dotty");
|
||||||
|
const defaultValue = require("default-value");
|
||||||
|
|
||||||
module.exports = createSlice({
|
module.exports = createSlice({
|
||||||
name: "user",
|
name: "user",
|
||||||
|
@ -29,9 +30,11 @@ module.exports = createSlice({
|
||||||
},
|
},
|
||||||
reducers: {
|
reducers: {
|
||||||
setAccount: (state, { payload }) => {
|
setAccount: (state, { payload }) => {
|
||||||
if (payload.source != undefined && payload.source.language != undefined) {
|
payload.source = defaultValue(payload.source, {});
|
||||||
payload.source.language = payload.source.language.toUpperCase();
|
payload.source.language = defaultValue(payload.source.language.toUpperCase(), "EN");
|
||||||
}
|
payload.source.status_format = defaultValue(payload.source.status_format, "plain");
|
||||||
|
payload.source.sensitive = defaultValue(payload.source.sensitive, false);
|
||||||
|
|
||||||
state.profile = payload;
|
state.profile = payload;
|
||||||
// /user/settings only needs a copy of the 'source' obj
|
// /user/settings only needs a copy of the 'source' obj
|
||||||
state.settings = {
|
state.settings = {
|
||||||
|
|
Loading…
Reference in New Issue