style: clean up code with prettier and eslint
This commit is contained in:
1 parent
60278b9e71
commit
fb8e77bb68
378 files changed
+22407
-20689
No files matched your search
@@ -1,28 +1,28 @@
|
||||
import { withAdmin } from '@/lib/api-handler'
|
||||
import { apiError, apiOk } from '@/lib/api-response'
|
||||
import { PERMS } from '@/lib/permissions'
|
||||
import { logAudit } from '@/lib/services/audit'
|
||||
import { deleteImportedFigure, getFigureList, getFigureStats } from '@/lib/services/figure-import'
|
||||
import { withAdmin } from "@/lib/api-handler";
|
||||
import { apiError, apiOk } from "@/lib/api-response";
|
||||
import { PERMS } from "@/lib/permissions";
|
||||
import { logAudit } from "@/lib/services/audit";
|
||||
import { deleteImportedFigure, getFigureList, getFigureStats } from "@/lib/services/figure-import";
|
||||
|
||||
export const GET = withAdmin({ permission: PERMS.ASSETS_IMPORT }, async (request) => {
|
||||
if (request.nextUrl.searchParams.get('action') === 'stats') return apiOk(await getFigureStats())
|
||||
const search = request.nextUrl.searchParams.get('search') || ''
|
||||
const page = Number.parseInt(request.nextUrl.searchParams.get('page') || '1', 10)
|
||||
const { items, meta } = await getFigureList({ search, page: page || 1, perPage: 100 })
|
||||
return apiOk({ items, meta })
|
||||
})
|
||||
if (request.nextUrl.searchParams.get("action") === "stats") return apiOk(await getFigureStats());
|
||||
const search = request.nextUrl.searchParams.get("search") || "";
|
||||
const page = Number.parseInt(request.nextUrl.searchParams.get("page") || "1", 10);
|
||||
const { items, meta } = await getFigureList({ search, page: page || 1, perPage: 100 });
|
||||
return apiOk({ items, meta });
|
||||
});
|
||||
|
||||
export const DELETE = withAdmin({ permission: PERMS.ASSETS_IMPORT }, async (request, ctx) => {
|
||||
const lib = request.nextUrl.searchParams.get('lib')
|
||||
if (!lib) return apiError('Missing lib', 400)
|
||||
const { deletedFile } = await deleteImportedFigure(lib)
|
||||
if (!deletedFile) return apiError(`Library "${lib}" not found`, 404)
|
||||
const lib = request.nextUrl.searchParams.get("lib");
|
||||
if (!lib) return apiError("Missing lib", 400);
|
||||
const { deletedFile } = await deleteImportedFigure(lib);
|
||||
if (!deletedFile) return apiError(`Library "${lib}" not found`, 404);
|
||||
logAudit({
|
||||
userId: ctx.session.user.id,
|
||||
action: 'figure_delete',
|
||||
target: 'FigureAsset',
|
||||
action: "figure_delete",
|
||||
target: "FigureAsset",
|
||||
targetId: 0,
|
||||
after: { lib },
|
||||
})
|
||||
return apiOk({ lib, deletedFile })
|
||||
})
|
||||
});
|
||||
return apiOk({ lib, deletedFile });
|
||||
});
|
||||
Reference in new issue
Block a user