mirror of
https://github.com/marcogll/TaxHacker_s23.git
synced 2026-01-13 13:25:18 +00:00
feat: config.js
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
import { useNotification } from "@/app/(app)/context"
|
||||
import { uploadFilesAction } from "@/app/(app)/files/actions"
|
||||
import { FormError } from "@/components/forms/error"
|
||||
import { FILE_ACCEPTED_MIMETYPES } from "@/lib/constants"
|
||||
import config from "@/lib/config"
|
||||
import { Camera, Loader2 } from "lucide-react"
|
||||
import { useRouter } from "next/navigation"
|
||||
import { startTransition, useState } from "react"
|
||||
@@ -48,7 +48,7 @@ export default function DashboardDropZoneWidget() {
|
||||
id="fileInput"
|
||||
className="hidden"
|
||||
multiple
|
||||
accept={FILE_ACCEPTED_MIMETYPES}
|
||||
accept={config.upload.acceptedMimeTypes}
|
||||
onChange={handleFileChange}
|
||||
/>
|
||||
<div className="flex flex-col items-center justify-center gap-4 p-8 text-center h-full">
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import { useNotification } from "@/app/(app)/context"
|
||||
import { uploadFilesAction } from "@/app/(app)/files/actions"
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { FILE_ACCEPTED_MIMETYPES } from "@/lib/constants"
|
||||
import config from "@/lib/config"
|
||||
import { Loader2 } from "lucide-react"
|
||||
import { useRouter } from "next/navigation"
|
||||
import { ComponentProps, startTransition, useRef, useState } from "react"
|
||||
@@ -54,7 +54,7 @@ export function UploadButton({ children, ...props }: { children: React.ReactNode
|
||||
id="fileInput"
|
||||
className="hidden"
|
||||
multiple
|
||||
accept={FILE_ACCEPTED_MIMETYPES}
|
||||
accept={config.upload.acceptedMimeTypes}
|
||||
onChange={handleFileChange}
|
||||
/>
|
||||
|
||||
|
||||
@@ -6,29 +6,40 @@ import { FormError } from "@/components/forms/error"
|
||||
import { FormInput, FormTextarea } from "@/components/forms/simple"
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { Card, CardTitle } from "@/components/ui/card"
|
||||
import { IS_SELF_HOSTED_MODE } from "@/lib/constants"
|
||||
import { Field } from "@prisma/client"
|
||||
import { CircleCheckBig, Edit } from "lucide-react"
|
||||
import Link from "next/link"
|
||||
import { useActionState } from "react"
|
||||
|
||||
export default function LLMSettingsForm({ settings, fields }: { settings: Record<string, string>; fields: Field[] }) {
|
||||
export default function LLMSettingsForm({
|
||||
settings,
|
||||
fields,
|
||||
showApiKey = true,
|
||||
}: {
|
||||
settings: Record<string, string>
|
||||
fields: Field[]
|
||||
showApiKey?: boolean
|
||||
}) {
|
||||
const [saveState, saveAction, pending] = useActionState(saveSettingsAction, null)
|
||||
|
||||
return (
|
||||
<>
|
||||
<form action={saveAction} className="space-y-4">
|
||||
{IS_SELF_HOSTED_MODE && (
|
||||
<FormInput title="OpenAI API Key" name="openai_api_key" defaultValue={settings.openai_api_key} />
|
||||
)}
|
||||
{showApiKey && (
|
||||
<>
|
||||
<FormInput title="OpenAI API Key" name="openai_api_key" defaultValue={settings.openai_api_key} />
|
||||
|
||||
{IS_SELF_HOSTED_MODE && (
|
||||
<small className="text-muted-foreground">
|
||||
Get your API key from{" "}
|
||||
<a href="https://platform.openai.com/settings/organization/api-keys" target="_blank" className="underline">
|
||||
OpenAI Platform Console
|
||||
</a>
|
||||
</small>
|
||||
<small className="text-muted-foreground">
|
||||
Get your API key from{" "}
|
||||
<a
|
||||
href="https://platform.openai.com/settings/organization/api-keys"
|
||||
target="_blank"
|
||||
className="underline"
|
||||
>
|
||||
OpenAI Platform Console
|
||||
</a>
|
||||
</small>
|
||||
</>
|
||||
)}
|
||||
|
||||
<FormTextarea
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"
|
||||
import { useSidebar } from "@/components/ui/sidebar"
|
||||
import { APP_TITLE } from "@/lib/constants"
|
||||
import config from "@/lib/config"
|
||||
import Link from "next/link"
|
||||
|
||||
export default function MobileMenu({ unsortedFilesCount }: { unsortedFilesCount: number }) {
|
||||
@@ -15,7 +15,7 @@ export default function MobileMenu({ unsortedFilesCount }: { unsortedFilesCount:
|
||||
<AvatarFallback className="rounded-lg">AI</AvatarFallback>
|
||||
</Avatar>
|
||||
<Link href="/" className="text-lg font-bold">
|
||||
{APP_TITLE}
|
||||
{config.app.title}
|
||||
</Link>
|
||||
<Link
|
||||
href="/unsorted"
|
||||
|
||||
@@ -10,12 +10,11 @@ import {
|
||||
import { SidebarMenuButton } from "@/components/ui/sidebar"
|
||||
import { UserProfile } from "@/lib/auth"
|
||||
import { authClient } from "@/lib/auth-client"
|
||||
import { IS_SELF_HOSTED_MODE } from "@/lib/constants"
|
||||
import { LogOut, MoreVertical, User } from "lucide-react"
|
||||
import Link from "next/link"
|
||||
import { redirect } from "next/navigation"
|
||||
|
||||
export default function SidebarUser({ profile }: { profile: UserProfile }) {
|
||||
export default function SidebarUser({ profile, isSelfHosted }: { profile: UserProfile; isSelfHosted: boolean }) {
|
||||
const signOut = async () => {
|
||||
await authClient.signOut({})
|
||||
redirect("/")
|
||||
@@ -61,14 +60,16 @@ export default function SidebarUser({ profile }: { profile: UserProfile }) {
|
||||
</Link>
|
||||
</DropdownMenuItem> */}
|
||||
</DropdownMenuGroup>
|
||||
<DropdownMenuSeparator />
|
||||
{!IS_SELF_HOSTED_MODE && (
|
||||
<DropdownMenuItem asChild>
|
||||
<span onClick={signOut} className="flex items-center gap-2 text-red-600 cursor-pointer">
|
||||
<LogOut className="h-4 w-4" />
|
||||
Log out
|
||||
</span>
|
||||
</DropdownMenuItem>
|
||||
{!isSelfHosted && (
|
||||
<>
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuItem asChild>
|
||||
<span onClick={signOut} className="flex items-center gap-2 text-red-600 cursor-pointer">
|
||||
<LogOut className="h-4 w-4" />
|
||||
Log out
|
||||
</span>
|
||||
</DropdownMenuItem>
|
||||
</>
|
||||
)}
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
useSidebar,
|
||||
} from "@/components/ui/sidebar"
|
||||
import { UserProfile } from "@/lib/auth"
|
||||
import { APP_TITLE, IS_SELF_HOSTED_MODE } from "@/lib/constants"
|
||||
import config from "@/lib/config"
|
||||
import { ClockArrowUp, FileText, Import, LayoutDashboard, Settings, Sparkles, Upload } from "lucide-react"
|
||||
import Image from "next/image"
|
||||
import Link from "next/link"
|
||||
@@ -28,7 +28,15 @@ import { Blinker } from "./blinker"
|
||||
import { SidebarMenuItemWithHighlight } from "./sidebar-item"
|
||||
import SidebarUser from "./sidebar-user"
|
||||
|
||||
export function AppSidebar({ unsortedFilesCount, profile }: { unsortedFilesCount: number; profile: UserProfile }) {
|
||||
export function AppSidebar({
|
||||
profile,
|
||||
unsortedFilesCount,
|
||||
isSelfHosted,
|
||||
}: {
|
||||
profile: UserProfile
|
||||
unsortedFilesCount: number
|
||||
isSelfHosted: boolean
|
||||
}) {
|
||||
const { open, setOpenMobile } = useSidebar()
|
||||
const pathname = usePathname()
|
||||
const { notification } = useNotification()
|
||||
@@ -46,7 +54,7 @@ export function AppSidebar({ unsortedFilesCount, profile }: { unsortedFilesCount
|
||||
<Image src="/logo/256.png" alt="Logo" className="h-10 w-10 rounded-lg" width={40} height={40} />
|
||||
<div className="grid flex-1 text-left leading-tight">
|
||||
<span className="truncate font-semibold text-lg">
|
||||
<ColoredText>{APP_TITLE}</ColoredText>
|
||||
<ColoredText>{config.app.title}</ColoredText>
|
||||
</span>
|
||||
</div>
|
||||
</Link>
|
||||
@@ -124,7 +132,7 @@ export function AppSidebar({ unsortedFilesCount, profile }: { unsortedFilesCount
|
||||
</Link>
|
||||
</SidebarMenuButton>
|
||||
</SidebarMenuItem>
|
||||
{IS_SELF_HOSTED_MODE && (
|
||||
{isSelfHosted && (
|
||||
<SidebarMenuItem>
|
||||
<SidebarMenuButton asChild>
|
||||
<Link href="https://vas3k.com/donate/" target="_blank">
|
||||
@@ -146,7 +154,7 @@ export function AppSidebar({ unsortedFilesCount, profile }: { unsortedFilesCount
|
||||
<SidebarGroupContent>
|
||||
<SidebarMenu>
|
||||
<SidebarMenuItem>
|
||||
<SidebarUser profile={profile} />
|
||||
<SidebarUser profile={profile} isSelfHosted={isSelfHosted} />
|
||||
</SidebarMenuItem>
|
||||
</SidebarMenu>
|
||||
</SidebarGroupContent>
|
||||
|
||||
@@ -4,7 +4,7 @@ import { deleteTransactionFileAction, uploadTransactionFilesAction } from "@/app
|
||||
import { FilePreview } from "@/components/files/preview"
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { Card } from "@/components/ui/card"
|
||||
import { FILE_ACCEPTED_MIMETYPES } from "@/lib/constants"
|
||||
import config from "@/lib/config"
|
||||
import { File, Transaction } from "@prisma/client"
|
||||
import { Loader2, Upload, X } from "lucide-react"
|
||||
import { useState } from "react"
|
||||
@@ -72,7 +72,7 @@ export default function TransactionFiles({ transaction, files }: { transaction:
|
||||
name="file"
|
||||
className="absolute inset-0 top-0 left-0 w-full h-full opacity-0"
|
||||
onChange={handleFileChange}
|
||||
accept={FILE_ACCEPTED_MIMETYPES}
|
||||
accept={config.upload.acceptedMimeTypes}
|
||||
/>
|
||||
</label>
|
||||
</Card>
|
||||
|
||||
Reference in New Issue
Block a user