add create/join switch

This commit is contained in:
Johannes Kirschbauer
2023-10-31 19:05:07 +01:00
parent b2c6965ec3
commit 8677c14aaa
4 changed files with 101 additions and 19 deletions

View File

@@ -1,6 +1,4 @@
import { useListMachines } from "@/api/default/default";
import { MachinesResponse } from "@/api/model";
import { AxiosError, AxiosResponse } from "axios";
import { AxiosError } from "axios";
import React, {
Dispatch,
ReactNode,
@@ -8,7 +6,6 @@ import React, {
createContext,
useState,
} from "react";
import { KeyedMutator } from "swr";
type AppContextType = {
// data: AxiosResponse<{}, any> | undefined;
@@ -18,7 +15,7 @@ type AppContextType = {
error: AxiosError<any> | undefined;
setAppState: Dispatch<SetStateAction<AppState>>;
mutate: KeyedMutator<AxiosResponse<MachinesResponse, any>>;
// mutate: KeyedMutator<AxiosResponse<MachinesResponse, any>>;
swrKey: string | false | Record<any, any>;
};
@@ -38,7 +35,11 @@ interface AppContextProviderProps {
}
export const WithAppState = (props: AppContextProviderProps) => {
const { children } = props;
const { isLoading, error, mutate, swrKey } = useListMachines("defaultFlake");
const { isLoading, error, swrKey } = {
isLoading: false,
error: undefined,
swrKey: "default",
};
const [data, setAppState] = useState<AppState>({ isJoined: false });
@@ -50,7 +51,7 @@ export const WithAppState = (props: AppContextProviderProps) => {
isLoading,
error,
swrKey,
mutate,
// mutate,
}}
>
{children}