1
0
Fork 0
mirror of https://codeberg.org/MarkusThielker/next-ory.git synced 2025-07-01 04:29:18 +00:00

NORY-22: add missing UI for boolean traits

This commit is contained in:
Markus Thielker 2024-12-13 20:20:11 +01:00
parent 4736148219
commit 206a40baed
No known key found for this signature in database
2 changed files with 20 additions and 0 deletions

View file

@ -8,6 +8,7 @@ import { z } from 'zod';
import { zodResolver } from '@hookform/resolvers/zod';
import { toast } from 'sonner';
import { Identity } from '@ory/client';
import { Checkbox } from '@/components/ui/checkbox';
interface IdentityTraitFormProps {
schema: KratosSchema;
@ -21,6 +22,21 @@ function renderUiNodes(form: UseFormReturn, properties: KratosSchemaProperties,
return Object.entries(properties).map(([key, value]) => {
if (value.type === 'object') {
return renderUiNodes(form, value.properties!, key);
} else if (value.type === 'boolean') {
return (
<FormField
control={form.control}
name={keyPrefix + key}
key={key}
className="space-y-0"
render={({ field }) => (
<FormItem className="flex items-center space-x-2 space-y-0">
<Checkbox {...field} checked={field.value}/>
<FormLabel>{value.title}</FormLabel>
</FormItem>
)}
/>
);
} else {
return (
<FormField