re-structure to monorepo.

This commit is contained in:
a.bouhuolia
2023-02-03 01:02:31 +02:00
parent 8242ec64ba
commit 7a0a13f9d5
10400 changed files with 46966 additions and 17223 deletions

View File

@@ -0,0 +1,47 @@
// @ts-nocheck
import ApiService from '@/services/ApiService';
import t from '@/store/types';
export const submitOptions = ({ form }) => {
return (dispatch) => {
return ApiService.post('settings', form).then((response) => {
dispatch({
type: t.SETTING_SET,
options: form.options,
});
return response;
});
};
};
export const FetchOptions = ({ form }) => {
return (dispatch) =>
new Promise((resolve, reject) => {
ApiService.get('settings')
.then((response) => {
dispatch({
type: t.SETTING_SET,
options: response.data.settings,
});
resolve(response);
})
.catch((error) => {
reject(error);
});
});
};
export const setSettings = (settings) => {
return {
type: t.SETTING_SET,
options: settings,
};
}
export const addSettings = (group, key, value) => {
return {
type: t.SETTING_ADD,
payload: { group, key, value }
};
}

View File

@@ -0,0 +1,115 @@
// @ts-nocheck
import { camelCase } from 'lodash';
import { createReducer } from '@reduxjs/toolkit';
import storage from 'redux-persist/lib/storage';
import { persistReducer, purgeStoredState } from 'redux-persist';
import t from '@/store/types';
const initialState = {
data: {
organization: {
name: 'Bigcapital, LLC',
},
manualJournals: {
tableSize: 'small',
},
bills: {
tableSize: 'small',
},
billPayments: {
tableSize: 'small',
},
paymentReceives: {
tableSize: 'small',
},
salesEstimates: {
tableSize: 'small',
},
items: {
tableSize: 'small',
},
salesInvoices: {
tableSize: 'small',
},
salesReceipts: {
tableSize: 'small',
},
expenses: {
tableSize: 'small',
},
customers: {
tableSize: 'small',
},
vendors: {
tableSize: 'small',
},
accounts: {
tableSize: 'small',
},
cashflowAccounts: {
tableSize: 'small',
},
cashflowTransactions: {
tableSize: 'small',
},
creditNote: {
tableSize: 'small',
},
vendorCredit: {
tableSize: 'small',
},
warehouseTransfer: {
tableSize: 'small',
},
projectTasks: {
tableSize: 'small',
},
projectTasks: {
tableSize: 'medium',
},
},
};
const STORAGE_KEY = 'bigcapital:settings';
const PRESIST_CONFIG = {
key: STORAGE_KEY,
whitelist: ['data'],
storage,
};
const reducerInstance = createReducer(initialState, {
[t.SETTING_SET]: (state, action) => {
const { options } = action;
const _data = {
...state.data,
};
options.forEach((option) => {
const { key, group, value } = option;
const _group = camelCase(group);
const _key = camelCase(key);
if (!_data[_group]) {
_data[_group] = {};
}
_data[_group][_key] = value;
});
state.data = _data;
},
[t.SETTING_ADD]: (state, action) => {
const { group, key, value } = action.payload;
const newData = {
...state.data,
[group]: {
...state.data[group],
[key]: value,
},
};
state.data = newData;
},
});
export default persistReducer(PRESIST_CONFIG, reducerInstance);

View File

@@ -0,0 +1,7 @@
// @ts-nocheck
export default {
SETTING_LIST_SET: 'SETTING_LIST_SET',
CLEAR_OPTIONS_FORM_ERRORS: 'CLEAR_OPTIONS_FORM_ERRORS',
SETTING_SET: 'SETTING_SET',
SETTING_ADD: 'SETTING_ADD',
};