fix: jabatan

Deskripsi;
- order by name jabatan

No Issues'
This commit is contained in:
amel
2024-11-12 10:44:34 +08:00
parent 63a8d3cbd6
commit 2ca0852d24

View File

@@ -68,11 +68,14 @@ export async function GET(request: Request) {
});
const allData = positions.map((v: any) => ({
..._.omit(v, ["Group"]),
..._.omit(v, ["Group", "name"]),
name: v.name,
group: v.Group.name
}))
return NextResponse.json({ success: true, message: "Berhasil mendapatkan jabatan", data: allData, filter }, { status: 200 });
const dataFix = _.orderBy(allData, [data => data.name.toLowerCase()], ['asc']);
return NextResponse.json({ success: true, message: "Berhasil mendapatkan jabatan", data: dataFix, filter }, { status: 200 });
} catch (error) {
console.error(error);
return NextResponse.json({ success: false, message: "Gagal mendapatkan jabatan, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });