normalize polish signs
This commit is contained in:
parent
148156fdca
commit
770a5f09d3
@ -60,19 +60,30 @@ interface DropdownProps {
|
|||||||
export const Dropdown = ({ clearInput, handleClearInput }: DropdownProps) => {
|
export const Dropdown = ({ clearInput, handleClearInput }: DropdownProps) => {
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
|
|
||||||
const [open, setOpen] = React.useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
const [input, setInput] = useState<string>('');
|
const [input, setInput] = useState('');
|
||||||
|
|
||||||
//courses - choosenCourses
|
//courses - choosenCourses
|
||||||
const [filteredCourses, setFilteredCourses] = useState<Array<Course>>([]);
|
const [filteredCourses, setFilteredCourses] = useState<Array<Course>>([]);
|
||||||
|
|
||||||
|
|
||||||
const { courses, basket, addToBasket } = useContext(coursesContext)!;
|
const { courses, basket, addToBasket } = useContext(coursesContext)!;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const filterCourses = (input: string) => {
|
const filterCourses = (input: string) => {
|
||||||
const choosenCoursesNames = basket.map(({ name }) => name.trim());
|
const choosenCoursesNames = basket.map(({ name }) => name.trim());
|
||||||
const filteredCourses = courses.filter(
|
const filteredCourses = courses.filter(
|
||||||
({ name }) => name.toLowerCase().includes(input.toLowerCase()) && !choosenCoursesNames.includes(name),
|
({ name }) =>
|
||||||
|
name
|
||||||
|
.toLowerCase()
|
||||||
|
.normalize('NFD')
|
||||||
|
.replace(/[\u0300-\u036f]/g, '')
|
||||||
|
.includes(
|
||||||
|
input
|
||||||
|
.toLowerCase()
|
||||||
|
.normalize('NFD')
|
||||||
|
.replace(/[\u0300-\u036f]/g, ''),
|
||||||
|
) && !choosenCoursesNames.includes(name),
|
||||||
);
|
);
|
||||||
setFilteredCourses(filteredCourses);
|
setFilteredCourses(filteredCourses);
|
||||||
};
|
};
|
||||||
|
@ -107,7 +107,7 @@ export default function ({ handleTransfer }: TopbarProps) {
|
|||||||
<TopbarInputIconStyled alt="close" src={CloseIcon} onClick={handleClearInput} />
|
<TopbarInputIconStyled alt="close" src={CloseIcon} onClick={handleClearInput} />
|
||||||
</TopbarInputStyled>
|
</TopbarInputStyled>
|
||||||
<TopbarIconBox>
|
<TopbarIconBox>
|
||||||
<TopbarIcon alt="transfer" src={Transfer} onClick={handleTransfer} />
|
{/* <TopbarIcon alt="transfer" src={Transfer} onClick={handleTransfer} /> */}
|
||||||
<TopbarIcon alt="change_language" src={isPolish ? UK : PL} onClick={onLangChange} />
|
<TopbarIcon alt="change_language" src={isPolish ? UK : PL} onClick={onLangChange} />
|
||||||
<TopbarIcon alt="profile" src={User} onClick={handleProfile} />
|
<TopbarIcon alt="profile" src={User} onClick={handleProfile} />
|
||||||
<Profile anchorEl={anchorEl} handleClose={handleClose} />
|
<Profile anchorEl={anchorEl} handleClose={handleClose} />
|
||||||
|
Loading…
Reference in New Issue
Block a user