Skip to content

Commit

Permalink
Save account reference
Browse files Browse the repository at this point in the history
  • Loading branch information
pontusab committed Dec 12, 2024
1 parent 694fcc6 commit cd45ab0
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions apps/dashboard/src/actions/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ export const connectBankAccountSchema = z.object({
currency: z.string(),
name: z.string(),
institution_id: z.string(),
account_reference: z.string().nullable().optional(),
enabled: z.boolean(),
logo_url: z.string().nullable().optional(),
type: z.enum([
Expand Down
18 changes: 16 additions & 2 deletions apps/dashboard/src/components/modals/select-bank-accounts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { useConnectParams } from "@/hooks/use-connect-params";
import { useI18n } from "@/locales/client";
import { getInitials } from "@/utils/format";
import { zodResolver } from "@hookform/resolvers/zod";
import type { Accounts } from "@midday-ai/engine/resources/accounts.mjs";
import { Avatar, AvatarFallback } from "@midday/ui/avatar";
import { Button } from "@midday/ui/button";
import {
Expand Down Expand Up @@ -39,6 +38,20 @@ import z from "zod";
import { FormatAmount } from "../format-amount";
import { LoadingTransactionsEvent } from "../loading-transactions-event";

type Account = {
id: string;
name: string;
balance: number;
currency: string;
type: string;
subtype: string;
mask: string;
institution: {
id: string;
name: string;
};
};

function RowsSkeleton() {
return (
<div className="space-y-6">
Expand Down Expand Up @@ -140,7 +153,7 @@ export function SelectBankAccountsModal() {
const { toast } = useToast();
const t = useI18n();

const [accounts, setAccounts] = useState<Accounts.Data[]>([]);
const [accounts, setAccounts] = useState<Account[]>([]);
const [loading, setLoading] = useState(true);
const [runId, setRunId] = useState<string>();
const [accessToken, setAccessToken] = useState<string>();
Expand Down Expand Up @@ -235,6 +248,7 @@ export function SelectBankAccountsModal() {
institution_id: account.institution.id,
logo_url: account.institution?.logo,
account_id: account.id,
account_reference: account.resource_id,
bank_name: account.institution.name,
// TODO: Remove once we have a fix and return currency from engine
currency: account.currency ?? account.balance.currency,
Expand Down
2 changes: 2 additions & 0 deletions packages/supabase/src/mutations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type CreateBankConnectionPayload = {
enabled: boolean;
balance: number;
type: "depository" | "credit" | "other_asset" | "loan" | "other_liability";
account_reference: string | null;
}[];
balance: number;
accessToken?: string;
Expand Down Expand Up @@ -84,6 +85,7 @@ export async function createBankConnection(
currency: account.currency,
enabled: account.enabled,
type: account.type,
account_reference: account.account_reference,
balance: account.balance ?? 0,
}),
{
Expand Down

0 comments on commit cd45ab0

Please sign in to comment.