Skip to content

Commit

Permalink
feat: added NoRecords component to view apps screen
Browse files Browse the repository at this point in the history
  • Loading branch information
itssamuelrowe committed Apr 13, 2022
1 parent 244f3ba commit 504cc50
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions packages/console/src/screens/view-apps/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
Container,
Hidden,
Icon,
InputAdornment,
InputLabel,
MenuItem,
FormControl as MuiFormControl,
Expand All @@ -23,6 +22,8 @@ import { gql, useQuery } from "@apollo/client";

import { useNavigate } from "react-router";

import { NoRecords } from "../../components";

import AppCard from "./AppCard";
import AppFilter from "./AppFilter";

Expand Down Expand Up @@ -144,6 +145,7 @@ const ViewApps: FunctionComponent = (): ReactElement => {
const [filter, setFilter] = useState<string>(filters[0].url);
const navigate = useNavigate();
const { loading, data } = useQuery(GET_APPS);
const records = data?.getApps?.records ?? [];

const handleCreateNew = useCallback(() => {
navigate("/apps/new");
Expand Down Expand Up @@ -217,14 +219,21 @@ const ViewApps: FunctionComponent = (): ReactElement => {
</ProgressContainer>
)}

{!loading && data?.getApps?.records?.length === 0 && (
<Text>You do not have any apps yet.</Text>
{!loading && records.length === 0 && (
<NoRecords
message="We tried our best, but couldn't find any apps."
image="https://res.cloudinary.com/hypertool/image/upload/v1649820987/hypertool-assets/empty-apps_ok9nbh.svg"
actionText="Create New App"
actionIcon="add_circle_outline"
onAction={handleCreateNew}
/>
)}

{!loading && data?.getApps?.records?.length !== 0 && (
{!loading && records.length > 0 && (
<Apps>
{data?.getApps?.records?.map((app: any) => (
{records.map((app: any) => (
<AppCard
key={app.id}
id={app.id}
name={app.name}
description={app.description}
Expand Down

0 comments on commit 504cc50

Please sign in to comment.