13 |
setShowModal(false)}
16 | />
17 |
18 |
19 |
20 | {type === "delete" ? (
21 |
35 | ) : (
36 |
50 | )}
51 |
52 |
53 | {title}
54 |
55 |
56 | {content}
57 |
58 |
59 |
65 |
71 |
72 |
73 |
74 |
75 |
76 |
77 | )}
78 | >
79 | );
80 | }
81 |
--------------------------------------------------------------------------------
/src/components/Basic/SearchInput.js:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import { TextInput } from "@tremor/react";
3 | import { SearchIcon } from "@heroicons/react/solid";
4 |
5 | export default function SearchInput({ onSearch, ...rest }) {
6 | const handleEnterKeyDown = (e) => {
7 | var keycode = e.keyCode ? e.keyCode : e.which;
8 | if (keycode == 13) {
9 | onSearch();
10 | }
11 | };
12 |
13 | return (
14 |
19 | );
20 | }
21 |
--------------------------------------------------------------------------------
/src/components/ConnectButton.tsx:
--------------------------------------------------------------------------------
1 | "use client";
2 |
3 | import { useCallback } from "react";
4 | import { usePlaidLink } from "react-plaid-link";
5 | import { useDispatch, useSelector } from "react-redux";
6 | import { setPlaidState } from "@/store/actions/usePlaid";
7 | import apiCall from "@/utils/apiCall";
8 | import { setUserInfoState } from "@/store/actions/useUser";
9 | import { isEmpty } from "@/utils/util";
10 | import { RootState } from "@/store";
11 | import { AnyAction } from 'redux';
12 | import { Dispatch } from 'redux';
13 | import { Button } from "./ui/button";
14 |
15 | const ConnectButton = ({ children, type, setShowConnectModal }: { children: React.ReactNode, type: string | number, setShowConnectModal: (show: boolean) => void }) => {
16 | const { linkToken } = useSelector((state: RootState) => state.plaid);
17 | const { items: linkInfo } = useSelector((state: RootState) => state.user);
18 |
19 | const dispatch = useDispatch
>();
20 |
21 | const onSuccess = useCallback(
22 | (public_token: any, metadata: any) => {
23 | const exchangePublicTokenForAccessToken = async () => {
24 | const response = await apiCall.post("/api/v1/plaid/set_access_token", { public_token, metadata, type });
25 | if (response.status !== 200) {
26 | dispatch(setPlaidState({ isItemAccess: false }) as unknown as AnyAction);
27 | return;
28 | }
29 | const { isItemAccess, item_id, accounts } = response.data;
30 | dispatch(setPlaidState({ isItemAccess: isItemAccess }) as unknown as AnyAction);
31 | if (!isEmpty(item_id)) {
32 | dispatch(
33 | setUserInfoState({
34 | items: [...linkInfo, { ...metadata, accounts }]
35 | })
36 | );
37 | }
38 | setShowConnectModal(false);
39 | };
40 | exchangePublicTokenForAccessToken();
41 | },
42 | [dispatch, linkInfo, setShowConnectModal, type]
43 | );
44 |
45 | const config = {
46 | token: !isEmpty(linkToken) ? linkToken[type].link_token : null,
47 | onSuccess
48 | };
49 |
50 | const { open, ready } = usePlaidLink(config);
51 |
52 | const handleOpenPlaidLink = () => {
53 | dispatch(setPlaidState({ isItemAccess: false, linkSuccess: false }) as unknown as AnyAction);
54 | open();
55 | };
56 |
57 | const setupConfig = {
58 | token: !isEmpty(linkToken) ? linkToken[type].link_token : "Token not found",
59 | open: open,
60 | ready: ready,
61 | onSuccess: onSuccess,
62 | linkInfo: linkInfo,
63 | }
64 |
65 | console.log(setupConfig);
66 |
67 | return (
68 |
74 | );
75 | };
76 |
77 | export default ConnectButton;
78 |
--------------------------------------------------------------------------------
/src/components/CreditCard.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 |
3 | const CreditCardComponent = () => {
4 | return (
5 |
6 |
How should I tackle my credit card debt?
7 |
We can help with that.
8 |
9 |
10 |
Slope
11 |
PATRIC BATEMAN
12 |
0004 4889 3989 5660
13 |
14 |
15 | );
16 | }
17 |
18 | export default CreditCardComponent;
--------------------------------------------------------------------------------
/src/components/FullConnectButton.tsx:
--------------------------------------------------------------------------------
1 | "use client";
2 |
3 | import { useState } from "react";
4 | import {
5 | Dialog,
6 | DialogContent,
7 | DialogHeader,
8 | DialogTitle
9 | } from "./ui/dialog";
10 | import { PlusCircleIcon, PlusIcon } from "lucide-react";
11 | import ConnectButton from "./ConnectButton";
12 | import { Button } from "./ui/button";
13 | const ConnectButtonModal = () => {
14 | const [showConnectModal, setShowConnectModal] = useState(false);
15 |
16 | return (
17 |
18 |
28 |
59 |
60 | );
61 | };
62 |
63 | export default ConnectButtonModal;
64 |
--------------------------------------------------------------------------------
/src/components/MobileNavbar.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react";
2 | import Link from "next/link";
3 | import { useEffect, useCallback } from "react";
4 | import { useDispatch, useSelector } from "react-redux";
5 | import DarkModeSwitcher from "./DarkModeSwitcher";
6 | import DropdownUser from "./DropdownUser";
7 | import usePlaidInit from "@/hooks/usePlaidInit";
8 | import useGetTransactionsSync from "@/hooks/useGetTransactionsSync";
9 | import useGetAccounts from "@/hooks/useGetAccounts";
10 | import { getUserInfo } from "@/store/actions/useUser";
11 | import { usePathname } from "next/navigation";
12 |
13 | const Navbar = () => {
14 | const { isTransactionsLoaded } = useSelector((state: { plaid: { isTransactionsLoaded: boolean } }) => state.plaid);
15 |
16 | const pathname = usePathname();
17 |
18 | const navItems = [
19 | {
20 | label: "Home",
21 | href: "/dashboard"
22 | },
23 | {
24 | label: "Chat",
25 | href: "/dashboard/chat"
26 | },
27 | {
28 | label: "Explore",
29 | href: "/dashboard/transaction"
30 | },
31 | // {
32 | // label: "Analyze",
33 | // href: "/dashboard/charts"
34 | // }
35 | ];
36 |
37 | return (
38 |
58 | );
59 | };
60 |
61 | export default Navbar;
62 |
--------------------------------------------------------------------------------
/src/components/Table.tsx:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/components/button-scroll-to-bottom.tsx:
--------------------------------------------------------------------------------
1 | 'use client'
2 |
3 | import * as React from 'react'
4 |
5 | import { cn } from '@/lib/utils'
6 | import { Button, type ButtonProps } from '@/components/ui/button'
7 | import { IconArrowDown } from '@/components/ui/icons'
8 |
9 | interface ButtonScrollToBottomProps extends ButtonProps {
10 | isAtBottom: boolean
11 | scrollToBottom: () => void
12 | }
13 |
14 | export function ButtonScrollToBottom({
15 | className,
16 | isAtBottom,
17 | scrollToBottom,
18 | ...props
19 | }: ButtonScrollToBottomProps) {
20 | return (
21 |
35 | )
36 | }
37 |
--------------------------------------------------------------------------------
/src/components/chat-history.tsx:
--------------------------------------------------------------------------------
1 | import * as React from 'react'
2 |
3 | import Link from 'next/link'
4 |
5 | import { cn } from '@/lib/utils'
6 | import { SidebarList } from '@/components/sidebar-list'
7 | import { buttonVariants } from '@/components/ui/button'
8 | import { PlusCircleIcon } from 'lucide-react'
9 |
10 | interface ChatHistoryProps {
11 | userId?: string
12 | }
13 |
14 | export async function ChatHistory({ userId }: ChatHistoryProps) {
15 | return (
16 |
17 |
18 |
Chat History
19 |
20 |
21 |
28 |
29 | New Chat
30 |
31 |
32 |
35 | {Array.from({ length: 10 }).map((_, i) => (
36 |
40 | ))}
41 |
42 | }
43 | >
44 | {/* @ts-ignore */}
45 |
46 |
47 |
48 | )
49 | }
50 |
--------------------------------------------------------------------------------
/src/components/chat-list.tsx:
--------------------------------------------------------------------------------
1 | import { Separator } from '@/components/ui/separator'
2 | import { UIState } from '@/lib/chat/actions'
3 | import { UserSession } from '@/lib/types'
4 | import Link from 'next/link'
5 | import { ExclamationTriangleIcon } from '@radix-ui/react-icons'
6 |
7 | export interface ChatList {
8 | messages: UIState
9 | session?: UserSession
10 | isShared: boolean
11 | }
12 |
13 | export function ChatList({ messages, session, isShared }: ChatList) {
14 | if (!messages.length) {
15 | return null
16 | }
17 |
18 | return (
19 |
20 | {/* {!isShared && !session ? (
21 | <>
22 |
23 |
24 |
25 |
26 |
27 |
28 | Please{' '}
29 |
30 | log in
31 | {' '}
32 | or{' '}
33 |
34 | sign up
35 | {' '}
36 | to save and revisit your chat history!
37 |
38 |
39 |
40 |
41 | >
42 | ) : null} */}
43 |
44 | {messages.map((message, index) => (
45 |
46 | {message.display}
47 | {index < messages.length - 1 && }
48 |
49 | ))}
50 |
51 | )
52 | }
53 |
--------------------------------------------------------------------------------
/src/components/chat-message-actions.tsx:
--------------------------------------------------------------------------------
1 | 'use client'
2 |
3 | import { type Message } from 'ai'
4 |
5 | import { Button } from '@/components/ui/button'
6 | import { IconCheck, IconCopy } from '@/components/ui/icons'
7 | import { useCopyToClipboard } from '@/lib/hooks/use-copy-to-clipboard'
8 | import { cn } from '@/lib/utils'
9 |
10 | interface ChatMessageActionsProps extends React.ComponentProps<'div'> {
11 | message: Message
12 | }
13 |
14 | export function ChatMessageActions({
15 | message,
16 | className,
17 | ...props
18 | }: ChatMessageActionsProps) {
19 | const { isCopied, copyToClipboard } = useCopyToClipboard({ timeout: 2000 })
20 |
21 | const onCopy = () => {
22 | if (isCopied) return
23 | copyToClipboard(message.content)
24 | }
25 |
26 | return (
27 |