diff --git a/apps/client/app/api-client/@tanstack/react-query.gen.ts b/apps/client/app/api-client/@tanstack/react-query.gen.ts index 4dc4c91..360b7d1 100644 --- a/apps/client/app/api-client/@tanstack/react-query.gen.ts +++ b/apps/client/app/api-client/@tanstack/react-query.gen.ts @@ -22,6 +22,7 @@ import { createRepository, deleteRepository, getRepository, + listSnapshots, } from "../sdk.gen"; import { queryOptions, type UseMutationOptions, type DefaultError } from "@tanstack/react-query"; import type { @@ -57,6 +58,7 @@ import type { DeleteRepositoryData, DeleteRepositoryResponse, GetRepositoryData, + ListSnapshotsData, } from "../types.gen"; import { client as _heyApiClient } from "../client.gen"; @@ -671,3 +673,23 @@ export const getRepositoryOptions = (options: Options) => { queryKey: getRepositoryQueryKey(options), }); }; + +export const listSnapshotsQueryKey = (options: Options) => createQueryKey("listSnapshots", options); + +/** + * List all snapshots in a repository + */ +export const listSnapshotsOptions = (options: Options) => { + return queryOptions({ + queryFn: async ({ queryKey, signal }) => { + const { data } = await listSnapshots({ + ...options, + ...queryKey[0], + signal, + throwOnError: true, + }); + return data; + }, + queryKey: listSnapshotsQueryKey(options), + }); +}; diff --git a/apps/client/app/api-client/sdk.gen.ts b/apps/client/app/api-client/sdk.gen.ts index 81bb3af..80c88ec 100644 --- a/apps/client/app/api-client/sdk.gen.ts +++ b/apps/client/app/api-client/sdk.gen.ts @@ -52,6 +52,8 @@ import type { DeleteRepositoryResponses, GetRepositoryData, GetRepositoryResponses, + ListSnapshotsData, + ListSnapshotsResponses, } from "./types.gen"; import { client as _heyApiClient } from "./client.gen"; @@ -321,3 +323,15 @@ export const getRepository = ( ...options, }); }; + +/** + * List all snapshots in a repository + */ +export const listSnapshots = ( + options: Options, +) => { + return (options.client ?? _heyApiClient).get({ + url: "/api/v1/repositories/{name}/snapshots", + ...options, + }); +}; diff --git a/apps/client/app/api-client/types.gen.ts b/apps/client/app/api-client/types.gen.ts index 7313aa1..8efa5e6 100644 --- a/apps/client/app/api-client/types.gen.ts +++ b/apps/client/app/api-client/types.gen.ts @@ -778,6 +778,32 @@ export type GetRepositoryResponses = { export type GetRepositoryResponse = GetRepositoryResponses[keyof GetRepositoryResponses]; +export type ListSnapshotsData = { + body?: never; + path: { + name: string; + }; + query?: never; + url: "/api/v1/repositories/{name}/snapshots"; +}; + +export type ListSnapshotsResponses = { + /** + * List of snapshots + */ + 200: { + snapshots: Array<{ + duration: number; + paths: Array; + short_id: string; + size: number; + time: number; + }>; + }; +}; + +export type ListSnapshotsResponse = ListSnapshotsResponses[keyof ListSnapshotsResponses]; + export type ClientOptions = { baseUrl: "http://192.168.2.42:4096" | (string & {}); }; diff --git a/apps/client/app/components/bytes-size.tsx b/apps/client/app/components/bytes-size.tsx index fbe1b15..979d144 100644 --- a/apps/client/app/components/bytes-size.tsx +++ b/apps/client/app/components/bytes-size.tsx @@ -1,4 +1,4 @@ -import React from "react"; +import type React from "react"; type ByteSizeProps = { bytes: number; @@ -54,7 +54,7 @@ export function formatBytes( idx = Math.max(0, Math.min(idx, units.length - 1)); } - const numeric = (abs / Math.pow(base, idx)) * sign; + const numeric = (abs / base ** idx) * sign; const maxFrac = (() => { if (!smartRounding) return maximumFractionDigits; diff --git a/apps/client/app/components/layout.tsx b/apps/client/app/components/layout.tsx index a1bd202..13b45de 100644 --- a/apps/client/app/components/layout.tsx +++ b/apps/client/app/components/layout.tsx @@ -47,9 +47,7 @@ export default function Layout({ loaderData }: Route.ComponentProps) {
Welcome,  - - {loaderData.user?.username[0].toUpperCase() + loaderData.user?.username.slice(1)} - + {loaderData.user?.username}