Automatic category from expense title (#80)

* environment variable

* random category draft

* get category from ai

* input limit and documentation

* use watch

* use field.name

* prettier

* presigned upload, readme warning, category to string util

* prettier

* check whether feature is enabled

* use process.env

* improved prompt to return id only

* remove console.debug

* show loader

* share class name

* prettier

* use template literals

* rename format util

* prettier
This commit is contained in:
Mert Demir
2024-02-05 02:23:11 +09:00
committed by GitHub
parent 10fd69404a
commit fb49fb596a
8 changed files with 136 additions and 15 deletions

View File

@@ -29,7 +29,7 @@ import { useMediaQuery } from '@/lib/hooks'
import { formatExpenseDate } from '@/lib/utils'
import { Category } from '@prisma/client'
import { ChevronRight, FileQuestion, Loader2, Receipt } from 'lucide-react'
import { getImageData, useS3Upload } from 'next-s3-upload'
import { getImageData, usePresignedUpload } from 'next-s3-upload'
import Image from 'next/image'
import { useRouter } from 'next/navigation'
import { PropsWithChildren, ReactNode, useState } from 'react'
@@ -46,7 +46,7 @@ export function CreateFromReceiptButton({
categories,
}: Props) {
const [pending, setPending] = useState(false)
const { uploadToS3, FileInput, openFileDialog } = useS3Upload()
const { uploadToS3, FileInput, openFileDialog } = usePresignedUpload()
const { toast } = useToast()
const router = useRouter()
const [receiptInfo, setReceiptInfo] = useState<