Compare commits
4 Commits
nico/20-ju
...
nico/25-ju
| Author | SHA1 | Date | |
|---|---|---|---|
| 4f6cc66b7c | |||
| 4683034cd7 | |||
| 37de71a75a | |||
| 27fa7ac0fc |
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "desa-darmasaba",
|
"name": "desa-darmasaba",
|
||||||
"version": "0.1.2",
|
"version": "0.1.3",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev --turbopack",
|
"dev": "next dev --turbopack",
|
||||||
|
|||||||
139
prisma/migrations/20250624034125_24_jun2025/migration.sql
Normal file
139
prisma/migrations/20250624034125_24_jun2025/migration.sql
Normal file
@@ -0,0 +1,139 @@
|
|||||||
|
/*
|
||||||
|
Warnings:
|
||||||
|
|
||||||
|
- The primary key for the `DataKematian_Kelahiran` table will be changed. If it partially fails, the table could be left without primary key constraint.
|
||||||
|
|
||||||
|
*/
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "DataKematian_Kelahiran" DROP CONSTRAINT "DataKematian_Kelahiran_pkey",
|
||||||
|
ALTER COLUMN "id" DROP DEFAULT,
|
||||||
|
ALTER COLUMN "id" SET DATA TYPE TEXT,
|
||||||
|
ADD CONSTRAINT "DataKematian_Kelahiran_pkey" PRIMARY KEY ("id");
|
||||||
|
DROP SEQUENCE "DataKematian_Kelahiran_id_seq";
|
||||||
|
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "ProfilePPID" ADD COLUMN "imageUrl" TEXT;
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "Puskesmas" (
|
||||||
|
"id" TEXT NOT NULL,
|
||||||
|
"name" TEXT NOT NULL,
|
||||||
|
"alamat" TEXT NOT NULL,
|
||||||
|
"jamId" TEXT NOT NULL,
|
||||||
|
"imageId" TEXT NOT NULL,
|
||||||
|
"kontakId" TEXT NOT NULL,
|
||||||
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||||
|
"deletedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"isActive" BOOLEAN NOT NULL DEFAULT true,
|
||||||
|
|
||||||
|
CONSTRAINT "Puskesmas_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "JamOperasional" (
|
||||||
|
"id" TEXT NOT NULL,
|
||||||
|
"workDays" TEXT NOT NULL,
|
||||||
|
"weekDays" TEXT NOT NULL,
|
||||||
|
"holiday" TEXT NOT NULL,
|
||||||
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||||
|
"deletedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"isActive" BOOLEAN NOT NULL DEFAULT true,
|
||||||
|
|
||||||
|
CONSTRAINT "JamOperasional_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "KontakPuskesmas" (
|
||||||
|
"id" TEXT NOT NULL,
|
||||||
|
"kontakPuskesmas" TEXT NOT NULL,
|
||||||
|
"email" TEXT NOT NULL,
|
||||||
|
"facebook" TEXT NOT NULL,
|
||||||
|
"kontakUGD" TEXT NOT NULL,
|
||||||
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||||
|
"deletedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"isActive" BOOLEAN NOT NULL DEFAULT true,
|
||||||
|
|
||||||
|
CONSTRAINT "KontakPuskesmas_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "ProgramKesehatan" (
|
||||||
|
"id" TEXT NOT NULL,
|
||||||
|
"name" TEXT NOT NULL,
|
||||||
|
"deskripsiSingkat" TEXT NOT NULL,
|
||||||
|
"deskripsi" TEXT NOT NULL,
|
||||||
|
"imageId" TEXT NOT NULL,
|
||||||
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||||
|
"deletedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"isActive" BOOLEAN NOT NULL DEFAULT true,
|
||||||
|
|
||||||
|
CONSTRAINT "ProgramKesehatan_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "PenangananDarurat" (
|
||||||
|
"id" TEXT NOT NULL,
|
||||||
|
"name" TEXT NOT NULL,
|
||||||
|
"deskripsi" TEXT NOT NULL,
|
||||||
|
"imageId" TEXT NOT NULL,
|
||||||
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||||
|
"deletedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"isActive" BOOLEAN NOT NULL DEFAULT true,
|
||||||
|
|
||||||
|
CONSTRAINT "PenangananDarurat_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "KontakDarurat" (
|
||||||
|
"id" TEXT NOT NULL,
|
||||||
|
"name" TEXT NOT NULL,
|
||||||
|
"deskripsi" TEXT NOT NULL,
|
||||||
|
"imageId" TEXT NOT NULL,
|
||||||
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||||
|
"deletedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"isActive" BOOLEAN NOT NULL DEFAULT true,
|
||||||
|
|
||||||
|
CONSTRAINT "KontakDarurat_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "InfoWabahPenyakit" (
|
||||||
|
"id" TEXT NOT NULL,
|
||||||
|
"name" TEXT NOT NULL,
|
||||||
|
"deskripsiSingkat" TEXT NOT NULL,
|
||||||
|
"deskripsiLengkap" TEXT NOT NULL,
|
||||||
|
"imageId" TEXT NOT NULL,
|
||||||
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||||
|
"deletedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"isActive" BOOLEAN NOT NULL DEFAULT true,
|
||||||
|
|
||||||
|
CONSTRAINT "InfoWabahPenyakit_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "Puskesmas" ADD CONSTRAINT "Puskesmas_jamId_fkey" FOREIGN KEY ("jamId") REFERENCES "JamOperasional"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "Puskesmas" ADD CONSTRAINT "Puskesmas_imageId_fkey" FOREIGN KEY ("imageId") REFERENCES "FileStorage"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "Puskesmas" ADD CONSTRAINT "Puskesmas_kontakId_fkey" FOREIGN KEY ("kontakId") REFERENCES "KontakPuskesmas"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "ProgramKesehatan" ADD CONSTRAINT "ProgramKesehatan_imageId_fkey" FOREIGN KEY ("imageId") REFERENCES "FileStorage"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "PenangananDarurat" ADD CONSTRAINT "PenangananDarurat_imageId_fkey" FOREIGN KEY ("imageId") REFERENCES "FileStorage"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "KontakDarurat" ADD CONSTRAINT "KontakDarurat_imageId_fkey" FOREIGN KEY ("imageId") REFERENCES "FileStorage"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "InfoWabahPenyakit" ADD CONSTRAINT "InfoWabahPenyakit_imageId_fkey" FOREIGN KEY ("imageId") REFERENCES "FileStorage"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
12
prisma/migrations/20250624061829_24jun2025_2/migration.sql
Normal file
12
prisma/migrations/20250624061829_24jun2025_2/migration.sql
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
/*
|
||||||
|
Warnings:
|
||||||
|
|
||||||
|
- The primary key for the `GrafikKepuasan` table will be changed. If it partially fails, the table could be left without primary key constraint.
|
||||||
|
|
||||||
|
*/
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "GrafikKepuasan" DROP CONSTRAINT "GrafikKepuasan_pkey",
|
||||||
|
ALTER COLUMN "id" DROP DEFAULT,
|
||||||
|
ALTER COLUMN "id" SET DATA TYPE TEXT,
|
||||||
|
ADD CONSTRAINT "GrafikKepuasan_pkey" PRIMARY KEY ("id");
|
||||||
|
DROP SEQUENCE "GrafikKepuasan_id_seq";
|
||||||
96
prisma/migrations/20250625035558_25jun2025_1/migration.sql
Normal file
96
prisma/migrations/20250625035558_25jun2025_1/migration.sql
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
/*
|
||||||
|
Warnings:
|
||||||
|
|
||||||
|
- You are about to drop the `_DokterdanTenagaMedisToFasilitasKesehatan` table. If the table is not empty, all the data it contains will be lost.
|
||||||
|
- You are about to drop the `_FasilitasKesehatanToFasilitasPendukung` table. If the table is not empty, all the data it contains will be lost.
|
||||||
|
- You are about to drop the `_FasilitasKesehatanToInformasiUmum` table. If the table is not empty, all the data it contains will be lost.
|
||||||
|
- You are about to drop the `_FasilitasKesehatanToLayananUnggulan` table. If the table is not empty, all the data it contains will be lost.
|
||||||
|
- You are about to drop the `_FasilitasKesehatanToProsedurPendaftaran` table. If the table is not empty, all the data it contains will be lost.
|
||||||
|
- You are about to drop the `_FasilitasKesehatanToTarifDanLayanan` table. If the table is not empty, all the data it contains will be lost.
|
||||||
|
- Added the required column `dokterdanTenagaMedisId` to the `FasilitasKesehatan` table without a default value. This is not possible if the table is not empty.
|
||||||
|
- Added the required column `fasilitasPendukungId` to the `FasilitasKesehatan` table without a default value. This is not possible if the table is not empty.
|
||||||
|
- Added the required column `informasiUmumId` to the `FasilitasKesehatan` table without a default value. This is not possible if the table is not empty.
|
||||||
|
- Added the required column `layananUnggulanId` to the `FasilitasKesehatan` table without a default value. This is not possible if the table is not empty.
|
||||||
|
- Added the required column `prosedurPendaftaranId` to the `FasilitasKesehatan` table without a default value. This is not possible if the table is not empty.
|
||||||
|
- Added the required column `tarifDanLayananId` to the `FasilitasKesehatan` table without a default value. This is not possible if the table is not empty.
|
||||||
|
|
||||||
|
*/
|
||||||
|
-- DropForeignKey
|
||||||
|
ALTER TABLE "_DokterdanTenagaMedisToFasilitasKesehatan" DROP CONSTRAINT "_DokterdanTenagaMedisToFasilitasKesehatan_A_fkey";
|
||||||
|
|
||||||
|
-- DropForeignKey
|
||||||
|
ALTER TABLE "_DokterdanTenagaMedisToFasilitasKesehatan" DROP CONSTRAINT "_DokterdanTenagaMedisToFasilitasKesehatan_B_fkey";
|
||||||
|
|
||||||
|
-- DropForeignKey
|
||||||
|
ALTER TABLE "_FasilitasKesehatanToFasilitasPendukung" DROP CONSTRAINT "_FasilitasKesehatanToFasilitasPendukung_A_fkey";
|
||||||
|
|
||||||
|
-- DropForeignKey
|
||||||
|
ALTER TABLE "_FasilitasKesehatanToFasilitasPendukung" DROP CONSTRAINT "_FasilitasKesehatanToFasilitasPendukung_B_fkey";
|
||||||
|
|
||||||
|
-- DropForeignKey
|
||||||
|
ALTER TABLE "_FasilitasKesehatanToInformasiUmum" DROP CONSTRAINT "_FasilitasKesehatanToInformasiUmum_A_fkey";
|
||||||
|
|
||||||
|
-- DropForeignKey
|
||||||
|
ALTER TABLE "_FasilitasKesehatanToInformasiUmum" DROP CONSTRAINT "_FasilitasKesehatanToInformasiUmum_B_fkey";
|
||||||
|
|
||||||
|
-- DropForeignKey
|
||||||
|
ALTER TABLE "_FasilitasKesehatanToLayananUnggulan" DROP CONSTRAINT "_FasilitasKesehatanToLayananUnggulan_A_fkey";
|
||||||
|
|
||||||
|
-- DropForeignKey
|
||||||
|
ALTER TABLE "_FasilitasKesehatanToLayananUnggulan" DROP CONSTRAINT "_FasilitasKesehatanToLayananUnggulan_B_fkey";
|
||||||
|
|
||||||
|
-- DropForeignKey
|
||||||
|
ALTER TABLE "_FasilitasKesehatanToProsedurPendaftaran" DROP CONSTRAINT "_FasilitasKesehatanToProsedurPendaftaran_A_fkey";
|
||||||
|
|
||||||
|
-- DropForeignKey
|
||||||
|
ALTER TABLE "_FasilitasKesehatanToProsedurPendaftaran" DROP CONSTRAINT "_FasilitasKesehatanToProsedurPendaftaran_B_fkey";
|
||||||
|
|
||||||
|
-- DropForeignKey
|
||||||
|
ALTER TABLE "_FasilitasKesehatanToTarifDanLayanan" DROP CONSTRAINT "_FasilitasKesehatanToTarifDanLayanan_A_fkey";
|
||||||
|
|
||||||
|
-- DropForeignKey
|
||||||
|
ALTER TABLE "_FasilitasKesehatanToTarifDanLayanan" DROP CONSTRAINT "_FasilitasKesehatanToTarifDanLayanan_B_fkey";
|
||||||
|
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "FasilitasKesehatan" ADD COLUMN "dokterdanTenagaMedisId" TEXT NOT NULL,
|
||||||
|
ADD COLUMN "fasilitasPendukungId" TEXT NOT NULL,
|
||||||
|
ADD COLUMN "informasiUmumId" TEXT NOT NULL,
|
||||||
|
ADD COLUMN "layananUnggulanId" TEXT NOT NULL,
|
||||||
|
ADD COLUMN "prosedurPendaftaranId" TEXT NOT NULL,
|
||||||
|
ADD COLUMN "tarifDanLayananId" TEXT NOT NULL;
|
||||||
|
|
||||||
|
-- DropTable
|
||||||
|
DROP TABLE "_DokterdanTenagaMedisToFasilitasKesehatan";
|
||||||
|
|
||||||
|
-- DropTable
|
||||||
|
DROP TABLE "_FasilitasKesehatanToFasilitasPendukung";
|
||||||
|
|
||||||
|
-- DropTable
|
||||||
|
DROP TABLE "_FasilitasKesehatanToInformasiUmum";
|
||||||
|
|
||||||
|
-- DropTable
|
||||||
|
DROP TABLE "_FasilitasKesehatanToLayananUnggulan";
|
||||||
|
|
||||||
|
-- DropTable
|
||||||
|
DROP TABLE "_FasilitasKesehatanToProsedurPendaftaran";
|
||||||
|
|
||||||
|
-- DropTable
|
||||||
|
DROP TABLE "_FasilitasKesehatanToTarifDanLayanan";
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "FasilitasKesehatan" ADD CONSTRAINT "FasilitasKesehatan_informasiUmumId_fkey" FOREIGN KEY ("informasiUmumId") REFERENCES "InformasiUmum"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "FasilitasKesehatan" ADD CONSTRAINT "FasilitasKesehatan_layananUnggulanId_fkey" FOREIGN KEY ("layananUnggulanId") REFERENCES "LayananUnggulan"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "FasilitasKesehatan" ADD CONSTRAINT "FasilitasKesehatan_dokterdanTenagaMedisId_fkey" FOREIGN KEY ("dokterdanTenagaMedisId") REFERENCES "DokterdanTenagaMedis"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "FasilitasKesehatan" ADD CONSTRAINT "FasilitasKesehatan_fasilitasPendukungId_fkey" FOREIGN KEY ("fasilitasPendukungId") REFERENCES "FasilitasPendukung"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "FasilitasKesehatan" ADD CONSTRAINT "FasilitasKesehatan_prosedurPendaftaranId_fkey" FOREIGN KEY ("prosedurPendaftaranId") REFERENCES "ProsedurPendaftaran"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "FasilitasKesehatan" ADD CONSTRAINT "FasilitasKesehatan_tarifDanLayananId_fkey" FOREIGN KEY ("tarifDanLayananId") REFERENCES "TarifDanLayanan"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
32
prisma/migrations/20250625085706_25_jun_25_2/migration.sql
Normal file
32
prisma/migrations/20250625085706_25_jun_25_2/migration.sql
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
Warnings:
|
||||||
|
|
||||||
|
- The primary key for the `DataKematian_Kelahiran` table will be changed. If it partially fails, the table could be left without primary key constraint.
|
||||||
|
- The `id` column on the `DataKematian_Kelahiran` table would be dropped and recreated. This will lead to data loss if there is data in the column.
|
||||||
|
- The primary key for the `GrafikKepuasan` table will be changed. If it partially fails, the table could be left without primary key constraint.
|
||||||
|
- The `id` column on the `GrafikKepuasan` table would be dropped and recreated. This will lead to data loss if there is data in the column.
|
||||||
|
- A unique constraint covering the columns `[uuid]` on the table `DataKematian_Kelahiran` will be added. If there are existing duplicate values, this will fail.
|
||||||
|
- A unique constraint covering the columns `[uuid]` on the table `GrafikKepuasan` will be added. If there are existing duplicate values, this will fail.
|
||||||
|
- The required column `uuid` was added to the `DataKematian_Kelahiran` table with a prisma-level default value. This is not possible if the table is not empty. Please add this column as optional, then populate it before making it required.
|
||||||
|
- The required column `uuid` was added to the `GrafikKepuasan` table with a prisma-level default value. This is not possible if the table is not empty. Please add this column as optional, then populate it before making it required.
|
||||||
|
|
||||||
|
*/
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "DataKematian_Kelahiran" DROP CONSTRAINT "DataKematian_Kelahiran_pkey",
|
||||||
|
ADD COLUMN "uuid" TEXT NOT NULL,
|
||||||
|
DROP COLUMN "id",
|
||||||
|
ADD COLUMN "id" SERIAL NOT NULL,
|
||||||
|
ADD CONSTRAINT "DataKematian_Kelahiran_pkey" PRIMARY KEY ("id");
|
||||||
|
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "GrafikKepuasan" DROP CONSTRAINT "GrafikKepuasan_pkey",
|
||||||
|
ADD COLUMN "uuid" TEXT NOT NULL,
|
||||||
|
DROP COLUMN "id",
|
||||||
|
ADD COLUMN "id" SERIAL NOT NULL,
|
||||||
|
ADD CONSTRAINT "GrafikKepuasan_pkey" PRIMARY KEY ("id");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "DataKematian_Kelahiran_uuid_key" ON "DataKematian_Kelahiran"("uuid");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "GrafikKepuasan_uuid_key" ON "GrafikKepuasan"("uuid");
|
||||||
@@ -477,12 +477,18 @@ model FasilitasKesehatan {
|
|||||||
updatedAt DateTime @updatedAt
|
updatedAt DateTime @updatedAt
|
||||||
deletedAt DateTime @default(now())
|
deletedAt DateTime @default(now())
|
||||||
isActive Boolean @default(true)
|
isActive Boolean @default(true)
|
||||||
InformasiUmum InformasiUmum[]
|
informasiumum InformasiUmum @relation(fields: [informasiUmumId], references: [id])
|
||||||
LayananUnggulan LayananUnggulan[]
|
informasiUmumId String
|
||||||
DokterdanTenagaMedis DokterdanTenagaMedis[]
|
layananunggulan LayananUnggulan @relation(fields: [layananUnggulanId], references: [id])
|
||||||
FasilitasPendukung FasilitasPendukung[]
|
layananUnggulanId String
|
||||||
ProsedurPendaftaran ProsedurPendaftaran[]
|
dokterdantenagamedis DokterdanTenagaMedis @relation(fields: [dokterdanTenagaMedisId], references: [id])
|
||||||
TarifDanLayanan TarifDanLayanan[]
|
dokterdanTenagaMedisId String
|
||||||
|
fasilitaspendukung FasilitasPendukung @relation(fields: [fasilitasPendukungId], references: [id])
|
||||||
|
fasilitasPendukungId String
|
||||||
|
prosedurpendaftaran ProsedurPendaftaran @relation(fields: [prosedurPendaftaranId], references: [id])
|
||||||
|
prosedurPendaftaranId String
|
||||||
|
tarifdanlayanan TarifDanLayanan @relation(fields: [tarifDanLayananId], references: [id])
|
||||||
|
tarifDanLayananId String
|
||||||
}
|
}
|
||||||
|
|
||||||
model InformasiUmum {
|
model InformasiUmum {
|
||||||
@@ -490,10 +496,10 @@ model InformasiUmum {
|
|||||||
fasilitas String
|
fasilitas String
|
||||||
alamat String
|
alamat String
|
||||||
jamOperasional String
|
jamOperasional String
|
||||||
FasilitasKesehatan FasilitasKesehatan[]
|
|
||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
updatedAt DateTime @updatedAt
|
updatedAt DateTime @updatedAt
|
||||||
deletedAt DateTime @default(now())
|
deletedAt DateTime @default(now())
|
||||||
|
FasilitasKesehatan FasilitasKesehatan[]
|
||||||
isActive Boolean @default(true)
|
isActive Boolean @default(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -624,7 +630,8 @@ model PendaftaranJadwalKegiatan {
|
|||||||
|
|
||||||
// ========================================= PERSENTASE KELAHIRAN & KEMATIAN ========================================= //
|
// ========================================= PERSENTASE KELAHIRAN & KEMATIAN ========================================= //
|
||||||
model DataKematian_Kelahiran {
|
model DataKematian_Kelahiran {
|
||||||
id Int @id @default(autoincrement())
|
id Int @id @default(autoincrement())
|
||||||
|
uuid String @default(cuid()) @unique
|
||||||
tahun String
|
tahun String
|
||||||
kematianKasar String
|
kematianKasar String
|
||||||
kematianBayi String
|
kematianBayi String
|
||||||
@@ -638,6 +645,7 @@ model DataKematian_Kelahiran {
|
|||||||
// ========================================= GRAFIK KEPUASAN ========================================= //
|
// ========================================= GRAFIK KEPUASAN ========================================= //
|
||||||
model GrafikKepuasan {
|
model GrafikKepuasan {
|
||||||
id Int @id @default(autoincrement())
|
id Int @id @default(autoincrement())
|
||||||
|
uuid String @default(cuid()) @unique
|
||||||
label String
|
label String
|
||||||
jumlah String
|
jumlah String
|
||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
|
|||||||
@@ -1,333 +1,308 @@
|
|||||||
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
import ApiFetch from "@/lib/api-fetch";
|
import ApiFetch from "@/lib/api-fetch";
|
||||||
import { Prisma } from "@prisma/client";
|
import { Prisma } from "@prisma/client";
|
||||||
import { toast } from "react-toastify";
|
import { toast } from "react-toastify";
|
||||||
import { proxy } from "valtio";
|
import { proxy } from "valtio";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
/* Informasi Umum */
|
// Validasi form
|
||||||
const templateInformasiUmum = z.object({
|
const templateForm = z.object({
|
||||||
fasilitas: z.string().min(3, "Fasilitas minimal 3 karakter"),
|
name: z.string().min(1, "Nama harus diisi"),
|
||||||
alamat: z.string().min(3, "Alamat minimal 3 karakter"),
|
informasiUmum: z.object({
|
||||||
jamOperasional: z.string().min(3, "Jam Operasional minimal 3 karakter"),
|
fasilitas: z.string().min(1, "Fasilitas harus diisi"),
|
||||||
|
alamat: z.string().min(1, "Alamat harus diisi"),
|
||||||
|
jamOperasional: z.string().min(1, "Jam operasional harus diisi"),
|
||||||
|
}),
|
||||||
|
layananUnggulan: z.object({
|
||||||
|
content: z.string().min(1, "Layanan unggulan harus diisi"),
|
||||||
|
}),
|
||||||
|
dokterdanTenagaMedis: z.object({
|
||||||
|
name: z.string().min(1, "Nama dokter harus diisi"),
|
||||||
|
specialist: z.string().min(1, "Spesialis harus diisi"),
|
||||||
|
jadwal: z.string().min(1, "Jadwal harus diisi"),
|
||||||
|
}),
|
||||||
|
fasilitasPendukung: z.object({
|
||||||
|
content: z.string().min(1, "Fasilitas pendukung harus diisi"),
|
||||||
|
}),
|
||||||
|
prosedurPendaftaran: z.object({
|
||||||
|
content: z.string().min(1, "Prosedur pendaftaran harus diisi"),
|
||||||
|
}),
|
||||||
|
tarifDanLayanan: z.object({
|
||||||
|
layanan: z.string().min(1, "Layanan harus diisi"),
|
||||||
|
tarif: z.string().min(1, "Tarif harus diisi"),
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
type InfromasiUmum = Prisma.InformasiUmumGetPayload<{
|
// Default form kosong
|
||||||
select: {
|
const defaultForm = {
|
||||||
fasilitas: true;
|
name: "",
|
||||||
alamat: true;
|
informasiUmum: {
|
||||||
jamOperasional: true;
|
fasilitas: "",
|
||||||
};
|
alamat: "",
|
||||||
}>;
|
jamOperasional: "",
|
||||||
|
},
|
||||||
|
layananUnggulan: {
|
||||||
|
content: "",
|
||||||
|
},
|
||||||
|
dokterdanTenagaMedis: {
|
||||||
|
name: "",
|
||||||
|
specialist: "",
|
||||||
|
jadwal: "",
|
||||||
|
},
|
||||||
|
fasilitasPendukung: {
|
||||||
|
content: "",
|
||||||
|
},
|
||||||
|
prosedurPendaftaran: {
|
||||||
|
content: "",
|
||||||
|
},
|
||||||
|
tarifDanLayanan: {
|
||||||
|
layanan: "",
|
||||||
|
tarif: "",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
const informasiumum = proxy({
|
const fasilitasKesehatanState = proxy({
|
||||||
create: {
|
create: {
|
||||||
form: {} as InfromasiUmum,
|
form: { ...defaultForm },
|
||||||
loading: false,
|
loading: false,
|
||||||
async create() {
|
async submit() {
|
||||||
const cek = templateInformasiUmum.safeParse(informasiumum.create.form);
|
const cek = templateForm.safeParse(this.form);
|
||||||
if (!cek.success) {
|
if (!cek.success) {
|
||||||
const err = `[${cek.error.issues
|
const errMsg = cek.error.issues
|
||||||
.map((v) => `${v.path.join(".")}`)
|
.map((v) => `${v.path.join(".")}: ${v.message}`)
|
||||||
.join("\n")}] required`;
|
.join("\n");
|
||||||
return toast.error(err);
|
toast.error(errMsg);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
informasiumum.create.loading = true;
|
this.loading = true;
|
||||||
const res = await ApiFetch.api.kesehatan.informasiumum["create"].post(
|
const payload = { ...this.form };
|
||||||
informasiumum.create.form
|
|
||||||
|
const res = await (ApiFetch.api.kesehatan as any)[
|
||||||
|
"fasilitas-kesehatan"
|
||||||
|
].create.post(payload);
|
||||||
|
|
||||||
|
if (res.status === 200) {
|
||||||
|
toast.success("Berhasil menambahkan fasilitas kesehatan");
|
||||||
|
this.resetForm();
|
||||||
|
await fasilitasKesehatanState.findMany.load();
|
||||||
|
return res.data;
|
||||||
|
}
|
||||||
|
} catch (err: any) {
|
||||||
|
const msg = err?.message || "Terjadi kesalahan saat mengirim data";
|
||||||
|
toast.error(msg);
|
||||||
|
console.error("SUBMIT ERROR:", err);
|
||||||
|
return null;
|
||||||
|
} finally {
|
||||||
|
this.loading = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
resetForm() {
|
||||||
|
this.form = { ...defaultForm };
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
findMany: {
|
||||||
|
data: null as
|
||||||
|
| Prisma.FasilitasKesehatanGetPayload<{
|
||||||
|
include: {
|
||||||
|
informasiumum: true;
|
||||||
|
layananunggulan: true;
|
||||||
|
dokterdantenagamedis: true;
|
||||||
|
fasilitaspendukung: true;
|
||||||
|
prosedurpendaftaran: true;
|
||||||
|
tarifdanlayanan: true;
|
||||||
|
};
|
||||||
|
}>[]
|
||||||
|
| null,
|
||||||
|
loading: false,
|
||||||
|
async load() {
|
||||||
|
try {
|
||||||
|
this.loading = true;
|
||||||
|
const res = await (ApiFetch.api.kesehatan as any)[
|
||||||
|
"fasilitas-kesehatan"
|
||||||
|
]["find-many"].get();
|
||||||
|
|
||||||
|
if (res.status === 200) {
|
||||||
|
this.data = res.data?.data ?? [];
|
||||||
|
} else {
|
||||||
|
toast.error("Gagal memuat data fasilitas kesehatan");
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
} catch (err) {
|
||||||
|
toast.error("Terjadi error saat load data");
|
||||||
|
console.error("LOAD ERROR:", err);
|
||||||
|
throw err;
|
||||||
|
} finally {
|
||||||
|
this.loading = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
findUnique: {
|
||||||
|
data: null as Prisma.FasilitasKesehatanGetPayload<{
|
||||||
|
include: {
|
||||||
|
informasiumum: true;
|
||||||
|
layananunggulan: true;
|
||||||
|
dokterdantenagamedis: true;
|
||||||
|
fasilitaspendukung: true;
|
||||||
|
prosedurpendaftaran: true;
|
||||||
|
tarifdanlayanan: true;
|
||||||
|
};
|
||||||
|
}> | null,
|
||||||
|
loading: false,
|
||||||
|
async load(id: string) {
|
||||||
|
const res = await fetch(`/api/kesehatan/fasilitas-kesehatan/${id}`);
|
||||||
|
if (res.ok) {
|
||||||
|
const data = await res.json();
|
||||||
|
fasilitasKesehatanState.findUnique.data = data.data ?? null;
|
||||||
|
} else {
|
||||||
|
toast.error("Gagal load data fasilitas kesehatan");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
edit: {
|
||||||
|
id: "",
|
||||||
|
form: { ...defaultForm },
|
||||||
|
loading: false,
|
||||||
|
async load(id: string) {
|
||||||
|
const res = await fetch(`/api/kesehatan/fasilitas-kesehatan/${id}`);
|
||||||
|
if (!res.ok) {
|
||||||
|
toast.error("Gagal load data fasilitas kesehatan");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = await res.json();
|
||||||
|
const data = result.data;
|
||||||
|
|
||||||
|
fasilitasKesehatanState.edit.id = data.id;
|
||||||
|
fasilitasKesehatanState.edit.form = {
|
||||||
|
name: data.name,
|
||||||
|
informasiUmum: {
|
||||||
|
fasilitas: data.informasiumum.fasilitas,
|
||||||
|
alamat: data.informasiumum.alamat,
|
||||||
|
jamOperasional: data.informasiumum.jamOperasional,
|
||||||
|
},
|
||||||
|
layananUnggulan: {
|
||||||
|
content: data.layananunggulan.content,
|
||||||
|
},
|
||||||
|
dokterdanTenagaMedis: {
|
||||||
|
name: data.dokterdantenagamedis.name,
|
||||||
|
specialist: data.dokterdantenagamedis.specialist,
|
||||||
|
jadwal: data.dokterdantenagamedis.jadwal,
|
||||||
|
},
|
||||||
|
fasilitasPendukung: {
|
||||||
|
content: data.fasilitaspendukung.content,
|
||||||
|
},
|
||||||
|
prosedurPendaftaran: {
|
||||||
|
content: data.prosedurpendaftaran.content,
|
||||||
|
},
|
||||||
|
tarifDanLayanan: {
|
||||||
|
layanan: data.tarifdanlayanan.layanan,
|
||||||
|
tarif: data.tarifdanlayanan.tarif,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
async submit() {
|
||||||
|
const cek = templateForm.safeParse(fasilitasKesehatanState.edit.form);
|
||||||
|
if (!cek.success) {
|
||||||
|
const errMsg = cek.error.issues
|
||||||
|
.map((v) => `${v.path.join(".")}: ${v.message}`)
|
||||||
|
.join("\n");
|
||||||
|
toast.error(errMsg);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
fasilitasKesehatanState.edit.loading = true;
|
||||||
|
const payload = {
|
||||||
|
name: fasilitasKesehatanState.edit.form.name,
|
||||||
|
informasiUmum: {
|
||||||
|
fasilitas:
|
||||||
|
fasilitasKesehatanState.edit.form.informasiUmum.fasilitas,
|
||||||
|
alamat: fasilitasKesehatanState.edit.form.informasiUmum.alamat,
|
||||||
|
jamOperasional:
|
||||||
|
fasilitasKesehatanState.edit.form.informasiUmum.jamOperasional,
|
||||||
|
},
|
||||||
|
layananUnggulan: {
|
||||||
|
content: fasilitasKesehatanState.edit.form.layananUnggulan.content,
|
||||||
|
},
|
||||||
|
dokterdanTenagaMedis: {
|
||||||
|
name: fasilitasKesehatanState.edit.form.dokterdanTenagaMedis.name,
|
||||||
|
specialist:
|
||||||
|
fasilitasKesehatanState.edit.form.dokterdanTenagaMedis.specialist,
|
||||||
|
jadwal:
|
||||||
|
fasilitasKesehatanState.edit.form.dokterdanTenagaMedis.jadwal,
|
||||||
|
},
|
||||||
|
fasilitasPendukung: {
|
||||||
|
content:
|
||||||
|
fasilitasKesehatanState.edit.form.fasilitasPendukung.content,
|
||||||
|
},
|
||||||
|
prosedurPendaftaran: {
|
||||||
|
content:
|
||||||
|
fasilitasKesehatanState.edit.form.prosedurPendaftaran.content,
|
||||||
|
},
|
||||||
|
tarifDanLayanan: {
|
||||||
|
layanan: fasilitasKesehatanState.edit.form.tarifDanLayanan.layanan,
|
||||||
|
tarif: fasilitasKesehatanState.edit.form.tarifDanLayanan.tarif,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const res = await fetch(
|
||||||
|
`/api/kesehatan/fasilitas-kesehatan/${fasilitasKesehatanState.edit.id}`,
|
||||||
|
{
|
||||||
|
method: "PUT",
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
body: JSON.stringify(payload),
|
||||||
|
}
|
||||||
);
|
);
|
||||||
if (res.status === 200) {
|
|
||||||
informasiumum.findMany.load();
|
if (!res.ok) {
|
||||||
return toast.success("success create");
|
const error = await res.json();
|
||||||
|
throw new Error(error.message || "Update gagal");
|
||||||
}
|
}
|
||||||
return toast.error("failed create");
|
|
||||||
} catch (error) {
|
|
||||||
console.log((error as Error).message);
|
|
||||||
} finally {
|
|
||||||
informasiumum.create.loading = false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
findMany: {
|
|
||||||
data: null as
|
|
||||||
| Prisma.InformasiUmumGetPayload<{ omit: { isActive: true } }>[]
|
|
||||||
| null,
|
|
||||||
async load() {
|
|
||||||
const res = await ApiFetch.api.kesehatan.
|
|
||||||
informasiumum["find-many"].get();
|
|
||||||
if (res.status === 200) {
|
|
||||||
informasiumum.findMany.data = res.data?.data ?? [];
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
/* ======================================================================= */
|
|
||||||
|
|
||||||
/* Layanan Unggulan */
|
toast.success("Berhasil update fasilitas kesehatan");
|
||||||
const templateLayananUnggulanForm = z.object({
|
await fasilitasKesehatanState.findMany.load();
|
||||||
content: z.string().min(3, "Content minimal 3 karakter"),
|
return true;
|
||||||
});
|
} catch (err) {
|
||||||
|
toast.error(
|
||||||
type LayananUnggulan = Prisma.LayananUnggulanGetPayload<{
|
err instanceof Error ? err.message : "Terjadi kesalahan saat update"
|
||||||
select: {
|
|
||||||
content: true;
|
|
||||||
};
|
|
||||||
}>;
|
|
||||||
|
|
||||||
const layananunggulan = proxy({
|
|
||||||
create: {
|
|
||||||
form: {} as LayananUnggulan,
|
|
||||||
loading: false,
|
|
||||||
async create() {
|
|
||||||
const cek = templateLayananUnggulanForm.safeParse(layananunggulan.create.form);
|
|
||||||
if (!cek.success) {
|
|
||||||
const err = `[${cek.error.issues
|
|
||||||
.map((v) => `${v.path.join(".")}`)
|
|
||||||
.join("\n")}] required`;
|
|
||||||
return toast.error(err);
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
layananunggulan.create.loading = true;
|
|
||||||
const res = await ApiFetch.api.kesehatan.layananunggulan["create"].post(
|
|
||||||
layananunggulan.create.form
|
|
||||||
);
|
);
|
||||||
if (res.status === 200) {
|
return false;
|
||||||
layananunggulan.findMany.load();
|
|
||||||
return toast.success("success create");
|
|
||||||
}
|
|
||||||
return toast.error("failed create");
|
|
||||||
} catch (error) {
|
|
||||||
console.log((error as Error).message);
|
|
||||||
} finally {
|
} finally {
|
||||||
layananunggulan.create.loading = false;
|
fasilitasKesehatanState.edit.loading = false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
resetForm() {
|
||||||
findMany: {
|
fasilitasKesehatanState.edit.id = "";
|
||||||
data: null as
|
fasilitasKesehatanState.edit.form = { ...defaultForm };
|
||||||
| Prisma.LayananUnggulanGetPayload<{ omit: { isActive: true } }>[]
|
|
||||||
| null,
|
|
||||||
async load() {
|
|
||||||
const res = await ApiFetch.api.kesehatan.
|
|
||||||
layananunggulan["find-many"].get();
|
|
||||||
if (res.status === 200) {
|
|
||||||
layananunggulan.findMany.data = res.data?.data ?? [];
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
delete: {
|
||||||
/* ======================================================================= */
|
|
||||||
|
|
||||||
/* Dokter dan Tenaga Medis */
|
|
||||||
const templateDokterdanTenagaMedis = z.object({
|
|
||||||
name: z.string().min(3, "Name minimal 3 karakter"),
|
|
||||||
specialist: z.string().min(3, "Specialist minimal 3 karakter"),
|
|
||||||
jadwal: z.string().min(3, "Jadwal minimal 3 karakter"),
|
|
||||||
})
|
|
||||||
|
|
||||||
type DokterdanTenagaMedis = Prisma.DokterdanTenagaMedisGetPayload<{
|
|
||||||
select: {
|
|
||||||
name: true;
|
|
||||||
specialist: true;
|
|
||||||
jadwal: true;
|
|
||||||
};
|
|
||||||
}>;
|
|
||||||
|
|
||||||
const dokterdantenagamedis = proxy({
|
|
||||||
create: {
|
|
||||||
form: {} as DokterdanTenagaMedis,
|
|
||||||
loading: false,
|
loading: false,
|
||||||
async create() {
|
async byId(id: string){
|
||||||
const cek = templateDokterdanTenagaMedis.safeParse(dokterdantenagamedis.create.form);
|
|
||||||
if (!cek.success) {
|
|
||||||
const err = `[${cek.error.issues
|
|
||||||
.map((v) => `${v.path.join(".")}`)
|
|
||||||
.join("\n")}] required`;
|
|
||||||
return toast.error(err);
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
dokterdantenagamedis.create.loading = true;
|
fasilitasKesehatanState.delete.loading = true;
|
||||||
const res = await ApiFetch.api.kesehatan.dokterdantenagamedis["create"].post(dokterdantenagamedis.create.form);
|
const res = await fetch(`/api/kesehatan/fasilitas-kesehatan/del/${id}`, {
|
||||||
if (res.status === 200) {
|
method: "DELETE",
|
||||||
dokterdantenagamedis.findMany.load();
|
});
|
||||||
return toast.success("success create");
|
|
||||||
|
const result = await res.json();
|
||||||
|
if (res.ok && result.success) {
|
||||||
|
toast.success("Fasilitas kesehatan berhasil dihapus");
|
||||||
|
await fasilitasKesehatanState.findMany.load();
|
||||||
|
} else {
|
||||||
|
toast.error(result.message || "Gagal menghapus");
|
||||||
}
|
}
|
||||||
return toast.error("failed create");
|
} catch {
|
||||||
} catch (error) {
|
toast.error("Terjadi kesalahan saat menghapus");
|
||||||
console.log((error as Error).message);
|
|
||||||
} finally {
|
} finally {
|
||||||
dokterdantenagamedis.create.loading = false;
|
fasilitasKesehatanState.delete.loading = false;
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
findMany: {
|
});
|
||||||
data: null as
|
|
||||||
| Prisma.DokterdanTenagaMedisGetPayload<{ omit: { isActive: true } }>[]
|
|
||||||
| null,
|
|
||||||
async load() {
|
|
||||||
const res = await ApiFetch.api.kesehatan.dokterdantenagamedis["find-many"].get();
|
|
||||||
if (res.status === 200) {
|
|
||||||
dokterdantenagamedis.findMany.data = res.data?.data ?? [];
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
/* ======================================================================= */
|
|
||||||
|
|
||||||
/* Fasilitas Pendukung */
|
export default fasilitasKesehatanState;
|
||||||
const templateFasilitasPendukung = z.object({
|
|
||||||
content: z.string().min(3, "Content minimal 3 karakter"),
|
|
||||||
})
|
|
||||||
|
|
||||||
type FasilitasPendukung = Prisma.FasilitasPendukungGetPayload<{
|
|
||||||
select: {
|
|
||||||
content: true;
|
|
||||||
};
|
|
||||||
}>;
|
|
||||||
|
|
||||||
const fasilitaspendukung = proxy({
|
|
||||||
create: {
|
|
||||||
form: {} as FasilitasPendukung,
|
|
||||||
loading: false,
|
|
||||||
async create() {
|
|
||||||
const cek = templateFasilitasPendukung.safeParse(fasilitaspendukung.create.form);
|
|
||||||
if (!cek.success) {
|
|
||||||
const err = `[${cek.error.issues
|
|
||||||
.map((v) => `${v.path.join(".")}`)
|
|
||||||
.join("\n")}] required`;
|
|
||||||
return toast.error(err);
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
fasilitaspendukung.create.loading = true;
|
|
||||||
const res = await ApiFetch.api.kesehatan.fasilitaspendukung["create"].post(fasilitaspendukung.create.form);
|
|
||||||
if (res.status === 200) {
|
|
||||||
fasilitaspendukung.findMany.load();
|
|
||||||
return toast.success("success create");
|
|
||||||
}
|
|
||||||
return toast.error("failed create");
|
|
||||||
} catch (error) {
|
|
||||||
console.log((error as Error).message);
|
|
||||||
} finally {
|
|
||||||
fasilitaspendukung.create.loading = false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
findMany: {
|
|
||||||
data: null as
|
|
||||||
| Prisma.FasilitasPendukungGetPayload<{ omit: { isActive: true } }>[]
|
|
||||||
| null,
|
|
||||||
async load() {
|
|
||||||
const res = await ApiFetch.api.kesehatan.
|
|
||||||
fasilitaspendukung["find-many"].get();
|
|
||||||
if (res.status === 200) {
|
|
||||||
fasilitaspendukung.findMany.data = res.data?.data ?? [];
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
/* ======================================================================= */
|
|
||||||
|
|
||||||
/* Tarif dan Layanan */
|
|
||||||
const templateTarifDanLayanan = z.object({
|
|
||||||
layanan: z.string().min(3, "Layanan minimal 3 karakter"),
|
|
||||||
tarif: z.string().min(3, "Tarif minimal 3 karakter"),
|
|
||||||
})
|
|
||||||
|
|
||||||
const tarifdanlayanan = proxy({
|
|
||||||
create: {
|
|
||||||
form: {} as Prisma.TarifDanLayananGetPayload<{ select: { layanan: true; tarif: true } }>,
|
|
||||||
loading: false,
|
|
||||||
async create() {
|
|
||||||
const cek = templateTarifDanLayanan.safeParse(tarifdanlayanan.create.form);
|
|
||||||
if (!cek.success) {
|
|
||||||
const err = `[${cek.error.issues
|
|
||||||
.map((v) => `${v.path.join(".")}`)
|
|
||||||
.join("\n")}] required`;
|
|
||||||
return toast.error(err);
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
tarifdanlayanan.create.loading = true;
|
|
||||||
const res = await ApiFetch.api.kesehatan.tarifdanlayanan["create"].post(tarifdanlayanan.create.form);
|
|
||||||
if (res.status === 200) {
|
|
||||||
tarifdanlayanan.findMany.load();
|
|
||||||
return toast.success("success create");
|
|
||||||
}
|
|
||||||
return toast.error("failed create");
|
|
||||||
} catch (error) {
|
|
||||||
console.log((error as Error).message);
|
|
||||||
} finally {
|
|
||||||
tarifdanlayanan.create.loading = false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
findMany: {
|
|
||||||
data: null as
|
|
||||||
| Prisma.TarifDanLayananGetPayload<{ omit: { isActive: true } }>[]
|
|
||||||
| null,
|
|
||||||
async load() {
|
|
||||||
const res = await ApiFetch.api.kesehatan.
|
|
||||||
tarifdanlayanan["find-many"].get();
|
|
||||||
if (res.status === 200) {
|
|
||||||
tarifdanlayanan.findMany.data = res.data?.data ?? [];
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
/* ======================================================================= */
|
|
||||||
|
|
||||||
/* Prosedur Pendaftaran */
|
|
||||||
const templateProsedurPendaftaran = z.object({
|
|
||||||
content: z.string().min(3, "Content minimal 3 karakter"),
|
|
||||||
})
|
|
||||||
|
|
||||||
const prosedurpendaftaran = proxy({
|
|
||||||
create: {
|
|
||||||
form: {} as Prisma.ProsedurPendaftaranGetPayload<{ select: { content: true } }>,
|
|
||||||
loading: false,
|
|
||||||
async create() {
|
|
||||||
const cek = templateProsedurPendaftaran.safeParse(prosedurpendaftaran.create.form);
|
|
||||||
if (!cek.success) {
|
|
||||||
const err = `[${cek.error.issues
|
|
||||||
.map((v) => `${v.path.join(".")}`)
|
|
||||||
.join("\n")}] required`;
|
|
||||||
return toast.error(err);
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
prosedurpendaftaran.create.loading = true;
|
|
||||||
const res = await ApiFetch.api.kesehatan.prosedurpendaftaran["create"].post(prosedurpendaftaran.create.form);
|
|
||||||
if (res.status === 200) {
|
|
||||||
prosedurpendaftaran.findMany.load();
|
|
||||||
return toast.success("success create");
|
|
||||||
}
|
|
||||||
return toast.error("failed create");
|
|
||||||
} catch (error) {
|
|
||||||
console.log((error as Error).message);
|
|
||||||
} finally {
|
|
||||||
prosedurpendaftaran.create.loading = false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
findMany: {
|
|
||||||
data: null as
|
|
||||||
| Prisma.ProsedurPendaftaranGetPayload<{ omit: { isActive: true } }>[]
|
|
||||||
| null,
|
|
||||||
async load() {
|
|
||||||
const res = await ApiFetch.api.kesehatan.
|
|
||||||
prosedurpendaftaran["find-many"].get();
|
|
||||||
if (res.status === 200) {
|
|
||||||
prosedurpendaftaran.findMany.data = res.data?.data ?? [];
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
const stateFasilitasKesehatan = proxy({
|
|
||||||
informasiumum,
|
|
||||||
layananunggulan,
|
|
||||||
dokterdantenagamedis,
|
|
||||||
fasilitaspendukung,
|
|
||||||
tarifdanlayanan,
|
|
||||||
prosedurpendaftaran
|
|
||||||
})
|
|
||||||
|
|
||||||
export default stateFasilitasKesehatan
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { z } from "zod";
|
|||||||
|
|
||||||
const templateGrafikKepuasan = z.object({
|
const templateGrafikKepuasan = z.object({
|
||||||
label: z.string().min(2, "Label harus diisi"),
|
label: z.string().min(2, "Label harus diisi"),
|
||||||
jumlah: z.string().min(2, "Jumlah harus diisi"),
|
jumlah: z.string().min(1, "Jumlah harus diisi"),
|
||||||
});
|
});
|
||||||
|
|
||||||
type GrafikKepuasan = Prisma.GrafikKepuasanGetPayload<{
|
type GrafikKepuasan = Prisma.GrafikKepuasanGetPayload<{
|
||||||
@@ -31,24 +31,30 @@ const grafikkepuasan = proxy({
|
|||||||
const err = `[${cek.error.issues
|
const err = `[${cek.error.issues
|
||||||
.map((v) => `${v.path.join(".")}`)
|
.map((v) => `${v.path.join(".")}`)
|
||||||
.join("\n")}] required`;
|
.join("\n")}] required`;
|
||||||
return toast.error(err);
|
toast.error(err);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
grafikkepuasan.create.loading = true;
|
grafikkepuasan.create.loading = true;
|
||||||
const res = await ApiFetch.api.kesehatan.grafikkepuasan["create"].post(
|
const res = await ApiFetch.api.kesehatan.grafikkepuasan["create"].post(grafikkepuasan.create.form);
|
||||||
grafikkepuasan.create.form
|
|
||||||
);
|
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
grafikkepuasan.create.form = {
|
const uuid = res.data?.data?.uuid;
|
||||||
label: "",
|
if (uuid) {
|
||||||
jumlah: ""
|
toast.success("Success create");
|
||||||
};
|
grafikkepuasan.create.form = {
|
||||||
grafikkepuasan.findMany.load();
|
label: "",
|
||||||
return toast.success("success create");
|
jumlah: "",
|
||||||
|
};
|
||||||
|
grafikkepuasan.findMany.load();
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return toast.error("failed create");
|
toast.error("failed create");
|
||||||
|
return null;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log((error as Error).message);
|
console.log((error as Error).message);
|
||||||
|
return null;
|
||||||
} finally {
|
} finally {
|
||||||
grafikkepuasan.create.loading = false;
|
grafikkepuasan.create.loading = false;
|
||||||
}
|
}
|
||||||
@@ -67,10 +73,110 @@ const grafikkepuasan = proxy({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
findUnique: {
|
||||||
|
data: null as Prisma.GrafikKepuasanGetPayload<{
|
||||||
|
omit: { isActive: true }
|
||||||
|
}> | null,
|
||||||
|
async load(uuid: string) {
|
||||||
|
try {
|
||||||
|
const res = await fetch(`/api/kesehatan/grafikkepuasan/${uuid}`);
|
||||||
|
if (res.ok) {
|
||||||
|
const data = await res.json();
|
||||||
|
grafikkepuasan.findUnique.data = data.data ?? null;
|
||||||
|
} else {
|
||||||
|
console.error("Failed to fetch grafikkepuasan:", res.statusText);
|
||||||
|
grafikkepuasan.findUnique.data = null;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error fetching grafikkepuasan:", error);
|
||||||
|
grafikkepuasan.findUnique.data = null;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
update: {
|
||||||
|
uuid: "",
|
||||||
|
form: {...defaultForm},
|
||||||
|
loading: false,
|
||||||
|
async byId() {
|
||||||
|
},
|
||||||
|
async submit() {
|
||||||
|
const uuid = this.uuid;
|
||||||
|
if (!uuid) {
|
||||||
|
toast.warn("ID tidak valid");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const cek = templateGrafikKepuasan.safeParse(grafikkepuasan.update.form);
|
||||||
|
if (!cek.success) {
|
||||||
|
const err = `[${cek.error.issues
|
||||||
|
.map((v) => `${v.path.join(".")}`)
|
||||||
|
.join("\n")}] required`;
|
||||||
|
return toast.error(err);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
this.loading = true;
|
||||||
|
const response = await fetch(`/api/kesehatan/grafikkepuasan/${uuid}`, {
|
||||||
|
method: "PUT",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify(this.form),
|
||||||
|
});
|
||||||
|
const result = await response.json();
|
||||||
|
|
||||||
|
if (!response.ok || !result?.success) {
|
||||||
|
throw new Error(result?.message || "Gagal update data");
|
||||||
|
}
|
||||||
|
|
||||||
|
toast.success("Berhasil update data!");
|
||||||
|
|
||||||
|
// ✅ Optional: refresh list kalau kamu langsung ke halaman list
|
||||||
|
await grafikkepuasan.findMany.load();
|
||||||
|
|
||||||
|
return result.data;
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error update data:", error);
|
||||||
|
toast.error("Gagal update data grafik kepuasan");
|
||||||
|
} finally {
|
||||||
|
this.loading = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
delete: {
|
||||||
|
loading: false,
|
||||||
|
async byId(uuid: string) {
|
||||||
|
if (!uuid) {
|
||||||
|
return toast.warn("ID tidak valid");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
grafikkepuasan.delete.loading = true;
|
||||||
|
|
||||||
|
const response = await fetch(`/api/kesehatan/grafikkepuasan/del/${uuid}`, {
|
||||||
|
method: "DELETE",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await response.json();
|
||||||
|
|
||||||
|
if (response.ok && result?.success) {
|
||||||
|
toast.success(
|
||||||
|
result.message || "Grafik kepuasan berhasil dihapus"
|
||||||
|
);
|
||||||
|
await grafikkepuasan.findMany.load(); // refresh list
|
||||||
|
} else {
|
||||||
|
toast.error(
|
||||||
|
result?.message || "Gagal menghapus grafik kepuasan"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Gagal delete:", error);
|
||||||
|
toast.error("Terjadi kesalahan saat menghapus grafik kepuasan");
|
||||||
|
} finally {
|
||||||
|
grafikkepuasan.delete.loading = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const stategrafikKepuasan = proxy({
|
export default grafikkepuasan;
|
||||||
grafikkepuasan,
|
|
||||||
});
|
|
||||||
|
|
||||||
export default stategrafikKepuasan;
|
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ import { z } from "zod";
|
|||||||
|
|
||||||
const templatePersentase = z.object({
|
const templatePersentase = z.object({
|
||||||
tahun: z.string().min(4, "Tahun harus diisi"),
|
tahun: z.string().min(4, "Tahun harus diisi"),
|
||||||
kematianKasar: z.string().min(2, "Kematian kasar harus diisi"),
|
kematianKasar: z.string().min(1, "Kematian kasar harus diisi"),
|
||||||
kelahiranKasar: z.string().min(2, "Kelahiran kasar harus diisi"),
|
kelahiranKasar: z.string().min(1, "Kelahiran kasar harus diisi"),
|
||||||
kematianBayi: z.string().min(2, "Kematian bayi harus diisi"),
|
kematianBayi: z.string().min(1, "Kematian bayi harus diisi"),
|
||||||
});
|
});
|
||||||
|
|
||||||
type Persentase = Prisma.DataKematian_KelahiranGetPayload<{
|
type Persentase = Prisma.DataKematian_KelahiranGetPayload<{
|
||||||
@@ -34,51 +34,157 @@ const persentasekelahiran = proxy({
|
|||||||
async create() {
|
async create() {
|
||||||
const cek = templatePersentase.safeParse(persentasekelahiran.create.form);
|
const cek = templatePersentase.safeParse(persentasekelahiran.create.form);
|
||||||
if (!cek.success) {
|
if (!cek.success) {
|
||||||
const err = `[${cek.error.issues
|
const err = `[${cek.error.issues.map((v) => `${v.path.join(".")}`).join("\n")}] required`;
|
||||||
.map((v) => `${v.path.join(".")}`)
|
toast.error(err);
|
||||||
.join("\n")}] required`;
|
return null;
|
||||||
return toast.error(err);
|
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
persentasekelahiran.create.loading = true;
|
persentasekelahiran.create.loading = true;
|
||||||
const res = await ApiFetch.api.kesehatan.persentasekelahiran[
|
const res = await ApiFetch.api.kesehatan.persentasekelahiran["create"].post(
|
||||||
"create"
|
persentasekelahiran.create.form
|
||||||
].post(persentasekelahiran.create.form);
|
);
|
||||||
|
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
persentasekelahiran.create.form = {
|
const uuid = res.data?.data?.uuid;
|
||||||
tahun: "",
|
if (uuid) {
|
||||||
kematianKasar: "",
|
toast.success("Success create");
|
||||||
kelahiranKasar: "",
|
persentasekelahiran.create.form = { ...defaultForm };
|
||||||
kematianBayi: "",
|
persentasekelahiran.findMany.load();
|
||||||
};
|
return uuid;
|
||||||
persentasekelahiran.findMany.load();
|
}
|
||||||
return toast.success("success create");
|
|
||||||
}
|
}
|
||||||
return toast.error("failed create");
|
toast.error("failed create");
|
||||||
|
return null;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log((error as Error).message);
|
console.log((error as Error).message);
|
||||||
|
return null;
|
||||||
} finally {
|
} finally {
|
||||||
persentasekelahiran.create.loading = false;
|
persentasekelahiran.create.loading = false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
findMany: {
|
findMany: {
|
||||||
data: null as
|
data: null as Prisma.DataKematian_KelahiranGetPayload<{
|
||||||
| Prisma.DataKematian_KelahiranGetPayload<{ omit: { isActive: true } }>[]
|
omit: { isActive: true };
|
||||||
| null,
|
}>[] | null,
|
||||||
async load() {
|
async load() {
|
||||||
const res = await ApiFetch.api.kesehatan.persentasekelahiran[
|
const res = await ApiFetch.api.kesehatan.persentasekelahiran["find-many"].get();
|
||||||
"find-many"
|
|
||||||
].get();
|
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
persentasekelahiran.findMany.data = res.data?.data ?? [];
|
persentasekelahiran.findMany.data = res.data?.data ?? [];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
findUnique: {
|
||||||
|
data: null as Prisma.DataKematian_KelahiranGetPayload<{
|
||||||
|
omit: { isActive: true };
|
||||||
|
}> | null,
|
||||||
|
async load(uuid: string) {
|
||||||
|
try {
|
||||||
|
const res = await fetch(`/api/kesehatan/persentasekelahiran/${uuid}`);
|
||||||
|
if (res.ok) {
|
||||||
|
const data = await res.json();
|
||||||
|
persentasekelahiran.findUnique.data = data.data ?? null;
|
||||||
|
} else {
|
||||||
|
console.error("Failed to fetch persentasekelahiran:", res.statusText);
|
||||||
|
persentasekelahiran.findUnique.data = null;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error fetching persentasekelahiran:", error);
|
||||||
|
persentasekelahiran.findUnique.data = null;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
update: {
|
||||||
|
uuid: "",
|
||||||
|
form: { ...defaultForm },
|
||||||
|
loading: false,
|
||||||
|
async submit() {
|
||||||
|
const uuid = this.uuid;
|
||||||
|
if (!uuid) {
|
||||||
|
toast.warn("UUID tidak valid");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const formData = {
|
||||||
|
tahun: this.form.tahun,
|
||||||
|
kematianKasar: this.form.kematianKasar,
|
||||||
|
kelahiranKasar: this.form.kelahiranKasar,
|
||||||
|
kematianBayi: this.form.kematianBayi,
|
||||||
|
};
|
||||||
|
|
||||||
|
const cek = templatePersentase.safeParse(formData);
|
||||||
|
if (!cek.success) {
|
||||||
|
const err = `[${cek.error.issues
|
||||||
|
.map((v) => `${v.path.join(".")}`)
|
||||||
|
.join("\n")}] required`;
|
||||||
|
toast.error(err);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
this.loading = true;
|
||||||
|
const res = await fetch(`/api/kesehatan/persentasekelahiran/${uuid}`, {
|
||||||
|
method: "PUT",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify(formData),
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await res.json();
|
||||||
|
|
||||||
|
if (!res.ok || !result?.success) {
|
||||||
|
throw new Error(result?.message || "Gagal update data");
|
||||||
|
}
|
||||||
|
|
||||||
|
toast.success("Berhasil update data!");
|
||||||
|
await persentasekelahiran.findMany.load();
|
||||||
|
return result.data;
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Update error:", error);
|
||||||
|
toast.error("Gagal update data persentase kelahiran");
|
||||||
|
throw error;
|
||||||
|
} finally {
|
||||||
|
this.loading = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
delete: {
|
||||||
|
loading: false,
|
||||||
|
async byId(uuid: string) {
|
||||||
|
if (!uuid) return toast.warn("UUID tidak valid");
|
||||||
|
|
||||||
|
try {
|
||||||
|
persentasekelahiran.delete.loading = true;
|
||||||
|
|
||||||
|
const response = await fetch(`/api/kesehatan/persentasekelahiran/del/${uuid}`, {
|
||||||
|
method: "DELETE",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await response.json();
|
||||||
|
|
||||||
|
if (response.ok && result?.success) {
|
||||||
|
toast.success(result.message || "Persentase kelahiran berhasil dihapus");
|
||||||
|
await persentasekelahiran.findMany.load();
|
||||||
|
} else {
|
||||||
|
toast.error(result?.message || "Gagal menghapus persentase kelahiran");
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Gagal delete:", error);
|
||||||
|
toast.error("Terjadi kesalahan saat menghapus persentase kelahiran");
|
||||||
|
} finally {
|
||||||
|
persentasekelahiran.delete.loading = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const statePersentase = proxy({
|
export default persentasekelahiran;
|
||||||
persentasekelahiran,
|
|
||||||
});
|
|
||||||
|
|
||||||
export default statePersentase;
|
|
||||||
|
|||||||
@@ -0,0 +1,77 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
|
'use client'
|
||||||
|
import colors from '@/con/colors';
|
||||||
|
import { Stack, Tabs, TabsList, TabsPanel, TabsTab, Title } from '@mantine/core';
|
||||||
|
import { usePathname, useRouter } from 'next/navigation';
|
||||||
|
import React, { useEffect, useState } from 'react';
|
||||||
|
|
||||||
|
function LayoutTabs({ children }: { children: React.ReactNode }) {
|
||||||
|
const router = useRouter()
|
||||||
|
const pathname = usePathname()
|
||||||
|
const tabs = [
|
||||||
|
{
|
||||||
|
label: "Presentase Kelahiran & Kematian",
|
||||||
|
value: "presentasekelahiran&kematian",
|
||||||
|
href: "/admin/kesehatan/data-kesehatan-warga/persentase_data_kelahiran_kematian"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Grafik Hasil Kepuasan Masyarakat Terhadap Pelayanan Publik",
|
||||||
|
value: "grafikhasilkepuasan",
|
||||||
|
href: "/admin/kesehatan/data-kesehatan-warga/grafik_hasil_kepuasan"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Fasilitas Kesehatan",
|
||||||
|
value: "fasilitaskesehatan",
|
||||||
|
href: "/admin/kesehatan/data-kesehatan-warga/fasilitas_kesehatan"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Jadwal Kegiatan",
|
||||||
|
value: "jadwalkegiatan",
|
||||||
|
href: "/admin/kesehatan/data-kesehatan-warga/jadwal_kegiatan"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Artikel Kesehatan",
|
||||||
|
value: "artikelkesehatan",
|
||||||
|
href: "/admin/kesehatan/data-kesehatan-warga/artikel_kesehatan"
|
||||||
|
},
|
||||||
|
];
|
||||||
|
const curentTab = tabs.find(tab => tab.href === pathname)
|
||||||
|
const [activeTab, setActiveTab] = useState<string | null>(curentTab?.value || tabs[0].value);
|
||||||
|
|
||||||
|
const handleTabChange = (value: string | null) => {
|
||||||
|
const tab = tabs.find(t => t.value === value)
|
||||||
|
if (tab) {
|
||||||
|
router.push(tab.href)
|
||||||
|
}
|
||||||
|
setActiveTab(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const match = tabs.find(tab => tab.href === pathname)
|
||||||
|
if (match) {
|
||||||
|
setActiveTab(match.value)
|
||||||
|
}
|
||||||
|
}, [pathname])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Stack>
|
||||||
|
<Title order={3}>Data Kesehatan Warga</Title>
|
||||||
|
<Tabs color={colors['blue-button']} variant='pills' value={activeTab} onChange={handleTabChange}>
|
||||||
|
<TabsList p={"xs"} bg={"#BBC8E7FF"}>
|
||||||
|
{tabs.map((e, i) => (
|
||||||
|
<TabsTab key={i} value={e.value}>{e.label}</TabsTab>
|
||||||
|
))}
|
||||||
|
</TabsList>
|
||||||
|
{tabs.map((e, i) => (
|
||||||
|
<TabsPanel key={i} value={e.value}>
|
||||||
|
{/* Konten dummy, bisa diganti tergantung routing */}
|
||||||
|
<></>
|
||||||
|
</TabsPanel>
|
||||||
|
))}
|
||||||
|
</Tabs>
|
||||||
|
{children}
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default LayoutTabs;
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
import stateFasilitasKesehatan from '@/app/admin/(dashboard)/_state/kesehatan/data_kesehatan_warga/fasilitasKesehatan';
|
|
||||||
import colors from '@/con/colors';
|
|
||||||
import { Center, Stack, Table, TableTbody, TableTd, TableTh, TableThead, TableTr, Text } from '@mantine/core';
|
|
||||||
import { useShallowEffect } from '@mantine/hooks';
|
|
||||||
import _ from 'lodash';
|
|
||||||
import { useProxy } from 'valtio/utils';
|
|
||||||
|
|
||||||
function DokterdanTenagaMedisList() {
|
|
||||||
const kesehatanState = useProxy(stateFasilitasKesehatan.dokterdantenagamedis);
|
|
||||||
|
|
||||||
useShallowEffect(() => {
|
|
||||||
kesehatanState.findMany.load();
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
// Penanganan kasus ketika tidak ada data
|
|
||||||
if (_.isEmpty(kesehatanState.findMany.data)) {
|
|
||||||
return (
|
|
||||||
<Stack>
|
|
||||||
<Table
|
|
||||||
striped
|
|
||||||
highlightOnHover
|
|
||||||
withTableBorder
|
|
||||||
withColumnBorders
|
|
||||||
bg={colors['white-1']}
|
|
||||||
>
|
|
||||||
<TableThead>
|
|
||||||
<TableTr>
|
|
||||||
<TableTh>
|
|
||||||
<Center>Nama</Center>
|
|
||||||
</TableTh>
|
|
||||||
<TableTh>
|
|
||||||
<Center>Specialist</Center>
|
|
||||||
</TableTh>
|
|
||||||
<TableTh >
|
|
||||||
<Center>Jadwal</Center>
|
|
||||||
</TableTh>
|
|
||||||
</TableTr>
|
|
||||||
</TableThead>
|
|
||||||
<TableTbody >
|
|
||||||
<TableTr >
|
|
||||||
<TableTd colSpan={3}>
|
|
||||||
<Center>
|
|
||||||
<Text>Tidak ada data</Text>
|
|
||||||
</Center>
|
|
||||||
</TableTd>
|
|
||||||
</TableTr>
|
|
||||||
</TableTbody>
|
|
||||||
</Table>
|
|
||||||
</Stack>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Stack>
|
|
||||||
<Table
|
|
||||||
striped
|
|
||||||
highlightOnHover
|
|
||||||
withTableBorder
|
|
||||||
withColumnBorders
|
|
||||||
bg={colors['white-1']}
|
|
||||||
>
|
|
||||||
<TableThead >
|
|
||||||
<TableTr >
|
|
||||||
<TableTh >
|
|
||||||
<Center>Nama</Center>
|
|
||||||
</TableTh>
|
|
||||||
<TableTh >
|
|
||||||
<Center>Specialist</Center>
|
|
||||||
</TableTh>
|
|
||||||
<TableTh >
|
|
||||||
<Center>Jadwal</Center>
|
|
||||||
</TableTh>
|
|
||||||
</TableTr>
|
|
||||||
</TableThead>
|
|
||||||
<TableTbody >
|
|
||||||
{kesehatanState.findMany.data?.map((item) => (
|
|
||||||
<TableTr key={item.id}>
|
|
||||||
<TableTd ta="center">{item.name}</TableTd>
|
|
||||||
<TableTd ta="center">Specialist {item.specialist}</TableTd>
|
|
||||||
<TableTd ta="center">{item.jadwal}</TableTd>
|
|
||||||
</TableTr>
|
|
||||||
))}
|
|
||||||
</TableTbody>
|
|
||||||
</Table>
|
|
||||||
</Stack>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default DokterdanTenagaMedisList;
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
import stateFasilitasKesehatan from '@/app/admin/(dashboard)/_state/kesehatan/data_kesehatan_warga/fasilitasKesehatan';
|
|
||||||
import colors from '@/con/colors';
|
|
||||||
import { Box, Paper, Stack, Text, TextInput } from '@mantine/core';
|
|
||||||
import { useProxy } from 'valtio/utils';
|
|
||||||
|
|
||||||
function DokterDanTenagaMedis() {
|
|
||||||
const dokterdantenagamedisState = useProxy(stateFasilitasKesehatan.dokterdantenagamedis)
|
|
||||||
return (
|
|
||||||
<Box>
|
|
||||||
<Paper bg={colors['white-1']} p={"md"}>
|
|
||||||
<Stack gap={"xs"}>
|
|
||||||
<Text fw={"bold"}>Dokter & Tenaga Medis</Text>
|
|
||||||
<TextInput
|
|
||||||
label="Nama Dokter"
|
|
||||||
placeholder='masukkan nama dokter'
|
|
||||||
onChange={(val) => {
|
|
||||||
dokterdantenagamedisState.create.form.name = val.target.value
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<TextInput
|
|
||||||
label="Specialist"
|
|
||||||
placeholder='masukkan specialist'
|
|
||||||
onChange={(val) => {
|
|
||||||
dokterdantenagamedisState.create.form.specialist = val.target.value
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<TextInput
|
|
||||||
mb={10}
|
|
||||||
label="Jadwal"
|
|
||||||
placeholder='masukkan jadwal'
|
|
||||||
onChange={(val) => {
|
|
||||||
dokterdantenagamedisState.create.form.jadwal = val.target.value
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Stack>
|
|
||||||
</Paper>
|
|
||||||
</Box>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default DokterDanTenagaMedis;
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
import { Box, Stack, Text } from '@mantine/core';
|
|
||||||
import React from 'react';
|
|
||||||
import { useProxy } from 'valtio/utils';
|
|
||||||
import stateFasilitasKesehatan from '@/app/admin/(dashboard)/_state/kesehatan/data_kesehatan_warga/fasilitasKesehatan';
|
|
||||||
import { useShallowEffect } from '@mantine/hooks';
|
|
||||||
|
|
||||||
function FasilitasPendukungList() {
|
|
||||||
const fasilitaspendukungState = useProxy(stateFasilitasKesehatan.fasilitaspendukung)
|
|
||||||
useShallowEffect(() => {
|
|
||||||
fasilitaspendukungState.findMany.load()
|
|
||||||
}, [])
|
|
||||||
return <Stack>
|
|
||||||
{fasilitaspendukungState.findMany.data?.map((item) => (
|
|
||||||
<Box key={item.id}>
|
|
||||||
<Text dangerouslySetInnerHTML={{__html: item.content}}/>
|
|
||||||
</Box>
|
|
||||||
))}
|
|
||||||
</Stack>
|
|
||||||
}
|
|
||||||
|
|
||||||
export default FasilitasPendukungList;
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
import stateFasilitasKesehatan from '@/app/admin/(dashboard)/_state/kesehatan/data_kesehatan_warga/fasilitasKesehatan';
|
|
||||||
import { Box, Paper, Text } from '@mantine/core';
|
|
||||||
import { useProxy } from 'valtio/utils';
|
|
||||||
import { KesehatanEditor } from '../../../_com/kesehatanEditor';
|
|
||||||
import colors from '@/con/colors';
|
|
||||||
|
|
||||||
function FasilitasPendukung() {
|
|
||||||
const fasilitaspendukungState = useProxy(stateFasilitasKesehatan.fasilitaspendukung)
|
|
||||||
return <Box>
|
|
||||||
<Paper bg={colors['white-1']} p={'md'}>
|
|
||||||
<Text fw={"bold"}>Fasilitas Pendukung</Text>
|
|
||||||
<KesehatanEditor
|
|
||||||
showSubmit={false}
|
|
||||||
onChange={(val) => {
|
|
||||||
fasilitaspendukungState.create.form.content = val;
|
|
||||||
}} />
|
|
||||||
</Paper>
|
|
||||||
</Box>
|
|
||||||
}
|
|
||||||
|
|
||||||
export default FasilitasPendukung;
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
'use client'
|
|
||||||
import stateFasilitasKesehatan from '@/app/admin/(dashboard)/_state/kesehatan/data_kesehatan_warga/fasilitasKesehatan';
|
|
||||||
import colors from '@/con/colors';
|
|
||||||
import { Box, Paper, Stack, Text, TextInput } from '@mantine/core';
|
|
||||||
import { useProxy } from 'valtio/utils';
|
|
||||||
|
|
||||||
function InformasiUmum() {
|
|
||||||
const infromasiState = useProxy(stateFasilitasKesehatan.informasiumum)
|
|
||||||
return <Box>
|
|
||||||
<Paper bg={colors['white-1']} p={'md'}>
|
|
||||||
<Text fw={"bold"}>Informasi Umum</Text>
|
|
||||||
<Stack gap={"xs"}>
|
|
||||||
<TextInput
|
|
||||||
label="Fasilitas"
|
|
||||||
placeholder='masukkan nama fasilitas kesehatan'
|
|
||||||
onChange={(val) => {
|
|
||||||
infromasiState.create.form.fasilitas = val.target.value
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<TextInput
|
|
||||||
label="Alamat"
|
|
||||||
placeholder='masukkan alamat'
|
|
||||||
onChange={(val) => {
|
|
||||||
infromasiState.create.form.alamat = val.target.value
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<TextInput
|
|
||||||
mb={10}
|
|
||||||
label="Jam Operasional"
|
|
||||||
placeholder='masukkan jam operasional'
|
|
||||||
onChange={(val) => {
|
|
||||||
infromasiState.create.form.jamOperasional = val.target.value
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Stack>
|
|
||||||
</Paper>
|
|
||||||
</Box>
|
|
||||||
}
|
|
||||||
|
|
||||||
export default InformasiUmum;
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
'use client'
|
|
||||||
import stateFasilitasKesehatan from '@/app/admin/(dashboard)/_state/kesehatan/data_kesehatan_warga/fasilitasKesehatan';
|
|
||||||
import { Box, Paper, Text } from '@mantine/core';
|
|
||||||
import { useProxy } from 'valtio/utils';
|
|
||||||
import { KesehatanEditor } from '../../../_com/kesehatanEditor';
|
|
||||||
import colors from '@/con/colors';
|
|
||||||
|
|
||||||
function LayananUnggulan() {
|
|
||||||
const informasiumumState = useProxy(stateFasilitasKesehatan.layananunggulan)
|
|
||||||
return <Box>
|
|
||||||
<Paper bg={colors['white-1']} p={'md'}>
|
|
||||||
<Text fw={"bold"}>Layanan Unggulan</Text>
|
|
||||||
<KesehatanEditor
|
|
||||||
showSubmit={false}
|
|
||||||
onChange={(val) => {
|
|
||||||
informasiumumState.create.form.content = val;
|
|
||||||
}} />
|
|
||||||
</Paper>
|
|
||||||
</Box>
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default LayananUnggulan;
|
|
||||||
@@ -1,254 +0,0 @@
|
|||||||
"use client"
|
|
||||||
|
|
||||||
import stateFasilitasKesehatan from '@/app/admin/(dashboard)/_state/kesehatan/data_kesehatan_warga/fasilitasKesehatan';
|
|
||||||
import colors from '@/con/colors';
|
|
||||||
import { Box, Button, Center, Paper, SimpleGrid, Skeleton, Stack, Table, TableTbody, TableTd, TableTh, TableThead, TableTr, Text, Title } from '@mantine/core';
|
|
||||||
import { useShallowEffect } from '@mantine/hooks';
|
|
||||||
import { useProxy } from 'valtio/utils';
|
|
||||||
import DokterDanTenagaMedis from './dokterdantenagamedis/page';
|
|
||||||
import FasilitasPendukung from './fasilitas_pendukung/page';
|
|
||||||
import InformasiUmum from './informasi_umum/page';
|
|
||||||
import LayananUnggulan from './layanan_unggulan/page';
|
|
||||||
import ProsedurPendaftaran from './prosedurpendaftaran/page';
|
|
||||||
import TarifDanLayanan from './tarifdanlayanan/page';
|
|
||||||
|
|
||||||
|
|
||||||
function FasilitasKesehatan() {
|
|
||||||
const allState = useProxy(stateFasilitasKesehatan)
|
|
||||||
const submitAllForms = () => {
|
|
||||||
if (allState.informasiumum.create.form.fasilitas &&
|
|
||||||
allState.informasiumum.create.form.alamat &&
|
|
||||||
allState.informasiumum.create.form.jamOperasional) {
|
|
||||||
allState.informasiumum.create.create()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (allState.layananunggulan.create.form.content) {
|
|
||||||
allState.layananunggulan.create.create();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (allState.dokterdantenagamedis.create.form.name &&
|
|
||||||
allState.dokterdantenagamedis.create.form.specialist &&
|
|
||||||
allState.dokterdantenagamedis.create.form.jadwal) {
|
|
||||||
allState.dokterdantenagamedis.create.create()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (allState.fasilitaspendukung.create.form.content) {
|
|
||||||
allState.fasilitaspendukung.create.create();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (allState.tarifdanlayanan.create.form.tarif &&
|
|
||||||
allState.tarifdanlayanan.create.form.layanan) {
|
|
||||||
allState.tarifdanlayanan.create.create()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (allState.prosedurpendaftaran.create.form.content) {
|
|
||||||
allState.prosedurpendaftaran.create.create();
|
|
||||||
}
|
|
||||||
|
|
||||||
// refreshListData();
|
|
||||||
// resetAllForms();
|
|
||||||
}
|
|
||||||
|
|
||||||
// const refreshListData = () => {
|
|
||||||
// allState.informasiumum.findMany.load();
|
|
||||||
// allState.layananunggulan.findMany.load();
|
|
||||||
// allState.dokterdantenagamedis.findMany.load();
|
|
||||||
// allState.fasilitaspendukung.findMany.load();
|
|
||||||
// allState.tarifdanlayanan.findMany.load();
|
|
||||||
// allState.prosedurpendaftaran.findMany.load();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// const resetAllForms = () => {
|
|
||||||
// allState.informasiumum.create.form = {
|
|
||||||
// fasilitas: '',
|
|
||||||
// alamat: '',
|
|
||||||
// jamOperasional: ''
|
|
||||||
// };
|
|
||||||
// allState.layananunggulan.create.form = {
|
|
||||||
// content: ''
|
|
||||||
// };
|
|
||||||
// allState.dokterdantenagamedis.create.form = {
|
|
||||||
// name: '',
|
|
||||||
// specialist: '',
|
|
||||||
// jadwal: ''
|
|
||||||
// };
|
|
||||||
// allState.fasilitaspendukung.create.form = {
|
|
||||||
// content: ''
|
|
||||||
// };
|
|
||||||
// allState.tarifdanlayanan.create.form = {
|
|
||||||
// tarif: '',
|
|
||||||
// layanan: ''
|
|
||||||
// };
|
|
||||||
// allState.prosedurpendaftaran.create.form = {
|
|
||||||
// content: ''
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Stack py={10}>
|
|
||||||
<SimpleGrid cols={{
|
|
||||||
base: 1, md: 2
|
|
||||||
}}>
|
|
||||||
<Box>
|
|
||||||
<Stack gap={'xs'}>
|
|
||||||
<Title order={4}>Tambah Fasilitas Kesehatan</Title>
|
|
||||||
{/* Informasi Umum */}
|
|
||||||
<InformasiUmum />
|
|
||||||
{/* Layanan Unggulan */}
|
|
||||||
<LayananUnggulan />
|
|
||||||
{/* Dokter & Tenaga Medis */}
|
|
||||||
<DokterDanTenagaMedis />
|
|
||||||
{/* Fasilitas Pendukung */}
|
|
||||||
<FasilitasPendukung />
|
|
||||||
{/* Tarif & Layanan */}
|
|
||||||
<TarifDanLayanan />
|
|
||||||
{/* Prosedur Pendaftaran */}
|
|
||||||
<ProsedurPendaftaran />
|
|
||||||
<Button onClick={submitAllForms}>Submit</Button>
|
|
||||||
</Stack>
|
|
||||||
</Box>
|
|
||||||
|
|
||||||
<Box>
|
|
||||||
<Stack gap={"xs"}>
|
|
||||||
<Title order={4}>Data Fasilitas Kesehatan</Title>
|
|
||||||
<AllList />
|
|
||||||
</Stack>
|
|
||||||
</Box>
|
|
||||||
</SimpleGrid>
|
|
||||||
|
|
||||||
</Stack>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function AllList() {
|
|
||||||
const allListState = useProxy(stateFasilitasKesehatan)
|
|
||||||
useShallowEffect(() => {
|
|
||||||
allListState.informasiumum.findMany.load();
|
|
||||||
allListState.layananunggulan.findMany.load();
|
|
||||||
allListState.dokterdantenagamedis.findMany.load();
|
|
||||||
allListState.fasilitaspendukung.findMany.load();
|
|
||||||
allListState.tarifdanlayanan.findMany.load();
|
|
||||||
allListState.prosedurpendaftaran.findMany.load();
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
if (!allListState.informasiumum.findMany.data
|
|
||||||
|| !allListState.layananunggulan.findMany.data
|
|
||||||
|| !allListState.dokterdantenagamedis.findMany.data
|
|
||||||
|| !allListState.fasilitaspendukung.findMany.data
|
|
||||||
|| !allListState.tarifdanlayanan.findMany.data
|
|
||||||
|| !allListState.prosedurpendaftaran.findMany.data
|
|
||||||
) return <Stack>
|
|
||||||
{Array.from({ length: 10 }).map((v, k) => <Skeleton key={k} h={40} />)}
|
|
||||||
</Stack>
|
|
||||||
return <Stack>
|
|
||||||
<Paper bg={colors['white-1']} p={'md'}>
|
|
||||||
<Title order={4}>Informasi Umum</Title>
|
|
||||||
{allListState.informasiumum.findMany.data?.map((item) => (
|
|
||||||
<Box key={item.id}>
|
|
||||||
|
|
||||||
<Text>{item.fasilitas}</Text>
|
|
||||||
<Text>{item.alamat}</Text>
|
|
||||||
<Text>{item.jamOperasional}</Text>
|
|
||||||
</Box>
|
|
||||||
))}
|
|
||||||
</Paper>
|
|
||||||
|
|
||||||
<Paper bg={colors['white-1']} p={'md'}>
|
|
||||||
<Title order={4}>Layanan Unggulan</Title>
|
|
||||||
{allListState.layananunggulan.findMany.data?.map((item) => (
|
|
||||||
<Box key={item.id}>
|
|
||||||
<Text dangerouslySetInnerHTML={{ __html: item.content }} />
|
|
||||||
</Box>
|
|
||||||
))}
|
|
||||||
</Paper>
|
|
||||||
|
|
||||||
|
|
||||||
<Paper bg={colors['white-1']} p={'md'}>
|
|
||||||
<Title order={4}>Dokter & Tenaga Medis</Title>
|
|
||||||
|
|
||||||
<Table
|
|
||||||
striped
|
|
||||||
highlightOnHover
|
|
||||||
withTableBorder
|
|
||||||
withColumnBorders
|
|
||||||
bg={colors['white-1']}
|
|
||||||
>
|
|
||||||
<TableThead >
|
|
||||||
<TableTr >
|
|
||||||
<TableTh >
|
|
||||||
<Center>Nama</Center>
|
|
||||||
</TableTh>
|
|
||||||
<TableTh >
|
|
||||||
<Center>Specialist</Center>
|
|
||||||
</TableTh>
|
|
||||||
<TableTh >
|
|
||||||
<Center>Jadwal</Center>
|
|
||||||
</TableTh>
|
|
||||||
</TableTr>
|
|
||||||
</TableThead>
|
|
||||||
<TableTbody >
|
|
||||||
{allListState.dokterdantenagamedis.findMany.data?.map((item) => (
|
|
||||||
<TableTr key={item.id}>
|
|
||||||
<TableTd ta="center">{item.name}</TableTd>
|
|
||||||
<TableTd ta="center">Specialist {item.specialist}</TableTd>
|
|
||||||
<TableTd ta="center">{item.jadwal}</TableTd>
|
|
||||||
</TableTr>
|
|
||||||
))}
|
|
||||||
</TableTbody>
|
|
||||||
</Table>
|
|
||||||
</Paper>
|
|
||||||
|
|
||||||
<Paper bg={colors['white-1']} p={'md'}>
|
|
||||||
|
|
||||||
<Title order={4}>Fasilitas Pendukung</Title>
|
|
||||||
{allListState.fasilitaspendukung.findMany.data?.map((item) => (
|
|
||||||
<Box key={item.id}>
|
|
||||||
<Text dangerouslySetInnerHTML={{ __html: item.content }} />
|
|
||||||
</Box>
|
|
||||||
))}
|
|
||||||
</Paper>
|
|
||||||
|
|
||||||
<Paper bg={colors['white-1']} p={'md'}>
|
|
||||||
<Title order={4}>Tarif & Layanan</Title>
|
|
||||||
<Table
|
|
||||||
suppressHydrationWarning
|
|
||||||
striped
|
|
||||||
highlightOnHover
|
|
||||||
withTableBorder
|
|
||||||
withColumnBorders
|
|
||||||
bg={colors['white-1']}
|
|
||||||
>
|
|
||||||
<TableThead>
|
|
||||||
<TableTr>
|
|
||||||
<TableTh>
|
|
||||||
Layanan
|
|
||||||
</TableTh>
|
|
||||||
<TableTh>
|
|
||||||
Tarif
|
|
||||||
</TableTh>
|
|
||||||
</TableTr>
|
|
||||||
</TableThead>
|
|
||||||
<TableTbody>
|
|
||||||
{allListState.tarifdanlayanan.findMany.data?.map((item) => (
|
|
||||||
<TableTr key={item.id}>
|
|
||||||
<TableTd>{item.layanan}</TableTd>
|
|
||||||
<TableTd>Rp.{item.tarif}</TableTd>
|
|
||||||
</TableTr>
|
|
||||||
))}
|
|
||||||
</TableTbody>
|
|
||||||
</Table>
|
|
||||||
</Paper>
|
|
||||||
|
|
||||||
<Paper bg={colors['white-1']} p={'md'}>
|
|
||||||
|
|
||||||
<Title order={4}>Prosedur Pendaftaran</Title>
|
|
||||||
{allListState.prosedurpendaftaran.findMany.data?.map((item) => (
|
|
||||||
<Box key={item.id}>
|
|
||||||
<Text dangerouslySetInnerHTML={{ __html: item.content }} />
|
|
||||||
</Box>
|
|
||||||
))}
|
|
||||||
</Paper>
|
|
||||||
</Stack>
|
|
||||||
}
|
|
||||||
|
|
||||||
export default FasilitasKesehatan;
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
import stateFasilitasKesehatan from '@/app/admin/(dashboard)/_state/kesehatan/data_kesehatan_warga/fasilitasKesehatan';
|
|
||||||
import { Box, Skeleton, Stack, Text } from '@mantine/core';
|
|
||||||
import { useShallowEffect } from '@mantine/hooks';
|
|
||||||
import { useProxy } from 'valtio/utils';
|
|
||||||
|
|
||||||
function ListProsedurPendaftaran() {
|
|
||||||
const prosedurpendaftaranState = useProxy(stateFasilitasKesehatan.prosedurpendaftaran)
|
|
||||||
useShallowEffect(() => {
|
|
||||||
prosedurpendaftaranState.findMany.load()
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
if (!prosedurpendaftaranState.findMany.data)return<Stack>
|
|
||||||
{Array.from({ length: 10 }).map((v, k) => <Skeleton key={k} h={40} />)}
|
|
||||||
</Stack>
|
|
||||||
|
|
||||||
return <Stack>
|
|
||||||
{prosedurpendaftaranState.findMany.data?.map((item) => (
|
|
||||||
<Box key={item.id}>
|
|
||||||
<Text dangerouslySetInnerHTML={{__html: item.content}}/>
|
|
||||||
</Box>
|
|
||||||
))}
|
|
||||||
</Stack>
|
|
||||||
}
|
|
||||||
|
|
||||||
export default ListProsedurPendaftaran;
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
import stateFasilitasKesehatan from '@/app/admin/(dashboard)/_state/kesehatan/data_kesehatan_warga/fasilitasKesehatan';
|
|
||||||
import { Box, Text, Paper } from '@mantine/core';
|
|
||||||
import { useProxy } from 'valtio/utils';
|
|
||||||
import { KesehatanEditor } from '../../../_com/kesehatanEditor';
|
|
||||||
import colors from '@/con/colors';
|
|
||||||
|
|
||||||
function ProsedurPendaftaran() {
|
|
||||||
const prosedurpendaftaranState = useProxy(stateFasilitasKesehatan.prosedurpendaftaran)
|
|
||||||
return <Box>
|
|
||||||
<Paper bg={colors['white-1']} p={'md'}>
|
|
||||||
<Text fw={"bold"}>Prosedur Pendaftaran</Text>
|
|
||||||
<KesehatanEditor
|
|
||||||
showSubmit={false}
|
|
||||||
onChange={(val) => {
|
|
||||||
prosedurpendaftaranState.create.form.content = val;
|
|
||||||
}} />
|
|
||||||
</Paper>
|
|
||||||
</Box>
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
export default ProsedurPendaftaran;
|
|
||||||
@@ -1,82 +0,0 @@
|
|||||||
import stateFasilitasKesehatan from '@/app/admin/(dashboard)/_state/kesehatan/data_kesehatan_warga/fasilitasKesehatan';
|
|
||||||
import colors from '@/con/colors';
|
|
||||||
import { Center, Stack, Table, TableTbody, TableTd, TableTh, TableThead, TableTr, Text } from '@mantine/core';
|
|
||||||
import { useShallowEffect } from '@mantine/hooks';
|
|
||||||
import _ from 'lodash';
|
|
||||||
import { useProxy } from 'valtio/utils';
|
|
||||||
|
|
||||||
function TarifDanLayananList() {
|
|
||||||
const tarifdanlayanan = useProxy(stateFasilitasKesehatan.tarifdanlayanan)
|
|
||||||
useShallowEffect(() => {
|
|
||||||
tarifdanlayanan.findMany.load()
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
if (_.isEmpty(tarifdanlayanan.findMany.data)) {
|
|
||||||
return (
|
|
||||||
<Stack>
|
|
||||||
<Table
|
|
||||||
striped
|
|
||||||
highlightOnHover
|
|
||||||
withTableBorder
|
|
||||||
withColumnBorders
|
|
||||||
bg={colors['white-1']}
|
|
||||||
>
|
|
||||||
<TableThead>
|
|
||||||
<TableTr>
|
|
||||||
<TableTh>
|
|
||||||
<Center>Nama</Center>
|
|
||||||
</TableTh>
|
|
||||||
<TableTh>
|
|
||||||
<Center>Specialist</Center>
|
|
||||||
</TableTh>
|
|
||||||
<TableTh >
|
|
||||||
<Center>Jadwal</Center>
|
|
||||||
</TableTh>
|
|
||||||
</TableTr>
|
|
||||||
</TableThead>
|
|
||||||
<TableTbody >
|
|
||||||
<TableTr >
|
|
||||||
<TableTd colSpan={3}>
|
|
||||||
<Center>
|
|
||||||
<Text>Tidak ada data</Text>
|
|
||||||
</Center>
|
|
||||||
</TableTd>
|
|
||||||
</TableTr>
|
|
||||||
</TableTbody>
|
|
||||||
</Table>
|
|
||||||
</Stack>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return <Stack>
|
|
||||||
<Table
|
|
||||||
suppressHydrationWarning
|
|
||||||
striped
|
|
||||||
highlightOnHover
|
|
||||||
withTableBorder
|
|
||||||
withColumnBorders
|
|
||||||
bg={colors['white-1']}
|
|
||||||
>
|
|
||||||
<TableThead>
|
|
||||||
<TableTr>
|
|
||||||
<TableTh>
|
|
||||||
Layanan
|
|
||||||
</TableTh>
|
|
||||||
<TableTh>
|
|
||||||
Tarif
|
|
||||||
</TableTh>
|
|
||||||
</TableTr>
|
|
||||||
</TableThead>
|
|
||||||
<TableTbody>
|
|
||||||
{tarifdanlayanan.findMany.data?.map((item) => (
|
|
||||||
<TableTr key={item.id}>
|
|
||||||
<TableTd>{item.layanan}</TableTd>
|
|
||||||
<TableTd>Rp.{item.tarif}</TableTd>
|
|
||||||
</TableTr>
|
|
||||||
))}
|
|
||||||
</TableTbody>
|
|
||||||
</Table>
|
|
||||||
</Stack>
|
|
||||||
}
|
|
||||||
|
|
||||||
export default TarifDanLayananList;
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
import stateFasilitasKesehatan from '@/app/admin/(dashboard)/_state/kesehatan/data_kesehatan_warga/fasilitasKesehatan';
|
|
||||||
import colors from '@/con/colors';
|
|
||||||
import { Box, Paper, Stack, Text, TextInput } from '@mantine/core';
|
|
||||||
import { useProxy } from 'valtio/utils';
|
|
||||||
|
|
||||||
function TarifDanLayanan() {
|
|
||||||
const tarifdanlayanan = useProxy(stateFasilitasKesehatan.tarifdanlayanan)
|
|
||||||
return <Box>
|
|
||||||
<Paper bg={colors['white-1']} p={'md'}>
|
|
||||||
<Text fw={"bold"}>Tarif & Layanan</Text>
|
|
||||||
<Stack gap={"xs"}>
|
|
||||||
<TextInput
|
|
||||||
label="Tarif"
|
|
||||||
placeholder='masukkan tarif'
|
|
||||||
onChange={(val) => {
|
|
||||||
tarifdanlayanan.create.form.tarif = val.target.value
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<TextInput
|
|
||||||
mb={10}
|
|
||||||
label="Layanan"
|
|
||||||
placeholder='masukkan layanan'
|
|
||||||
onChange={(val) => {
|
|
||||||
tarifdanlayanan.create.form.layanan = val.target.value
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Stack>
|
|
||||||
</Paper>
|
|
||||||
</Box>
|
|
||||||
}
|
|
||||||
|
|
||||||
export default TarifDanLayanan;
|
|
||||||
@@ -1,101 +0,0 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
||||||
'use client'
|
|
||||||
import stategrafikKepuasan from '@/app/admin/(dashboard)/_state/kesehatan/data_kesehatan_warga/grafikKepuasan';
|
|
||||||
import colors from '@/con/colors';
|
|
||||||
import { Box, Button, Group, Paper, Skeleton, Stack, TextInput, Title } from '@mantine/core';
|
|
||||||
import { useMediaQuery, useShallowEffect } from '@mantine/hooks';
|
|
||||||
import { useEffect, useState } from 'react';
|
|
||||||
import { Bar, BarChart, Legend, Tooltip, XAxis, YAxis } from 'recharts';
|
|
||||||
import { useProxy } from 'valtio/utils';
|
|
||||||
|
|
||||||
function GrafikHasilKepuasan() {
|
|
||||||
const grafikkepuasan = useProxy(stategrafikKepuasan.grafikkepuasan)
|
|
||||||
const [mounted, setMounted] = useState(false);
|
|
||||||
const isTablet = useMediaQuery('(max-width: 1024px)')
|
|
||||||
const isMobile = useMediaQuery('(max-width: 768px)')
|
|
||||||
const [chartData, setChartData] = useState<any[]>([])
|
|
||||||
|
|
||||||
useShallowEffect(() => {
|
|
||||||
const fetchData = async () => {
|
|
||||||
await grafikkepuasan.findMany.load();
|
|
||||||
if (grafikkepuasan.findMany.data && grafikkepuasan.findMany.data.length > 0) {
|
|
||||||
setChartData(grafikkepuasan.findMany.data);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
fetchData();
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
setMounted(true); // setelah komponen siap di client
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
if (!mounted) {
|
|
||||||
return null; // Jangan render apa-apa dulu sebelum mounted
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Stack py={10} gap={"xs"}>
|
|
||||||
<Paper w={{ base: '100%', md: '50%' }} bg={colors['white-1']} p={'md'}>
|
|
||||||
<Title order={4}>Tambah Grafik Hasil Kepuasan</Title>
|
|
||||||
<Stack gap={"xs"}>
|
|
||||||
<TextInput
|
|
||||||
label="Label"
|
|
||||||
placeholder='Masukkan label yang diinginkan'
|
|
||||||
value={grafikkepuasan.create.form.label}
|
|
||||||
onChange={(val) => {
|
|
||||||
grafikkepuasan.create.form.label = val.currentTarget.value
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<TextInput
|
|
||||||
label="Jumlah Penderita"
|
|
||||||
type='number'
|
|
||||||
placeholder='Masukkan jumlah penderita'
|
|
||||||
value={grafikkepuasan.create.form.jumlah}
|
|
||||||
onChange={(val) => {
|
|
||||||
grafikkepuasan.create.form.jumlah = val.currentTarget.value
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<Group>
|
|
||||||
<Button bg={colors['blue-button']} mt={10}
|
|
||||||
onClick={async () => {
|
|
||||||
await grafikkepuasan.create.create();
|
|
||||||
await grafikkepuasan.findMany.load();
|
|
||||||
if (grafikkepuasan.findMany.data) {
|
|
||||||
setChartData(grafikkepuasan.findMany.data);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>Submit</Button>
|
|
||||||
</Group>
|
|
||||||
</Stack>
|
|
||||||
</Paper>
|
|
||||||
{!chartData ? (
|
|
||||||
<Box style={{ width: '100%', minWidth: 300, minHeight: 300 }}>
|
|
||||||
<Paper bg={colors['white-1']} p={'md'}>
|
|
||||||
<Title py={15} order={4}>Data Hasil Kepuasan</Title>
|
|
||||||
<Skeleton h={400} />
|
|
||||||
</Paper>
|
|
||||||
</Box>
|
|
||||||
) : (
|
|
||||||
<Box style={{ width: '100%', minWidth: 300, minHeight: 300 }}>
|
|
||||||
<Paper bg={colors['white-1']} p={'md'}>
|
|
||||||
<Title py={15} order={4}>Data Hasil Kepuasan</Title>
|
|
||||||
<BarChart
|
|
||||||
width={isMobile ? 250 : isTablet ? 300 : 350}
|
|
||||||
height={380}
|
|
||||||
data={chartData}
|
|
||||||
>
|
|
||||||
<XAxis dataKey="label" />
|
|
||||||
<YAxis />
|
|
||||||
<Tooltip />
|
|
||||||
<Legend />
|
|
||||||
<Bar dataKey="jumlah" fill={colors['blue-button']} name="Jumlah" />
|
|
||||||
</BarChart>
|
|
||||||
</Paper>
|
|
||||||
</Box>
|
|
||||||
)}
|
|
||||||
</Stack>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default GrafikHasilKepuasan;
|
|
||||||
@@ -1,124 +0,0 @@
|
|||||||
'use client'
|
|
||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
||||||
import statePersentase from '@/app/admin/(dashboard)/_state/kesehatan/data_kesehatan_warga/persentaseKelahiran';
|
|
||||||
import colors from '@/con/colors';
|
|
||||||
import { Box, Button, Group, Paper, Skeleton, Stack, TextInput, Title } from '@mantine/core';
|
|
||||||
import { useMediaQuery, useShallowEffect } from '@mantine/hooks';
|
|
||||||
import { useEffect, useState } from 'react';
|
|
||||||
import { Bar, BarChart, Legend, Tooltip, XAxis, YAxis } from 'recharts';
|
|
||||||
import { useProxy } from 'valtio/utils';
|
|
||||||
|
|
||||||
function PersentaseDataKelahiranKematian() {
|
|
||||||
const persentase = useProxy(statePersentase.persentasekelahiran);
|
|
||||||
const [chartData, setChartData] = useState<any[]>([]);
|
|
||||||
const [mounted, setMounted] = useState(false); // untuk memastikan DOM sudah ready
|
|
||||||
const isTablet = useMediaQuery('(max-width: 1024px)')
|
|
||||||
const isMobile = useMediaQuery('(max-width: 768px)')
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
setMounted(true);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
useShallowEffect(() => {
|
|
||||||
const fetchData = async () => {
|
|
||||||
await persentase.findMany.load();
|
|
||||||
if (persentase.findMany.data && persentase.findMany.data.length > 0) {
|
|
||||||
setChartData(persentase.findMany.data);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
fetchData();
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Stack py={10}>
|
|
||||||
{/* Form Input */}
|
|
||||||
<Box>
|
|
||||||
<Paper w={{ base: '100%', md: '50%' }} bg={colors['white-1']} p={'md'}>
|
|
||||||
<Title order={4}>Tambah Persentase Data Kelahiran & Kematian</Title>
|
|
||||||
<Stack gap={"xs"}>
|
|
||||||
<TextInput
|
|
||||||
label="Tahun"
|
|
||||||
type="number"
|
|
||||||
value={persentase.create.form.tahun}
|
|
||||||
placeholder="Masukkan tahun"
|
|
||||||
onChange={(val) => {
|
|
||||||
persentase.create.form.tahun = val.currentTarget.value;
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<TextInput
|
|
||||||
label="Kematian Kasar"
|
|
||||||
type="number"
|
|
||||||
value={persentase.create.form.kematianKasar}
|
|
||||||
placeholder="Masukkan kematian kasar"
|
|
||||||
onChange={(val) => {
|
|
||||||
persentase.create.form.kematianKasar = val.currentTarget.value;
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<TextInput
|
|
||||||
label="Kematian Bayi"
|
|
||||||
type="number"
|
|
||||||
value={persentase.create.form.kematianBayi}
|
|
||||||
placeholder="Masukkan kematian bayi"
|
|
||||||
onChange={(val) => {
|
|
||||||
persentase.create.form.kematianBayi = val.currentTarget.value;
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<TextInput
|
|
||||||
label="Kelahiran Kasar"
|
|
||||||
type="number"
|
|
||||||
value={persentase.create.form.kelahiranKasar}
|
|
||||||
placeholder="Masukkan kelahiran kasar"
|
|
||||||
onChange={(val) => {
|
|
||||||
persentase.create.form.kelahiranKasar = val.currentTarget.value;
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<Group>
|
|
||||||
<Button
|
|
||||||
bg={colors['blue-button']}
|
|
||||||
mt={10}
|
|
||||||
onClick={async () => {
|
|
||||||
await persentase.create.create();
|
|
||||||
await persentase.findMany.load();
|
|
||||||
if (persentase.findMany.data) {
|
|
||||||
setChartData(persentase.findMany.data);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Submit
|
|
||||||
</Button>
|
|
||||||
</Group>
|
|
||||||
</Stack>
|
|
||||||
</Paper>
|
|
||||||
</Box>
|
|
||||||
|
|
||||||
{/* Chart */}
|
|
||||||
{!mounted && !chartData ? (
|
|
||||||
<Box style={{ width: '100%', minWidth: 300, height: 400, minHeight: 300 }}>
|
|
||||||
<Paper bg={colors['white-1']} p={'md'}>
|
|
||||||
<Title pb={10} order={3}>Data Kelahiran & Kematian</Title>
|
|
||||||
<Skeleton h={400} />
|
|
||||||
</Paper>
|
|
||||||
</Box>
|
|
||||||
) : (
|
|
||||||
<Box style={{ width: '100%', minWidth: 300, height: 400, minHeight: 300 }}>
|
|
||||||
<Paper bg={colors['white-1']} p={'md'}>
|
|
||||||
<Title pb={10} order={4}>Data Kelahiran & Kematian</Title>
|
|
||||||
{mounted && chartData.length > 0 && (
|
|
||||||
<BarChart width={isMobile ? 450 : isTablet ? 500 : 550} height={350} data={chartData} >
|
|
||||||
<XAxis dataKey="tahun" />
|
|
||||||
<YAxis />
|
|
||||||
<Tooltip />
|
|
||||||
<Legend />
|
|
||||||
<Bar dataKey="kematianKasar" fill="#f03e3e" name="Kematian Kasar" />
|
|
||||||
<Bar dataKey="kematianBayi" fill="#ff922b" name="Kematian Bayi" />
|
|
||||||
<Bar dataKey="kelahiranKasar" fill="#4dabf7" name="Kelahiran Kasar" />
|
|
||||||
</BarChart>
|
|
||||||
)}
|
|
||||||
</Paper>
|
|
||||||
</Box>
|
|
||||||
)}
|
|
||||||
</Stack>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default PersentaseDataKelahiranKematian;
|
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
'use client'
|
'use client'
|
||||||
import { Box, Paper, Text } from '@mantine/core';
|
|
||||||
import React from 'react';
|
|
||||||
import { KesehatanEditor } from '../../../_com/kesehatanEditor';
|
|
||||||
import { useProxy } from 'valtio/utils';
|
|
||||||
import stateArtikelKesehatan from '@/app/admin/(dashboard)/_state/kesehatan/data_kesehatan_warga/artikelKesehatan';
|
|
||||||
import colors from '@/con/colors';
|
import colors from '@/con/colors';
|
||||||
|
import { Box, Paper, Text } from '@mantine/core';
|
||||||
|
import { KesehatanEditor } from '../../_com/kesehatanEditor';
|
||||||
|
import stateArtikelKesehatan from '@/app/admin/(dashboard)/_state/kesehatan/data_kesehatan_warga/artikelKesehatan';
|
||||||
|
import { useProxy } from 'valtio/utils';
|
||||||
|
|
||||||
function DoctorSignUI() {
|
function DoctorSignUI() {
|
||||||
const doctorSign = useProxy(stateArtikelKesehatan.doctorSign)
|
const doctorSign = useProxy(stateArtikelKesehatan.doctorSign)
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
'use client'
|
'use client'
|
||||||
import { Box, Paper, Stack, Text, TextInput } from '@mantine/core';
|
|
||||||
import React from 'react';
|
|
||||||
import { useProxy } from 'valtio/utils';
|
|
||||||
import stateArtikelKesehatan from '@/app/admin/(dashboard)/_state/kesehatan/data_kesehatan_warga/artikelKesehatan';
|
import stateArtikelKesehatan from '@/app/admin/(dashboard)/_state/kesehatan/data_kesehatan_warga/artikelKesehatan';
|
||||||
import { KesehatanEditor } from '../../../_com/kesehatanEditor';
|
|
||||||
import colors from '@/con/colors';
|
import colors from '@/con/colors';
|
||||||
|
import { Box, Paper, Stack, Text, TextInput } from '@mantine/core';
|
||||||
|
import { useProxy } from 'valtio/utils';
|
||||||
|
import { KesehatanEditor } from '../../_com/kesehatanEditor';
|
||||||
|
|
||||||
function FirstAidUI() {
|
function FirstAidUI() {
|
||||||
const firstAidState = useProxy(stateArtikelKesehatan.firstAid)
|
const firstAidState = useProxy(stateArtikelKesehatan.firstAid)
|
||||||
@@ -2,9 +2,9 @@
|
|||||||
import { Box, Paper, Stack, Text } from '@mantine/core';
|
import { Box, Paper, Stack, Text } from '@mantine/core';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { useProxy } from 'valtio/utils';
|
import { useProxy } from 'valtio/utils';
|
||||||
import { KesehatanEditor } from '../../../_com/kesehatanEditor';
|
|
||||||
import stateArtikelKesehatan from '@/app/admin/(dashboard)/_state/kesehatan/data_kesehatan_warga/artikelKesehatan';
|
|
||||||
import colors from '@/con/colors';
|
import colors from '@/con/colors';
|
||||||
|
import { KesehatanEditor } from '../../_com/kesehatanEditor';
|
||||||
|
import stateArtikelKesehatan from '@/app/admin/(dashboard)/_state/kesehatan/data_kesehatan_warga/artikelKesehatan';
|
||||||
|
|
||||||
function IntoductionUI() {
|
function IntoductionUI() {
|
||||||
const introduction = useProxy(stateArtikelKesehatan.introduction)
|
const introduction = useProxy(stateArtikelKesehatan.introduction)
|
||||||
@@ -169,4 +169,4 @@ function AllList() {
|
|||||||
</Stack>
|
</Stack>
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ArtikelKesehatan;
|
export default ArtikelKesehatan;
|
||||||
@@ -1,10 +1,9 @@
|
|||||||
'use client'
|
'use client'
|
||||||
import stateArtikelKesehatan from '@/app/admin/(dashboard)/_state/kesehatan/data_kesehatan_warga/artikelKesehatan';
|
import stateArtikelKesehatan from '@/app/admin/(dashboard)/_state/kesehatan/data_kesehatan_warga/artikelKesehatan';
|
||||||
import { Box, Paper, Stack, Text, TextInput } from '@mantine/core';
|
|
||||||
import React from 'react';
|
|
||||||
import { useProxy } from 'valtio/utils';
|
|
||||||
import { KesehatanEditor } from '../../../_com/kesehatanEditor';
|
|
||||||
import colors from '@/con/colors';
|
import colors from '@/con/colors';
|
||||||
|
import { Box, Paper, Stack, Text, TextInput } from '@mantine/core';
|
||||||
|
import { useProxy } from 'valtio/utils';
|
||||||
|
import { KesehatanEditor } from '../../_com/kesehatanEditor';
|
||||||
|
|
||||||
function PreventionUI() {
|
function PreventionUI() {
|
||||||
const preventionState = useProxy(stateArtikelKesehatan.prevention)
|
const preventionState = useProxy(stateArtikelKesehatan.prevention)
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
'use client'
|
'use client'
|
||||||
import stateArtikelKesehatan from '@/app/admin/(dashboard)/_state/kesehatan/data_kesehatan_warga/artikelKesehatan';
|
import stateArtikelKesehatan from '@/app/admin/(dashboard)/_state/kesehatan/data_kesehatan_warga/artikelKesehatan';
|
||||||
|
import colors from '@/con/colors';
|
||||||
import { Box, Paper, Stack, Text, TextInput } from '@mantine/core';
|
import { Box, Paper, Stack, Text, TextInput } from '@mantine/core';
|
||||||
import { useProxy } from 'valtio/utils';
|
import { useProxy } from 'valtio/utils';
|
||||||
import { KesehatanEditor } from '../../../_com/kesehatanEditor';
|
import { KesehatanEditor } from '../../_com/kesehatanEditor';
|
||||||
import colors from '@/con/colors';
|
|
||||||
|
|
||||||
function SymptomUI() {
|
function SymptomUI() {
|
||||||
const symptomState = useProxy(stateArtikelKesehatan.symptom)
|
const symptomState = useProxy(stateArtikelKesehatan.symptom)
|
||||||
@@ -0,0 +1,359 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
|
'use client'
|
||||||
|
|
||||||
|
import EditEditor from '@/app/admin/(dashboard)/_com/editEditor';
|
||||||
|
import fasilitasKesehatanState from '@/app/admin/(dashboard)/_state/kesehatan/data_kesehatan_warga/fasilitasKesehatan';
|
||||||
|
import colors from '@/con/colors';
|
||||||
|
import { Box, Button, Paper, Stack, Text, TextInput, Title } from '@mantine/core';
|
||||||
|
import { IconArrowBack } from '@tabler/icons-react';
|
||||||
|
import { useParams, useRouter } from 'next/navigation';
|
||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
import { toast } from 'react-toastify';
|
||||||
|
import { useProxy } from 'valtio/utils';
|
||||||
|
|
||||||
|
interface FasilitasKesehatanFormBase {
|
||||||
|
name: string;
|
||||||
|
informasiUmum: {
|
||||||
|
fasilitas: string;
|
||||||
|
alamat: string;
|
||||||
|
jamOperasional: string;
|
||||||
|
};
|
||||||
|
layananUnggulan: {
|
||||||
|
content: string;
|
||||||
|
};
|
||||||
|
dokterdanTenagaMedis: {
|
||||||
|
name: string;
|
||||||
|
specialist: string;
|
||||||
|
jadwal: string;
|
||||||
|
};
|
||||||
|
fasilitasPendukung: {
|
||||||
|
content: string;
|
||||||
|
};
|
||||||
|
prosedurPendaftaran: {
|
||||||
|
content: string;
|
||||||
|
};
|
||||||
|
tarifDanLayanan: {
|
||||||
|
layanan: string;
|
||||||
|
tarif: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function EditFasilitasKesehatan() {
|
||||||
|
const stateFasilitasKesehatan = useProxy(fasilitasKesehatanState);
|
||||||
|
const router = useRouter();
|
||||||
|
const params = useParams();
|
||||||
|
|
||||||
|
const [formData, setFormData] = useState<FasilitasKesehatanFormBase>({
|
||||||
|
name: stateFasilitasKesehatan.edit.form.name || '',
|
||||||
|
informasiUmum: {
|
||||||
|
fasilitas: stateFasilitasKesehatan.edit.form.informasiUmum?.fasilitas || '',
|
||||||
|
alamat: stateFasilitasKesehatan.edit.form.informasiUmum?.alamat || '',
|
||||||
|
jamOperasional: stateFasilitasKesehatan.edit.form.informasiUmum?.jamOperasional || '',
|
||||||
|
},
|
||||||
|
layananUnggulan: {
|
||||||
|
content: stateFasilitasKesehatan.edit.form.layananUnggulan?.content || '',
|
||||||
|
},
|
||||||
|
dokterdanTenagaMedis: {
|
||||||
|
name: stateFasilitasKesehatan.edit.form.dokterdanTenagaMedis?.name || '',
|
||||||
|
specialist: stateFasilitasKesehatan.edit.form.dokterdanTenagaMedis?.specialist || '',
|
||||||
|
jadwal: stateFasilitasKesehatan.edit.form.dokterdanTenagaMedis?.jadwal || '',
|
||||||
|
},
|
||||||
|
fasilitasPendukung: {
|
||||||
|
content: stateFasilitasKesehatan.edit.form.fasilitasPendukung?.content || '',
|
||||||
|
},
|
||||||
|
prosedurPendaftaran: {
|
||||||
|
content: stateFasilitasKesehatan.edit.form.prosedurPendaftaran?.content || '',
|
||||||
|
},
|
||||||
|
tarifDanLayanan: {
|
||||||
|
layanan: stateFasilitasKesehatan.edit.form.tarifDanLayanan?.layanan || '',
|
||||||
|
tarif: stateFasilitasKesehatan.edit.form.tarifDanLayanan?.tarif || '',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const loadFasilitasKesehatan = async () => {
|
||||||
|
const id = params?.id as string;
|
||||||
|
if (!id) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
await stateFasilitasKesehatan.edit.load(id);
|
||||||
|
const { form } = stateFasilitasKesehatan.edit;
|
||||||
|
if (form) {
|
||||||
|
setFormData({
|
||||||
|
name: form.name,
|
||||||
|
informasiUmum: {
|
||||||
|
fasilitas: form.informasiUmum?.fasilitas || '',
|
||||||
|
alamat: form.informasiUmum?.alamat || '',
|
||||||
|
jamOperasional: form.informasiUmum?.jamOperasional || '',
|
||||||
|
},
|
||||||
|
layananUnggulan: {
|
||||||
|
content: form.layananUnggulan?.content || '',
|
||||||
|
},
|
||||||
|
dokterdanTenagaMedis: {
|
||||||
|
name: form.dokterdanTenagaMedis?.name || '',
|
||||||
|
specialist: form.dokterdanTenagaMedis?.specialist || '',
|
||||||
|
jadwal: form.dokterdanTenagaMedis?.jadwal || '',
|
||||||
|
},
|
||||||
|
fasilitasPendukung: {
|
||||||
|
content: form.fasilitasPendukung?.content || '',
|
||||||
|
},
|
||||||
|
prosedurPendaftaran: {
|
||||||
|
content: form.prosedurPendaftaran?.content || '',
|
||||||
|
},
|
||||||
|
tarifDanLayanan: {
|
||||||
|
layanan: form.tarifDanLayanan?.layanan || '',
|
||||||
|
tarif: form.tarifDanLayanan?.tarif || '',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error loading fasilitas kesehatan:", error);
|
||||||
|
toast.error("Gagal memuat data fasilitas kesehatan");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
loadFasilitasKesehatan();
|
||||||
|
}, [params?.id]);
|
||||||
|
|
||||||
|
const handleSubmit = async () => {
|
||||||
|
try {
|
||||||
|
stateFasilitasKesehatan.edit.form = {
|
||||||
|
...stateFasilitasKesehatan.edit.form,
|
||||||
|
name: formData.name,
|
||||||
|
informasiUmum: {
|
||||||
|
fasilitas: formData.informasiUmum.fasilitas,
|
||||||
|
alamat: formData.informasiUmum.alamat,
|
||||||
|
jamOperasional: formData.informasiUmum.jamOperasional,
|
||||||
|
},
|
||||||
|
layananUnggulan: {
|
||||||
|
content: formData.layananUnggulan.content,
|
||||||
|
},
|
||||||
|
dokterdanTenagaMedis: {
|
||||||
|
name: formData.dokterdanTenagaMedis.name,
|
||||||
|
specialist: formData.dokterdanTenagaMedis.specialist,
|
||||||
|
jadwal: formData.dokterdanTenagaMedis.jadwal,
|
||||||
|
},
|
||||||
|
fasilitasPendukung: {
|
||||||
|
content: formData.fasilitasPendukung.content,
|
||||||
|
},
|
||||||
|
prosedurPendaftaran: {
|
||||||
|
content: formData.prosedurPendaftaran.content,
|
||||||
|
},
|
||||||
|
tarifDanLayanan: {
|
||||||
|
layanan: formData.tarifDanLayanan.layanan,
|
||||||
|
tarif: formData.tarifDanLayanan.tarif,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const success = await stateFasilitasKesehatan.edit.submit();
|
||||||
|
if (success) {
|
||||||
|
toast.success("Fasilitas kesehatan berhasil diperbarui!");
|
||||||
|
router.push("/admin/kesehatan/data-kesehatan-warga/fasilitas_kesehatan");
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error updating fasilitas kesehatan:", error);
|
||||||
|
toast.error(error instanceof Error ? error.message : "Gagal memperbarui data fasilitas kesehatan");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<Box>
|
||||||
|
<Box mb={10}>
|
||||||
|
<Button onClick={() => router.back()} variant="subtle" color="blue">
|
||||||
|
<IconArrowBack color={colors['blue-button']} size={25} />
|
||||||
|
</Button>
|
||||||
|
</Box>
|
||||||
|
<Stack gap="xs">
|
||||||
|
<Paper bg={colors['white-1']} p="md" w={{ base: '100%', md: '50%' }}>
|
||||||
|
<Stack gap="xs">
|
||||||
|
<Title order={3}>Edit Fasilitas Kesehatan</Title>
|
||||||
|
<TextInput
|
||||||
|
label={<Text fz="sm" fw="bold">Nama Fasilitas Kesehatan</Text>}
|
||||||
|
placeholder="masukkan nama fasilitas kesehatan"
|
||||||
|
value={formData.name}
|
||||||
|
onChange={(e) => {
|
||||||
|
setFormData(prev => ({
|
||||||
|
...prev,
|
||||||
|
name: e.target.value
|
||||||
|
}));
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Box>
|
||||||
|
<Text fz="md" fw="bold">Informasi Umum</Text>
|
||||||
|
<TextInput
|
||||||
|
label={<Text fz="sm" fw="bold">Fasilitas</Text>}
|
||||||
|
placeholder="masukkan fasilitas"
|
||||||
|
value={formData.informasiUmum.fasilitas}
|
||||||
|
onChange={(e) => {
|
||||||
|
setFormData(prev => ({
|
||||||
|
...prev,
|
||||||
|
informasiUmum: {
|
||||||
|
...prev.informasiUmum,
|
||||||
|
fasilitas: e.target.value
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<TextInput
|
||||||
|
label={<Text fz="sm" fw="bold">Alamat</Text>}
|
||||||
|
placeholder="masukkan alamat"
|
||||||
|
value={formData.informasiUmum.alamat}
|
||||||
|
onChange={(e) => {
|
||||||
|
setFormData(prev => ({
|
||||||
|
...prev,
|
||||||
|
informasiUmum: {
|
||||||
|
...prev.informasiUmum,
|
||||||
|
alamat: e.target.value
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<TextInput
|
||||||
|
label={<Text fz="sm" fw="bold">Jam Operasional</Text>}
|
||||||
|
placeholder="masukkan jam operasional"
|
||||||
|
value={formData.informasiUmum.jamOperasional}
|
||||||
|
onChange={(e) => {
|
||||||
|
setFormData(prev => ({
|
||||||
|
...prev,
|
||||||
|
informasiUmum: {
|
||||||
|
...prev.informasiUmum,
|
||||||
|
jamOperasional: e.target.value
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
<Box>
|
||||||
|
<Text fz="md" fw="bold">Layanan Unggulan</Text>
|
||||||
|
<EditEditor
|
||||||
|
value={formData.layananUnggulan.content}
|
||||||
|
onChange={(e) => {
|
||||||
|
setFormData(prev => ({
|
||||||
|
...prev,
|
||||||
|
layananUnggulan: {
|
||||||
|
...prev.layananUnggulan,
|
||||||
|
content: e
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
<Box>
|
||||||
|
<Text fz="md" fw="bold">Dokter dan Tenaga Medis</Text>
|
||||||
|
<TextInput
|
||||||
|
label={<Text fz="sm" fw="bold">Nama Dokter</Text>}
|
||||||
|
placeholder="masukkan nama dokter"
|
||||||
|
value={formData.dokterdanTenagaMedis.name}
|
||||||
|
onChange={(e) => {
|
||||||
|
setFormData(prev => ({
|
||||||
|
...prev,
|
||||||
|
dokterdanTenagaMedis: {
|
||||||
|
...prev.dokterdanTenagaMedis,
|
||||||
|
name: e.target.value
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<TextInput
|
||||||
|
label={<Text fz="sm" fw="bold">Specialist</Text>}
|
||||||
|
placeholder="masukkan specialist"
|
||||||
|
value={formData.dokterdanTenagaMedis.specialist}
|
||||||
|
onChange={(e) => {
|
||||||
|
setFormData(prev => ({
|
||||||
|
...prev,
|
||||||
|
dokterdanTenagaMedis: {
|
||||||
|
...prev.dokterdanTenagaMedis,
|
||||||
|
specialist: e.target.value
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<TextInput
|
||||||
|
label={<Text fz="sm" fw="bold">Jadwal</Text>}
|
||||||
|
placeholder="masukkan jadwal"
|
||||||
|
value={formData.dokterdanTenagaMedis.jadwal}
|
||||||
|
onChange={(e) => {
|
||||||
|
setFormData(prev => ({
|
||||||
|
...prev,
|
||||||
|
dokterdanTenagaMedis: {
|
||||||
|
...prev.dokterdanTenagaMedis,
|
||||||
|
jadwal: e.target.value
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
<Box>
|
||||||
|
<Text fz="md" fw="bold">Fasilitas Pendukung</Text>
|
||||||
|
<EditEditor
|
||||||
|
value={formData.fasilitasPendukung.content}
|
||||||
|
onChange={(e) => {
|
||||||
|
setFormData(prev => ({
|
||||||
|
...prev,
|
||||||
|
fasilitasPendukung: {
|
||||||
|
...prev.fasilitasPendukung,
|
||||||
|
content: e
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
<Box>
|
||||||
|
<Text fz="md" fw="bold">Prosedur Pendaftaran</Text>
|
||||||
|
<EditEditor
|
||||||
|
value={formData.prosedurPendaftaran.content}
|
||||||
|
onChange={(e) => {
|
||||||
|
setFormData(prev => ({
|
||||||
|
...prev,
|
||||||
|
prosedurPendaftaran: {
|
||||||
|
...prev.prosedurPendaftaran,
|
||||||
|
content: e
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
<Box>
|
||||||
|
<Text fz="md" fw="bold">Tarif dan Layanan</Text>
|
||||||
|
<TextInput
|
||||||
|
label={<Text fz="sm" fw="bold">Tarif</Text>}
|
||||||
|
placeholder="masukkan tarif"
|
||||||
|
value={formData.tarifDanLayanan.tarif}
|
||||||
|
onChange={(e) => {
|
||||||
|
setFormData(prev => ({
|
||||||
|
...prev,
|
||||||
|
tarifDanLayanan: {
|
||||||
|
...prev.tarifDanLayanan,
|
||||||
|
tarif: e.target.value
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<TextInput
|
||||||
|
label={<Text fz="sm" fw="bold">Layanan</Text>}
|
||||||
|
placeholder="masukkan layanan"
|
||||||
|
value={formData.tarifDanLayanan.layanan}
|
||||||
|
onChange={(e) => {
|
||||||
|
setFormData(prev => ({
|
||||||
|
...prev,
|
||||||
|
tarifDanLayanan: {
|
||||||
|
...prev.tarifDanLayanan,
|
||||||
|
layanan: e.target.value
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
onClick={handleSubmit}
|
||||||
|
bg={colors['blue-button']}
|
||||||
|
loading={stateFasilitasKesehatan.edit.loading}
|
||||||
|
>
|
||||||
|
Simpan
|
||||||
|
</Button>
|
||||||
|
</Stack>
|
||||||
|
</Paper>
|
||||||
|
</Stack>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default EditFasilitasKesehatan;
|
||||||
@@ -0,0 +1,127 @@
|
|||||||
|
'use client'
|
||||||
|
import { ModalKonfirmasiHapus } from '@/app/admin/(dashboard)/_com/modalKonfirmasiHapus';
|
||||||
|
import fasilitasKesehatanState from '@/app/admin/(dashboard)/_state/kesehatan/data_kesehatan_warga/fasilitasKesehatan';
|
||||||
|
import colors from '@/con/colors';
|
||||||
|
import { Box, Button, Flex, Paper, Skeleton, Stack, Text } from '@mantine/core';
|
||||||
|
import { useShallowEffect } from '@mantine/hooks';
|
||||||
|
import { IconArrowBack, IconEdit, IconX } from '@tabler/icons-react';
|
||||||
|
import { useParams, useRouter } from 'next/navigation';
|
||||||
|
import { useState } from 'react';
|
||||||
|
import { useProxy } from 'valtio/utils';
|
||||||
|
|
||||||
|
function DetailFasilitasKesehatan() {
|
||||||
|
const params = useParams()
|
||||||
|
const router = useRouter();
|
||||||
|
const stateFasilitasKesehatan = useProxy(fasilitasKesehatanState)
|
||||||
|
const [modalHapus, setModalHapus] = useState(false);
|
||||||
|
const [selectedId, setSelectedId] = useState<string | null>(null)
|
||||||
|
|
||||||
|
useShallowEffect(() => {
|
||||||
|
stateFasilitasKesehatan.findUnique.load(params?.id as string)
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
const handleHapus = () => {
|
||||||
|
if (selectedId) {
|
||||||
|
stateFasilitasKesehatan.delete.byId(selectedId)
|
||||||
|
setModalHapus(false)
|
||||||
|
setSelectedId(null)
|
||||||
|
router.push("/admin/kesehatan/data-kesehatan-warga/fasilitas_kesehatan")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!stateFasilitasKesehatan.findUnique.data) {
|
||||||
|
return (
|
||||||
|
<Stack py={10}>
|
||||||
|
<Skeleton h={500} />
|
||||||
|
</Stack>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box>
|
||||||
|
<Box mb={10}>
|
||||||
|
<Button variant="subtle" onClick={() => router.back()}>
|
||||||
|
<IconArrowBack color={colors['blue-button']} size={25} />
|
||||||
|
</Button>
|
||||||
|
</Box>
|
||||||
|
<Paper w={{ base: "100%", md: "50%" }} bg={colors['white-1']} p={'md'}>
|
||||||
|
<Stack>
|
||||||
|
<Text fz={"xl"} fw={"bold"}>Detail Fasilitas Kesehatan</Text>
|
||||||
|
{stateFasilitasKesehatan.findUnique.data ? (
|
||||||
|
<Paper bg={colors['BG-trans']} p={'md'}>
|
||||||
|
<Stack gap={"xs"}>
|
||||||
|
<Box>
|
||||||
|
<Text fz={"lg"} fw={"bold"}>Nama Fasilitas Kesehatan</Text>
|
||||||
|
<Text fz={"md"}>{stateFasilitasKesehatan.findUnique.data.name}</Text>
|
||||||
|
</Box>
|
||||||
|
<Box>
|
||||||
|
<Text fz={"lg"} fw={"bold"}>Informasi Umum</Text>
|
||||||
|
<Text fz={"md"} fw={"bold"}>Fasilitas</Text>
|
||||||
|
<Text fz={"md"}>{stateFasilitasKesehatan.findUnique.data.informasiumum.fasilitas}</Text>
|
||||||
|
<Text fz={"md"} fw={"bold"}>Alamat</Text>
|
||||||
|
<Text fz={"md"}>{stateFasilitasKesehatan.findUnique.data.informasiumum.alamat}</Text>
|
||||||
|
<Text fz={"md"} fw={"bold"}>Jam Operasional</Text>
|
||||||
|
<Text fz={"md"}>{stateFasilitasKesehatan.findUnique.data.informasiumum.jamOperasional}</Text>
|
||||||
|
</Box>
|
||||||
|
<Box>
|
||||||
|
<Text fz={"md"} fw={"bold"}>Layanan Unggulan</Text>
|
||||||
|
<Text fz={"md"} dangerouslySetInnerHTML={{ __html: stateFasilitasKesehatan.findUnique.data.layananunggulan.content }} />
|
||||||
|
</Box>
|
||||||
|
<Box>
|
||||||
|
<Text fz={"md"} fw={"bold"}>Dokter dan Tenaga Medis</Text>
|
||||||
|
<Text fz={"md"} fw={"bold"}>Nama Dokter</Text>
|
||||||
|
<Text fz={"md"}>{stateFasilitasKesehatan.findUnique.data.dokterdantenagamedis.name}</Text>
|
||||||
|
<Text fz={"md"} fw={"bold"}>Specialist</Text>
|
||||||
|
<Text fz={"md"}>{stateFasilitasKesehatan.findUnique.data.dokterdantenagamedis.specialist}</Text>
|
||||||
|
<Text fz={"md"} fw={"bold"}>Jadwal</Text>
|
||||||
|
<Text fz={"md"}>{stateFasilitasKesehatan.findUnique.data.dokterdantenagamedis.jadwal}</Text>
|
||||||
|
</Box>
|
||||||
|
<Box>
|
||||||
|
<Text fz={"lg"} fw={"bold"}>Fasilitas Pendukung</Text>
|
||||||
|
<Text fz={"md"} dangerouslySetInnerHTML={{ __html: stateFasilitasKesehatan.findUnique.data.fasilitaspendukung.content }} />
|
||||||
|
</Box>
|
||||||
|
<Box>
|
||||||
|
<Text fz={"lg"} fw={"bold"}>Prosedur Pendaftaran</Text>
|
||||||
|
<Text fz={"md"} dangerouslySetInnerHTML={{ __html: stateFasilitasKesehatan.findUnique.data.prosedurpendaftaran.content }} />
|
||||||
|
</Box>
|
||||||
|
<Box>
|
||||||
|
<Text fz={"lg"} fw={"bold"}>Tarif dan Layanan</Text>
|
||||||
|
<Text fz={"md"} fw={"bold"}>Layanan</Text>
|
||||||
|
<Text fz={"md"}>{stateFasilitasKesehatan.findUnique.data.tarifdanlayanan.layanan}</Text>
|
||||||
|
<Text fz={"md"} fw={"bold"}>Tarif</Text>
|
||||||
|
<Text fz={"md"}>{stateFasilitasKesehatan.findUnique.data.tarifdanlayanan.tarif}</Text>
|
||||||
|
</Box>
|
||||||
|
<Box>
|
||||||
|
<Flex gap={"xs"}>
|
||||||
|
<Button color="red" onClick={() => {
|
||||||
|
if (stateFasilitasKesehatan.findUnique.data) {
|
||||||
|
setSelectedId(stateFasilitasKesehatan.findUnique.data.id)
|
||||||
|
setModalHapus(true)
|
||||||
|
}
|
||||||
|
}}>
|
||||||
|
<IconX size={20} />
|
||||||
|
</Button>
|
||||||
|
<Button onClick={() => router.push(`/admin/kesehatan/data-kesehatan-warga/fasilitas_kesehatan/${stateFasilitasKesehatan.findUnique.data?.id}/edit`)} color="green">
|
||||||
|
<IconEdit size={20} />
|
||||||
|
</Button>
|
||||||
|
</Flex>
|
||||||
|
</Box>
|
||||||
|
</Stack>
|
||||||
|
</Paper>
|
||||||
|
) : null}
|
||||||
|
</Stack>
|
||||||
|
</Paper>
|
||||||
|
|
||||||
|
{/* Modal Hapus */}
|
||||||
|
<ModalKonfirmasiHapus
|
||||||
|
opened={modalHapus}
|
||||||
|
onClose={() => setModalHapus(false)}
|
||||||
|
onConfirm={handleHapus}
|
||||||
|
text="Apakah anda yakin ingin menghapus fasilitas kesehatan ini?"
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default DetailFasilitasKesehatan;
|
||||||
@@ -0,0 +1,187 @@
|
|||||||
|
'use client'
|
||||||
|
import CreateEditor from '@/app/admin/(dashboard)/_com/createEditor';
|
||||||
|
import fasilitasKesehatanState from '@/app/admin/(dashboard)/_state/kesehatan/data_kesehatan_warga/fasilitasKesehatan';
|
||||||
|
import colors from '@/con/colors';
|
||||||
|
import { Box, Button, Paper, Stack, Text, TextInput, Title } from '@mantine/core';
|
||||||
|
import { IconArrowBack } from '@tabler/icons-react';
|
||||||
|
import { useRouter } from 'next/navigation';
|
||||||
|
import { toast } from 'react-toastify';
|
||||||
|
import { useProxy } from 'valtio/utils';
|
||||||
|
|
||||||
|
|
||||||
|
function CreateFasilitasKesehatan() {
|
||||||
|
const stateFasilitasKesehatan = useProxy(fasilitasKesehatanState)
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
|
||||||
|
const resetForm = () => {
|
||||||
|
stateFasilitasKesehatan.create.form = {
|
||||||
|
name: "",
|
||||||
|
informasiUmum: {
|
||||||
|
fasilitas: "",
|
||||||
|
alamat: "",
|
||||||
|
jamOperasional: "",
|
||||||
|
},
|
||||||
|
layananUnggulan: {
|
||||||
|
content: "",
|
||||||
|
},
|
||||||
|
dokterdanTenagaMedis: {
|
||||||
|
name: "",
|
||||||
|
specialist: "",
|
||||||
|
jadwal: "",
|
||||||
|
},
|
||||||
|
fasilitasPendukung: {
|
||||||
|
content: "",
|
||||||
|
},
|
||||||
|
prosedurPendaftaran: {
|
||||||
|
content: "",
|
||||||
|
},
|
||||||
|
tarifDanLayanan: {
|
||||||
|
layanan: "",
|
||||||
|
tarif: "",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const handleSubmit = async (e: React.FormEvent) => {
|
||||||
|
e.preventDefault();
|
||||||
|
await stateFasilitasKesehatan.create.submit();
|
||||||
|
|
||||||
|
toast.success("Data berhasil disimpan");
|
||||||
|
resetForm();
|
||||||
|
// After successful submission, redirect to the list page
|
||||||
|
router.push('/admin/kesehatan/data-kesehatan-warga/fasilitas_kesehatan');
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box component="form" onSubmit={handleSubmit}>
|
||||||
|
<Box mb={10}>
|
||||||
|
<Button variant="subtle" onClick={() => router.back()}>
|
||||||
|
<IconArrowBack color={colors['blue-button']} size={25} />
|
||||||
|
</Button>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
<Paper bg={colors['white-1']} p="md" w={{ base: '100%', md: '50%' }}>
|
||||||
|
<Stack gap="xs">
|
||||||
|
<Title order={3}>Create Fasilitas Kesehatan</Title>
|
||||||
|
<TextInput
|
||||||
|
label={<Text fz="sm" fw="bold">Nama Fasilitas Kesehatan</Text>}
|
||||||
|
placeholder="masukkan nama fasilitas kesehatan"
|
||||||
|
value={stateFasilitasKesehatan.create.form.name}
|
||||||
|
onChange={(e) => {
|
||||||
|
stateFasilitasKesehatan.create.form.name = e.target.value;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Box>
|
||||||
|
<Text fz="md" fw="bold">Informasi Umum</Text>
|
||||||
|
<TextInput
|
||||||
|
label={<Text fz="sm" fw="bold">Fasilitas</Text>}
|
||||||
|
placeholder="masukkan fasilitas"
|
||||||
|
value={stateFasilitasKesehatan.create.form.informasiUmum.fasilitas}
|
||||||
|
onChange={(e) => {
|
||||||
|
stateFasilitasKesehatan.create.form.informasiUmum.fasilitas = e.target.value;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<TextInput
|
||||||
|
label={<Text fz="sm" fw="bold">Alamat</Text>}
|
||||||
|
placeholder="masukkan alamat"
|
||||||
|
value={stateFasilitasKesehatan.create.form.informasiUmum.alamat}
|
||||||
|
onChange={(e) => {
|
||||||
|
stateFasilitasKesehatan.create.form.informasiUmum.alamat = e.target.value;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<TextInput
|
||||||
|
label={<Text fz="sm" fw="bold">Jam Operasional</Text>}
|
||||||
|
placeholder="masukkan jam operasional"
|
||||||
|
value={stateFasilitasKesehatan.create.form.informasiUmum.jamOperasional}
|
||||||
|
onChange={(e) => {
|
||||||
|
stateFasilitasKesehatan.create.form.informasiUmum.jamOperasional = e.target.value;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
<Box>
|
||||||
|
<Text fz="md" fw="bold">Layanan Unggulan</Text>
|
||||||
|
<CreateEditor
|
||||||
|
value={stateFasilitasKesehatan.create.form.layananUnggulan.content}
|
||||||
|
onChange={(e) => {
|
||||||
|
stateFasilitasKesehatan.create.form.layananUnggulan.content = e;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
<Box>
|
||||||
|
<Text fz="md" fw="bold">Dokter dan Tenaga Medis</Text>
|
||||||
|
<TextInput
|
||||||
|
label={<Text fz="sm" fw="bold">Nama Dokter</Text>}
|
||||||
|
placeholder="masukkan nama dokter"
|
||||||
|
value={stateFasilitasKesehatan.create.form.dokterdanTenagaMedis.name}
|
||||||
|
onChange={(e) => {
|
||||||
|
stateFasilitasKesehatan.create.form.dokterdanTenagaMedis.name = e.target.value;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<TextInput
|
||||||
|
label={<Text fz="sm" fw="bold">Specialist</Text>}
|
||||||
|
placeholder="masukkan specialist"
|
||||||
|
value={stateFasilitasKesehatan.create.form.dokterdanTenagaMedis.specialist}
|
||||||
|
onChange={(e) => {
|
||||||
|
stateFasilitasKesehatan.create.form.dokterdanTenagaMedis.specialist = e.target.value;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<TextInput
|
||||||
|
label={<Text fz="sm" fw="bold">Jadwal</Text>}
|
||||||
|
placeholder="masukkan jadwal"
|
||||||
|
value={stateFasilitasKesehatan.create.form.dokterdanTenagaMedis.jadwal}
|
||||||
|
onChange={(e) => {
|
||||||
|
stateFasilitasKesehatan.create.form.dokterdanTenagaMedis.jadwal = e.target.value;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
<Box>
|
||||||
|
<Text fz="md" fw="bold">Fasilitas Pendukung</Text>
|
||||||
|
<CreateEditor
|
||||||
|
value={stateFasilitasKesehatan.create.form.fasilitasPendukung.content}
|
||||||
|
onChange={(e) => {
|
||||||
|
stateFasilitasKesehatan.create.form.fasilitasPendukung.content = e;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
<Box>
|
||||||
|
<Text fz="md" fw="bold">Prosedur Pendaftaran</Text>
|
||||||
|
<CreateEditor
|
||||||
|
value={stateFasilitasKesehatan.create.form.prosedurPendaftaran.content}
|
||||||
|
onChange={(e) => {
|
||||||
|
stateFasilitasKesehatan.create.form.prosedurPendaftaran.content = e;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
<Box>
|
||||||
|
<Text fz="md" fw="bold">Tarif dan Layanan</Text>
|
||||||
|
<TextInput
|
||||||
|
label={<Text fz="sm" fw="bold">Tarif</Text>}
|
||||||
|
placeholder="masukkan tarif"
|
||||||
|
value={stateFasilitasKesehatan.create.form.tarifDanLayanan.tarif}
|
||||||
|
onChange={(e) => {
|
||||||
|
stateFasilitasKesehatan.create.form.tarifDanLayanan.tarif = e.target.value;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<TextInput
|
||||||
|
label={<Text fz="sm" fw="bold">Layanan</Text>}
|
||||||
|
placeholder="masukkan layanan"
|
||||||
|
value={stateFasilitasKesehatan.create.form.tarifDanLayanan.layanan}
|
||||||
|
onChange={(e) => {
|
||||||
|
stateFasilitasKesehatan.create.form.tarifDanLayanan.layanan = e.target.value;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
<Button onClick={handleSubmit} bg={colors['blue-button']}>
|
||||||
|
Simpan
|
||||||
|
</Button>
|
||||||
|
</Stack>
|
||||||
|
</Paper>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default CreateFasilitasKesehatan;
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
'use client'
|
||||||
|
import colors from '@/con/colors';
|
||||||
|
import { Box, Button, Paper, Skeleton, Stack, Table, TableTbody, TableTd, TableTh, TableThead, TableTr } from '@mantine/core';
|
||||||
|
import { useShallowEffect } from '@mantine/hooks';
|
||||||
|
import { IconDeviceImacCog, IconSearch } from '@tabler/icons-react';
|
||||||
|
import { useRouter } from 'next/navigation';
|
||||||
|
import { useProxy } from 'valtio/utils';
|
||||||
|
import fasilitasKesehatanState from '../../../_state/kesehatan/data_kesehatan_warga/fasilitasKesehatan';
|
||||||
|
import HeaderSearch from '../../../_com/header';
|
||||||
|
import JudulList from '../../../_com/judulList';
|
||||||
|
|
||||||
|
|
||||||
|
function FasilitasKesehatan() {
|
||||||
|
return (
|
||||||
|
<Box>
|
||||||
|
<HeaderSearch
|
||||||
|
title='Fasilitas Kesehatan'
|
||||||
|
placeholder='pencarian'
|
||||||
|
searchIcon={<IconSearch size={20} />}
|
||||||
|
/>
|
||||||
|
<ListFasilitasKesehatan/>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function ListFasilitasKesehatan() {
|
||||||
|
const stateFasilitasKesehatan = useProxy(fasilitasKesehatanState)
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
useShallowEffect(() => {
|
||||||
|
stateFasilitasKesehatan.findMany.load()
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
if (!stateFasilitasKesehatan.findMany.data) {
|
||||||
|
return (
|
||||||
|
<Box py={10}>
|
||||||
|
<Skeleton h={500}/>
|
||||||
|
</Box>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<Box py={10}>
|
||||||
|
<Paper bg={colors['white-1']} p={'md'}>
|
||||||
|
<Stack>
|
||||||
|
<JudulList
|
||||||
|
title='List Fasilitas Kesehatan'
|
||||||
|
href='/admin/kesehatan/data-kesehatan-warga/fasilitas_kesehatan/create'
|
||||||
|
/>
|
||||||
|
<Box style={{ overflowX: "auto" }}>
|
||||||
|
<Table striped withRowBorders withTableBorder style={{ minWidth: '700px' }}>
|
||||||
|
<TableThead>
|
||||||
|
<TableTr>
|
||||||
|
<TableTh>Fasilitas Kesehatan</TableTh>
|
||||||
|
<TableTh>Alamat</TableTh>
|
||||||
|
<TableTh>Jam Operasional</TableTh>
|
||||||
|
<TableTh>Detail</TableTh>
|
||||||
|
</TableTr>
|
||||||
|
</TableThead>
|
||||||
|
<TableTbody>
|
||||||
|
{stateFasilitasKesehatan.findMany.data?.map((item) => (
|
||||||
|
<TableTr key={item.id}>
|
||||||
|
<TableTd>{item.name}</TableTd>
|
||||||
|
<TableTd>{item.informasiumum.alamat}</TableTd>
|
||||||
|
<TableTd>{item.informasiumum.jamOperasional}</TableTd>
|
||||||
|
<TableTd>
|
||||||
|
<Button onClick={() => router.push(`/admin/kesehatan/data-kesehatan-warga/fasilitas_kesehatan/${item.id}`)}>
|
||||||
|
<IconDeviceImacCog size={25} />
|
||||||
|
</Button>
|
||||||
|
</TableTd>
|
||||||
|
</TableTr>
|
||||||
|
))}
|
||||||
|
</TableTbody>
|
||||||
|
</Table>
|
||||||
|
</Box>
|
||||||
|
</Stack>
|
||||||
|
</Paper>
|
||||||
|
</Box>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default FasilitasKesehatan;
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
|
'use client'
|
||||||
|
|
||||||
|
import grafikkepuasan from '@/app/admin/(dashboard)/_state/kesehatan/data_kesehatan_warga/grafikKepuasan';
|
||||||
|
import colors from '@/con/colors';
|
||||||
|
import { Box, Button, Paper, Stack, TextInput, Title } from '@mantine/core';
|
||||||
|
import { IconArrowBack } from '@tabler/icons-react';
|
||||||
|
import { useParams, useRouter } from 'next/navigation';
|
||||||
|
import { useEffect } from 'react';
|
||||||
|
import { useProxy } from 'valtio/utils';
|
||||||
|
|
||||||
|
function EditGrafikHasilKepuasan() {
|
||||||
|
const router = useRouter()
|
||||||
|
const params = useParams() as { uuid: string }
|
||||||
|
const stateGrafikKepuasan = useProxy(grafikkepuasan)
|
||||||
|
|
||||||
|
const uuid = params.uuid
|
||||||
|
|
||||||
|
// Load data saat komponen mount
|
||||||
|
useEffect(() => {
|
||||||
|
if (uuid) {
|
||||||
|
stateGrafikKepuasan.findUnique.load(uuid).then(() => {
|
||||||
|
const data = stateGrafikKepuasan.findUnique.data
|
||||||
|
if (data) {
|
||||||
|
stateGrafikKepuasan.update.form = {
|
||||||
|
label: data.label || '',
|
||||||
|
jumlah: data.jumlah || '',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}, [uuid])
|
||||||
|
|
||||||
|
const handleSubmit = async () => {
|
||||||
|
// Set the ID before submitting
|
||||||
|
stateGrafikKepuasan.update.uuid = uuid;
|
||||||
|
await stateGrafikKepuasan.update.submit();
|
||||||
|
router.push('/admin/kesehatan/data-kesehatan-warga/grafik_hasil_kepuasan')
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<Box>
|
||||||
|
<Box mb={10}>
|
||||||
|
<Button variant="subtle" onClick={() => router.back()}>
|
||||||
|
<IconArrowBack size={20} />
|
||||||
|
</Button>
|
||||||
|
</Box>
|
||||||
|
<Paper bg={colors['white-1']} w={{ base: '100%', md: '50%' }} p={'md'}>
|
||||||
|
<Stack>
|
||||||
|
<Title order={3}>Edit Grafik Hasil Kepuasan</Title>
|
||||||
|
<TextInput
|
||||||
|
label="Label"
|
||||||
|
placeholder="masukkan label"
|
||||||
|
value={stateGrafikKepuasan.update.form.label}
|
||||||
|
onChange={(val) => {
|
||||||
|
stateGrafikKepuasan.update.form.label = val.currentTarget.value;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<TextInput
|
||||||
|
label="Jumlah"
|
||||||
|
type="number"
|
||||||
|
placeholder="masukkan jumlah"
|
||||||
|
value={stateGrafikKepuasan.update.form.jumlah}
|
||||||
|
onChange={(val) => {
|
||||||
|
stateGrafikKepuasan.update.form.jumlah = val.currentTarget.value;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
mt={10}
|
||||||
|
bg={colors['blue-button']}
|
||||||
|
onClick={handleSubmit}
|
||||||
|
>
|
||||||
|
Simpan
|
||||||
|
</Button>
|
||||||
|
</Stack>
|
||||||
|
</Paper>
|
||||||
|
</Box>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default EditGrafikHasilKepuasan;
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||||
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
|
'use client'
|
||||||
|
import grafikkepuasan from '@/app/admin/(dashboard)/_state/kesehatan/data_kesehatan_warga/grafikKepuasan';
|
||||||
|
import colors from '@/con/colors';
|
||||||
|
import { Box, Button, Group, Paper, Stack, TextInput, Title } from '@mantine/core';
|
||||||
|
import { IconArrowBack } from '@tabler/icons-react';
|
||||||
|
import { useRouter } from 'next/navigation';
|
||||||
|
import { useState } from 'react';
|
||||||
|
import { useProxy } from 'valtio/utils';
|
||||||
|
|
||||||
|
function CreateGrafikHasilKepuasanMasyarakat() {
|
||||||
|
const stateGrafikKepuasan = useProxy(grafikkepuasan);
|
||||||
|
const [chartData, setChartData] = useState<any[]>([]);
|
||||||
|
const router = useRouter()
|
||||||
|
|
||||||
|
const resetForm = () => {
|
||||||
|
stateGrafikKepuasan.create.form = {
|
||||||
|
label: "",
|
||||||
|
jumlah: "",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleSubmit = async () => {
|
||||||
|
const id = await stateGrafikKepuasan.create.create();
|
||||||
|
if (id) {
|
||||||
|
const idStr = String(id);
|
||||||
|
await stateGrafikKepuasan.findUnique.load(idStr);
|
||||||
|
if (stateGrafikKepuasan.findUnique.data) {
|
||||||
|
setChartData([stateGrafikKepuasan.findUnique.data]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
resetForm();
|
||||||
|
router.push("/admin/kesehatan/data-kesehatan-warga/grafik_hasil_kepuasan");
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<Box>
|
||||||
|
<Box mb={10}>
|
||||||
|
<Button variant="subtle" onClick={() => router.back()}>
|
||||||
|
<IconArrowBack size={20} />
|
||||||
|
</Button>
|
||||||
|
</Box>
|
||||||
|
<Box>
|
||||||
|
<Paper w={{ base: '100%', md: '50%' }} bg={colors['white-1']} p={'md'}>
|
||||||
|
<Title order={4}>Tambah Grafik Hasil Kepuasan Masyarakat</Title>
|
||||||
|
<Stack gap={"xs"}>
|
||||||
|
<TextInput
|
||||||
|
label="Label"
|
||||||
|
type="text"
|
||||||
|
value={stateGrafikKepuasan.create.form.label}
|
||||||
|
placeholder="Masukkan label"
|
||||||
|
onChange={(val) => {
|
||||||
|
stateGrafikKepuasan.create.form.label = val.currentTarget.value;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<TextInput
|
||||||
|
label="Jumlah"
|
||||||
|
type="number"
|
||||||
|
value={stateGrafikKepuasan.create.form.jumlah}
|
||||||
|
placeholder="Masukkan jumlah"
|
||||||
|
onChange={(val) => {
|
||||||
|
stateGrafikKepuasan.create.form.jumlah = val.currentTarget.value;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Group>
|
||||||
|
<Button
|
||||||
|
bg={colors['blue-button']}
|
||||||
|
mt={10}
|
||||||
|
onClick={handleSubmit}
|
||||||
|
>
|
||||||
|
Submit
|
||||||
|
</Button>
|
||||||
|
</Group>
|
||||||
|
</Stack>
|
||||||
|
</Paper>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default CreateGrafikHasilKepuasanMasyarakat;
|
||||||
@@ -0,0 +1,148 @@
|
|||||||
|
'use client'
|
||||||
|
import colors from '@/con/colors';
|
||||||
|
import { Box, Button, Paper, Skeleton, Stack, Table, TableTbody, TableTd, TableTh, TableThead, TableTr, Text, Title } from '@mantine/core';
|
||||||
|
import { useMediaQuery, useShallowEffect } from '@mantine/hooks';
|
||||||
|
import { IconEdit, IconSearch, IconTrash } from '@tabler/icons-react';
|
||||||
|
import { useRouter } from 'next/navigation';
|
||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
import { Bar, BarChart, Legend, Tooltip, XAxis, YAxis } from 'recharts';
|
||||||
|
import { useProxy } from 'valtio/utils';
|
||||||
|
import JudulListTab from '../../../_com/jusulListTab';
|
||||||
|
import { ModalKonfirmasiHapus } from '../../../_com/modalKonfirmasiHapus';
|
||||||
|
import grafikkepuasan from '../../../_state/kesehatan/data_kesehatan_warga/grafikKepuasan';
|
||||||
|
|
||||||
|
function GrafikHasilKepuasanMasyarakat() {
|
||||||
|
type PDKMGrafik = {
|
||||||
|
id: string;
|
||||||
|
label: string;
|
||||||
|
jumlah: number;
|
||||||
|
}
|
||||||
|
const stateGrafikKepuasan = useProxy(grafikkepuasan);
|
||||||
|
const [chartData, setChartData] = useState<PDKMGrafik[]>([]);
|
||||||
|
const [mounted, setMounted] = useState(false); // untuk memastikan DOM sudah ready
|
||||||
|
const isTablet = useMediaQuery('(max-width: 1024px)')
|
||||||
|
const isMobile = useMediaQuery('(max-width: 768px)')
|
||||||
|
const [modalHapus, setModalHapus] = useState(false)
|
||||||
|
const [selectedId, setSelectedId] = useState<string | null>(null)
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
const handleDelete = () => {
|
||||||
|
if (selectedId) {
|
||||||
|
stateGrafikKepuasan.delete.byId(selectedId)
|
||||||
|
setModalHapus(false)
|
||||||
|
setSelectedId(null)
|
||||||
|
|
||||||
|
stateGrafikKepuasan.findMany.load()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
useShallowEffect(() => {
|
||||||
|
setMounted(true)
|
||||||
|
stateGrafikKepuasan.findMany.load()
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setMounted(true);
|
||||||
|
if (stateGrafikKepuasan.findMany.data) {
|
||||||
|
setChartData(stateGrafikKepuasan.findMany.data.map((item) => ({
|
||||||
|
id: item.uuid,
|
||||||
|
label: item.label,
|
||||||
|
jumlah: Number(item.jumlah),
|
||||||
|
})));
|
||||||
|
}
|
||||||
|
}, [stateGrafikKepuasan.findMany.data]);
|
||||||
|
|
||||||
|
if (!stateGrafikKepuasan.findMany.data) {
|
||||||
|
return (
|
||||||
|
<Stack>
|
||||||
|
<Skeleton h={500} />
|
||||||
|
</Stack>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box>
|
||||||
|
<Stack gap={"xs"}>
|
||||||
|
{/* Form Input */}
|
||||||
|
<Paper bg={colors['white-1']} p={'md'}>
|
||||||
|
<JudulListTab
|
||||||
|
title='List Grafik Hasil Kepuasan Masyarakat'
|
||||||
|
href='/admin/kesehatan/data-kesehatan-warga/grafik_hasil_kepuasan/create'
|
||||||
|
placeholder='pencarian'
|
||||||
|
searchIcon={<IconSearch size={16} />}
|
||||||
|
/>
|
||||||
|
<Table striped withTableBorder withRowBorders>
|
||||||
|
<TableThead>
|
||||||
|
<TableTr>
|
||||||
|
<TableTh>Label</TableTh>
|
||||||
|
<TableTh>Jumlah</TableTh>
|
||||||
|
<TableTh>Edit</TableTh>
|
||||||
|
<TableTh>Delete</TableTh>
|
||||||
|
</TableTr>
|
||||||
|
</TableThead>
|
||||||
|
<TableTbody>
|
||||||
|
{stateGrafikKepuasan.findMany.data?.map((item) => (
|
||||||
|
<TableTr key={item.uuid}>
|
||||||
|
<TableTd>{item.label}</TableTd>
|
||||||
|
<TableTd>{item.jumlah}</TableTd>
|
||||||
|
<TableTd>
|
||||||
|
<Button color='green' onClick={() => router.push(`/admin/kesehatan/data-kesehatan-warga/grafik_hasil_kepuasan/${item.uuid}`)}>
|
||||||
|
<IconEdit size={20} />
|
||||||
|
</Button>
|
||||||
|
</TableTd>
|
||||||
|
<TableTd>
|
||||||
|
<Button
|
||||||
|
color='red'
|
||||||
|
disabled={stateGrafikKepuasan.delete.loading}
|
||||||
|
onClick={() => {
|
||||||
|
setSelectedId(item.uuid)
|
||||||
|
setModalHapus(true)
|
||||||
|
}}>
|
||||||
|
<IconTrash size={20} />
|
||||||
|
</Button>
|
||||||
|
</TableTd>
|
||||||
|
</TableTr>
|
||||||
|
))}
|
||||||
|
</TableTbody>
|
||||||
|
</Table>
|
||||||
|
</Paper>
|
||||||
|
|
||||||
|
|
||||||
|
{/* Chart */}
|
||||||
|
{!mounted && !chartData ? (
|
||||||
|
<Box style={{ width: '100%', minWidth: 300, height: 400, minHeight: 300 }}>
|
||||||
|
<Paper bg={colors['white-1']} p={'md'}>
|
||||||
|
<Title pb={10} order={3}>Grafik Hasil Kepuasan Masyarakat</Title>
|
||||||
|
<Text c='dimmed'>Belum ada data untuk ditampilkan dalam grafik</Text>
|
||||||
|
</Paper>
|
||||||
|
</Box>
|
||||||
|
) : (
|
||||||
|
<Box style={{ width: '100%', minWidth: 300, height: 400, minHeight: 300 }}>
|
||||||
|
<Paper bg={colors['white-1']} p={'md'}>
|
||||||
|
<Title pb={10} order={4}>Grafik Hasil Kepuasan Masyarakat</Title>
|
||||||
|
{mounted && chartData.length > 0 && (
|
||||||
|
<BarChart width={isMobile ? 450 : isTablet ? 500 : 550} height={350} data={chartData} >
|
||||||
|
<XAxis dataKey="label" />
|
||||||
|
<YAxis />
|
||||||
|
<Tooltip />
|
||||||
|
<Legend />
|
||||||
|
<Bar dataKey="jumlah" fill={colors['blue-button']} name="Jumlah" />
|
||||||
|
</BarChart>
|
||||||
|
)}
|
||||||
|
</Paper>
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
|
</Stack>
|
||||||
|
|
||||||
|
{/* Modal Konfirmasi Hapus */}
|
||||||
|
<ModalKonfirmasiHapus
|
||||||
|
opened={modalHapus}
|
||||||
|
onClose={() => setModalHapus(false)}
|
||||||
|
onConfirm={handleDelete}
|
||||||
|
text='Apakah anda yakin ingin menghapus grafik hasil kepuasan masyarakat ini?'
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default GrafikHasilKepuasanMasyarakat;
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
|
'use client'
|
||||||
import stateJadwalKegiatan from '@/app/admin/(dashboard)/_state/kesehatan/data_kesehatan_warga/jadwalKegiatan';
|
import stateJadwalKegiatan from '@/app/admin/(dashboard)/_state/kesehatan/data_kesehatan_warga/jadwalKegiatan';
|
||||||
|
import colors from '@/con/colors';
|
||||||
import { Box, Paper, Stack, Text } from '@mantine/core';
|
import { Box, Paper, Stack, Text } from '@mantine/core';
|
||||||
import { useProxy } from 'valtio/utils';
|
import { useProxy } from 'valtio/utils';
|
||||||
import { KesehatanEditor } from '../../../_com/kesehatanEditor';
|
import { KesehatanEditor } from '../../_com/kesehatanEditor';
|
||||||
import colors from '@/con/colors';
|
|
||||||
|
|
||||||
function DeskripsiKegiatan() {
|
function DeskripsiKegiatan() {
|
||||||
const deskripsiKegiatanState = useProxy(stateJadwalKegiatan.deskripsiKegiatan)
|
const deskripsiKegiatanState = useProxy(stateJadwalKegiatan.deskripsiKegiatan)
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
|
'use client'
|
||||||
import stateJadwalKegiatan from '@/app/admin/(dashboard)/_state/kesehatan/data_kesehatan_warga/jadwalKegiatan';
|
import stateJadwalKegiatan from '@/app/admin/(dashboard)/_state/kesehatan/data_kesehatan_warga/jadwalKegiatan';
|
||||||
|
import colors from '@/con/colors';
|
||||||
import { Box, Paper, Stack, Text } from '@mantine/core';
|
import { Box, Paper, Stack, Text } from '@mantine/core';
|
||||||
import { useProxy } from 'valtio/utils';
|
import { useProxy } from 'valtio/utils';
|
||||||
import { KesehatanEditor } from '../../../_com/kesehatanEditor';
|
import { KesehatanEditor } from '../../_com/kesehatanEditor';
|
||||||
import colors from '@/con/colors';
|
|
||||||
|
|
||||||
function DokumenYangDiperlukan() {
|
function DokumenYangDiperlukan() {
|
||||||
const dokumenDiperlukan = useProxy(stateJadwalKegiatan.dokumenjadwalkegiatan)
|
const dokumenDiperlukan = useProxy(stateJadwalKegiatan.dokumenjadwalkegiatan)
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
'use client'
|
||||||
import stateJadwalKegiatan from '@/app/admin/(dashboard)/_state/kesehatan/data_kesehatan_warga/jadwalKegiatan';
|
import stateJadwalKegiatan from '@/app/admin/(dashboard)/_state/kesehatan/data_kesehatan_warga/jadwalKegiatan';
|
||||||
import colors from '@/con/colors';
|
import colors from '@/con/colors';
|
||||||
import { Box, Paper, Stack, TextInput, Title } from '@mantine/core';
|
import { Box, Paper, Stack, TextInput, Title } from '@mantine/core';
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
|
'use client'
|
||||||
import stateJadwalKegiatan from '@/app/admin/(dashboard)/_state/kesehatan/data_kesehatan_warga/jadwalKegiatan';
|
import stateJadwalKegiatan from '@/app/admin/(dashboard)/_state/kesehatan/data_kesehatan_warga/jadwalKegiatan';
|
||||||
|
import colors from '@/con/colors';
|
||||||
import { Box, Paper, Stack, Text } from '@mantine/core';
|
import { Box, Paper, Stack, Text } from '@mantine/core';
|
||||||
import { useProxy } from 'valtio/utils';
|
import { useProxy } from 'valtio/utils';
|
||||||
import { KesehatanEditor } from '../../../_com/kesehatanEditor';
|
import { KesehatanEditor } from '../../_com/kesehatanEditor';
|
||||||
import colors from '@/con/colors';
|
|
||||||
|
|
||||||
function LayananTersedia() {
|
function LayananTersedia() {
|
||||||
const layananTersediaState = useProxy(stateJadwalKegiatan.layanantersedia)
|
const layananTersediaState = useProxy(stateJadwalKegiatan.layanantersedia)
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
import stateJadwalKegiatan from '@/app/admin/(dashboard)/_state/kesehatan/data_kesehatan_warga/jadwalKegiatan';
|
'use client'
|
||||||
|
import colors from '@/con/colors';
|
||||||
import { Box, Paper, Stack, Text } from '@mantine/core';
|
import { Box, Paper, Stack, Text } from '@mantine/core';
|
||||||
import { useProxy } from 'valtio/utils';
|
import { useProxy } from 'valtio/utils';
|
||||||
import { KesehatanEditor } from '../../../_com/kesehatanEditor';
|
import { KesehatanEditor } from '../../_com/kesehatanEditor';
|
||||||
import colors from '@/con/colors';
|
import stateJadwalKegiatan from '@/app/admin/(dashboard)/_state/kesehatan/data_kesehatan_warga/jadwalKegiatan';
|
||||||
|
|
||||||
function SyaratDanKetentuan() {
|
function SyaratDanKetentuan() {
|
||||||
const syaratKetentuan = useProxy(stateJadwalKegiatan.syaratketentuan)
|
const syaratKetentuan = useProxy(stateJadwalKegiatan.syaratketentuan)
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
'use client'
|
||||||
|
|
||||||
|
import LayoutTabs from "./_lib/layoutTabs"
|
||||||
|
|
||||||
|
|
||||||
|
export default function Layout({children} : {children: React.ReactNode}) {
|
||||||
|
return (
|
||||||
|
<LayoutTabs>
|
||||||
|
{children}
|
||||||
|
</LayoutTabs>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
import colors from '@/con/colors';
|
|
||||||
import { Stack, Tabs, TabsList, TabsPanel, TabsTab, Title } from '@mantine/core';
|
|
||||||
import ArtikelKesehatan from './_ui/artikel_kesehatan/page';
|
|
||||||
import FasilitasKesehatan from './_ui/fasilitas_kesehatan/page';
|
|
||||||
import GrafikHasilKepuasan from './_ui/grafik_hasil_kepuasan/page';
|
|
||||||
import JadwalKegiatan from './_ui/jadwal_kegiatan/page';
|
|
||||||
import PersentaseDataKelahiranKematian from './_ui/persentase_data_kelahiran_kematian/page';
|
|
||||||
|
|
||||||
|
|
||||||
function Page() {
|
|
||||||
return (
|
|
||||||
<Stack>
|
|
||||||
<Title order={3}>Data Kesehatan Warga</Title>
|
|
||||||
<Tabs color={colors['blue-button']} variant='pills' defaultValue={"Persentase Kelahiran & Kematian"}>
|
|
||||||
<TabsList bg={colors['BG-trans']} p={'xs'}>
|
|
||||||
<TabsTab value="Persentase Kelahiran & Kematian">
|
|
||||||
Persentase Kelahiran & Kematian
|
|
||||||
</TabsTab>
|
|
||||||
<TabsTab value="Grafik Hasil Kepuasan">
|
|
||||||
Grafik Hasil Kepuasan
|
|
||||||
</TabsTab>
|
|
||||||
<TabsTab value="Fasilitas Kesehatan">
|
|
||||||
Fasilitas Kesehatan
|
|
||||||
</TabsTab>
|
|
||||||
<TabsTab value="Jadwal Kegiatan">
|
|
||||||
Jadwal Kegiatan
|
|
||||||
</TabsTab>
|
|
||||||
<TabsTab value="Artikel Kesehatan">
|
|
||||||
Artikel Kesehatan
|
|
||||||
</TabsTab>
|
|
||||||
</TabsList>
|
|
||||||
|
|
||||||
<TabsPanel value="Persentase Kelahiran & Kematian">
|
|
||||||
<PersentaseDataKelahiranKematian />
|
|
||||||
</TabsPanel>
|
|
||||||
<TabsPanel value="Grafik Hasil Kepuasan">
|
|
||||||
<GrafikHasilKepuasan/>
|
|
||||||
</TabsPanel>
|
|
||||||
<TabsPanel value="Fasilitas Kesehatan">
|
|
||||||
<FasilitasKesehatan/>
|
|
||||||
</TabsPanel>
|
|
||||||
<TabsPanel value="Jadwal Kegiatan">
|
|
||||||
<JadwalKegiatan/>
|
|
||||||
</TabsPanel>
|
|
||||||
<TabsPanel value="Artikel Kesehatan">
|
|
||||||
<ArtikelKesehatan/>
|
|
||||||
</TabsPanel>
|
|
||||||
|
|
||||||
</Tabs>
|
|
||||||
</Stack>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default Page;
|
|
||||||
@@ -0,0 +1,114 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
|
'use client'
|
||||||
|
|
||||||
|
import persentasekelahiran from '@/app/admin/(dashboard)/_state/kesehatan/data_kesehatan_warga/persentaseKelahiran';
|
||||||
|
import colors from '@/con/colors';
|
||||||
|
import { Box, Button, Paper, Stack, TextInput, Title } from '@mantine/core';
|
||||||
|
import { IconArrowBack } from '@tabler/icons-react';
|
||||||
|
import { useParams, useRouter } from 'next/navigation';
|
||||||
|
import { useEffect } from 'react';
|
||||||
|
import { toast } from 'react-toastify';
|
||||||
|
import { useProxy } from 'valtio/utils';
|
||||||
|
|
||||||
|
function EditPersentaseDataKelahiranKematian() {
|
||||||
|
const router = useRouter()
|
||||||
|
const params = useParams() as { uuid: string }
|
||||||
|
const statePresentase = useProxy(persentasekelahiran)
|
||||||
|
|
||||||
|
const id = params.uuid
|
||||||
|
|
||||||
|
// Load data saat komponen mount
|
||||||
|
// Di file page.tsx, ubah useEffect-nya menjadi:
|
||||||
|
useEffect(() => {
|
||||||
|
if (!id) return;
|
||||||
|
statePresentase.update.uuid = id;
|
||||||
|
statePresentase.findUnique.load(id)
|
||||||
|
.then(() => {
|
||||||
|
const data = statePresentase.findUnique.data;
|
||||||
|
if (data) {
|
||||||
|
statePresentase.update.form = {
|
||||||
|
tahun: String(data.tahun || ''),
|
||||||
|
kematianKasar: String(data.kematianKasar || ''),
|
||||||
|
kelahiranKasar: String(data.kelahiranKasar || ''),
|
||||||
|
kematianBayi: String(data.kematianBayi || '')
|
||||||
|
};
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('Error loading data:', error);
|
||||||
|
toast.error('Gagal memuat data');
|
||||||
|
});
|
||||||
|
}, [id]);
|
||||||
|
|
||||||
|
// Di handleSubmit, ubah menjadi:
|
||||||
|
const handleSubmit = async () => {
|
||||||
|
try {
|
||||||
|
statePresentase.update.uuid = id;
|
||||||
|
await statePresentase.update.submit();
|
||||||
|
toast.success('Data berhasil diperbarui');
|
||||||
|
router.push('/admin/kesehatan/data-kesehatan-warga/persentase_data_kelahiran_kematian');
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error updating data:', error);
|
||||||
|
toast.error('Gagal memperbarui data');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box>
|
||||||
|
<Box mb={10}>
|
||||||
|
<Button variant="subtle" onClick={() => router.back()}>
|
||||||
|
<IconArrowBack size={20} />
|
||||||
|
</Button>
|
||||||
|
</Box>
|
||||||
|
<Paper bg={colors['white-1']} w={{ base: '100%', md: '50%' }} p={'md'}>
|
||||||
|
<Stack>
|
||||||
|
<Title order={3}>Edit Persentase Data Kelahiran & Kematian</Title>
|
||||||
|
<TextInput
|
||||||
|
label="Tahun"
|
||||||
|
placeholder="masukkan tahun"
|
||||||
|
value={statePresentase.update.form.tahun}
|
||||||
|
onChange={(val) => {
|
||||||
|
statePresentase.update.form.tahun = val.currentTarget.value;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<TextInput
|
||||||
|
label="Kematian Kasar"
|
||||||
|
type="number"
|
||||||
|
placeholder="masukkan kematian kasar"
|
||||||
|
value={statePresentase.update.form.kematianKasar}
|
||||||
|
onChange={(val) => {
|
||||||
|
statePresentase.update.form.kematianKasar = val.currentTarget.value;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<TextInput
|
||||||
|
label="Kematian Bayi"
|
||||||
|
type="number"
|
||||||
|
placeholder="masukkan kematian bayi"
|
||||||
|
value={statePresentase.update.form.kematianBayi}
|
||||||
|
onChange={(val) => {
|
||||||
|
statePresentase.update.form.kematianBayi = val.currentTarget.value;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<TextInput
|
||||||
|
label="Kelahiran Kasar"
|
||||||
|
type="number"
|
||||||
|
placeholder="masukkan kelahiran kasar"
|
||||||
|
value={statePresentase.update.form.kelahiranKasar}
|
||||||
|
onChange={(val) => {
|
||||||
|
statePresentase.update.form.kelahiranKasar = val.currentTarget.value;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
mt={10}
|
||||||
|
bg={colors['blue-button']}
|
||||||
|
onClick={handleSubmit}
|
||||||
|
>
|
||||||
|
Simpan Perubahan
|
||||||
|
</Button>
|
||||||
|
</Stack>
|
||||||
|
</Paper>
|
||||||
|
</Box>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default EditPersentaseDataKelahiranKematian;
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||||
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
|
'use client'
|
||||||
|
import persentasekelahiran from '@/app/admin/(dashboard)/_state/kesehatan/data_kesehatan_warga/persentaseKelahiran';
|
||||||
|
import colors from '@/con/colors';
|
||||||
|
import { Box, Button, Group, Paper, Stack, TextInput, Title } from '@mantine/core';
|
||||||
|
import { IconArrowBack } from '@tabler/icons-react';
|
||||||
|
import { useRouter } from 'next/navigation';
|
||||||
|
import { useState } from 'react';
|
||||||
|
import { useProxy } from 'valtio/utils';
|
||||||
|
|
||||||
|
function CreatePersentaseDataKelahiranKematian() {
|
||||||
|
const statePersentase = useProxy(persentasekelahiran);
|
||||||
|
const [chartData, setChartData] = useState<any[]>([]);
|
||||||
|
const router = useRouter()
|
||||||
|
|
||||||
|
const resetForm = () => {
|
||||||
|
statePersentase.create.form = {
|
||||||
|
tahun: "",
|
||||||
|
kematianBayi: "",
|
||||||
|
kematianKasar: "",
|
||||||
|
kelahiranKasar: "",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleSubmit = async () => {
|
||||||
|
const id = await statePersentase.create.create();
|
||||||
|
if (id) {
|
||||||
|
const idStr = String(id);
|
||||||
|
await statePersentase.findUnique.load(idStr);
|
||||||
|
if (statePersentase.findUnique.data) {
|
||||||
|
setChartData([statePersentase.findUnique.data]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
resetForm();
|
||||||
|
router.push("/admin/kesehatan/data-kesehatan-warga/persentase_data_kelahiran_kematian");
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<Box>
|
||||||
|
<Box mb={10}>
|
||||||
|
<Button variant="subtle" onClick={() => router.back()}>
|
||||||
|
<IconArrowBack size={20} />
|
||||||
|
</Button>
|
||||||
|
</Box>
|
||||||
|
<Box>
|
||||||
|
<Paper w={{ base: '100%', md: '50%' }} bg={colors['white-1']} p={'md'}>
|
||||||
|
<Title order={4}>Tambah Persentase Data Kelahiran & Kematian</Title>
|
||||||
|
<Stack gap={"xs"}>
|
||||||
|
<TextInput
|
||||||
|
label="Tahun"
|
||||||
|
type="number"
|
||||||
|
value={statePersentase.create.form.tahun}
|
||||||
|
placeholder="Masukkan tahun"
|
||||||
|
onChange={(val) => {
|
||||||
|
statePersentase.create.form.tahun = val.currentTarget.value;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<TextInput
|
||||||
|
label="Kematian Kasar"
|
||||||
|
type="number"
|
||||||
|
value={statePersentase.create.form.kematianKasar}
|
||||||
|
placeholder="Masukkan kematian kasar"
|
||||||
|
onChange={(val) => {
|
||||||
|
statePersentase.create.form.kematianKasar = val.currentTarget.value;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<TextInput
|
||||||
|
label="Kematian Bayi"
|
||||||
|
type="number"
|
||||||
|
value={statePersentase.create.form.kematianBayi}
|
||||||
|
placeholder="Masukkan kematian bayi"
|
||||||
|
onChange={(val) => {
|
||||||
|
statePersentase.create.form.kematianBayi = val.currentTarget.value;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<TextInput
|
||||||
|
label="Kelahiran Kasar"
|
||||||
|
type="number"
|
||||||
|
value={statePersentase.create.form.kelahiranKasar}
|
||||||
|
placeholder="Masukkan kelahiran kasar"
|
||||||
|
onChange={(val) => {
|
||||||
|
statePersentase.create.form.kelahiranKasar = val.currentTarget.value;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Group>
|
||||||
|
<Button
|
||||||
|
bg={colors['blue-button']}
|
||||||
|
mt={10}
|
||||||
|
onClick={handleSubmit}
|
||||||
|
>
|
||||||
|
Submit
|
||||||
|
</Button>
|
||||||
|
</Group>
|
||||||
|
</Stack>
|
||||||
|
</Paper>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default CreatePersentaseDataKelahiranKematian;
|
||||||
@@ -0,0 +1,158 @@
|
|||||||
|
'use client'
|
||||||
|
import persentasekelahiran from '@/app/admin/(dashboard)/_state/kesehatan/data_kesehatan_warga/persentaseKelahiran';
|
||||||
|
import colors from '@/con/colors';
|
||||||
|
import { Box, Button, Paper, Skeleton, Stack, Table, TableTbody, TableTd, TableTh, TableThead, TableTr, Text, Title } from '@mantine/core';
|
||||||
|
import { useMediaQuery, useShallowEffect } from '@mantine/hooks';
|
||||||
|
import { IconEdit, IconSearch, IconTrash } from '@tabler/icons-react';
|
||||||
|
import { useRouter } from 'next/navigation';
|
||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
import { Bar, BarChart, Legend, Tooltip, XAxis, YAxis } from 'recharts';
|
||||||
|
import { useProxy } from 'valtio/utils';
|
||||||
|
import JudulListTab from '../../../_com/jusulListTab';
|
||||||
|
import { ModalKonfirmasiHapus } from '../../../_com/modalKonfirmasiHapus';
|
||||||
|
|
||||||
|
function PersentaseDataKelahiranKematian() {
|
||||||
|
type PDKMGrafik = {
|
||||||
|
uuid: string;
|
||||||
|
tahun: string;
|
||||||
|
kematianKasar: number;
|
||||||
|
kematianBayi: number;
|
||||||
|
kelahiranKasar: number;
|
||||||
|
}
|
||||||
|
const statePersentase = useProxy(persentasekelahiran);
|
||||||
|
const [chartData, setChartData] = useState<PDKMGrafik[]>([]);
|
||||||
|
const [mounted, setMounted] = useState(false); // untuk memastikan DOM sudah ready
|
||||||
|
const isTablet = useMediaQuery('(max-width: 1024px)')
|
||||||
|
const isMobile = useMediaQuery('(max-width: 768px)')
|
||||||
|
const [modalHapus, setModalHapus] = useState(false)
|
||||||
|
const [selectedId, setSelectedId] = useState<string | null>(null)
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
const handleDelete = () => {
|
||||||
|
if (selectedId) {
|
||||||
|
statePersentase.delete.byId(selectedId)
|
||||||
|
setModalHapus(false)
|
||||||
|
setSelectedId(null)
|
||||||
|
|
||||||
|
statePersentase.findMany.load()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
useShallowEffect(() => {
|
||||||
|
setMounted(true)
|
||||||
|
statePersentase.findMany.load()
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setMounted(true);
|
||||||
|
if (statePersentase.findMany.data) {
|
||||||
|
setChartData(statePersentase.findMany.data.map((item) => ({
|
||||||
|
uuid: item.uuid,
|
||||||
|
tahun: item.tahun,
|
||||||
|
kematianKasar: Number(item.kematianKasar),
|
||||||
|
kematianBayi: Number(item.kematianBayi),
|
||||||
|
kelahiranKasar: Number(item.kelahiranKasar),
|
||||||
|
})));
|
||||||
|
}
|
||||||
|
}, [statePersentase.findMany.data]);
|
||||||
|
|
||||||
|
if (!statePersentase.findMany.data) {
|
||||||
|
return (
|
||||||
|
<Stack>
|
||||||
|
<Skeleton h={500} />
|
||||||
|
</Stack>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box>
|
||||||
|
<Stack gap={"xs"}>
|
||||||
|
{/* Form Input */}
|
||||||
|
<Paper bg={colors['white-1']} p={'md'}>
|
||||||
|
<JudulListTab
|
||||||
|
title='List Persentase Data Kelahiran & Kematian'
|
||||||
|
href='/admin/kesehatan/data-kesehatan-warga/persentase_data_kelahiran_kematian/create'
|
||||||
|
placeholder='pencarian'
|
||||||
|
searchIcon={<IconSearch size={16} />}
|
||||||
|
/>
|
||||||
|
<Table striped withTableBorder withRowBorders>
|
||||||
|
<TableThead>
|
||||||
|
<TableTr>
|
||||||
|
<TableTh>Tahun</TableTh>
|
||||||
|
<TableTh>Kematian Kasar</TableTh>
|
||||||
|
<TableTh>Kematian Bayi</TableTh>
|
||||||
|
<TableTh>kelahiran Kasar</TableTh>
|
||||||
|
<TableTh>Edit</TableTh>
|
||||||
|
<TableTh>Delete</TableTh>
|
||||||
|
</TableTr>
|
||||||
|
</TableThead>
|
||||||
|
<TableTbody>
|
||||||
|
{statePersentase.findMany.data?.map((item) => (
|
||||||
|
<TableTr key={item.uuid}>
|
||||||
|
<TableTd>{item.tahun}</TableTd>
|
||||||
|
<TableTd>{item.kematianKasar}</TableTd>
|
||||||
|
<TableTd>{item.kematianBayi}</TableTd>
|
||||||
|
<TableTd>{item.kelahiranKasar}</TableTd>
|
||||||
|
<TableTd>
|
||||||
|
<Button color='green' onClick={() => router.push(`/admin/kesehatan/data-kesehatan-warga/persentase_data_kelahiran_kematian/${item.uuid}`)}>
|
||||||
|
<IconEdit size={20} />
|
||||||
|
</Button>
|
||||||
|
</TableTd>
|
||||||
|
<TableTd>
|
||||||
|
<Button
|
||||||
|
color='red'
|
||||||
|
disabled={statePersentase.delete.loading}
|
||||||
|
onClick={() => {
|
||||||
|
setSelectedId(item.uuid)
|
||||||
|
setModalHapus(true)
|
||||||
|
}}>
|
||||||
|
<IconTrash size={20} />
|
||||||
|
</Button>
|
||||||
|
</TableTd>
|
||||||
|
</TableTr>
|
||||||
|
))}
|
||||||
|
</TableTbody>
|
||||||
|
</Table>
|
||||||
|
</Paper>
|
||||||
|
|
||||||
|
|
||||||
|
{/* Chart */}
|
||||||
|
{!mounted && !chartData ? (
|
||||||
|
<Box style={{ width: '100%', minWidth: 300, height: 400, minHeight: 300 }}>
|
||||||
|
<Paper bg={colors['white-1']} p={'md'}>
|
||||||
|
<Title pb={10} order={3}>Data Kelahiran & Kematian</Title>
|
||||||
|
<Text c='dimmed'>Belum ada data untuk ditampilkan dalam grafik</Text>
|
||||||
|
</Paper>
|
||||||
|
</Box>
|
||||||
|
) : (
|
||||||
|
<Box style={{ width: '100%', minWidth: 300, height: 400, minHeight: 300 }}>
|
||||||
|
<Paper bg={colors['white-1']} p={'md'}>
|
||||||
|
<Title pb={10} order={4}>Data Kelahiran & Kematian</Title>
|
||||||
|
{mounted && chartData.length > 0 && (
|
||||||
|
<BarChart width={isMobile ? 450 : isTablet ? 500 : 550} height={350} data={chartData} >
|
||||||
|
<XAxis dataKey="tahun" />
|
||||||
|
<YAxis />
|
||||||
|
<Tooltip />
|
||||||
|
<Legend />
|
||||||
|
<Bar dataKey="kematianKasar" fill="#f03e3e" name="Kematian Kasar" />
|
||||||
|
<Bar dataKey="kematianBayi" fill="#ff922b" name="Kematian Bayi" />
|
||||||
|
<Bar dataKey="kelahiranKasar" fill="#4dabf7" name="Kelahiran Kasar" />
|
||||||
|
</BarChart>
|
||||||
|
)}
|
||||||
|
</Paper>
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
|
</Stack>
|
||||||
|
|
||||||
|
{/* Modal Konfirmasi Hapus */}
|
||||||
|
<ModalKonfirmasiHapus
|
||||||
|
opened={modalHapus}
|
||||||
|
onClose={() => setModalHapus(false)}
|
||||||
|
onConfirm={handleDelete}
|
||||||
|
text='Apakah anda yakin ingin menghapus persentase data kelahiran & kematian ini?'
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default PersentaseDataKelahiranKematian;
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
'use client'
|
|
||||||
import colors from '@/con/colors';
|
|
||||||
import { Box, Stack, SimpleGrid, Paper, Title, TextInput, Text, Button } from '@mantine/core';
|
|
||||||
import { KesehatanEditor } from '../../_com/kesehatanEditor';
|
|
||||||
import { useRouter } from 'next/navigation';
|
|
||||||
import { IconArrowBack } from '@tabler/icons-react';
|
|
||||||
|
|
||||||
|
|
||||||
function EditPuskesmas() {
|
|
||||||
const router = useRouter();
|
|
||||||
return (
|
|
||||||
<Box>
|
|
||||||
<Box mb={10}>
|
|
||||||
<Button onClick={() => router.back()} variant='subtle' color={'blue'}>
|
|
||||||
<IconArrowBack color={colors['blue-button']} size={25}/>
|
|
||||||
</Button>
|
|
||||||
</Box>
|
|
||||||
<Stack gap={"xs"}>
|
|
||||||
<SimpleGrid cols={{ base: 1, md: 2 }}>
|
|
||||||
<Box>
|
|
||||||
<Paper bg={colors['white-1']} p={"md"}>
|
|
||||||
<Stack gap={"xs"}>
|
|
||||||
<Title order={4}>Edit Puskesmas</Title>
|
|
||||||
<TextInput
|
|
||||||
label={<Text fw={"bold"} fz={"sm"}>Nama Puskesmas</Text>}
|
|
||||||
placeholder='Masukkan nama puskesmas'
|
|
||||||
/>
|
|
||||||
<TextInput
|
|
||||||
label={<Text fw={"bold"} fz={"sm"}>No Telp Puskesmas</Text>}
|
|
||||||
placeholder='Masukkan no telp puskesmas'
|
|
||||||
/>
|
|
||||||
<Box>
|
|
||||||
<Text fw={"bold"} fz={"sm"}>Deskripsi</Text>
|
|
||||||
<KesehatanEditor
|
|
||||||
showSubmit={false}
|
|
||||||
/>
|
|
||||||
</Box>
|
|
||||||
<Box>
|
|
||||||
<Text fw={"bold"} fz={"sm"}>Pelayanan Posyandu</Text>
|
|
||||||
<KesehatanEditor
|
|
||||||
showSubmit={false}
|
|
||||||
/>
|
|
||||||
</Box>
|
|
||||||
</Stack>
|
|
||||||
</Paper>
|
|
||||||
</Box>
|
|
||||||
<Box>
|
|
||||||
<Paper bg={colors['white-1']} p={"md"}>
|
|
||||||
<Stack gap={"xs"}>
|
|
||||||
<Title order={4}>Preview Data Puskesmas</Title>
|
|
||||||
<Text fw={"bold"} fz={"sm"}>Nama Puskesmas</Text>
|
|
||||||
<Text fw={"bold"} fz={"sm"}>No Telp Puskesmas</Text>
|
|
||||||
<Text fw={"bold"} fz={"sm"}>Deskripsi</Text>
|
|
||||||
<Text fw={"bold"} fz={"sm"}>Pelayanan Posyandu</Text>
|
|
||||||
</Stack>
|
|
||||||
</Paper>
|
|
||||||
</Box>
|
|
||||||
</SimpleGrid>
|
|
||||||
</Stack>
|
|
||||||
</Box>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default EditPuskesmas;
|
|
||||||
@@ -141,7 +141,7 @@ export const navBar = [
|
|||||||
{
|
{
|
||||||
id: "Kesehatan_2",
|
id: "Kesehatan_2",
|
||||||
name: "Data Kesehatan Warga",
|
name: "Data Kesehatan Warga",
|
||||||
path: "/admin/kesehatan/data-kesehatan-warga"
|
path: "/admin/kesehatan/data-kesehatan-warga/persentase_data_kelahiran_kematian"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "Kesehatan_3",
|
id: "Kesehatan_3",
|
||||||
|
|||||||
@@ -0,0 +1,64 @@
|
|||||||
|
import prisma from "@/lib/prisma";
|
||||||
|
import { Context } from "elysia";
|
||||||
|
|
||||||
|
type FasilitasKesehatanInput = {
|
||||||
|
name: string;
|
||||||
|
informasiUmum: { fasilitas: string; alamat: string; jamOperasional: string };
|
||||||
|
layananUnggulan: { content: string };
|
||||||
|
dokterdanTenagaMedis: { name: string; specialist: string; jadwal: string };
|
||||||
|
fasilitasPendukung: { content: string };
|
||||||
|
prosedurPendaftaran: { content: string };
|
||||||
|
tarifDanLayanan: { layanan: string; tarif: string };
|
||||||
|
};
|
||||||
|
|
||||||
|
const fasilitasKesehatanCreate = async (context: Context) => {
|
||||||
|
const body = await context.body as FasilitasKesehatanInput;
|
||||||
|
|
||||||
|
const {
|
||||||
|
name,
|
||||||
|
informasiUmum,
|
||||||
|
layananUnggulan,
|
||||||
|
dokterdanTenagaMedis,
|
||||||
|
fasilitasPendukung,
|
||||||
|
prosedurPendaftaran,
|
||||||
|
tarifDanLayanan,
|
||||||
|
} = body;
|
||||||
|
|
||||||
|
// Buat masing-masing relasi terlebih dahulu
|
||||||
|
const [createdInformasiUmum, createdLayananUnggulan, createdDokter, createdPendukung, createdProsedur, createdTarif] = await Promise.all([
|
||||||
|
prisma.informasiUmum.create({ data: informasiUmum }),
|
||||||
|
prisma.layananUnggulan.create({ data: layananUnggulan }),
|
||||||
|
prisma.dokterdanTenagaMedis.create({ data: dokterdanTenagaMedis }),
|
||||||
|
prisma.fasilitasPendukung.create({ data: fasilitasPendukung }),
|
||||||
|
prisma.prosedurPendaftaran.create({ data: prosedurPendaftaran }),
|
||||||
|
prisma.tarifDanLayanan.create({ data: tarifDanLayanan }),
|
||||||
|
]);
|
||||||
|
|
||||||
|
const fasilitas = await prisma.fasilitasKesehatan.create({
|
||||||
|
data: {
|
||||||
|
name,
|
||||||
|
informasiUmumId: createdInformasiUmum.id,
|
||||||
|
layananUnggulanId: createdLayananUnggulan.id,
|
||||||
|
dokterdanTenagaMedisId: createdDokter.id,
|
||||||
|
fasilitasPendukungId: createdPendukung.id,
|
||||||
|
prosedurPendaftaranId: createdProsedur.id,
|
||||||
|
tarifDanLayananId: createdTarif.id,
|
||||||
|
},
|
||||||
|
include: {
|
||||||
|
informasiumum: true,
|
||||||
|
layananunggulan: true,
|
||||||
|
dokterdantenagamedis: true,
|
||||||
|
fasilitaspendukung: true,
|
||||||
|
prosedurpendaftaran: true,
|
||||||
|
tarifdanlayanan: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: "Fasilitas berhasil dibuat",
|
||||||
|
data: fasilitas,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export default fasilitasKesehatanCreate;
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
import prisma from "@/lib/prisma";
|
||||||
|
import { Context } from "elysia";
|
||||||
|
|
||||||
|
const fasilitasKesehatanDelete = async (context: Context) => {
|
||||||
|
const id = context.params?.id as string;
|
||||||
|
|
||||||
|
if (!id) {
|
||||||
|
return {
|
||||||
|
status: 400,
|
||||||
|
message: "ID tidak ditemukan",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const fasilitasKesehatan = await prisma.fasilitasKesehatan.findUnique({
|
||||||
|
where: { id },
|
||||||
|
include: {
|
||||||
|
informasiumum: true,
|
||||||
|
layananunggulan: true,
|
||||||
|
dokterdantenagamedis: true,
|
||||||
|
fasilitaspendukung: true,
|
||||||
|
prosedurpendaftaran: true,
|
||||||
|
tarifdanlayanan: true,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if (!fasilitasKesehatan) {
|
||||||
|
return {
|
||||||
|
status: 404,
|
||||||
|
message: "Fasilitas kesehatan tidak ditemukan",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await prisma.fasilitasKesehatan.delete({
|
||||||
|
where: { id },
|
||||||
|
})
|
||||||
|
|
||||||
|
return {
|
||||||
|
status: 200,
|
||||||
|
success: true,
|
||||||
|
message: "Fasilitas kesehatan berhasil dihapus",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export default fasilitasKesehatanDelete
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
import prisma from "@/lib/prisma";
|
|
||||||
import { Prisma } from "@prisma/client";
|
|
||||||
import { Context } from "elysia";
|
|
||||||
|
|
||||||
type FormCreate = Prisma.DokterdanTenagaMedisGetPayload<{
|
|
||||||
select: {
|
|
||||||
name: true
|
|
||||||
specialist: true
|
|
||||||
jadwal: true
|
|
||||||
}
|
|
||||||
}>
|
|
||||||
|
|
||||||
async function dokterDantenagamedisCreate(context: Context) {
|
|
||||||
const body = context.body as FormCreate
|
|
||||||
|
|
||||||
await prisma.dokterdanTenagaMedis.create({
|
|
||||||
data: {
|
|
||||||
name: body.name,
|
|
||||||
specialist: body.specialist,
|
|
||||||
jadwal: body.jadwal,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return {
|
|
||||||
success: true,
|
|
||||||
message: "Success create dokter dan tenaga medis",
|
|
||||||
data: {
|
|
||||||
...body
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
export default dokterDantenagamedisCreate
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
import prisma from "@/lib/prisma";
|
|
||||||
|
|
||||||
export default async function dokterDantenagamedisFindMany() {
|
|
||||||
const res = await prisma.dokterdanTenagaMedis.findMany();
|
|
||||||
return {
|
|
||||||
data: res
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
import Elysia, { t } from "elysia";
|
|
||||||
import dokterDantenagamedisFindMany from "./find-many";
|
|
||||||
import dokterDantenagamedisCreate from "./create";
|
|
||||||
|
|
||||||
const DokterDantenagamedis = new Elysia({
|
|
||||||
prefix: "/dokterdantenagamedis",
|
|
||||||
tags: ["Data Kesehatan/Fasilitas Kesehatan/Dokter dan Tenaga Medis"],
|
|
||||||
})
|
|
||||||
.get("/find-many", dokterDantenagamedisFindMany)
|
|
||||||
.post("/create", dokterDantenagamedisCreate, {
|
|
||||||
body: t.Object({
|
|
||||||
name: t.String(),
|
|
||||||
specialist: t.String(),
|
|
||||||
jadwal: t.String(),
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
export default DokterDantenagamedis
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
import prisma from "@/lib/prisma";
|
|
||||||
import { Prisma } from "@prisma/client";
|
|
||||||
import { Context } from "elysia";
|
|
||||||
|
|
||||||
type FormCreate = Prisma.FasilitasPendukungGetPayload<{
|
|
||||||
select: {
|
|
||||||
content: true
|
|
||||||
}
|
|
||||||
}>
|
|
||||||
|
|
||||||
async function FasilitasPendukungCreate(context: Context){
|
|
||||||
const body = context.body as FormCreate
|
|
||||||
|
|
||||||
await prisma.fasilitasPendukung.create({
|
|
||||||
data: {
|
|
||||||
|
|
||||||
content: body.content
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return {
|
|
||||||
success: true,
|
|
||||||
message: "Success create fasilitas pendukung",
|
|
||||||
data: {
|
|
||||||
...body
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default FasilitasPendukungCreate
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
import prisma from "@/lib/prisma";
|
|
||||||
|
|
||||||
export default async function fasilitasPendukungFindMany() {
|
|
||||||
const res = await prisma.fasilitasPendukung.findMany();
|
|
||||||
return {
|
|
||||||
data: res
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
import Elysia, { t } from "elysia";
|
|
||||||
import fasilitasPendukungFindMany from "./find-many";
|
|
||||||
import FasilitasPendukungCreate from "./create";
|
|
||||||
|
|
||||||
const FasilitasPendukung = new Elysia({
|
|
||||||
prefix: "/fasilitaspendukung",
|
|
||||||
tags: ["Data Kesehatan/Fasilitas Kesehatan/Fasilitas Pendukung"],
|
|
||||||
})
|
|
||||||
.get("/find-many", fasilitasPendukungFindMany)
|
|
||||||
.post("/create", FasilitasPendukungCreate, {
|
|
||||||
body: t.Object({
|
|
||||||
content: t.String(),
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
|
|
||||||
export default FasilitasPendukung;
|
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
import prisma from "@/lib/prisma";
|
||||||
|
|
||||||
|
export default async function findManyFasilitasKesehatan() {
|
||||||
|
try {
|
||||||
|
const data = await prisma.fasilitasKesehatan.findMany({
|
||||||
|
where: {
|
||||||
|
isActive: true,
|
||||||
|
},
|
||||||
|
include: {
|
||||||
|
informasiumum: true,
|
||||||
|
layananunggulan: true,
|
||||||
|
dokterdantenagamedis: true,
|
||||||
|
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",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
import prisma from "@/lib/prisma";
|
||||||
|
|
||||||
|
export default async function findUniqueFasilitasKesehatan(request: Request) {
|
||||||
|
const url = new URL(request.url);
|
||||||
|
const pathSegments = url.pathname.split('/');
|
||||||
|
const id = pathSegments[pathSegments.length - 1];
|
||||||
|
|
||||||
|
if (!id) {
|
||||||
|
return Response.json({
|
||||||
|
success: false,
|
||||||
|
message: "ID tidak boleh kosong",
|
||||||
|
}, { status: 400 })
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (typeof id !== 'string') {
|
||||||
|
return Response.json({
|
||||||
|
success: false,
|
||||||
|
message: "ID tidak valid",
|
||||||
|
}, { status: 400 })
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = await prisma.fasilitasKesehatan.findUnique({
|
||||||
|
where: {id},
|
||||||
|
include: {
|
||||||
|
informasiumum: true,
|
||||||
|
layananunggulan: true,
|
||||||
|
dokterdantenagamedis: true,
|
||||||
|
fasilitaspendukung: true,
|
||||||
|
prosedurpendaftaran: true,
|
||||||
|
tarifdanlayanan: true,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if (!data) {
|
||||||
|
return Response.json({
|
||||||
|
success: false,
|
||||||
|
message: "Data tidak ditemukan",
|
||||||
|
}, { status: 404 })
|
||||||
|
}
|
||||||
|
|
||||||
|
return Response.json({
|
||||||
|
success: true,
|
||||||
|
data,
|
||||||
|
}, { status: 200 })
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Gagal mengambil data fasilitas kesehatan:", error);
|
||||||
|
return Response.json({
|
||||||
|
success: false,
|
||||||
|
message: "Gagal mengambil data fasilitas kesehatan",
|
||||||
|
}, { status: 500 })
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
import { Elysia, t } from "elysia";
|
||||||
|
import fasilitasKesehatanCreate from "./create";
|
||||||
|
import findManyFasilitasKesehatan from "./findMany";
|
||||||
|
import findUniqueFasilitasKesehatan from "./findUnique";
|
||||||
|
import fasilitasKesehatanUpdate from "./updt";
|
||||||
|
import fasilitasKesehatanDelete from "./del";
|
||||||
|
|
||||||
|
const FasilitasKesehatan = new Elysia({
|
||||||
|
prefix: "fasilitas-kesehatan",
|
||||||
|
tags: ["Kesehatan/Fasilitas Kesehatan"],
|
||||||
|
})
|
||||||
|
.post("/create", fasilitasKesehatanCreate, {
|
||||||
|
body: t.Object({
|
||||||
|
name: t.String(),
|
||||||
|
informasiUmum: t.Object({
|
||||||
|
fasilitas: t.String(),
|
||||||
|
alamat: t.String(),
|
||||||
|
jamOperasional: t.String(),
|
||||||
|
}),
|
||||||
|
layananUnggulan: t.Object({
|
||||||
|
content: t.String(),
|
||||||
|
}),
|
||||||
|
dokterdanTenagaMedis: t.Object({
|
||||||
|
name: t.String(),
|
||||||
|
specialist: t.String(),
|
||||||
|
jadwal: t.String(),
|
||||||
|
}),
|
||||||
|
fasilitasPendukung: t.Object({
|
||||||
|
content: t.String(),
|
||||||
|
}),
|
||||||
|
prosedurPendaftaran: t.Object({
|
||||||
|
content: t.String(),
|
||||||
|
}),
|
||||||
|
tarifDanLayanan: t.Object({
|
||||||
|
layanan: t.String(),
|
||||||
|
tarif: t.String(),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
.get("/find-many", findManyFasilitasKesehatan)
|
||||||
|
.delete("/del/:id", fasilitasKesehatanDelete)
|
||||||
|
.get("/:id", async (context) => {
|
||||||
|
const response = await findUniqueFasilitasKesehatan(
|
||||||
|
new Request(context.request)
|
||||||
|
);
|
||||||
|
return response;
|
||||||
|
})
|
||||||
|
.put(
|
||||||
|
"/:id",
|
||||||
|
async (context) => {
|
||||||
|
const response = await fasilitasKesehatanUpdate(context);
|
||||||
|
return response;
|
||||||
|
},
|
||||||
|
{
|
||||||
|
body: t.Object({
|
||||||
|
name: t.String(),
|
||||||
|
informasiUmum: t.Object({
|
||||||
|
fasilitas: t.String(),
|
||||||
|
alamat: t.String(),
|
||||||
|
jamOperasional: t.String(),
|
||||||
|
}),
|
||||||
|
layananUnggulan: t.Object({
|
||||||
|
content: t.String(),
|
||||||
|
}),
|
||||||
|
dokterdanTenagaMedis: t.Object({
|
||||||
|
name: t.String(),
|
||||||
|
specialist: t.String(),
|
||||||
|
jadwal: t.String(),
|
||||||
|
}),
|
||||||
|
fasilitasPendukung: t.Object({
|
||||||
|
content: t.String(),
|
||||||
|
}),
|
||||||
|
prosedurPendaftaran: t.Object({
|
||||||
|
content: t.String(),
|
||||||
|
}),
|
||||||
|
tarifDanLayanan: t.Object({
|
||||||
|
layanan: t.String(),
|
||||||
|
tarif: t.String(),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
export default FasilitasKesehatan;
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
import prisma from "@/lib/prisma";
|
|
||||||
import { Prisma } from "@prisma/client";
|
|
||||||
import { Context } from "elysia";
|
|
||||||
|
|
||||||
type FormCreate = Prisma.InformasiUmumGetPayload<{
|
|
||||||
select: {
|
|
||||||
fasilitas: true
|
|
||||||
alamat: true
|
|
||||||
jamOperasional: true
|
|
||||||
}
|
|
||||||
}>
|
|
||||||
async function informasiUmumCreate(context: Context) {
|
|
||||||
const body = context.body as FormCreate
|
|
||||||
|
|
||||||
await prisma.informasiUmum.create({
|
|
||||||
data: {
|
|
||||||
fasilitas: body.fasilitas,
|
|
||||||
alamat: body.alamat,
|
|
||||||
jamOperasional: body.jamOperasional,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return{
|
|
||||||
success: true,
|
|
||||||
message: "Success create informasi umum",
|
|
||||||
data: {
|
|
||||||
...body
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default informasiUmumCreate
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
import prisma from "@/lib/prisma";
|
|
||||||
|
|
||||||
export default async function informasiUmumFindMany() {
|
|
||||||
const res = await prisma.informasiUmum.findMany();
|
|
||||||
return {
|
|
||||||
data: res
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
import Elysia, { t } from "elysia";
|
|
||||||
import informasiUmumFindMany from "./find-many";
|
|
||||||
import informasiUmumCreate from "./create";
|
|
||||||
|
|
||||||
const InformasiUmum = new Elysia({
|
|
||||||
prefix: "/informasiumum",
|
|
||||||
tags: ["Data Kesehatan/Fasilitas Kesehatan/Informasi Umum"],
|
|
||||||
})
|
|
||||||
.get("/find-many", informasiUmumFindMany)
|
|
||||||
.post("/create", informasiUmumCreate, {
|
|
||||||
body: t.Object({
|
|
||||||
fasilitas: t.String(),
|
|
||||||
alamat: t.String(),
|
|
||||||
jamOperasional: t.String(),
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
|
|
||||||
export default InformasiUmum;
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
import prisma from "@/lib/prisma";
|
|
||||||
import { Prisma } from "@prisma/client";
|
|
||||||
import { Context } from "elysia";
|
|
||||||
|
|
||||||
type FormCreate = Prisma.LayananUnggulanGetPayload<{
|
|
||||||
select: {
|
|
||||||
content: true
|
|
||||||
}
|
|
||||||
}>
|
|
||||||
|
|
||||||
async function layananUnggulanCreate(context: Context) {
|
|
||||||
const body = context.body as FormCreate
|
|
||||||
|
|
||||||
await prisma.layananUnggulan.create({
|
|
||||||
data: {
|
|
||||||
content: body.content
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return {
|
|
||||||
success: true,
|
|
||||||
message: "Success create layanan unggulan",
|
|
||||||
data: {
|
|
||||||
...body
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default layananUnggulanCreate
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
import prisma from "@/lib/prisma";
|
|
||||||
|
|
||||||
export default async function layananUnggulanFindMany() {
|
|
||||||
const res = await prisma.layananUnggulan.findMany();
|
|
||||||
return {
|
|
||||||
data: res
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
import Elysia, { t } from "elysia";
|
|
||||||
import layananUnggulanCreate from "./create";
|
|
||||||
import layananUnggulanFindMany from "./find-many";
|
|
||||||
|
|
||||||
const LayananUnggulan = new Elysia({
|
|
||||||
prefix: "/layananunggulan",
|
|
||||||
tags: ["Data Kesehatan/Fasilitas Kesehatan/Layanan Unggulan"]
|
|
||||||
})
|
|
||||||
|
|
||||||
.get("/find-many", layananUnggulanFindMany)
|
|
||||||
.post("/create", layananUnggulanCreate, {
|
|
||||||
body: t.Object({
|
|
||||||
content: t.String()
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
export default LayananUnggulan
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
import prisma from "@/lib/prisma";
|
|
||||||
import { Prisma } from "@prisma/client";
|
|
||||||
import { Context } from "elysia";
|
|
||||||
|
|
||||||
type FormCreate = Prisma.ProsedurPendaftaranGetPayload<{
|
|
||||||
select: {
|
|
||||||
content: true
|
|
||||||
}
|
|
||||||
}>
|
|
||||||
|
|
||||||
async function prosedurPendaftaranCreate(context: Context) {
|
|
||||||
const body = context.body as FormCreate
|
|
||||||
|
|
||||||
await prisma.prosedurPendaftaran.create({
|
|
||||||
data: {
|
|
||||||
content: body.content
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return{
|
|
||||||
success: true,
|
|
||||||
message: "Success create prosedur pendaftaran",
|
|
||||||
data: {
|
|
||||||
...body
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default prosedurPendaftaranCreate
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
import prisma from "@/lib/prisma";
|
|
||||||
|
|
||||||
export default async function prosedurPendaftaranFindMany() {
|
|
||||||
const res = await prisma.prosedurPendaftaran.findMany();
|
|
||||||
return {
|
|
||||||
data: res
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
import Elysia, { t } from "elysia";
|
|
||||||
import prosedurPendaftaranFindMany from "./find-many";
|
|
||||||
import prosedurPendaftaranCreate from "./create";
|
|
||||||
|
|
||||||
const ProsedurPendaftaran = new Elysia({
|
|
||||||
prefix: "/prosedurpendaftaran",
|
|
||||||
tags: ["Data Kesehatan/Fasilitas Kesehatan/Prosedur Pendaftaran"],
|
|
||||||
})
|
|
||||||
.get("/find-many", prosedurPendaftaranFindMany)
|
|
||||||
.post("/create", prosedurPendaftaranCreate, {
|
|
||||||
body: t.Object({
|
|
||||||
content: t.String(),
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
export default ProsedurPendaftaran;
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
import prisma from "@/lib/prisma";
|
|
||||||
import { Prisma } from "@prisma/client";
|
|
||||||
import { Context } from "elysia";
|
|
||||||
|
|
||||||
type FormCreate = Prisma.TarifDanLayananGetPayload<{
|
|
||||||
select: {
|
|
||||||
layanan: true
|
|
||||||
tarif: true
|
|
||||||
}
|
|
||||||
}>
|
|
||||||
|
|
||||||
async function tarifdanlayananCreate(context: Context) {
|
|
||||||
const body = context.body as FormCreate
|
|
||||||
|
|
||||||
await prisma.tarifDanLayanan.create({
|
|
||||||
data: {
|
|
||||||
layanan: body.layanan,
|
|
||||||
tarif: body.tarif,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return {
|
|
||||||
success: true,
|
|
||||||
message: "Success create tarif dan layanan",
|
|
||||||
data: {
|
|
||||||
...body
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default tarifdanlayananCreate
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
import prisma from "@/lib/prisma";
|
|
||||||
|
|
||||||
export default async function tarifdanlayananFindMany() {
|
|
||||||
const res = await prisma.tarifDanLayanan.findMany();
|
|
||||||
return {
|
|
||||||
data: res
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
import Elysia, { t } from "elysia";
|
|
||||||
import tarifdanlayananFindMany from "./find-many";
|
|
||||||
import tarifdanlayananCreate from "./create";
|
|
||||||
|
|
||||||
|
|
||||||
const TarifDanLayanan = new Elysia({
|
|
||||||
prefix: "/tarifdanlayanan",
|
|
||||||
tags: ["Data Kesehatan/Fasilitas Kesehatan/Tarif dan Layanan"]
|
|
||||||
})
|
|
||||||
.get("/find-many", tarifdanlayananFindMany)
|
|
||||||
.post("/create", tarifdanlayananCreate, {
|
|
||||||
body: t.Object({
|
|
||||||
layanan: t.String(),
|
|
||||||
tarif: t.String(),
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
export default TarifDanLayanan;
|
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
import prisma from "@/lib/prisma";
|
||||||
|
import { Context } from "elysia";
|
||||||
|
|
||||||
|
type FasilitasKesehatanInput = {
|
||||||
|
name: string;
|
||||||
|
informasiUmum: { fasilitas: string; alamat: string; jamOperasional: string };
|
||||||
|
layananUnggulan: { content: string };
|
||||||
|
dokterdanTenagaMedis: { name: string; specialist: string; jadwal: string };
|
||||||
|
fasilitasPendukung: { content: string };
|
||||||
|
prosedurPendaftaran: { content: string };
|
||||||
|
tarifDanLayanan: { layanan: string; tarif: string };
|
||||||
|
};
|
||||||
|
|
||||||
|
const fasilitasKesehatanUpdate = async (context: Context) => {
|
||||||
|
const id = context.params?.id as string;
|
||||||
|
const body = await context.body as FasilitasKesehatanInput;
|
||||||
|
|
||||||
|
if (!id) {
|
||||||
|
return new Response(
|
||||||
|
JSON.stringify({ success: false, message: "ID is required" }),
|
||||||
|
{ status: 400, headers: { "Content-Type": "application/json" } }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const existing = await prisma.fasilitasKesehatan.findUnique({
|
||||||
|
where: { id },
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!existing) {
|
||||||
|
return new Response(
|
||||||
|
JSON.stringify({ success: false, message: "Data not found" }),
|
||||||
|
{ status: 404, headers: { "Content-Type": "application/json" } }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const {
|
||||||
|
name,
|
||||||
|
informasiUmum,
|
||||||
|
layananUnggulan,
|
||||||
|
dokterdanTenagaMedis,
|
||||||
|
fasilitasPendukung,
|
||||||
|
prosedurPendaftaran,
|
||||||
|
tarifDanLayanan,
|
||||||
|
} = body;
|
||||||
|
|
||||||
|
// Update data masing-masing relasi
|
||||||
|
await Promise.all([
|
||||||
|
prisma.informasiUmum.update({
|
||||||
|
where: { id: existing.informasiUmumId },
|
||||||
|
data: informasiUmum,
|
||||||
|
}),
|
||||||
|
prisma.layananUnggulan.update({
|
||||||
|
where: { id: existing.layananUnggulanId },
|
||||||
|
data: layananUnggulan,
|
||||||
|
}),
|
||||||
|
prisma.dokterdanTenagaMedis.update({
|
||||||
|
where: { id: existing.dokterdanTenagaMedisId },
|
||||||
|
data: dokterdanTenagaMedis,
|
||||||
|
}),
|
||||||
|
prisma.fasilitasPendukung.update({
|
||||||
|
where: { id: existing.fasilitasPendukungId },
|
||||||
|
data: fasilitasPendukung,
|
||||||
|
}),
|
||||||
|
prisma.prosedurPendaftaran.update({
|
||||||
|
where: { id: existing.prosedurPendaftaranId },
|
||||||
|
data: prosedurPendaftaran,
|
||||||
|
}),
|
||||||
|
prisma.tarifDanLayanan.update({
|
||||||
|
where: { id: existing.tarifDanLayananId },
|
||||||
|
data: tarifDanLayanan,
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Update main record
|
||||||
|
const updated = await prisma.fasilitasKesehatan.update({
|
||||||
|
where: { id },
|
||||||
|
data: { name },
|
||||||
|
include: {
|
||||||
|
informasiumum: true,
|
||||||
|
layananunggulan: true,
|
||||||
|
dokterdantenagamedis: true,
|
||||||
|
fasilitaspendukung: true,
|
||||||
|
prosedurpendaftaran: true,
|
||||||
|
tarifdanlayanan: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: "Fasilitas berhasil diupdate",
|
||||||
|
data: updated,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export default fasilitasKesehatanUpdate;
|
||||||
@@ -11,17 +11,20 @@ type FormCreate = Prisma.GrafikKepuasanGetPayload<{
|
|||||||
export default async function grafikKepuasanCreate(context: Context) {
|
export default async function grafikKepuasanCreate(context: Context) {
|
||||||
const body = context.body as FormCreate;
|
const body = context.body as FormCreate;
|
||||||
|
|
||||||
await prisma.grafikKepuasan.create({
|
const created = await prisma.grafikKepuasan.create({
|
||||||
data: {
|
data: {
|
||||||
label: body.label,
|
label: body.label,
|
||||||
jumlah: body.jumlah,
|
jumlah: body.jumlah,
|
||||||
},
|
},
|
||||||
|
select: {
|
||||||
|
uuid: true,
|
||||||
|
label: true,
|
||||||
|
jumlah: true,
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
message: "Success create grafik kepuasan",
|
message: "Success create grafik kepuasan",
|
||||||
data: {
|
data: created,
|
||||||
...body,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
import prisma from "@/lib/prisma";
|
||||||
|
import { Context } from "elysia";
|
||||||
|
|
||||||
|
export default async function grafikKepuasanDelete(context: Context) {
|
||||||
|
const uuid = context.params?.uuid;
|
||||||
|
|
||||||
|
if (!uuid) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "ID tidak ditemukan"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const existing = await prisma.grafikKepuasan.findUnique({
|
||||||
|
where: {
|
||||||
|
uuid: uuid,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
if (!existing) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "Data tidak ditemukan",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const deleted = await prisma.grafikKepuasan.delete({
|
||||||
|
where: { uuid },
|
||||||
|
})
|
||||||
|
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: "Data berhasil dihapus",
|
||||||
|
data: deleted,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
import prisma from "@/lib/prisma";
|
||||||
|
|
||||||
|
export default async function grafikKepuasanFindUnique(request: Request) {
|
||||||
|
const url = new URL(request.url);
|
||||||
|
const pathSegments = url.pathname.split('/');
|
||||||
|
const uuid = pathSegments[pathSegments.length - 1];
|
||||||
|
|
||||||
|
if (!uuid) {
|
||||||
|
return Response.json({
|
||||||
|
success: false,
|
||||||
|
message: 'ID tidak boleh kosong',
|
||||||
|
}, {status: 400})
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (typeof uuid !== 'string') {
|
||||||
|
return Response.json({
|
||||||
|
success: false,
|
||||||
|
message: "ID tidak valid",
|
||||||
|
}, { status: 400 });
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = await prisma.grafikKepuasan.findUnique({
|
||||||
|
where: { uuid },
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!data) {
|
||||||
|
return Response.json({
|
||||||
|
success: false,
|
||||||
|
message: "Data tidak ditemukan",
|
||||||
|
}, { status: 404 });
|
||||||
|
}
|
||||||
|
|
||||||
|
return Response.json({
|
||||||
|
success: true,
|
||||||
|
message: "Berhasil mengambil data berdasarkan ID",
|
||||||
|
data,
|
||||||
|
}, { status: 200 });
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error fetching data:", error);
|
||||||
|
return Response.json({
|
||||||
|
success: false,
|
||||||
|
message: "Terjadi kesalahan saat mengambil data",
|
||||||
|
}, { status: 500 });
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,11 +1,18 @@
|
|||||||
import Elysia, { t } from "elysia";
|
import Elysia, { t } from "elysia";
|
||||||
import grafikKepuasanCreate from "./create";
|
import grafikKepuasanCreate from "./create";
|
||||||
import grafikKepuasanFindMany from "./find-many";
|
import grafikKepuasanFindMany from "./find-many";
|
||||||
|
import grafikKepuasanFindUnique from "./findUnique";
|
||||||
|
import grafikKepuasanUpdate from "./updt";
|
||||||
|
import grafikKepuasanDelete from "./del";
|
||||||
|
|
||||||
const GrafikKepuasan = new Elysia({
|
const GrafikKepuasan = new Elysia({
|
||||||
prefix: "/grafikkepuasan",
|
prefix: "/grafikkepuasan",
|
||||||
tags: ["Data Kesehatan/Grafik Kepuasan"]
|
tags: ["Data Kesehatan/Grafik Kepuasan"]
|
||||||
})
|
})
|
||||||
|
.get("/:uuid", async (context) => {
|
||||||
|
const response = await grafikKepuasanFindUnique(new Request(context.request));
|
||||||
|
return response;
|
||||||
|
})
|
||||||
.get("/find-many", grafikKepuasanFindMany)
|
.get("/find-many", grafikKepuasanFindMany)
|
||||||
.post("/create", grafikKepuasanCreate, {
|
.post("/create", grafikKepuasanCreate, {
|
||||||
body: t.Object({
|
body: t.Object({
|
||||||
@@ -13,4 +20,18 @@ const GrafikKepuasan = new Elysia({
|
|||||||
jumlah: t.String(),
|
jumlah: t.String(),
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
|
.put("/:uuid", grafikKepuasanUpdate, {
|
||||||
|
params: t.Object({
|
||||||
|
uuid: t.String(),
|
||||||
|
}),
|
||||||
|
body: t.Object({
|
||||||
|
label: t.String(),
|
||||||
|
jumlah: t.String(),
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
.delete("/del/:uuid", grafikKepuasanDelete, {
|
||||||
|
params: t.Object({
|
||||||
|
uuid: t.String(),
|
||||||
|
}),
|
||||||
|
})
|
||||||
export default GrafikKepuasan
|
export default GrafikKepuasan
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
import prisma from "@/lib/prisma";
|
||||||
|
import { Context } from "elysia";
|
||||||
|
|
||||||
|
export default async function grafikKepuasanUpdate(context: Context) {
|
||||||
|
const uuid = context.params?.uuid;
|
||||||
|
|
||||||
|
if (!uuid) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "ID tidak ditemukan"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const {label, jumlah} = context.body as {
|
||||||
|
label: string;
|
||||||
|
jumlah: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const existing = await prisma.grafikKepuasan.findUnique({
|
||||||
|
where: {
|
||||||
|
uuid: uuid,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
if (!existing) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "Data tidak ditemukan",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const updated = await prisma.grafikKepuasan.update({
|
||||||
|
where: { uuid },
|
||||||
|
data: {
|
||||||
|
label,
|
||||||
|
jumlah,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: "Data berhasil diupdate",
|
||||||
|
data: updated,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,19 +14,24 @@ type FormCreate = Prisma.DataKematian_KelahiranGetPayload<{
|
|||||||
export default async function persentaseKelahiranKematianCreate(context: Context) {
|
export default async function persentaseKelahiranKematianCreate(context: Context) {
|
||||||
const body = context.body as FormCreate
|
const body = context.body as FormCreate
|
||||||
|
|
||||||
await prisma.dataKematian_Kelahiran.create({
|
const created = await prisma.dataKematian_Kelahiran.create({
|
||||||
data: {
|
data: {
|
||||||
tahun: body.tahun,
|
tahun: body.tahun,
|
||||||
kematianKasar: body.kematianKasar,
|
kematianKasar: body.kematianKasar,
|
||||||
kematianBayi: body.kematianBayi,
|
kematianBayi: body.kematianBayi,
|
||||||
kelahiranKasar: body.kelahiranKasar,
|
kelahiranKasar: body.kelahiranKasar,
|
||||||
|
},
|
||||||
|
select: {
|
||||||
|
uuid: true,
|
||||||
|
tahun: true,
|
||||||
|
kematianKasar: true,
|
||||||
|
kematianBayi: true,
|
||||||
|
kelahiranKasar: true,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return{
|
return{
|
||||||
success: true,
|
success: true,
|
||||||
message: "Success create persentase kelahiran kematian",
|
message: "Success create persentase kelahiran kematian",
|
||||||
data: {
|
data: created
|
||||||
...body
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
import prisma from "@/lib/prisma";
|
||||||
|
import { Context } from "elysia";
|
||||||
|
|
||||||
|
export default async function persentaseKelahiranKematianDelete(context: Context) {
|
||||||
|
const uuid = context.params?.uuid;
|
||||||
|
|
||||||
|
if (!uuid) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "ID tidak ditemukan",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const existing = await prisma.dataKematian_Kelahiran.findUnique({
|
||||||
|
where: {
|
||||||
|
uuid: uuid,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
if (!existing) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "Data tidak ditemukan",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const deleted = await prisma.dataKematian_Kelahiran.delete({
|
||||||
|
where: { uuid },
|
||||||
|
})
|
||||||
|
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: "Data berhasil dihapus",
|
||||||
|
data: deleted,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
import prisma from "@/lib/prisma";
|
||||||
|
|
||||||
|
export default async function persentaseKelahiranKematianFindUnique(request: Request) {
|
||||||
|
const url = new URL(request.url);
|
||||||
|
const pathSegments = url.pathname.split('/');
|
||||||
|
const uuid = pathSegments[pathSegments.length - 1];
|
||||||
|
|
||||||
|
if (!uuid) {
|
||||||
|
return Response.json({
|
||||||
|
success: false,
|
||||||
|
message: "ID tidak boleh kosong",
|
||||||
|
}, { status: 400 });
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (typeof uuid !== 'string') {
|
||||||
|
return Response.json({
|
||||||
|
success: false,
|
||||||
|
message: "ID tidak valid",
|
||||||
|
}, { status: 400 });
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = await prisma.dataKematian_Kelahiran.findUnique({
|
||||||
|
where: { uuid },
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!data) {
|
||||||
|
return Response.json({
|
||||||
|
success: false,
|
||||||
|
message: "Data tidak ditemukan",
|
||||||
|
}, { status: 404 });
|
||||||
|
}
|
||||||
|
|
||||||
|
return Response.json({
|
||||||
|
success: true,
|
||||||
|
message: "Berhasil mengambil data berdasarkan ID",
|
||||||
|
data,
|
||||||
|
}, { status: 200 });
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error fetching data:", error);
|
||||||
|
return Response.json({
|
||||||
|
success: false,
|
||||||
|
message: "Terjadi kesalahan saat mengambil data",
|
||||||
|
}, { status: 500 });
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,11 +1,18 @@
|
|||||||
import Elysia, { t } from "elysia";
|
import Elysia, { t } from "elysia";
|
||||||
import persentaseKelahiranKematianCreate from "./create";
|
import persentaseKelahiranKematianCreate from "./create";
|
||||||
import persentaseKelahiranKematianFindMany from "./find-many";
|
import persentaseKelahiranKematianFindMany from "./find-many";
|
||||||
|
import persentaseKelahiranKematianFindUnique from "./findUnique";
|
||||||
|
import persentaseKelahiranKematianUpdate from "./updt";
|
||||||
|
import persentaseKelahiranKematianDelete from "./del";
|
||||||
|
|
||||||
const PersentaseKelahiranKematian = new Elysia({
|
const PersentaseKelahiranKematian = new Elysia({
|
||||||
prefix: "/persentasekelahiran",
|
prefix: "/persentasekelahiran",
|
||||||
tags: ["Data Kesehatan/Persentase Kelahiran Kematian"],
|
tags: ["Data Kesehatan/Persentase Kelahiran Kematian"],
|
||||||
})
|
})
|
||||||
|
.get("/:uuid", async (context) => {
|
||||||
|
const response = await persentaseKelahiranKematianFindUnique(new Request(context.request))
|
||||||
|
return response
|
||||||
|
})
|
||||||
.get("/find-many", persentaseKelahiranKematianFindMany)
|
.get("/find-many", persentaseKelahiranKematianFindMany)
|
||||||
.post("/create", persentaseKelahiranKematianCreate, {
|
.post("/create", persentaseKelahiranKematianCreate, {
|
||||||
body: t.Object({
|
body: t.Object({
|
||||||
@@ -15,5 +22,20 @@ const PersentaseKelahiranKematian = new Elysia({
|
|||||||
kelahiranKasar: t.String(),
|
kelahiranKasar: t.String(),
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
|
.put("/:uuid", persentaseKelahiranKematianUpdate, {
|
||||||
|
params: t.Object({
|
||||||
|
uuid: t.String(),
|
||||||
|
}),
|
||||||
|
body: t.Object({
|
||||||
|
tahun: t.String(),
|
||||||
|
kematianKasar: t.String(),
|
||||||
|
kematianBayi: t.String(),
|
||||||
|
kelahiranKasar: t.String(),
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
.delete("/del/:uuid", persentaseKelahiranKematianDelete, {
|
||||||
|
params: t.Object({
|
||||||
|
uuid: t.String(),
|
||||||
|
}),
|
||||||
|
})
|
||||||
export default PersentaseKelahiranKematian;
|
export default PersentaseKelahiranKematian;
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
import prisma from "@/lib/prisma";
|
||||||
|
import { Context } from "elysia";
|
||||||
|
|
||||||
|
export default async function persentaseKelahiranKematianUpdate(context: Context) {
|
||||||
|
const uuid = context.params?.uuid;
|
||||||
|
|
||||||
|
if (!uuid) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "ID tidak ditemukan",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const {tahun, kematianKasar, kematianBayi, kelahiranKasar} = context.body as {
|
||||||
|
tahun: string;
|
||||||
|
kematianKasar: string;
|
||||||
|
kematianBayi: string;
|
||||||
|
kelahiranKasar: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const existing = await prisma.dataKematian_Kelahiran.findUnique({
|
||||||
|
where: {
|
||||||
|
uuid: uuid,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
if (!existing) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "Data tidak ditemukan",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const updated = await prisma.dataKematian_Kelahiran.update({
|
||||||
|
where: { uuid },
|
||||||
|
data: {
|
||||||
|
tahun,
|
||||||
|
kematianKasar,
|
||||||
|
kematianBayi,
|
||||||
|
kelahiranKasar,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: "Data berhasil diupdate",
|
||||||
|
data: updated,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,42 +1,31 @@
|
|||||||
import Elysia from "elysia";
|
import Elysia from "elysia";
|
||||||
import InformasiUmum from "./data_kesehatan_warga/fasilitas_kesehatan/informasi_umum";
|
|
||||||
import LayananUnggulan from "./data_kesehatan_warga/fasilitas_kesehatan/layanan_unggulan";
|
|
||||||
import DokterDantenagamedis from "./data_kesehatan_warga/fasilitas_kesehatan/dokterDantenagamedis";
|
|
||||||
import FasilitasPendukung from "./data_kesehatan_warga/fasilitas_kesehatan/fasilitas_pendukung";
|
|
||||||
import TarifDanLayanan from "./data_kesehatan_warga/fasilitas_kesehatan/tarifDanlayanan";
|
|
||||||
import ProsedurPendaftaran from "./data_kesehatan_warga/fasilitas_kesehatan/prosedur_pendaftaran";
|
|
||||||
import InformasiJadwalKegiatan from "./data_kesehatan_warga/jadwal_kegiatan/informasi_kegiatan";
|
|
||||||
import DeskripsiJadwalKegiatan from "./data_kesehatan_warga/jadwal_kegiatan/deskripsi_kegiatan";
|
|
||||||
import LayananTersedia from "./data_kesehatan_warga/jadwal_kegiatan/layanan_yang_tersedia";
|
|
||||||
import SyaratKetentuan from "./data_kesehatan_warga/jadwal_kegiatan/syarat_dan_ketentuan";
|
|
||||||
import DokumenDiperlukan from "./data_kesehatan_warga/jadwal_kegiatan/dokumen_yang_diperlukan";
|
|
||||||
import PendaftaranJadwal from "./data_kesehatan_warga/jadwal_kegiatan/pendaftaran";
|
|
||||||
import PersentaseKelahiranKematian from "./data_kesehatan_warga/persentase_kelahiran_kematian";
|
|
||||||
import GrafikKepuasan from "./data_kesehatan_warga/grafik_kepuasan";
|
|
||||||
import Introduction from "./data_kesehatan_warga/artikel_kesehatan/introduction";
|
|
||||||
import Syptom from "./data_kesehatan_warga/artikel_kesehatan/syptom";
|
|
||||||
import Prevention from "./data_kesehatan_warga/artikel_kesehatan/prevention";
|
|
||||||
import FirstAid from "./data_kesehatan_warga/artikel_kesehatan/first_aid";
|
|
||||||
import MythVsFact from "./data_kesehatan_warga/artikel_kesehatan/myth_vs_fact";
|
|
||||||
import DoctorSign from "./data_kesehatan_warga/artikel_kesehatan/doctor_sign";
|
import DoctorSign from "./data_kesehatan_warga/artikel_kesehatan/doctor_sign";
|
||||||
import Posyandu from "./posyandu";
|
import FirstAid from "./data_kesehatan_warga/artikel_kesehatan/first_aid";
|
||||||
import Puskesmas from "./puskesmas";
|
import Introduction from "./data_kesehatan_warga/artikel_kesehatan/introduction";
|
||||||
import ProgramKesehatan from "./program-kesehatan";
|
import MythVsFact from "./data_kesehatan_warga/artikel_kesehatan/myth_vs_fact";
|
||||||
import PenangananDarurat from "./penanganan-darurat";
|
import Prevention from "./data_kesehatan_warga/artikel_kesehatan/prevention";
|
||||||
import KontakDarurat from "./kontak-darurat";
|
import Syptom from "./data_kesehatan_warga/artikel_kesehatan/syptom";
|
||||||
|
import GrafikKepuasan from "./data_kesehatan_warga/grafik_kepuasan";
|
||||||
|
import DeskripsiJadwalKegiatan from "./data_kesehatan_warga/jadwal_kegiatan/deskripsi_kegiatan";
|
||||||
|
import DokumenDiperlukan from "./data_kesehatan_warga/jadwal_kegiatan/dokumen_yang_diperlukan";
|
||||||
|
import InformasiJadwalKegiatan from "./data_kesehatan_warga/jadwal_kegiatan/informasi_kegiatan";
|
||||||
|
import LayananTersedia from "./data_kesehatan_warga/jadwal_kegiatan/layanan_yang_tersedia";
|
||||||
|
import PendaftaranJadwal from "./data_kesehatan_warga/jadwal_kegiatan/pendaftaran";
|
||||||
|
import SyaratKetentuan from "./data_kesehatan_warga/jadwal_kegiatan/syarat_dan_ketentuan";
|
||||||
|
import PersentaseKelahiranKematian from "./data_kesehatan_warga/persentase_kelahiran_kematian";
|
||||||
import InfoWabahPenyakit from "./info-wabah-penyakit";
|
import InfoWabahPenyakit from "./info-wabah-penyakit";
|
||||||
|
import KontakDarurat from "./kontak-darurat";
|
||||||
|
import PenangananDarurat from "./penanganan-darurat";
|
||||||
|
import Posyandu from "./posyandu";
|
||||||
|
import ProgramKesehatan from "./program-kesehatan";
|
||||||
|
import Puskesmas from "./puskesmas";
|
||||||
|
import FasilitasKesehatan from "./data_kesehatan_warga/fasilitas_kesehatan";
|
||||||
|
|
||||||
|
|
||||||
const Kesehatan = new Elysia({
|
const Kesehatan = new Elysia({
|
||||||
prefix: "/api/kesehatan",
|
prefix: "/api/kesehatan",
|
||||||
tags: ["Kesehatan"],
|
tags: ["Kesehatan"],
|
||||||
})
|
})
|
||||||
.use(InformasiUmum)
|
|
||||||
.use(LayananUnggulan)
|
|
||||||
.use(DokterDantenagamedis)
|
|
||||||
.use(FasilitasPendukung)
|
|
||||||
.use(TarifDanLayanan)
|
|
||||||
.use(ProsedurPendaftaran)
|
|
||||||
.use(InformasiJadwalKegiatan)
|
.use(InformasiJadwalKegiatan)
|
||||||
.use(DeskripsiJadwalKegiatan)
|
.use(DeskripsiJadwalKegiatan)
|
||||||
.use(LayananTersedia)
|
.use(LayananTersedia)
|
||||||
@@ -57,4 +46,5 @@ const Kesehatan = new Elysia({
|
|||||||
.use(PenangananDarurat)
|
.use(PenangananDarurat)
|
||||||
.use(KontakDarurat)
|
.use(KontakDarurat)
|
||||||
.use(InfoWabahPenyakit)
|
.use(InfoWabahPenyakit)
|
||||||
|
.use(FasilitasKesehatan)
|
||||||
export default Kesehatan;
|
export default Kesehatan;
|
||||||
|
|||||||
Reference in New Issue
Block a user