Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added skeleton loader during advanced filters #9020

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/CAREUI/display/Count.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { classNames } from "../../Utils/utils";
import CareIcon, { IconName } from "../icons/CareIcon";

interface Props {
count: number;
count: number | null;
text: string;
loading: boolean;
icon: IconName;
Expand All @@ -20,7 +20,7 @@ export default function CountBlock(props: Props) {
<dt className="mb-1 truncate text-sm font-semibold text-secondary-700">
{props.text}
</dt>
{props.loading ? (
{props.loading || props.count == null ? (
<dd className="h-10 w-full max-w-[100px] animate-pulse rounded-lg bg-secondary-300" />
) : (
<dd id="count" className="text-5xl font-black leading-9">
Expand Down
8 changes: 4 additions & 4 deletions src/components/Assets/AssetsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const AssetsList = () => {
const [assets, setAssets] = useState([{} as AssetData]);
const [isLoading, setIsLoading] = useState(false);
const [isScannerActive, setIsScannerActive] = useState(false);
const [totalCount, setTotalCount] = useState(0);
const [totalCount, setTotalCount] = useState<number | null>(null);
const [facility, setFacility] = useState<FacilityModel>();
const [status, setStatus] = useState<string>();
const [asset_class, setAssetClass] = useState<string>();
Expand Down Expand Up @@ -71,7 +71,7 @@ const AssetsList = () => {
onResponse: ({ res, data }) => {
if (res?.status === 200 && data) {
setAssets(data.results);
setTotalCount(data.count);
setTotalCount(data?.count);
}
},
});
Expand Down Expand Up @@ -359,7 +359,7 @@ const AssetsList = () => {
<div className="mt-5 gap-3 space-y-2 lg:flex">
<CountBlock
text="Total Assets"
count={totalCount}
count={loading || totalCount === undefined ? null : totalCount}
loading={loading}
icon="l-monitor-heart-rate"
className="flex-1"
Expand Down Expand Up @@ -443,7 +443,7 @@ const AssetsList = () => {
<div className="grow">
<div className="py-8 md:px-5">
{manageAssets}
<Pagination totalCount={totalCount} />
{totalCount !== null && <Pagination totalCount={totalCount} />}
</div>
</div>
</>
Expand Down
4 changes: 3 additions & 1 deletion src/components/Facility/DischargedPatientsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,9 @@ const DischargedPatientsList = ({
<div className="flex-1">
<CountBlock
text="Discharged Patients"
count={count}
count={
facilityQuery.loading || count === undefined ? null : count
}
loading={facilityQuery.loading}
icon="l-user-injured"
className="pb-12"
Expand Down
6 changes: 5 additions & 1 deletion src/components/Facility/FacilityList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,11 @@ export const FacilityList = () => {
<div className="mt-4 gap-2 lg:flex">
<CountBlock
text="Total Facilities"
count={permittedData ? permittedData.count : 0}
count={
isLoading || permittedData?.count === undefined
? null
: permittedData.count
}
loading={isLoading}
icon="l-hospital"
className="flex-1"
Expand Down
6 changes: 5 additions & 1 deletion src/components/Facility/FacilityUsers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,11 @@ export default function FacilityUsers(props: any) {
{facilityUserData && (
<CountBlock
text={t("total_users")}
count={facilityUserData.count}
count={
isLoading || facilityUserData?.count === undefined
? null
: facilityUserData.count
}
loading={isLoading}
icon="l-user-injured"
className="flex-1"
Expand Down
4 changes: 3 additions & 1 deletion src/components/Patient/ManagePatients.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,9 @@ export const PatientManager = () => {
<div className="flex-1" id="total-patientcount">
<CountBlock
text="Total Patients"
count={data?.count || 0}
count={
isLoading || data?.count === undefined ? null : data?.count
}
loading={isLoading}
icon="l-user-injured"
className="pb-12"
Expand Down
6 changes: 5 additions & 1 deletion src/components/Patient/SampleViewAdmin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,11 @@ export default function SampleViewAdmin() {
<div className="w-full">
<CountBlock
text="Total Samples Taken"
count={sampeleData?.count || 0}
count={
isLoading || sampeleData?.count === undefined
? null
: sampeleData.count
}
loading={isLoading}
icon="l-thermometer"
className="flex-1"
Expand Down
8 changes: 7 additions & 1 deletion src/components/Users/ManageUsers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,13 @@ export default function ManageUsers() {
<div className="mt-5 grid grid-cols-1 sm:grid-cols-3 md:gap-5">
<CountBlock
text="Total Users"
count={userListData?.count || 0}
count={
userListLoading ||
districtDataLoading ||
userListData?.count === undefined
? null
: userListData.count
}
loading={userListLoading || districtDataLoading}
icon="l-user-injured"
className="flex-1"
Expand Down
Loading