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

feat(provider): persistent storage #493

Merged
merged 9 commits into from
Jan 15, 2025
10 changes: 2 additions & 8 deletions apps/provider-console/src/pages/persistent-storage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,20 @@ import { useSelectedChain } from "@src/context/CustomChainProvider";
import { usePersistentStorage, useProviderDetails } from "@src/queries/useProviderQuery";
import restClient from "@src/utils/restClient";
import { sanitizeMachineAccess } from "@src/utils/sanityUtils";
import { formatBytes } from "@src/utils/formatBytes";

const PersistentStoragePage: React.FC = () => {
const router = useRouter();
const { activeControlMachine } = useControlMachine();
const { data: persistentDrives }: any = usePersistentStorage(activeControlMachine);
const { address }: any = useSelectedChain();
const { address } = useSelectedChain();
const { data: providerDetails }: any = useProviderDetails(address);
jigar-arc10 marked this conversation as resolved.
Show resolved Hide resolved

const [selectedDrives, setSelectedDrives] = useState<{ [key: string]: string[] }>({});
const [selectedType, setSelectedType] = useState<string | null>(null);

const [loading, setLoading] = useState<boolean>(false);

const formatBytes = (bytes: number) => {
const sizes = ["Bytes", "KB", "MB", "GB", "TB"];
if (bytes === 0) return "0 Byte";
const i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)).toString());
return Math.round(bytes / Math.pow(1024, i)) + " " + sizes[i];
};

const handleDriveSelection = (nodeName: string, driveName: string, driveType: string) => {
setSelectedDrives(prev => {
const nodeDrivers = prev[nodeName] || [];
Expand Down
2 changes: 1 addition & 1 deletion apps/provider-console/src/queries/useProviderQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const useDeploymentDetails = (owner: string, dseq: string) => {
});
};

export const useProviderDetails = (address: string) => {
export const useProviderDetails = (address: string | undefined) => {
return useQuery({
queryKey: ["providerDetails", address],
queryFn: () => consoleClient.get(`/v1/providers/${address}`),
Expand Down
Loading