Unverified Commit 015b4c86 authored by ksmirnov's avatar ksmirnov Committed by GitHub

Merge pull request #4 from AyaDigital/hotfix/DMVP-1057

DMVP-1057 - Bug.-Dictionary-selectors-fix
parents 811e7621 c62a070e
......@@ -16,5 +16,4 @@ test('renders learn react link', () => {
</BrowserRouter>
</Provider>
);
// expect(linkElement).toBeInTheDocument();
});
......@@ -15,14 +15,10 @@ const InfiniteLoaderWrapper =({
items,
loadNextPage,
wrapperClassName,
getOptionProps,
groupedOptions,
listboxProps,
fieldname = 'name',
search,
onChange,
onFocus,
onBlur,
handleSelect,
listOpen
}) => {
......@@ -33,25 +29,25 @@ const InfiniteLoaderWrapper =({
const isItemLoaded = (index) => !hasNextPage || index < items.length;
const Item = ({ index, style }) => {
console.log('index', index);
if (!isItemLoaded(index)) {
return <li style={style}>Loading...</li>;
} else {
const option = items[index];
const name = option.name || "no name";
if (!isItemLoaded(index)) {
return <li style={style}>Loading...</li>;
} else {
const option = groupedOptions[index];
const name = option.name || "no name";
return (
<li
style={style}
onClick={(e) => {
handleSelect(Number(option.id))
}}
>
{name}
</li>
);
}
};
return (
<li
style={style}
onClick={(e) => {
handleSelect(Number(option.id))
}}
>
{name}
</li>
);
}
};
return (
<Popover placement='bottom-start' isOpen={listOpen}>
......
......@@ -6,7 +6,7 @@ const SCHEDULES = '/api/schedules'
const ADMIN = '/admin'
export const schedulesApi = createApi({
reducerPath: 'statesApi',
reducerPath: 'schedulesApi',
baseQuery: baseQueryWithToken,
entityTypes: ["Schedule"],
endpoints: (builder) => ({
......
......@@ -53,7 +53,7 @@ export const statesApi = createApi({
})
export const {
useFetchStatesQuery,
// useFetchStatesQuery,
useFetchStatesByPageQuery,
useCreateStateMutation,
useUpdateStateMutation,
......
import React, {useState} from 'react';
import { useNavigate, useLocation } from "react-router-dom";
import upperfirst from 'lodash.upperfirst';
import ErrorBoundary from '_components/error/ErrorBoundary';
import clone from 'lodash/clone';
import { Button } from '@chakra-ui/react';
import { Checkbox } from '@chakra-ui/react';
......@@ -118,7 +118,6 @@ const ClinicPage = () => {
</BreadcrumbItem>
<BreadcrumbItem
isLoading={isOneClinicLoading}
isCurrentPage
>
<BreadcrumbLink
......
import React, { useState, useEffect } from 'react';
import { uniq } from 'lodash';
import { uniq, isEqual } from 'lodash';
import {
Spinner,
} from '@chakra-ui/react';
......@@ -28,8 +28,10 @@ const DegreesLoader = ({
useEffect(() => {
const list = currentScrollToken === null ? data : uniq([...data, ...currentList]);
setCurrentList(list)
}, [isSuccess, isLastPage, scrollToken, data, currentScrollToken, currentList]);
if (!isEqual(currentList, list)) {
setCurrentList(list);
}
}, [isSuccess, data, currentScrollToken, currentList]);
const _loadNextPage = () => {
return new Promise(resolve =>
......
import React, { useState, useEffect } from 'react';
import { uniq } from 'lodash';
import { uniq, isEqual } from 'lodash';
import {
Spinner,
} from '@chakra-ui/react';
......@@ -28,8 +28,10 @@ const InsurancesLoader = ({
useEffect(() => {
const list = currentScrollToken === null ? data : uniq([...data, ...currentList]);
setCurrentList(list)
}, [isSuccess, isLastPage, scrollToken, data, currentScrollToken, currentList]);
if (!isEqual(currentList, list)) {
setCurrentList(list);
}
}, [isSuccess, data, currentScrollToken, currentList]);
const _loadNextPage = () => {
return new Promise(resolve =>
......
import React, { useState, useEffect } from 'react';
import { uniq } from 'lodash';
import { uniq, isEqual } from 'lodash';
import {
Spinner,
} from '@chakra-ui/react';
......@@ -29,8 +29,10 @@ const LanguagesLoader = ({
useEffect(() => {
const list = currentScrollToken === null ? data : uniq([...data, ...currentList]);
setCurrentList(list)
}, [isSuccess, isLastPage, scrollToken, data, currentScrollToken, currentList]);
if (!isEqual(currentList, list)) {
setCurrentList(list);
}
}, [isSuccess, data, currentScrollToken, currentList]);
const _loadNextPage = () => {
return new Promise(resolve =>
......
import React, { useState, useEffect } from 'react';
import { uniq } from 'lodash';
import { uniq, isEqual } from 'lodash';
import {
Spinner,
} from '@chakra-ui/react';
......@@ -16,7 +16,7 @@ const SpecialitiesLoader = ({
}) => {
const [search, setSearch] = useState('');
const [currentScrollToken, setCurrentScrollToken] = useState(null);
const [currentSpecialities, setCurrentSpecialities] = useState([]);
const [currentList, setCurrentList] = useState([]);
const [page, setPage] = useState(0);
const { isLoading: isSpecialitiesLoading, isSuccess, data: specialities = {}}
......@@ -28,11 +28,14 @@ const SpecialitiesLoader = ({
const { data = [], scrollToken, isLastPage } = specialities;
useEffect(() => {
const specialitiesData = currentScrollToken === null ? data : uniq([...data, ...currentSpecialities]);
setCurrentSpecialities(specialitiesData)
}, [isSuccess, isLastPage, scrollToken, data, currentScrollToken, currentSpecialities]);
const list = currentScrollToken === null ? data : uniq([...data, ...currentList]);
if (!isEqual(list, currentList)) {
setCurrentList(list);
}
}, [isSuccess, data, currentScrollToken, currentList]);
const _loadNextPage = () => {
console.log('loadnextPage')
return new Promise(resolve =>
setTimeout(() => {
setPage(page + 1)
......@@ -44,12 +47,13 @@ const SpecialitiesLoader = ({
useEffect(() => {
if (search) {
console.log('search')
setPage(0)
setCurrentScrollToken(null);
setCurrentSpecialities([])
setCurrentList([])
}
}, [search])
console.log('8888')
return (
<div className='speciality-layout'>
<>
......@@ -67,11 +71,11 @@ const SpecialitiesLoader = ({
<InfiniteLoaderBlock
hasNextPage={!isLastPage}
isNextPageLoading={false}
items={currentSpecialities}
items={currentList || []}
fieldname='spec'
// listOpen={search}
loadNextPage={_loadNextPage}
wrapperClassName='listbox'
groupedOptions={currentSpecialities || []}
handleSelect={handleAddSpeciality}
search={search}
onFocus={handleListOpen}
......
......@@ -263,7 +263,7 @@ const SpecialityData = ({
<GridItem h='50px' colSpan={2}>
<InsurancesLoader
handleAddSpeciality={handleAddSpeciality}
handleAddInsurance={handleAddInsurance}
/>
</GridItem>
......@@ -294,7 +294,7 @@ const SpecialityData = ({
<GridItem h='50px' colSpan={2}>
<SpecialitiesLoader
handleAddInsurance={handleAddInsurance}
handleAddSpeciality={handleAddSpeciality}
/>
</GridItem>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment