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

Fix: Display Care Loading Icon Instead of "No Assets Found" on Asset Tab Revisit on advanced filter #9205

13 changes: 8 additions & 5 deletions src/components/Assets/AssetsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ const AssetsList = () => {
const [status, setStatus] = useState<string>();
const [asset_class, setAssetClass] = useState<string>();
const [importAssetModalOpen, setImportAssetModalOpen] = useState(false);
const assetsExist = assets.length > 0 && Object.keys(assets[0]).length > 0;
const [showFacilityDialog, setShowFacilityDialog] = useState(false);
const [selectedFacility, setSelectedFacility] = useState<FacilityModel>({
name: "",
Expand All @@ -70,7 +69,11 @@ const AssetsList = () => {
qParams.warranty_amc_end_of_validity_after || "",
};

const { refetch: assetsFetch, loading } = useQuery(routes.listAssets, {
const {
refetch: assetsFetch,
loading,
data,
} = useQuery(routes.listAssets, {
query: params,
onResponse: ({ res, data }) => {
if (res?.status === 200 && data) {
Expand Down Expand Up @@ -210,13 +213,13 @@ const AssetsList = () => {
);

let manageAssets = null;
if (loading) {
if (loading || !data) {
manageAssets = (
<div className="col-span-3 w-full py-8 text-center">
<Loading />
</div>
);
rithviknishad marked this conversation as resolved.
Show resolved Hide resolved
} else if (assetsExist) {
} else if (data.count) {
manageAssets = (
<div className="grid grid-cols-1 gap-2 md:-mx-8 md:grid-cols-2 lg:grid-cols-3">
{assets.map((asset: AssetData) => (
Expand Down Expand Up @@ -371,7 +374,7 @@ const AssetsList = () => {
<CountBlock
text="Total Assets"
count={totalCount}
loading={loading}
loading={loading || !data}
icon="l-monitor-heart-rate"
className="flex-1"
/>
Expand Down
Loading