Fix UI Admin Menu Kesehatan, Login Admin, OTP

This commit is contained in:
2025-09-08 14:02:21 +08:00
parent 8817b937b1
commit 797713ef49
80 changed files with 7648 additions and 4924 deletions

View File

@@ -1,30 +1,64 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import prisma from "@/lib/prisma";
import { Context } from "elysia";
export default async function artikelKesehatanFindMany(context: Context) {
// Ambil parameter dari query
const page = Number(context.query.page) || 1;
const limit = Number(context.query.limit) || 10;
const search = (context.query.search as string) || "";
const skip = (page - 1) * limit;
// Buat where clause
const where: any = { isActive: true };
// Tambahkan pencarian (jika ada)
if (search) {
where.OR = [
{ title: { contains: search, mode: "insensitive" } },
{ introduction: { content: { contains: search, mode: "insensitive" } } },
{ symptom: { title: { contains: search, mode: "insensitive" } } },
{ prevention: { title: { contains: search, mode: "insensitive" } } },
{ firstaid: { title: { contains: search, mode: "insensitive" } } },
{ mythvsfact: { title: { contains: search, mode: "insensitive" } } },
{ doctorsign: { content: { contains: search, mode: "insensitive" } } },
];
}
try {
// Ambil data dan total count secara paralel
const [data, total] = await Promise.all([
prisma.artikelKesehatan.findMany({
where,
include: {
introduction: true,
symptom: true,
prevention: true,
firstaid: true,
mythvsfact: true,
doctorsign: true,
},
skip,
take: limit,
orderBy: { createdAt: "desc" },
}),
prisma.artikelKesehatan.count({ where }),
]);
return {
success: true,
message: "Berhasil ambil keamanan lingkungan dengan pagination",
data,
page,
limit,
total,
totalPages: Math.ceil(total / limit),
};
} catch (e) {
console.error("Error di findMany paginated:", e);
return {
success: false,
message: "Gagal mengambil data keamanan lingkungan",
};
}
}
export default async function artikelKesehatanFindMany() {
try {
const data = await prisma.artikelKesehatan.findMany({
where: {
isActive: true,
},
include: {
introduction: true,
symptom: true,
prevention: true,
firstaid: true,
mythvsfact: true,
doctorsign: true,
}
})
return {
success: true,
message: "Success fetch artikel kesehatan",
data,
}
} catch (error) {
console.error("Find many error:", error);
return {
success: false,
message: "Failed fetch artikel kesehatan",
}
}
}

View File

@@ -1,11 +1,35 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
// /api/berita/findManyPaginated.ts
import prisma from "@/lib/prisma";
import { Context } from "elysia";
export default async function findManyFasilitasKesehatan() {
try {
const data = await prisma.fasilitasKesehatan.findMany({
where: {
isActive: true,
},
async function fasilitasKesehatanFindMany(context: Context) {
// Ambil parameter dari query
const page = Number(context.query.page) || 1;
const limit = Number(context.query.limit) || 10;
const search = (context.query.search as string) || '';
const skip = (page - 1) * limit;
// Buat where clause
const where: any = { isActive: true };
// Tambahkan pencarian (jika ada)
if (search) {
where.OR = [
{ informasiUmum: { fasilitas: { contains: search, mode: 'insensitive' } } },
{ layananUnggulan: { content: { contains: search, mode: 'insensitive' } } },
{ dokterdanTenagaMedis: { name: { contains: search, mode: 'insensitive' } } },
{ fasilitasPendukung: { content: { contains: search, mode: 'insensitive' } } },
{ prosedurPendaftaran: { content: { contains: search, mode: 'insensitive' } } },
{ tarifdanlayanan: { layanan: { contains: search, mode: 'insensitive' } } },
];
}
try {
// Ambil data dan total count secara paralel
const [data, total] = await Promise.all([
prisma.fasilitasKesehatan.findMany({
where,
include: {
informasiumum: true,
layananunggulan: true,
@@ -13,18 +37,29 @@ export default async function findManyFasilitasKesehatan() {
fasilitaspendukung: true,
prosedurpendaftaran: true,
tarifdanlayanan: true,
}
})
return {
success: true,
message: "Success fetch fasilitas kesehatan",
data,
}
} catch (error) {
console.error("Find many error:", error);
return {
success: false,
message: "Failed fetch fasilitas kesehatan",
}
},
skip,
take: limit,
orderBy: { createdAt: 'desc' },
}),
prisma.fasilitasKesehatan.count({ where }),
]);
return {
success: true,
message: "Berhasil ambil keamanan lingkungan dengan pagination",
data,
page,
limit,
total,
totalPages: Math.ceil(total / limit),
};
} catch (e) {
console.error("Error di findMany paginated:", e);
return {
success: false,
message: "Gagal mengambil data keamanan lingkungan",
};
}
}
}
export default fasilitasKesehatanFindMany

View File

@@ -1,30 +1,60 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import prisma from "@/lib/prisma";
import { Context } from "elysia";
export default async function jadwalKegiatanFindMany() {
try {
const data = await prisma.jadwalKegiatan.findMany({
where: {
isActive: true,
},
include: {
informasijadwalkegiatan: true,
deskripsijadwalkegiatan: true,
layananjadwalkegiatan: true,
syaratketentuanjadwalkegiatan: true,
dokumenjadwalkegiatan: true,
pendaftaranjadwalkegiatan: true,
}
})
return {
success: true,
message: "Success fetch jadwal kegiatan",
data,
}
} catch (error) {
console.error("Find many error:", error);
return {
success: false,
message: "Failed fetch jadwal kegiatan",
}
}
}
export default async function jadwalKegiatanFindMany(context: Context) {
// Ambil parameter dari query
const page = Number(context.query.page) || 1;
const limit = Number(context.query.limit) || 10;
const search = (context.query.search as string) || "";
const skip = (page - 1) * limit;
// Buat where clause
const where: any = { isActive: true };
// Tambahkan pencarian (jika ada)
if (search) {
where.OR = [
{ informasijadwalkegiatan: { name: { contains: search, mode: "insensitive" } } },
{ deskripsijadwalkegiatan: { deskripsi: { contains: search, mode: "insensitive" } } },
{layananjadwalkegiatan: { content: { contains: search, mode: "insensitive" } } },
{syaratketentuanjadwalkegiatan: { content: { contains: search, mode: "insensitive" } } },
{dokumenjadwalkegiatan: { content: { contains: search, mode: "insensitive" } } },
{pendaftaranjadwalkegiatan: { content: { contains: search, mode: "insensitive" } } },
];
}
try {
const [data, total] = await Promise.all([
prisma.jadwalKegiatan.findMany({
where,
include: {
informasijadwalkegiatan: true,
deskripsijadwalkegiatan: true,
layananjadwalkegiatan: true,
syaratketentuanjadwalkegiatan: true,
dokumenjadwalkegiatan: true,
pendaftaranjadwalkegiatan: true,
},
skip,
take: limit,
orderBy: { createdAt: "desc" },
}),
prisma.jadwalKegiatan.count({ where }),
]);
return {
success: true,
message: "Success fetch jadwal kegiatan",
data,
page,
limit,
total,
totalPages: Math.ceil(total / limit),
};
} catch (error) {
console.error("Find many error:", error);
return {
success: false,
message: "Failed fetch jadwal kegiatan",
};
}
}