diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..07ecc56 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +mobile/.env.production diff --git a/mobile/app/(app)/inventory/[id]/edit.tsx b/mobile/app/(app)/inventory/[id]/edit.tsx index 95a7c1e..1ed6b04 100644 --- a/mobile/app/(app)/inventory/[id]/edit.tsx +++ b/mobile/app/(app)/inventory/[id]/edit.tsx @@ -153,26 +153,30 @@ export default function EditFilamentScreen(): React.ReactElement { } setIsLoading(true); try { - // TODO: UpdateFilamentUseCase via container DI - const updated = { - ...filament!, + const user = useAuthStore.getState().user; + if (!user) { + Alert.alert('Erro', 'Usuário não autenticado.'); + return; + } + + const updated = await updateFilamentUseCase.execute(filament!.id, user.id, { brand: data.brand, model: data.model ?? null, colorHex: selectedColor, material: selectedMaterial, spoolPresetId: selectedPresetId, totalWeightG: Number(data.totalWeightG), - netWeightG: netWeight, tempHotendC: data.tempHotendC ?? null, tempBedC: data.tempBedC ?? null, flowFactorPct: data.flowFactorPct ?? null, notes: data.notes ?? null, - updatedAt: new Date().toISOString(), - }; + }); + updateFilament(updated); router.back(); - } catch { - Alert.alert('Erro', 'Não foi possível salvar as alterações.'); + } catch (err) { + console.error('update filament error', err); + Alert.alert('Erro', 'Falha ao atualizar: ' + (err as Error).message); } finally { setIsLoading(false); }