Skip to content
Merged
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
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