diff --git a/package.json b/package.json index 32a320e..855b718 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,8 @@ "test": "jest", "prune": "node scripts/find-unused-code", "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": { "type": "git", diff --git a/src/core/consts/common.ts b/src/core/consts/common.ts index 4afc484..511a8c2 100644 --- a/src/core/consts/common.ts +++ b/src/core/consts/common.ts @@ -7,13 +7,13 @@ export const ROUTES = { CURRENCIES: '/currencies', }; -const PROTOCOL = location.protocol; +const ORIGIN = location.origin; export const ENDPOINT = { - AUTH: `${PROTOCOL}//localhost:3189/api/auth`, - USERS: `${PROTOCOL}//localhost:3189/api/users`, - ACTIONS: `${PROTOCOL}//localhost:3189/api/bot/actions`, - CONDITIONS: `${PROTOCOL}//localhost:3189/api/bot/conditions`, - GRAPHS: `${PROTOCOL}//localhost:3189/api/bot/graphs`, - CURRENCIES: `${PROTOCOL}//localhost:3189/api/bot/currencies`, + AUTH: `${ORIGIN}/api/auth`, + USERS: `${ORIGIN}/api/users`, + ACTIONS: `${ORIGIN}/api/bot/actions`, + CONDITIONS: `${ORIGIN}/api/bot/conditions`, + GRAPHS: `${ORIGIN}/api/bot/graphs`, + CURRENCIES: `${ORIGIN}/api/bot/currencies`, }; diff --git a/src/pages/conditions/components/page/Page.tsx b/src/pages/conditions/components/page/Page.tsx index 82089c4..0ed5a97 100644 --- a/src/pages/conditions/components/page/Page.tsx +++ b/src/pages/conditions/components/page/Page.tsx @@ -1,26 +1,46 @@ import {Button, Layout} from 'antd'; import React, {FC, memo} from 'react'; 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 {ENDPOINT, ROUTES} from '../../../../core/consts/common'; import {createEntityAtoms} from '../../../../core/infrastructure/atom/createEntityAtoms'; import {CrudService} from '../../../../core/services/CrudService'; import {EntityMode} from '../../../../core/types/EntityModes'; -import {CurrencyModel} from '../../types'; +import {ConditionModel} from '../../types'; -const {entityListAtom, entityFormAtom, bindedActions} = createEntityAtoms({ - name: '', +const {entityListAtom, entityFormAtom, bindedActions} = createEntityAtoms({ + graphs: [], + currencies: [], + takeProfitCoeff: 0, + stopLossCoeff: 0, + cost: 0, + login: '', }); -const service = new CrudService(ROUTES.GRAPHS, ENDPOINT.GRAPHS, bindedActions); +const service = new CrudService(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 = [ - {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 EntitySidebar = createEntitySidebar({entityFormAtom, service, formOptions, entityName: 'Currency'}); +const EntitySidebar = createEntitySidebar({entityFormAtom, service, formOptions, entityName: 'Conditions'}); const useStyles = createUseStyles({ header: { @@ -42,7 +62,7 @@ const Page: FC = () => { type="primary" onClick={handleClickNewEntity} > - New currency + New condition diff --git a/src/pages/conditions/types.ts b/src/pages/conditions/types.ts index fd180e9..6e5e18b 100644 --- a/src/pages/conditions/types.ts +++ b/src/pages/conditions/types.ts @@ -1,3 +1,8 @@ -export type CurrencyModel = { - name: string; +export type ConditionModel = { + graphs: string[]; + currencies: string[]; + takeProfitCoeff: number; + stopLossCoeff: number; + cost: number; + login: string; };