From eb6c08c8c6bf714b18025389dc3f78c692a96438 Mon Sep 17 00:00:00 2001 From: Kozjar Date: Sun, 3 Dec 2023 12:15:04 +0300 Subject: [PATCH] feat: added bid status endpoint, insert strategy --- src/assets/i18n/ru.json | 9 ++++ .../ChangelogModal/ChangelogModal.tsx | 1 - .../IntegrationCommon/index.tsx | 50 +++++++++++++++++++ .../IntegrationPage/IntegrationPage.tsx | 14 ++++-- .../SettingsPage/AucSettings/AucSettings.tsx | 8 +-- .../AucSettings/BidsSortSelect.tsx | 11 +++- src/enums/settings.enum.ts | 6 +++ src/models/publicApi.model.d.ts | 7 +++ src/models/purchase.ts | 4 +- src/models/settings.model.ts | 3 ++ src/pages/auction/AucActions/AucActions.tsx | 17 ++++--- src/pages/auction/Slot/DroppableSlot.tsx | 2 +- src/reducers/AucSettings/AucSettings.ts | 10 ++-- src/reducers/Purchases/Purchases.ts | 33 ++++++++---- src/reducers/Slots/Slots.ts | 6 +-- src/reducers/socketIo/socketIo.ts | 29 +++++++++++ src/styles/common.scss | 9 ++++ src/utils/changelog.tsx | 22 +++++++- 18 files changed, 199 insertions(+), 42 deletions(-) create mode 100644 src/components/IntegrationPage/IntegrationCommon/index.tsx create mode 100644 src/enums/settings.enum.ts diff --git a/src/assets/i18n/ru.json b/src/assets/i18n/ru.json index 4b8be58..7e65a6c 100644 --- a/src/assets/i18n/ru.json +++ b/src/assets/i18n/ru.json @@ -64,6 +64,15 @@ "primaryColor": "Основной цвет", "backgroundTone": "Тон фона" }, + "integrationCommon": { + "title": "Общее", + "insertStrategyLabel": "Автодобавление ставок", + "insertStrategy": { + "force": "Всегда", + "match": "При полном совпадении имени", + "none": "Никогда" + } + }, "twitch": { "openRewards": "Включить награды", "closeRewards": "Скрыть награды", diff --git a/src/components/Changelog/ChangelogModal/ChangelogModal.tsx b/src/components/Changelog/ChangelogModal/ChangelogModal.tsx index a216566..9060196 100644 --- a/src/components/Changelog/ChangelogModal/ChangelogModal.tsx +++ b/src/components/Changelog/ChangelogModal/ChangelogModal.tsx @@ -1,6 +1,5 @@ import { FC, useEffect, useMemo, useState } from 'react'; import { Button, Dialog, DialogActions, DialogContent, DialogTitle } from '@mui/material'; -import dayjs from 'dayjs'; import { getUpdates } from '@utils/changelog.tsx'; diff --git a/src/components/IntegrationPage/IntegrationCommon/index.tsx b/src/components/IntegrationPage/IntegrationCommon/index.tsx new file mode 100644 index 0000000..50bd2ca --- /dev/null +++ b/src/components/IntegrationPage/IntegrationCommon/index.tsx @@ -0,0 +1,50 @@ +import React from 'react'; +import { useTranslation } from 'react-i18next'; +import { Controller, useFormContext } from 'react-hook-form'; +import { FormControl, MenuItem, Select, Typography, FormGroup } from '@mui/material'; + +import SettingsGroupTitle from '@components/SettingsGroupTitle/SettingsGroupTitle.tsx'; +import { InsertStrategy } from '@enums/settings.enum.ts'; + +const IntegrationCommon = () => { + const { t } = useTranslation(undefined, { keyPrefix: 'settings.integrationCommon' }); + const { control } = useFormContext(); + + return ( + <> + + + + {t('insertStrategyLabel')} + + ( + + + + )} + /> + + + ); +}; + +export default IntegrationCommon; diff --git a/src/components/IntegrationPage/IntegrationPage.tsx b/src/components/IntegrationPage/IntegrationPage.tsx index fb09d22..020ddb8 100644 --- a/src/components/IntegrationPage/IntegrationPage.tsx +++ b/src/components/IntegrationPage/IntegrationPage.tsx @@ -1,12 +1,13 @@ import { FC, useCallback, useEffect } from 'react'; import { useDispatch, useSelector } from 'react-redux'; -import { useForm } from 'react-hook-form'; +import { FormProvider, useForm } from 'react-hook-form'; import { useTranslation } from 'react-i18next'; import { initialState, saveSettings } from '@reducers/AucSettings/AucSettings.ts'; import { getDirtyValues } from '@utils/common.utils.ts'; import { SettingsForm } from '@models/settings.model.ts'; import { RootState } from '@reducers'; +import IntegrationCommon from '@components/IntegrationPage/IntegrationCommon'; import PageContainer from '../PageContainer/PageContainer'; @@ -58,10 +59,13 @@ const IntegrationPage: FC = () => { return ( -
- - - + +
+ + + + +
); }; diff --git a/src/components/SettingsPage/AucSettings/AucSettings.tsx b/src/components/SettingsPage/AucSettings/AucSettings.tsx index 81b36d5..22b5ad0 100644 --- a/src/components/SettingsPage/AucSettings/AucSettings.tsx +++ b/src/components/SettingsPage/AucSettings/AucSettings.tsx @@ -1,15 +1,11 @@ import { FC, useEffect } from 'react'; -import { FormGroup, IconButton, MenuItem, Select, Typography, Grid, FormControl } from '@mui/material'; +import { FormGroup, IconButton, Typography } from '@mui/material'; import ReplayIcon from '@mui/icons-material/Replay'; -import { Control, Controller, UseFormReturn } from 'react-hook-form'; -import ArrowUpwardOutlinedIcon from '@mui/icons-material/ArrowUpwardOutlined'; -import ArrowDownwardOutlinedIcon from '@mui/icons-material/ArrowDownwardOutlined'; -import { useSelector } from 'react-redux'; +import { Control, UseFormReturn } from 'react-hook-form'; import { useTranslation } from 'react-i18next'; import ImageLinkInput from '@components/Form/ImageLinkInput/ImageLinkInput'; import SettingsGroupTitle from '@components/SettingsGroupTitle/SettingsGroupTitle'; -import { RootState } from '@reducers'; import FormSwitch from '@components/Form/FormSwitch/FormSwitch'; import FormInput from '@components/Form/FormInput/FormInput'; import ImagePresetsInput from '@components/Form/ImagePresetsInput/ImagePresetsInput'; diff --git a/src/components/SettingsPage/AucSettings/BidsSortSelect.tsx b/src/components/SettingsPage/AucSettings/BidsSortSelect.tsx index 9536230..653233d 100644 --- a/src/components/SettingsPage/AucSettings/BidsSortSelect.tsx +++ b/src/components/SettingsPage/AucSettings/BidsSortSelect.tsx @@ -22,9 +22,16 @@ const BidsSortSelect: FC = ({ control }) => { control={control} name='purchaseSort' defaultValue={purchaseSort} - render={({ field: { onChange, value } }) => ( + render={({ field: { onChange, onBlur, value } }) => ( - { + onChange(e.target.value); + onBlur(); + }} + > {t('settings.auc.dateSort')} diff --git a/src/enums/settings.enum.ts b/src/enums/settings.enum.ts new file mode 100644 index 0000000..c6e908a --- /dev/null +++ b/src/enums/settings.enum.ts @@ -0,0 +1,6 @@ +export enum InsertStrategy { + Force = 'force', + Match = 'match', + None = 'none', + Auto = 'auto', +} diff --git a/src/models/publicApi.model.d.ts b/src/models/publicApi.model.d.ts index b5bb076..a360e8f 100644 --- a/src/models/publicApi.model.d.ts +++ b/src/models/publicApi.model.d.ts @@ -21,4 +21,11 @@ namespace PublicApi { query: LotQuery; lot: LotUpdateData; } + + interface BidStatus { + status: 'pending' | 'processed' | 'rejected' | 'notFound'; + lot?: { + id: string; + }; + } } diff --git a/src/models/purchase.ts b/src/models/purchase.ts index 7cc086f..40aa32f 100644 --- a/src/models/purchase.ts +++ b/src/models/purchase.ts @@ -6,6 +6,6 @@ export interface PurchaseSortOption { } export enum PurchaseStatusEnum { - Processed = 'Processed', - Deleted = 'Deleted', + Processed = 'processed', + Deleted = 'deleted', } diff --git a/src/models/settings.model.ts b/src/models/settings.model.ts index f21bbe5..df2c3d5 100644 --- a/src/models/settings.model.ts +++ b/src/models/settings.model.ts @@ -1,3 +1,5 @@ +import { InsertStrategy } from '@enums/settings.enum.ts'; + import { TwitchRewardPresetDto } from './user.model'; export interface TwitchIntegration { @@ -35,6 +37,7 @@ export interface Settings extends TwitchIntegration, DonationSettings { luckyWheelEnabled: boolean; luckyWheelSelectBet: boolean; showUpdates: boolean; + insertStrategy: InsertStrategy; // Appearance primaryColor: string; diff --git a/src/pages/auction/AucActions/AucActions.tsx b/src/pages/auction/AucActions/AucActions.tsx index b6d756e..4557a78 100644 --- a/src/pages/auction/AucActions/AucActions.tsx +++ b/src/pages/auction/AucActions/AucActions.tsx @@ -132,6 +132,17 @@ const AucActions: React.FC = () => {