mirror of
https://github.com/marcogll/TaxHacker_s23.git
synced 2026-01-13 13:25:18 +00:00
chore: organize ts types, fix eslint errors
This commit is contained in:
@@ -27,7 +27,7 @@ export default function DashboardDropZoneWidget() {
|
||||
|
||||
// Submit the files using the server action
|
||||
startTransition(async () => {
|
||||
const result = await uploadFilesAction(null, formData)
|
||||
const result = await uploadFilesAction(formData)
|
||||
if (result.success) {
|
||||
showNotification({ code: "sidebar.unsorted", message: "new" })
|
||||
setTimeout(() => showNotification({ code: "sidebar.unsorted", message: "" }), 3000)
|
||||
|
||||
@@ -65,7 +65,7 @@ export default function ScreenDropArea({ children }: { children: React.ReactNode
|
||||
startTransition(async () => {
|
||||
const result = transactionId
|
||||
? await uploadTransactionFilesAction(formData)
|
||||
: await uploadFilesAction(null, formData)
|
||||
: await uploadFilesAction(formData)
|
||||
|
||||
if (result.success) {
|
||||
showNotification({ code: "sidebar.unsorted", message: "new" })
|
||||
@@ -88,18 +88,18 @@ export default function ScreenDropArea({ children }: { children: React.ReactNode
|
||||
|
||||
// Add event listeners to document body
|
||||
useEffect(() => {
|
||||
document.body.addEventListener("dragenter", handleDragEnter as any)
|
||||
document.body.addEventListener("dragover", handleDragOver as any)
|
||||
document.body.addEventListener("dragleave", handleDragLeave as any)
|
||||
document.body.addEventListener("drop", handleDrop as any)
|
||||
document.body.addEventListener("dragenter", handleDragEnter as unknown as EventListener)
|
||||
document.body.addEventListener("dragover", handleDragOver as unknown as EventListener)
|
||||
document.body.addEventListener("dragleave", handleDragLeave as unknown as EventListener)
|
||||
document.body.addEventListener("drop", handleDrop as unknown as EventListener)
|
||||
|
||||
return () => {
|
||||
document.body.removeEventListener("dragenter", handleDragEnter as any)
|
||||
document.body.removeEventListener("dragover", handleDragOver as any)
|
||||
document.body.removeEventListener("dragleave", handleDragLeave as any)
|
||||
document.body.removeEventListener("drop", handleDrop as any)
|
||||
document.body.removeEventListener("dragenter", handleDragEnter as unknown as EventListener)
|
||||
document.body.removeEventListener("dragover", handleDragOver as unknown as EventListener)
|
||||
document.body.removeEventListener("dragleave", handleDragLeave as unknown as EventListener)
|
||||
document.body.removeEventListener("drop", handleDrop as unknown as EventListener)
|
||||
}
|
||||
}, [isDragging])
|
||||
}, [isDragging, handleDrop])
|
||||
|
||||
return (
|
||||
<div className="relative min-h-screen w-full">
|
||||
|
||||
@@ -28,7 +28,7 @@ export function UploadButton({ children, ...props }: { children: React.ReactNode
|
||||
|
||||
// Submit the files using the server action
|
||||
startTransition(async () => {
|
||||
const result = await uploadFilesAction(null, formData)
|
||||
const result = await uploadFilesAction(formData)
|
||||
if (result.success) {
|
||||
showNotification({ code: "sidebar.unsorted", message: "new" })
|
||||
setTimeout(() => showNotification({ code: "sidebar.unsorted", message: "" }), 3000)
|
||||
|
||||
@@ -16,16 +16,8 @@ export const FormConvertCurrency = ({
|
||||
date?: Date | undefined
|
||||
onChange?: (value: number) => void
|
||||
}) => {
|
||||
if (
|
||||
originalTotal === 0 ||
|
||||
!originalCurrencyCode ||
|
||||
!targetCurrencyCode ||
|
||||
originalCurrencyCode === targetCurrencyCode
|
||||
) {
|
||||
return <></>
|
||||
}
|
||||
|
||||
const normalizedDate = startOfDay(date || new Date(Date.now() - 24 * 60 * 60 * 1000))
|
||||
const normalizedDateString = format(normalizedDate, "yyyy-MM-dd")
|
||||
const [exchangeRate, setExchangeRate] = useState(0)
|
||||
const [isLoading, setIsLoading] = useState(false)
|
||||
|
||||
@@ -46,7 +38,11 @@ export const FormConvertCurrency = ({
|
||||
}
|
||||
|
||||
fetchData()
|
||||
}, [originalCurrencyCode, targetCurrencyCode, format(normalizedDate, "LLLL-mm-dd")])
|
||||
}, [originalCurrencyCode, targetCurrencyCode, normalizedDateString, originalTotal])
|
||||
|
||||
if (!originalTotal || !originalCurrencyCode || !targetCurrencyCode || originalCurrencyCode === targetCurrencyCode) {
|
||||
return <></>
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex flex-row gap-2 items-center text-muted-foreground">
|
||||
|
||||
@@ -117,7 +117,7 @@ export const FormDate = ({
|
||||
if (!isNaN(newDate.getTime())) {
|
||||
setDate(newDate)
|
||||
}
|
||||
} catch (error) {}
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@@ -23,10 +23,11 @@ export function ImportCSVTable({ fields }: { fields: Field[] }) {
|
||||
|
||||
useEffect(() => {
|
||||
if (parseState?.success && parseState.data) {
|
||||
setCSVData(parseState.data)
|
||||
if (parseState.data.length > 0) {
|
||||
const parsedData = parseState.data as string[][]
|
||||
setCSVData(parsedData)
|
||||
if (parsedData.length > 0) {
|
||||
setColumnMappings(
|
||||
parseState.data[0].map((value) => {
|
||||
parsedData[0].map((value) => {
|
||||
const field = fields.find((field) => field.code === value || field.name === value)
|
||||
return field?.code || ""
|
||||
})
|
||||
|
||||
@@ -44,8 +44,8 @@ export default function TransactionCreateForm({
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
if (createState?.success) {
|
||||
router.push(`/transactions/${createState.transactionId}`)
|
||||
if (createState?.success && createState.data) {
|
||||
router.push(`/transactions/${createState.data.id}`)
|
||||
}
|
||||
}, [createState, router])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user