Skip to content

Commit

Permalink
bug fixed (#723)
Browse files Browse the repository at this point in the history
  • Loading branch information
besizzo authored Apr 1, 2022
1 parent 198b65f commit c568cde
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 22 deletions.
2 changes: 2 additions & 0 deletions src/locales/uk/parts/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,6 @@ export const admin = {
close: 'Закрити',
selectedImportantMaterials: 'Зараз використовуються:',
selectOption: `Оберіть об'єкт налаштування у меню`,
searchTitlePlaceholder: `Пошук по назві`,
searchAuthorPlaceholder: `Пошук по автору`,
};
6 changes: 3 additions & 3 deletions src/views/Profile/AdminTable/AdminTableFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { useSelector } from 'react-redux';
import { Grid, IconButton } from '@material-ui/core';
import HighlightOffRoundedIcon from '@material-ui/icons/HighlightOffRounded';

import i18, { langTokens } from '../../../locales/localizationInit';
import { QueryTypeEnum } from '../../../old/lib/types';
import { FieldEnum } from '../../../models/adminLab/types';
import {
Expand Down Expand Up @@ -83,15 +83,15 @@ const AdminTableFilters: React.FC = () => {
<Grid item md={2}>
<AdminTextField
field={FieldEnum.TITLE}
placeholder={i18.t(langTokens.admin.searchTitlePlaceholder)}
setChanges={boundedSetField}
inputValue={textFields.title}
/>
</Grid>
<Grid item md={2}>
<AdminTextField
field={FieldEnum.AUTHOR}
placeholder={i18.t(langTokens.admin.searchAuthorPlaceholder)}
setChanges={boundedSetField}
inputValue={textFields.author}
/>
</Grid>
</Grid>
Expand Down
29 changes: 10 additions & 19 deletions src/views/Profile/AdminTable/AdminTextField.tsx
Original file line number Diff line number Diff line change
@@ -1,37 +1,28 @@
import React from 'react';
import React, { useState, useEffect } from 'react';
import FormControl from '@material-ui/core/FormControl';
import TextField from '@material-ui/core/TextField';
import { FieldEnum, IField } from '../../../models/adminLab/types';
import i18, { langTokens } from '../../../locales/localizationInit';
import { TextFieldWithDebounce } from './TextFieldWithDebounce';

interface IMaterialsTextField {
field: FieldEnum;
placeholder: string;
setChanges: (payload: IField) => void;
inputValue: string;
}

export const AdminTextField: React.FC<IMaterialsTextField> = ({
field,
placeholder,
setChanges,
inputValue,
}) => {
const handleChange = (
event: React.ChangeEvent<HTMLTextAreaElement | HTMLInputElement>,
) => {
setChanges({
field: field || '',
text: event.target.value || '',
});
};
const [text, setText] = useState<string>('');

useEffect(() => {
setChanges({ field, text });
}, [text]);

return (
<FormControl>
<TextField
type="text"
value={inputValue}
placeholder={i18.t(langTokens.admin[field])}
onChange={(event) => handleChange(event)}
/>
<TextFieldWithDebounce placeholder={placeholder} setInput={setText} />
</FormControl>
);
};

0 comments on commit c568cde

Please sign in to comment.