-
Notifications
You must be signed in to change notification settings - Fork 275
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* working tabs * working Table review BIG * working table with cat search and input search * working table with filter, category etc * working multiple review OK * working update labels, but x10000 calls * working new usestate, but table update goes to bottom * complete review table
- Loading branch information
Showing
27 changed files
with
1,357 additions
and
471 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// actions/update-category.ts | ||
"use server"; | ||
|
||
import { revalidatePath } from "next/cache"; | ||
|
||
import { prisma } from "@/lib/db"; | ||
import { getCurrentUser } from "@/lib/session"; | ||
|
||
export async function updateCategoryReviewTable( | ||
transactionId: string, | ||
categoryId: string, | ||
) { | ||
try { | ||
const category = await prisma.category.findUnique({ | ||
where: { id: categoryId }, | ||
}); | ||
|
||
if (!category) { | ||
return { success: false, error: "Category not found" }; | ||
} | ||
|
||
const updatedTransaction = await prisma.transaction.update({ | ||
where: { id: transactionId }, | ||
data: { categoryId: categoryId }, | ||
}); | ||
|
||
revalidatePath("/dashboard/banking"); | ||
|
||
return { success: true, data: updatedTransaction }; | ||
} catch (error) { | ||
console.error("Error updating category:", error); | ||
return { success: false, error: "Failed to update category" }; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
apps/www/src/actions/update-multiple-transactions-review.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
"use server"; | ||
|
||
import { revalidatePath } from "next/cache"; | ||
|
||
import { prisma } from "@/lib/db"; | ||
import { getCurrentUser } from "@/lib/session"; | ||
|
||
export async function updateMultipleTransactionReviews( | ||
transactionIds: string[], | ||
) { | ||
const user = await getCurrentUser(); | ||
if (!user) { | ||
throw new Error("User not authenticated"); | ||
} | ||
|
||
try { | ||
await prisma.transaction.updateMany({ | ||
where: { id: { in: transactionIds } }, | ||
data: { review: true }, | ||
}); | ||
|
||
revalidatePath("/dashboard"); | ||
|
||
return { success: true }; | ||
} catch (error) { | ||
console.error("Error updating multiple transaction reviews:", error); | ||
return { success: false, error: error.message }; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
"use server"; | ||
|
||
import { revalidatePath } from "next/cache"; | ||
|
||
import { prisma } from "@/lib/db"; | ||
import { getCurrentUser } from "@/lib/session"; | ||
|
||
interface UpdateTransactionData { | ||
id: string; | ||
accountId?: string; | ||
assetId?: string; | ||
currencyIso?: string; | ||
categoryId?: string; | ||
amount?: number; | ||
date?: Date; | ||
description?: string; | ||
review?: boolean; | ||
} | ||
|
||
export async function updateTransaction(data: UpdateTransactionData) { | ||
const user = await getCurrentUser(); | ||
const userId = user?.id; | ||
|
||
if (!userId) { | ||
console.error("No user is currently logged in."); | ||
return { success: false, error: "User not authenticated" }; | ||
} | ||
|
||
try { | ||
const updatedTransaction = await prisma.transaction.update({ | ||
where: { id: data.id }, | ||
data: { | ||
accountId: data.accountId, | ||
assetId: data.assetId, | ||
currencyIso: data.currencyIso, | ||
categoryId: data.categoryId, | ||
date: data.date, | ||
description: data.description, | ||
review: data.review, | ||
}, | ||
}); | ||
|
||
revalidatePath("/dashboard"); | ||
|
||
console.log(`Updated transaction with ID: ${updatedTransaction.id}`); | ||
|
||
return { success: true, transaction: updatedTransaction }; | ||
} catch (error) { | ||
console.error(`Error updating transaction: ${error.message}`); | ||
return { success: false, error: error.message }; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.