forked from CopilotKit/CopilotKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.ts
More file actions
44 lines (38 loc) · 1.25 KB
/
Copy pathutils.ts
File metadata and controls
44 lines (38 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import type { Card, Transaction } from "@/app/api/v1/data";
import { clsx } from "clsx";
import type { ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
export const formatCurrency = (n: number) =>
new Intl.NumberFormat("en-US", { style: "currency", currency: "USD" }).format(
n,
);
export function randomDigits(digitsAmount: number): number {
const min = Math.pow(10, digitsAmount - 1);
const max = Math.pow(10, digitsAmount) - 1;
return Math.floor(Math.random() * (max - min + 1)) + min;
}
export function filterTransactionsByCardLast4(
transactions: Transaction[],
cards: Card[],
card4Digits: string,
): Transaction[] {
const card = cards.find((c) => c.last4 === card4Digits);
return transactions.filter((transaction) => transaction.cardId === card?.id);
}
export function filterTransactionsByPolicyId(
transactions: Transaction[],
policyId: string,
): Transaction[] {
return transactions.filter(
(transaction) => transaction.policyId === policyId,
);
}
export function filterTransactionByTitle(
transactions: Transaction[],
title: string,
): Transaction[] {
return transactions.filter((transaction) => transaction.title === title);
}