ali-ahnaf / ali-ahnaf/pocket_pixel

[Frontend] AI transaction parsing: pre-select detected vault in the log modal

Aperta
#83 1 commento 0 reazioni 1 assegnatario Rivendicata da @Ayu360 Vedi su GitHub
epic frontend up for grabs
Lingua principale
TypeScript
Stelle
14
Fork
91
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

## 📋 Context

The app lets users log transactions with natural language via an AI parser. Issue #82 extends the **backend** to detect which vault the user mentioned. This issue is the **frontend** counterpart: once the API returns a `vaultId`, the UI should automatically pre-select that vault in the transaction form.

> ⚠️ This issue depends on #82 (backend vault detection) being completed first, or being worked on in parallel.

## 🐛 Problem

After AI parsing, the log modal (`packages/ui/src/components/LogResourceModal.tsx`) populates the title, amount, type, and tags from the API response — but ignores any vault information, so the vault selector always remains blank even if the user said *"from my savings account"*.

## ✅ Goal

When the AI parse response includes a `vaultId`, the vault selector in the modal should be pre-filled with that vault.

## 🗺️ Suggested Approach

**Files to touch:**

| File | What to do |
|---|---|
| `packages/ui/src/components/LogResourceModal.tsx` | After receiving the AI parse result, set the `selectedVaultId` state to the returned `vaultId` (if present). |
| `packages/ui/src/lib/api/` (transactions API client) | Ensure the `parseTransaction` response type includes the new `vaultId?: string \| null` field from the updated shared DTO. |

Steps:
1. Look at how the modal currently handles the AI response and sets `selectedTags`, `amount`, etc.
2. Add `setSelectedVaultId(parsedResult.vaultId ?? null)` (or equivalent) in the same block.
3. Make sure the vault dropdown reflects the pre-selected vault visually.

No backend changes needed here — that's covered in #82.

## ✔️ Acceptance Criteria

- [ ] After AI parsing, the vault selector is pre-filled when the AI detected a vault.
- [ ] When no vault is detected the selector remains blank (no regression).
- [ ] The user can still manually change the vault after AI pre-selection.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.