Fix: Select.Item value prop error
The Select.Item component requires a non-empty string value prop. This commit addresses the error by ensuring that the value prop is not an empty string.
This commit is contained in:
parent
1c78451e07
commit
34968ee74a
@ -33,7 +33,7 @@ const transactionSchema = z.object({
|
|||||||
categoria: z.string().min(1, { message: 'Categoria é obrigatória' }),
|
categoria: z.string().min(1, { message: 'Categoria é obrigatória' }),
|
||||||
tipo: z.string().min(1, { message: 'Tipo é obrigatório' }),
|
tipo: z.string().min(1, { message: 'Tipo é obrigatório' }),
|
||||||
quando: z.string().min(1, { message: 'Data é obrigatória' }),
|
quando: z.string().min(1, { message: 'Data é obrigatória' }),
|
||||||
grupo_id: z.string().optional()
|
grupo_id: z.string().nullable().optional()
|
||||||
});
|
});
|
||||||
|
|
||||||
type TransactionFormValues = z.infer<typeof transactionSchema>;
|
type TransactionFormValues = z.infer<typeof transactionSchema>;
|
||||||
@ -43,8 +43,8 @@ interface TransactionFormProps {
|
|||||||
onCancel: () => void;
|
onCancel: () => void;
|
||||||
defaultTipo?: 'receita' | 'despesa';
|
defaultTipo?: 'receita' | 'despesa';
|
||||||
grupoId?: string;
|
grupoId?: string;
|
||||||
transaction?: Transaction | null; // Added this property
|
transaction?: Transaction | null;
|
||||||
isEditing?: boolean; // Added this property
|
isEditing?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function TransactionForm({
|
export function TransactionForm({
|
||||||
@ -52,8 +52,8 @@ export function TransactionForm({
|
|||||||
onCancel,
|
onCancel,
|
||||||
defaultTipo = 'despesa',
|
defaultTipo = 'despesa',
|
||||||
grupoId,
|
grupoId,
|
||||||
transaction = null, // Default to null
|
transaction = null,
|
||||||
isEditing = false // Default to false
|
isEditing = false
|
||||||
}: TransactionFormProps) {
|
}: TransactionFormProps) {
|
||||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||||
const [grupos, setGrupos] = useState<{remote_jid: string, nome_grupo: string | null}[]>([]);
|
const [grupos, setGrupos] = useState<{remote_jid: string, nome_grupo: string | null}[]>([]);
|
||||||
@ -98,7 +98,7 @@ export function TransactionForm({
|
|||||||
quando: transaction?.quando ?
|
quando: transaction?.quando ?
|
||||||
new Date(transaction.quando).toISOString().split('T')[0] :
|
new Date(transaction.quando).toISOString().split('T')[0] :
|
||||||
new Date().toISOString().split('T')[0],
|
new Date().toISOString().split('T')[0],
|
||||||
grupo_id: transaction?.grupo_id || grupoId || ''
|
grupo_id: transaction?.grupo_id || grupoId || null
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -324,7 +324,7 @@ export function TransactionForm({
|
|||||||
<FormLabel>Grupo WhatsApp (opcional)</FormLabel>
|
<FormLabel>Grupo WhatsApp (opcional)</FormLabel>
|
||||||
<Select
|
<Select
|
||||||
onValueChange={field.onChange}
|
onValueChange={field.onChange}
|
||||||
value={field.value || ""}
|
value={field.value || undefined}
|
||||||
>
|
>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<SelectTrigger>
|
<SelectTrigger>
|
||||||
@ -332,7 +332,7 @@ export function TransactionForm({
|
|||||||
</SelectTrigger>
|
</SelectTrigger>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<SelectContent>
|
<SelectContent>
|
||||||
<SelectItem value="">Nenhum grupo</SelectItem>
|
<SelectItem value="none">Nenhum grupo</SelectItem>
|
||||||
{grupos.map((grupo) => (
|
{grupos.map((grupo) => (
|
||||||
<SelectItem key={grupo.remote_jid} value={grupo.remote_jid}>
|
<SelectItem key={grupo.remote_jid} value={grupo.remote_jid}>
|
||||||
{grupo.nome_grupo || grupo.remote_jid}
|
{grupo.nome_grupo || grupo.remote_jid}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user