home-lab/src/app/index/index.tsx

45 lines
1.2 KiB
TypeScript
Raw Normal View History

2024-03-09 18:48:49 +07:00
import React from "react";
2024-03-15 09:05:49 +07:00
import api from "@/lib/api";
import { useQuery } from "react-query";
import Text from "@ui/Text";
import Performance from "./_sections/Performance";
import Summary from "./_sections/Summary";
import Storage from "./_sections/Storage";
2024-03-16 07:52:42 +07:00
import Container from "@ui/Container";
import { useAuth } from "@/stores/authStore";
2024-03-16 10:14:17 +07:00
import { HStack } from "@ui/Stack";
import Box from "@ui/Box";
import Apps from "./_sections/Apps";
2024-03-09 18:48:49 +07:00
2024-03-16 07:52:42 +07:00
const HomePage = () => {
const { isLoggedIn } = useAuth();
2024-03-15 09:05:49 +07:00
const { data: system } = useQuery({
queryKey: ["system"],
queryFn: () => api.system.$get().then((r) => r.json()),
refetchInterval: 1000,
2024-03-16 07:52:42 +07:00
enabled: isLoggedIn,
2024-03-15 09:05:49 +07:00
});
2024-03-09 18:48:49 +07:00
2024-03-16 07:52:42 +07:00
if (!isLoggedIn) {
return null;
}
2024-03-09 18:48:49 +07:00
return (
2024-03-16 10:14:17 +07:00
<Container scrollable className="px-4 md:px-8 max-w-none py-8">
<HStack className="items-start gap-8">
<Box className="flex-1 md:max-w-lg">
<Text className="text-2xl font-medium">Home Lab</Text>
<Summary data={system} />
<Apps className="md:hidden mt-6" />
<Performance data={system} />
<Storage data={system} />
</Box>
2024-03-16 13:21:12 +07:00
2024-03-16 10:14:17 +07:00
<Apps className="hidden md:flex md:flex-col md:flex-1" />
</HStack>
2024-03-16 07:52:42 +07:00
</Container>
2024-03-09 18:48:49 +07:00
);
};
2024-03-16 07:52:42 +07:00
export default HomePage;