Skip to content

Commit

Permalink
Merge pull request #10 from ssec-jhu/iainland/handle-empty-history
Browse files Browse the repository at this point in the history
handle empty history
  • Loading branch information
imaitland authored Nov 14, 2024
2 parents 89c340f + 926c792 commit 853f4cb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
21 changes: 13 additions & 8 deletions app/routes/devices.$id.hardware.$hardware_name.history.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import * as Evolver from "client/services.gen";
import { db } from "~/utils/db.server";
import { HardwareLineChart } from "~/components/LineChart";
import { loader as rootLoader } from "~/root";
import { XCircleIcon } from "@heroicons/react/24/solid";

export const handle = {
breadcrumb: (
Expand Down Expand Up @@ -47,18 +48,16 @@ export async function loader({ params, request }: LoaderFunctionArgs) {

const properties = searchParams.get("properties")?.split(",");

const {
data: { data },
} = await Evolver.history({
body: {
const { data } = await Evolver.history({
query: {
name: hardware_name,
vials,
properties,
},
query: { name: hardware_name },
client: evolverClient,
});

return json({ data });
return json({ data: data?.data });
}

export default function Hardware() {
Expand All @@ -69,8 +68,14 @@ export default function Hardware() {
const excludedProperties = EXCLUDED_PROPERTIES?.split(",") ?? [];
const [searchParams] = useSearchParams();
const { hardware_name } = useParams();
if (!hardware_name) {
return <div>Hardware not found</div>;

if (!data || !hardware_name || !data[hardware_name]) {
return (
<div className="flex flex-col items-center justify-center p-10">
<XCircleIcon className="w-6 h-6" />
<div>Data not found</div>
</div>
);
}
const hardwareHistory = data[hardware_name];
const allHardwareVials = Object.keys(hardwareHistory[0].data);
Expand Down
2 changes: 1 addition & 1 deletion app/routes/devices.$id.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export function ErrorBoundary() {
</div>
</div>

<Link to="/" className="link">
<Link to="/devices" className="link">
home
</Link>
</div>
Expand Down

0 comments on commit 853f4cb

Please sign in to comment.