Add public IP field and Network interface to host form
This commit is contained in:
@@ -1,6 +1,13 @@
|
||||
import type { BUN_SQLITE_WGUI_ALL_TYPEDEFS } from "@/db/types/db";
|
||||
import useStatus from "@/src/components/twui/hooks/useStatus";
|
||||
import { useCallback, useContext, useEffect, useState } from "react";
|
||||
import {
|
||||
useCallback,
|
||||
useContext,
|
||||
useEffect,
|
||||
useState,
|
||||
type Dispatch,
|
||||
type SetStateAction,
|
||||
} from "react";
|
||||
import { AppContext } from "../pages/__root";
|
||||
import type { ImageInputToBase64FunctionReturn } from "../components/twui/utils/form/imageInputToBase64";
|
||||
import EJSON from "../utils/ejson";
|
||||
@@ -32,6 +39,14 @@ type Params<T extends {} = BUN_SQLITE_WGUI_ALL_TYPEDEFS> = {
|
||||
* Is this the first user?
|
||||
*/
|
||||
is_first_user?: boolean;
|
||||
/**
|
||||
* Function to run before the `setReady`
|
||||
* dispatch is fired
|
||||
*/
|
||||
before_ready_function?: (params: {
|
||||
form: T;
|
||||
setForm: Dispatch<SetStateAction<T>>;
|
||||
}) => Promise<void>;
|
||||
};
|
||||
|
||||
export default function useFormInit<
|
||||
@@ -94,7 +109,22 @@ export default function useFormInit<
|
||||
}
|
||||
} catch (error) {
|
||||
} finally {
|
||||
setReady(true);
|
||||
if (params?.before_ready_function) {
|
||||
params
|
||||
.before_ready_function({ form, setForm })
|
||||
.then(() => {})
|
||||
.catch((e2) => {
|
||||
console.log(
|
||||
`Before ready function error:`,
|
||||
e2.message,
|
||||
);
|
||||
})
|
||||
.finally(() => {
|
||||
setReady(true);
|
||||
});
|
||||
} else {
|
||||
setReady(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, []);
|
||||
|
||||
Reference in New Issue
Block a user