add conditions

This commit is contained in:
2021-07-18 15:20:10 +03:00
parent 91b5ddcfaf
commit 54183b07c9
4 changed files with 44 additions and 18 deletions

View File

@ -14,7 +14,8 @@
"test": "jest", "test": "jest",
"prune": "node scripts/find-unused-code", "prune": "node scripts/find-unused-code",
"checks": "npm run eslint && npm run tsc && npm run prune && npm run test && npm run build", "checks": "npm run eslint && npm run tsc && npm run prune && npm run test && npm run build",
"clean": "rm -rf node_modules && rm -rf build" "clean": "rm -rf node_modules && rm -rf build",
"copy-front": "rm -rf ../crypto-bot-admin-server/static && cp -R build/ ../crypto-bot-admin-server/static"
}, },
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -7,13 +7,13 @@ export const ROUTES = {
CURRENCIES: '/currencies', CURRENCIES: '/currencies',
}; };
const PROTOCOL = location.protocol; const ORIGIN = location.origin;
export const ENDPOINT = { export const ENDPOINT = {
AUTH: `${PROTOCOL}//localhost:3189/api/auth`, AUTH: `${ORIGIN}/api/auth`,
USERS: `${PROTOCOL}//localhost:3189/api/users`, USERS: `${ORIGIN}/api/users`,
ACTIONS: `${PROTOCOL}//localhost:3189/api/bot/actions`, ACTIONS: `${ORIGIN}/api/bot/actions`,
CONDITIONS: `${PROTOCOL}//localhost:3189/api/bot/conditions`, CONDITIONS: `${ORIGIN}/api/bot/conditions`,
GRAPHS: `${PROTOCOL}//localhost:3189/api/bot/graphs`, GRAPHS: `${ORIGIN}/api/bot/graphs`,
CURRENCIES: `${PROTOCOL}//localhost:3189/api/bot/currencies`, CURRENCIES: `${ORIGIN}/api/bot/currencies`,
}; };

View File

@ -1,26 +1,46 @@
import {Button, Layout} from 'antd'; import {Button, Layout} from 'antd';
import React, {FC, memo} from 'react'; import React, {FC, memo} from 'react';
import {createUseStyles} from 'react-jss'; import {createUseStyles} from 'react-jss';
import {createEntitySidebar} from '../../../../core/blocks/entity-sidebar'; import {createEntitySidebar, FormInputType} from '../../../../core/blocks/entity-sidebar';
import {createEntityTable} from '../../../../core/blocks/entity-table'; import {createEntityTable} from '../../../../core/blocks/entity-table';
import {ENDPOINT, ROUTES} from '../../../../core/consts/common'; import {ENDPOINT, ROUTES} from '../../../../core/consts/common';
import {createEntityAtoms} from '../../../../core/infrastructure/atom/createEntityAtoms'; import {createEntityAtoms} from '../../../../core/infrastructure/atom/createEntityAtoms';
import {CrudService} from '../../../../core/services/CrudService'; import {CrudService} from '../../../../core/services/CrudService';
import {EntityMode} from '../../../../core/types/EntityModes'; import {EntityMode} from '../../../../core/types/EntityModes';
import {CurrencyModel} from '../../types'; import {ConditionModel} from '../../types';
const {entityListAtom, entityFormAtom, bindedActions} = createEntityAtoms<CurrencyModel>({ const {entityListAtom, entityFormAtom, bindedActions} = createEntityAtoms<ConditionModel>({
name: '', graphs: [],
currencies: [],
takeProfitCoeff: 0,
stopLossCoeff: 0,
cost: 0,
login: '',
}); });
const service = new CrudService<CurrencyModel>(ROUTES.GRAPHS, ENDPOINT.GRAPHS, bindedActions); const service = new CrudService<ConditionModel>(ROUTES.CONDITIONS, ENDPOINT.CONDITIONS, bindedActions);
const GRAPH_OPTIONS = [
{label: 'grapth1', value: '90431'},
{label: 'grapth2', value: '904311231'},
];
const CURRENCY_OPTIONS = [
{label: 'RUB', value: 'RUB'},
{label: 'EUR', value: 'EUR'},
];
const formOptions = [ const formOptions = [
{name: 'name', label: 'Name'}, {name: 'graphs', label: 'Graphs', type: FormInputType.Select, options: GRAPH_OPTIONS},
{name: 'currencies', label: 'Currencies', type: FormInputType.Select, options: CURRENCY_OPTIONS},
{name: 'takeProfitCoeff', label: 'Take Profit Coeff'},
{name: 'stopLossCoeff', label: 'Stop Loss Coeff'},
{name: 'cost', label: 'cost'},
{name: 'login', label: 'Login'},
]; ];
const EntityTable = createEntityTable({entityListAtom, service}); const EntityTable = createEntityTable({entityListAtom, service});
const EntitySidebar = createEntitySidebar({entityFormAtom, service, formOptions, entityName: 'Currency'}); const EntitySidebar = createEntitySidebar({entityFormAtom, service, formOptions, entityName: 'Conditions'});
const useStyles = createUseStyles({ const useStyles = createUseStyles({
header: { header: {
@ -42,7 +62,7 @@ const Page: FC = () => {
type="primary" type="primary"
onClick={handleClickNewEntity} onClick={handleClickNewEntity}
> >
New currency New condition
</Button> </Button>
</Layout.Header> </Layout.Header>
<Layout.Content> <Layout.Content>

View File

@ -1,3 +1,8 @@
export type CurrencyModel = { export type ConditionModel = {
name: string; graphs: string[];
currencies: string[];
takeProfitCoeff: number;
stopLossCoeff: number;
cost: number;
login: string;
}; };