Skip to content

Commit

Permalink
fix: remove the usage of lodash
Browse files Browse the repository at this point in the history
  • Loading branch information
AlasDiablo committed Jul 18, 2024
1 parent 0fe6fe6 commit 068760c
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions src/app/js/admin/configTenant/ConfigTenantForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import CancelButton from '../../lib/components/CancelButton';
import { toast } from '../../../../common/tools/toast';
import { loadConfigTenant } from '.';
import { SaveAs } from '@mui/icons-material';
import _ from 'lodash';

const shake = keyframes`
10%, 90% {
Expand All @@ -53,6 +52,7 @@ export const ConfigTenantForm = ({
history,
onLoadConfigTenant,
}) => {
const [initialConfig, setInitialConfig] = useState('');
const [configTenant, setConfigTenant] = useState('');
const [enableAutoPublication, setEnableAutoPublication] = useState(false);
const [userAuth, setUserAuth] = useState({});
Expand Down Expand Up @@ -90,6 +90,7 @@ export const ConfigTenantForm = ({
delete response.theme;

const stringified = JSON.stringify(response, null, 2);
setInitialConfig(stringified);
setConfigTenant(stringified);

const themesResponse = await getConfigTenantAvailableTheme();
Expand Down Expand Up @@ -143,13 +144,25 @@ export const ConfigTenantForm = ({
(value) => value.value === event.target.value,
);

const clonedConfig = _.cloneDeep(JSON.parse(configTenant));
try {
const parsedConfig = JSON.parse(configTenant);

if (clonedConfig.front) {
clonedConfig.front.theme = themeValue.defaultVariables;
}
if (parsedConfig.front) {
parsedConfig.front.theme = themeValue.defaultVariables;
}

setConfigTenant(JSON.stringify(parsedConfig, null, 2));
} catch (_) {
// If we can't parse the actual config fallback to the initial

const parsedConfig = JSON.parse(initialConfig);

setConfigTenant(JSON.stringify(clonedConfig, null, 2));
if (parsedConfig.front) {
parsedConfig.front.theme = themeValue.defaultVariables;
}

setConfigTenant(JSON.stringify(parsedConfig, null, 2));
}
} catch (_) {
/* empty */
}
Expand Down

0 comments on commit 068760c

Please sign in to comment.