remove unused useTheme import and add loading state for entity detail view (#154)

This commit is contained in:
dswbx
2025-04-22 15:43:27 +02:00
committed by GitHub
parent 4c11789ea8
commit 9010401af6
2 changed files with 30 additions and 22 deletions

View File

@@ -10,7 +10,6 @@ import { SocialLink } from "./SocialLink";
import type { ValueError } from "@sinclair/typebox/value"; import type { ValueError } from "@sinclair/typebox/value";
import { type TSchema, Value } from "core/utils"; import { type TSchema, Value } from "core/utils";
import type { Validator } from "json-schema-form-react"; import type { Validator } from "json-schema-form-react";
import { useTheme } from "ui/client/use-theme";
class TypeboxValidator implements Validator<ValueError> { class TypeboxValidator implements Validator<ValueError> {
async validate(schema: TSchema, data: any) { async validate(schema: TSchema, data: any) {
@@ -46,7 +45,6 @@ export function AuthForm({
buttonLabel = action === "login" ? "Sign in" : "Sign up", buttonLabel = action === "login" ? "Sign in" : "Sign up",
...props ...props
}: LoginFormProps) { }: LoginFormProps) {
const { theme } = useTheme();
const basepath = auth?.basepath ?? "/api/auth"; const basepath = auth?.basepath ?? "/api/auth";
const password = { const password = {
action: `${basepath}/password/${action}`, action: `${basepath}/password/${action}`,

View File

@@ -164,26 +164,36 @@ export function DataEntityUpdate({ params }) {
]} ]}
/> />
</AppShell.SectionHeader> </AppShell.SectionHeader>
<AppShell.Scrollable> {$q.isLoading ? (
{error && ( <div className="w-full h-full flex justify-center items-center font-mono opacity-30">
<div className="flex flex-row dark:bg-red-950 bg-red-100 p-4"> Loading...
<b className="mr-2">Update failed: </b> {error} </div>
</div> ) : (
)} <AppShell.Scrollable>
<EntityForm {error && (
entity={entity} <div className="flex flex-row dark:bg-red-950 bg-red-100 p-4">
entityId={entityId} <b className="mr-2">Update failed: </b> {error}
handleSubmit={handleSubmit} </div>
fieldsDisabled={fieldsDisabled} )}
data={data ?? undefined} <EntityForm
Form={Form} entity={entity}
action="update" entityId={entityId}
className="flex flex-grow flex-col gap-3 p-3" handleSubmit={handleSubmit}
/> fieldsDisabled={fieldsDisabled}
{targetRelations.length > 0 ? ( data={data ?? undefined}
<EntityDetailRelations id={entityId} entity={entity} relations={targetRelations} /> Form={Form}
) : null} action="update"
</AppShell.Scrollable> className="flex flex-grow flex-col gap-3 p-3"
/>
{targetRelations.length > 0 ? (
<EntityDetailRelations
id={entityId}
entity={entity}
relations={targetRelations}
/>
) : null}
</AppShell.Scrollable>
)}
</Fragment> </Fragment>
); );
} }