Configure initial bank history in the connection UI
This commit is contained in:
+34
-3
@@ -157,10 +157,15 @@ export function Accounts({
|
||||
</>
|
||||
);
|
||||
}
|
||||
async function authorize(institution: string, country: string) {
|
||||
async function authorize(
|
||||
institution: string,
|
||||
country: string,
|
||||
historyMonths: number,
|
||||
) {
|
||||
const response = await request<{ url: string }>("/api/banking/authorize", {
|
||||
institution,
|
||||
country,
|
||||
history_months: historyMonths,
|
||||
});
|
||||
const url = new URL(response.url);
|
||||
if (url.protocol !== "https:")
|
||||
@@ -218,6 +223,12 @@ function AccountCard({
|
||||
{connection?.valid_until && (
|
||||
<small>Authorization expires {connection.valid_until}</small>
|
||||
)}
|
||||
{connection && connection.status !== "local" && (
|
||||
<small>
|
||||
Initial history: {connection.history_months}{" "}
|
||||
{connection.history_months === 1 ? "month" : "months"}
|
||||
</small>
|
||||
)}
|
||||
{connection?.error && (
|
||||
<small className="text-danger">{connection.error}</small>
|
||||
)}
|
||||
@@ -229,7 +240,11 @@ function AccountCard({
|
||||
setConnecting(true);
|
||||
onError("");
|
||||
try {
|
||||
await authorize(institution, connection.country || "DE");
|
||||
await authorize(
|
||||
institution,
|
||||
connection.country || "DE",
|
||||
connection.history_months,
|
||||
);
|
||||
} catch (err) {
|
||||
onError(err instanceof Error ? err.message : String(err));
|
||||
setConnecting(false);
|
||||
@@ -406,6 +421,7 @@ function ConnectForm({
|
||||
}) {
|
||||
const [institution, setInstitution] = useState("");
|
||||
const [country, setCountry] = useState("DE");
|
||||
const [historyMonths, setHistoryMonths] = useState("12");
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [copied, setCopied] = useState(false);
|
||||
const callback =
|
||||
@@ -462,10 +478,11 @@ function ConnectForm({
|
||||
className="form-body"
|
||||
onSubmit={async (e) => {
|
||||
e.preventDefault();
|
||||
if (!e.currentTarget.reportValidity()) return;
|
||||
setBusy(true);
|
||||
onError("");
|
||||
try {
|
||||
await authorize(institution.trim(), country);
|
||||
await authorize(institution.trim(), country, Number(historyMonths));
|
||||
} catch (err) {
|
||||
onError(err instanceof Error ? err.message : String(err));
|
||||
setBusy(false);
|
||||
@@ -492,6 +509,20 @@ function ConnectForm({
|
||||
onChange={(e) => setCountry(e.target.value.toUpperCase())}
|
||||
/>
|
||||
</Field>
|
||||
<Field
|
||||
label="History to import (months)"
|
||||
hint="Initial history for newly synced accounts (1–120 calendar months). Your bank may provide less. Existing accounts keep their sync cursors; this does not backfill them."
|
||||
>
|
||||
<input
|
||||
type="number"
|
||||
required
|
||||
min={1}
|
||||
max={120}
|
||||
step={1}
|
||||
value={historyMonths}
|
||||
onChange={(e) => setHistoryMonths(e.target.value)}
|
||||
/>
|
||||
</Field>
|
||||
{!state.status.banking_configured && (
|
||||
<p className="muted small">
|
||||
Add your Enable Banking application ID and private key in{" "}
|
||||
|
||||
@@ -68,6 +68,7 @@ export interface Connection {
|
||||
account_id: string;
|
||||
institution: string;
|
||||
country: string;
|
||||
history_months: number;
|
||||
status: "local" | "connected" | "reconnect_required" | "error";
|
||||
valid_until: string;
|
||||
error: string;
|
||||
|
||||
Reference in New Issue
Block a user