Skip to content

Commit

Permalink
Merge pull request #169 from sledilnik/no-results-msg
Browse files Browse the repository at this point in the history
No results msg
  • Loading branch information
lukarenko authored Dec 26, 2021
2 parents 9d96a5a + a80fafa commit e89954a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/components/Doctors/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ import { filterContext } from 'context';
import DoctorCard from 'components/DoctorCard';
import { useLeafletContext } from 'context/leafletContext';
import { MAP } from 'const';
import { t } from 'i18next';
import L from 'leaflet';
import { Alert } from '@mui/material';
import * as Styled from './styles';
import { MainScrollTop } from '../Shared/ScrollTop';
import MainMap from './Map';
import FooterInfoCard from '../Shared/FooterInfo';
import { CardsList } from '../Shared/Loader';

const { GEO_LOCATION, BOUNDS } = MAP;

Expand Down Expand Up @@ -53,11 +56,19 @@ const Doctors = function Doctors({ itemsPerPage = 10, useShow }) {
const center = state?.center ?? MAP.GEO_LOCATION.SL_CENTER;

const areDoctors = Array.isArray(doctors) && doctors.length !== 0;
const dataLoading = !Array.isArray(doctors);
const noResults = !areDoctors && !dataLoading;

return (
<Styled.Wrapper show={show}>
<MainMap className="map" whenCreated={setMap} doctors={doctors} center={center} zoom={zoom} />
<Styled.WrapperInfinite id="scrollableDiv" className="cards">
{noResults && (
<Alert sx={{ margin: '24px', borderRadius: '5px' }} severity="info">
{t('noResults')}
</Alert>
)}
{dataLoading && <CardsList />}
<Styled.InfiniteScroll
id="infiniteScroll"
dataLength={doctorsPagination?.length ?? 0}
Expand All @@ -73,7 +84,7 @@ const Doctors = function Doctors({ itemsPerPage = 10, useShow }) {
/>
))}
</Styled.InfiniteScroll>
{areDoctors && <FooterInfoCard />}
{!dataLoading && <FooterInfoCard />}
<MainScrollTop />
</Styled.WrapperInfinite>
</Styled.Wrapper>
Expand Down
13 changes: 13 additions & 0 deletions src/components/Shared/Loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,18 @@ export const WrapperCenter = styled(Wrapper)(({ theme }) => ({
},
}));

export const WrapperCardsList = styled(WrapperCenter)(() => ({
width: '100%',
}));

export const Base = function Base() {
return (
<Wrapper>
<CircularProgress />
</Wrapper>
);
};

export const Center = function Center({ component = 'div' }) {
return (
<WrapperCenter component={component}>
Expand All @@ -41,6 +46,14 @@ export const Center = function Center({ component = 'div' }) {
);
};

export const CardsList = function CardsList({ component = 'div' }) {
return (
<WrapperCardsList component={component}>
<CircularProgress disableShrink />
</WrapperCardsList>
);
};

Center.defaultProps = {
component: 'div',
};
Expand Down
1 change: 1 addition & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"filter": "Filter",
"map": "Map",
"list": "List",
"noResults": "No doctors found based on your search criteria. Check if you have the right doctor type selected.",
"changedOn": "Changed on: ",
"headQuotient": "Weighted person quotient",
"doctorAvailability": "Availability can be lower than 100% for doctors that work part time on preventive programs or in other units (e.g. dentist working with adults and youth).",
Expand Down
1 change: 1 addition & 0 deletions src/locales/sl.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"filter": "Filter",
"map": "Zemljevid",
"list": "Seznam",
"noResults": "Noben zdravnik ne ustreza iskalnim pogojem. Preverite če imate označen pravilen tip zdravnika.",
"changedOn": "Popravek od: ",
"headQuotient": "Glavarinski količnik",
"doctorAvailability": "Obseg zaposlitve: delež je lahko nižji od 100 %, ker zdravnik določen del časa dela na preventivnih programih ali na drugih dejavnostih (recimo zobozdravnik za odrasle in mladino).",
Expand Down

0 comments on commit e89954a

Please sign in to comment.