forked from baron/baron-sso
fix: follow rules of hooks in TenantSchemaPage
This commit is contained in:
@@ -58,7 +58,10 @@ export function TenantSchemaPage() {
|
|||||||
|
|
||||||
const tenantQuery = useQuery({
|
const tenantQuery = useQuery({
|
||||||
queryKey: ["tenant", tenantId],
|
queryKey: ["tenant", tenantId],
|
||||||
queryFn: () => fetchTenant(tenantId!),
|
queryFn: () => {
|
||||||
|
if (!tenantId) throw new Error("Tenant ID is required");
|
||||||
|
return fetchTenant(tenantId);
|
||||||
|
},
|
||||||
enabled: !!tenantId && canAccess,
|
enabled: !!tenantId && canAccess,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -94,6 +97,8 @@ export function TenantSchemaPage() {
|
|||||||
|
|
||||||
const updateMutation = useMutation({
|
const updateMutation = useMutation({
|
||||||
mutationFn: (newFields: SchemaField[]) => {
|
mutationFn: (newFields: SchemaField[]) => {
|
||||||
|
if (!tenantId) throw new Error("Tenant ID is required");
|
||||||
|
|
||||||
// Remove legacy loginIdField, keep isLoginId natively in userSchema
|
// Remove legacy loginIdField, keep isLoginId natively in userSchema
|
||||||
const newConfig = { ...tenantQuery.data?.config };
|
const newConfig = { ...tenantQuery.data?.config };
|
||||||
newConfig.loginIdField = undefined;
|
newConfig.loginIdField = undefined;
|
||||||
|
|||||||
Reference in New Issue
Block a user