The first super admin now lands on Settings > Setup after signing up: a skippable walk through the app name, connecting a model provider and picking models, ending with where to go next. It stays under Settings to come back to. While a bot has no text model, its conversation shows a notice in the thread (centred when empty): super admins get Connect a provider and Guided setup, everyone else is told the super admin sets it up. The models modal keeps it current. The Models page's data and save logic move into useModelsOverview, shared with the setup. Co-Authored-By: Claude Opus 5.5 <[email protected]>
60 lines
1.7 KiB
TypeScript
60 lines
1.7 KiB
TypeScript
import fetchApi from "@moduletrace/twui/utils/fetch/fetchApi";
|
|
import { SettingsSetupPath } from "@/src/dict/settings-pages-dict";
|
|
import type useFormInit from "@/src/hooks/use-form-init";
|
|
import type { ApiReqParams, SignupFormObject } from "@/src/types";
|
|
import type { APIResponseObject } from "@moduletrace/bunext/types";
|
|
import validatePassword from "@/src/utils/validate-password";
|
|
|
|
type Params = ReturnType<typeof useFormInit<SignupFormObject>>;
|
|
|
|
export default async function submitSignupForm({
|
|
setLoading,
|
|
setStatus,
|
|
form,
|
|
}: Params) {
|
|
const password_error = validatePassword({ password: form.password });
|
|
|
|
if (password_error) {
|
|
setStatus({ error: true, msg: password_error });
|
|
return;
|
|
}
|
|
|
|
if (form.password != form.confirm_password) {
|
|
setStatus({ error: true, msg: "The passwords don't match." });
|
|
return;
|
|
}
|
|
|
|
setLoading(true);
|
|
|
|
const res = await fetchApi<ApiReqParams, APIResponseObject>(
|
|
`/api/auth/signup`,
|
|
{
|
|
method: "POST",
|
|
body: {
|
|
signup: {
|
|
first_name: form.first_name,
|
|
last_name: form.last_name,
|
|
username: form.username,
|
|
email: form.email,
|
|
password: form.password,
|
|
},
|
|
},
|
|
},
|
|
);
|
|
|
|
/**
|
|
* The first (super admin) account opens on the guided setup, which
|
|
* can be skipped.
|
|
*/
|
|
if (res.success) {
|
|
window.location.pathname = SettingsSetupPath;
|
|
} else {
|
|
setStatus({
|
|
error: true,
|
|
msg: res.msg || "Couldn't create your account. Please try again.",
|
|
});
|
|
|
|
setLoading(false);
|
|
}
|
|
}
|