mirror of
https://github.com/marcogll/TaxHacker_s23.git
synced 2026-01-13 13:25:18 +00:00
fix #11: unable to delete category
This commit is contained in:
@@ -47,6 +47,7 @@ export async function GET(request: Request) {
|
|||||||
value = transaction[field.code as keyof typeof transaction] ?? ""
|
value = transaction[field.code as keyof typeof transaction] ?? ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if the field has a special export rules
|
||||||
const exportFieldSettings = EXPORT_AND_IMPORT_FIELD_MAP[field.code]
|
const exportFieldSettings = EXPORT_AND_IMPORT_FIELD_MAP[field.code]
|
||||||
if (exportFieldSettings && exportFieldSettings.export) {
|
if (exportFieldSettings && exportFieldSettings.export) {
|
||||||
row[field.code] = await exportFieldSettings.export(user.id, value)
|
row[field.code] = await exportFieldSettings.export(user.id, value)
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ export async function editCategoryAction(userId: string, code: string, data: Pri
|
|||||||
return { success: true, category }
|
return { success: true, category }
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function deleteCategoryAction(code: string, userId: string) {
|
export async function deleteCategoryAction(userId: string, code: string) {
|
||||||
try {
|
try {
|
||||||
await deleteCategory(userId, code)
|
await deleteCategory(userId, code)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export const getCategories = cache(async (userId: string) => {
|
|||||||
|
|
||||||
export const getCategoryByCode = cache(async (userId: string, code: string) => {
|
export const getCategoryByCode = cache(async (userId: string, code: string) => {
|
||||||
return await prisma.category.findUnique({
|
return await prisma.category.findUnique({
|
||||||
where: { userId_code: { code, userId } },
|
where: { userId_code: { userId, code } },
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -40,13 +40,13 @@ export const createCategory = async (userId: string, category: CategoryData) =>
|
|||||||
|
|
||||||
export const updateCategory = async (userId: string, code: string, category: CategoryData) => {
|
export const updateCategory = async (userId: string, code: string, category: CategoryData) => {
|
||||||
return await prisma.category.update({
|
return await prisma.category.update({
|
||||||
where: { userId_code: { code, userId } },
|
where: { userId_code: { userId, code } },
|
||||||
data: category,
|
data: category,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const deleteCategory = async (userId: string, code: string) => {
|
export const deleteCategory = async (userId: string, code: string) => {
|
||||||
return await prisma.category.delete({
|
return await prisma.category.delete({
|
||||||
where: { userId_code: { code, userId } },
|
where: { userId_code: { userId, code } },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user