feat: better exchange rate tool ux

This commit is contained in:
Vasily Zubarev
2025-04-09 13:48:23 +02:00
parent 6ebc85c9df
commit d53044f3f6
3 changed files with 50 additions and 25 deletions

View File

@@ -11,8 +11,10 @@ import { FormSelectType } from "@/components/forms/select-type"
import { FormInput, FormTextarea } from "@/components/forms/simple"
import { Button } from "@/components/ui/button"
import { Category, Currency, Field, File, Project } from "@prisma/client"
import { format } from "date-fns"
import { Brain, Loader2 } from "lucide-react"
import { startTransition, useActionState, useMemo, useState } from "react"
import AgentWindow from "../agents/agent-window"
export default function AnalyzeForm({
file,
@@ -197,16 +199,16 @@ export default function AnalyzeForm({
</div>
{formData.total != 0 && formData.currencyCode && formData.currencyCode !== settings.default_currency && (
<>
<AgentWindow title={`Exchange rate on ${format(new Date(formData.issuedAt || Date.now()), "LLLL dd, yyyy")}`}>
<FormConvertCurrency
originalTotal={formData.total}
originalCurrencyCode={formData.currencyCode}
targetCurrencyCode={settings.default_currency}
date={formData.issuedAt ? new Date(formData.issuedAt) : undefined}
date={new Date(formData.issuedAt || Date.now())}
onChange={(value) => setFormData((prev) => ({ ...prev, convertedTotal: value }))}
/>
<input type="hidden" name="convertedCurrencyCode" value={settings.default_currency} />
</>
</AgentWindow>
)}
<div className="flex flex-row gap-4">