import React, { useEffect, useState, useCallback } from 'react';
import PropTypes from 'prop-types';
import { connect } from './StateProvider';
import { getConfigs, fetchConfigs, updateConfigs } from '../store/configs';
import {
getClashAPIConfig,
getSelectedChartStyleIndex,
clearStorage,
selectChartStyleIndex
} from '../store/app';
import ContentHeader from './ContentHeader';
import Switch from './Switch';
import ToggleSwitch from './ToggleSwitch';
import Input from './Input';
import Button from './Button';
import Selection from './Selection';
import TrafficChartSample from './TrafficChartSample';
import s0 from './Config.module.css';
const propsList = [{ id: 0 }, { id: 1 }, { id: 2 }, { id: 3 }];
const optionsRule = [
{
label: 'Global',
value: 'Global'
},
{
label: 'Rule',
value: 'Rule'
},
{
label: 'Direct',
value: 'Direct'
}
];
const optionsLogLevel = [
{
label: 'info',
value: 'info'
},
{
label: 'warning',
value: 'warning'
},
{
label: 'error',
value: 'error'
},
{
label: 'debug',
value: 'debug'
},
{
label: 'silent',
value: 'silent'
}
];
// const actions = {
// selectChartStyleIndex
// };
const mapState = s => ({
configs: getConfigs(s),
apiConfig: getClashAPIConfig(s)
});
const mapState2 = s => ({
selectedChartStyleIndex: getSelectedChartStyleIndex(s),
apiConfig: getClashAPIConfig(s)
});
const Config = connect(mapState2)(ConfigImpl);
export default connect(mapState)(ConfigContainer);
function ConfigContainer({ dispatch, configs, apiConfig }) {
useEffect(() => {
dispatch(fetchConfigs(apiConfig));
}, [dispatch, apiConfig]);
return