Skip to content

Commit e1ea9d5

Browse files
committed
Added the skeleton loader when running the queries.
1 parent 8765195 commit e1ea9d5

File tree

2 files changed

+43
-6
lines changed

2 files changed

+43
-6
lines changed

web-ui/src/pages/AnniversaryReportPage.jsx

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
noPermission,
1919
} from '../context/selectors';
2020
import { useQueryParameters } from '../helpers/query-parameters';
21+
import SkeletonLoader from '../components/skeleton_loader/SkeletonLoader';
2122

2223
const months = [
2324
'January',
@@ -43,6 +44,7 @@ const AnniversaryReportPage = () => {
4344
const [searchAnniversaryResults, setSearchAnniversaryResults] = useState([]);
4445
const [selectedMonths, setSelectedMonths] = useState(defaultMonths);
4546
const [hasSearched, setHasSearched] = useState(false);
47+
const [loading, setLoading] = useState(false);
4648

4749
useQueryParameters([
4850
{
@@ -57,9 +59,22 @@ const AnniversaryReportPage = () => {
5759
]);
5860

5961
const handleSearch = async monthsToSearch => {
60-
const anniversaryResults = await getAnniversaries(monthsToSearch, csrf);
61-
setSearchAnniversaryResults(sortAnniversaries(anniversaryResults));
62-
setHasSearched(true);
62+
setLoading(true);
63+
try {
64+
const anniversaryResults = await getAnniversaries(monthsToSearch, csrf);
65+
setSearchAnniversaryResults(sortAnniversaries(anniversaryResults));
66+
setHasSearched(true);
67+
} catch(e) {
68+
console.error(e);
69+
window.snackDispatch({
70+
type: UPDATE_TOAST,
71+
payload: {
72+
severity: 'error',
73+
toast: e,
74+
}
75+
});
76+
}
77+
setLoading(false);
6378
};
6479

6580
function onMonthChange(event, newValue) {
@@ -111,6 +126,10 @@ const AnniversaryReportPage = () => {
111126
</div>
112127
<div>
113128
{
129+
loading ?
130+
Array.from({ length: 10 }).map((_, index) => (
131+
<SkeletonLoader key={index} type="feedback_requests" />
132+
)) :
114133
<div className="search-results">
115134
<SearchBirthdayAnniversaryResults
116135
hasSearched={hasSearched}

web-ui/src/pages/BirthdayReportPage.jsx

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { getBirthdays } from '../api/birthdayanniversary';
1111
import { UPDATE_TOAST } from '../context/actions';
1212
import SearchBirthdayAnniversaryResults from '../components/search-results/SearchBirthdayAnniversaryResults';
1313
import { sortBirthdays } from '../context/util';
14+
import SkeletonLoader from '../components/skeleton_loader/SkeletonLoader';
1415

1516
import {
1617
selectCsrfToken,
@@ -43,6 +44,7 @@ const BirthdayReportPage = () => {
4344
const [searchBirthdayResults, setSearchBirthdayResults] = useState([]);
4445
const [selectedMonths, setSelectedMonths] = useState(defaultMonths);
4546
const [hasSearched, setHasSearched] = useState(false);
47+
const [loading, setLoading] = useState(false);
4648

4749
useQueryParameters([
4850
{
@@ -57,9 +59,21 @@ const BirthdayReportPage = () => {
5759
]);
5860

5961
const handleSearch = async monthsToSearch => {
60-
const birthdayResults = await getBirthdays(monthsToSearch, csrf);
61-
setSearchBirthdayResults(sortBirthdays(birthdayResults));
62-
setHasSearched(true);
62+
setLoading(true);
63+
try {
64+
const birthdayResults = await getBirthdays(monthsToSearch, csrf);
65+
setSearchBirthdayResults(sortBirthdays(birthdayResults));
66+
setHasSearched(true);
67+
} catch(e) {
68+
window.snackDispatch({
69+
type: UPDATE_TOAST,
70+
payload: {
71+
severity: 'error',
72+
toast: e,
73+
}
74+
});
75+
}
76+
setLoading(false);
6377
};
6478

6579
function onMonthChange(event, newValue) {
@@ -111,6 +125,10 @@ const BirthdayReportPage = () => {
111125
</div>
112126
<div>
113127
{
128+
loading ?
129+
Array.from({ length: 10 }).map((_, index) => (
130+
<SkeletonLoader key={index} type="feedback_requests" />
131+
)) :
114132
<div className="search-results">
115133
<SearchBirthdayAnniversaryResults
116134
hasSearched={hasSearched}

0 commit comments

Comments
 (0)