Fix Dibagian Data Kesehatan Warga
This commit is contained in:
@@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
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.
|
||||||
|
- You are about to drop the column `uuid` on the `DataKematian_Kelahiran` table. All the data in the column will be lost.
|
||||||
|
- The primary key for the `GrafikKepuasan` table will be changed. If it partially fails, the table could be left without primary key constraint.
|
||||||
|
- You are about to drop the column `uuid` on the `GrafikKepuasan` table. All the data in the column will be lost.
|
||||||
|
- A unique constraint covering the columns `[id]` on the table `DataKematian_Kelahiran` will be added. If there are existing duplicate values, this will fail.
|
||||||
|
- A unique constraint covering the columns `[id]` on the table `GrafikKepuasan` will be added. If there are existing duplicate values, this will fail.
|
||||||
|
- Added the required column `doctorSignId` to the `ArtikelKesehatan` table without a default value. This is not possible if the table is not empty.
|
||||||
|
- Added the required column `firstAidId` to the `ArtikelKesehatan` table without a default value. This is not possible if the table is not empty.
|
||||||
|
- Added the required column `introductionId` to the `ArtikelKesehatan` table without a default value. This is not possible if the table is not empty.
|
||||||
|
- Added the required column `mythVsFactId` to the `ArtikelKesehatan` table without a default value. This is not possible if the table is not empty.
|
||||||
|
- Added the required column `preventionId` to the `ArtikelKesehatan` table without a default value. This is not possible if the table is not empty.
|
||||||
|
- Added the required column `symptomId` to the `ArtikelKesehatan` table without a default value. This is not possible if the table is not empty.
|
||||||
|
|
||||||
|
*/
|
||||||
|
-- DropIndex
|
||||||
|
DROP INDEX "DataKematian_Kelahiran_uuid_key";
|
||||||
|
|
||||||
|
-- DropIndex
|
||||||
|
DROP INDEX "GrafikKepuasan_uuid_key";
|
||||||
|
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "ArtikelKesehatan" ADD COLUMN "doctorSignId" TEXT NOT NULL,
|
||||||
|
ADD COLUMN "firstAidId" TEXT NOT NULL,
|
||||||
|
ADD COLUMN "introductionId" TEXT NOT NULL,
|
||||||
|
ADD COLUMN "mythVsFactId" TEXT NOT NULL,
|
||||||
|
ADD COLUMN "preventionId" TEXT NOT NULL,
|
||||||
|
ADD COLUMN "symptomId" TEXT NOT NULL;
|
||||||
|
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "DataKematian_Kelahiran" DROP CONSTRAINT "DataKematian_Kelahiran_pkey",
|
||||||
|
DROP COLUMN "uuid",
|
||||||
|
ALTER COLUMN "id" DROP DEFAULT,
|
||||||
|
ALTER COLUMN "id" SET DATA TYPE TEXT;
|
||||||
|
DROP SEQUENCE "DataKematian_Kelahiran_id_seq";
|
||||||
|
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "GrafikKepuasan" DROP CONSTRAINT "GrafikKepuasan_pkey",
|
||||||
|
DROP COLUMN "uuid",
|
||||||
|
ALTER COLUMN "id" DROP DEFAULT,
|
||||||
|
ALTER COLUMN "id" SET DATA TYPE TEXT;
|
||||||
|
DROP SEQUENCE "GrafikKepuasan_id_seq";
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "DataKematian_Kelahiran_id_key" ON "DataKematian_Kelahiran"("id");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "GrafikKepuasan_id_key" ON "GrafikKepuasan"("id");
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "ArtikelKesehatan" ADD CONSTRAINT "ArtikelKesehatan_introductionId_fkey" FOREIGN KEY ("introductionId") REFERENCES "Introduction"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "ArtikelKesehatan" ADD CONSTRAINT "ArtikelKesehatan_symptomId_fkey" FOREIGN KEY ("symptomId") REFERENCES "Symptom"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "ArtikelKesehatan" ADD CONSTRAINT "ArtikelKesehatan_preventionId_fkey" FOREIGN KEY ("preventionId") REFERENCES "Prevention"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "ArtikelKesehatan" ADD CONSTRAINT "ArtikelKesehatan_firstAidId_fkey" FOREIGN KEY ("firstAidId") REFERENCES "FirstAid"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "ArtikelKesehatan" ADD CONSTRAINT "ArtikelKesehatan_mythVsFactId_fkey" FOREIGN KEY ("mythVsFactId") REFERENCES "MythVsFact"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "ArtikelKesehatan" ADD CONSTRAINT "ArtikelKesehatan_doctorSignId_fkey" FOREIGN KEY ("doctorSignId") REFERENCES "DoctorSign"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
@@ -650,8 +650,7 @@ model PendaftaranJadwalKegiatan {
|
|||||||
|
|
||||||
// ========================================= PERSENTASE KELAHIRAN & KEMATIAN ========================================= //
|
// ========================================= PERSENTASE KELAHIRAN & KEMATIAN ========================================= //
|
||||||
model DataKematian_Kelahiran {
|
model DataKematian_Kelahiran {
|
||||||
id Int @id @default(autoincrement())
|
id String @unique @default(cuid())
|
||||||
uuid String @unique @default(cuid())
|
|
||||||
tahun String
|
tahun String
|
||||||
kematianKasar String
|
kematianKasar String
|
||||||
kematianBayi String
|
kematianBayi String
|
||||||
@@ -664,8 +663,7 @@ model DataKematian_Kelahiran {
|
|||||||
|
|
||||||
// ========================================= GRAFIK KEPUASAN ========================================= //
|
// ========================================= GRAFIK KEPUASAN ========================================= //
|
||||||
model GrafikKepuasan {
|
model GrafikKepuasan {
|
||||||
id Int @id @default(autoincrement())
|
id String @unique @default(cuid())
|
||||||
uuid String @unique @default(cuid())
|
|
||||||
label String
|
label String
|
||||||
jumlah String
|
jumlah String
|
||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
@@ -708,13 +706,13 @@ model Introduction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
model Symptom {
|
model Symptom {
|
||||||
id String @id @default(cuid())
|
id String @id @default(cuid())
|
||||||
title String
|
title String
|
||||||
content String
|
content String
|
||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
updatedAt DateTime @updatedAt
|
updatedAt DateTime @updatedAt
|
||||||
deletedAt DateTime @default(now())
|
deletedAt DateTime @default(now())
|
||||||
isActive Boolean @default(true)
|
isActive Boolean @default(true)
|
||||||
ArtikelKesehatan ArtikelKesehatan[]
|
ArtikelKesehatan ArtikelKesehatan[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,15 +39,15 @@ const grafikkepuasan = proxy({
|
|||||||
const res = await ApiFetch.api.kesehatan.grafikkepuasan["create"].post(grafikkepuasan.create.form);
|
const res = await ApiFetch.api.kesehatan.grafikkepuasan["create"].post(grafikkepuasan.create.form);
|
||||||
|
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
const uuid = res.data?.data?.uuid;
|
const id = res.data?.data?.id;
|
||||||
if (uuid) {
|
if (id) {
|
||||||
toast.success("Success create");
|
toast.success("Success create");
|
||||||
grafikkepuasan.create.form = {
|
grafikkepuasan.create.form = {
|
||||||
label: "",
|
label: "",
|
||||||
jumlah: "",
|
jumlah: "",
|
||||||
};
|
};
|
||||||
grafikkepuasan.findMany.load();
|
grafikkepuasan.findMany.load();
|
||||||
return uuid;
|
return id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
toast.error("failed create");
|
toast.error("failed create");
|
||||||
@@ -77,9 +77,9 @@ const grafikkepuasan = proxy({
|
|||||||
data: null as Prisma.GrafikKepuasanGetPayload<{
|
data: null as Prisma.GrafikKepuasanGetPayload<{
|
||||||
omit: { isActive: true }
|
omit: { isActive: true }
|
||||||
}> | null,
|
}> | null,
|
||||||
async load(uuid: string) {
|
async load(id: string) {
|
||||||
try {
|
try {
|
||||||
const res = await fetch(`/api/kesehatan/grafikkepuasan/${uuid}`);
|
const res = await fetch(`/api/kesehatan/grafikkepuasan/${id}`);
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
grafikkepuasan.findUnique.data = data.data ?? null;
|
grafikkepuasan.findUnique.data = data.data ?? null;
|
||||||
@@ -94,14 +94,14 @@ const grafikkepuasan = proxy({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
update: {
|
update: {
|
||||||
uuid: "",
|
id: "",
|
||||||
form: {...defaultForm},
|
form: {...defaultForm},
|
||||||
loading: false,
|
loading: false,
|
||||||
async byId() {
|
async byId() {
|
||||||
},
|
},
|
||||||
async submit() {
|
async submit() {
|
||||||
const uuid = this.uuid;
|
const id = this.id;
|
||||||
if (!uuid) {
|
if (!id) {
|
||||||
toast.warn("ID tidak valid");
|
toast.warn("ID tidak valid");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -114,7 +114,7 @@ const grafikkepuasan = proxy({
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
const response = await fetch(`/api/kesehatan/grafikkepuasan/${uuid}`, {
|
const response = await fetch(`/api/kesehatan/grafikkepuasan/${id}`, {
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
@@ -143,14 +143,14 @@ const grafikkepuasan = proxy({
|
|||||||
},
|
},
|
||||||
delete: {
|
delete: {
|
||||||
loading: false,
|
loading: false,
|
||||||
async byId(uuid: string) {
|
async byId(id: string) {
|
||||||
if (!uuid) {
|
if (!id) {
|
||||||
return toast.warn("ID tidak valid");
|
return toast.warn("ID tidak valid");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
grafikkepuasan.delete.loading = true;
|
grafikkepuasan.delete.loading = true;
|
||||||
|
|
||||||
const response = await fetch(`/api/kesehatan/grafikkepuasan/del/${uuid}`, {
|
const response = await fetch(`/api/kesehatan/grafikkepuasan/del/${id}`, {
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
|
|||||||
@@ -45,12 +45,12 @@ const persentasekelahiran = proxy({
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
const uuid = res.data?.data?.uuid;
|
const id = res.data?.data?.id;
|
||||||
if (uuid) {
|
if (id) {
|
||||||
toast.success("Success create");
|
toast.success("Success create");
|
||||||
persentasekelahiran.create.form = { ...defaultForm };
|
persentasekelahiran.create.form = { ...defaultForm };
|
||||||
persentasekelahiran.findMany.load();
|
persentasekelahiran.findMany.load();
|
||||||
return uuid;
|
return id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
toast.error("failed create");
|
toast.error("failed create");
|
||||||
@@ -80,9 +80,9 @@ const persentasekelahiran = proxy({
|
|||||||
data: null as Prisma.DataKematian_KelahiranGetPayload<{
|
data: null as Prisma.DataKematian_KelahiranGetPayload<{
|
||||||
omit: { isActive: true };
|
omit: { isActive: true };
|
||||||
}> | null,
|
}> | null,
|
||||||
async load(uuid: string) {
|
async load(id: string) {
|
||||||
try {
|
try {
|
||||||
const res = await fetch(`/api/kesehatan/persentasekelahiran/${uuid}`);
|
const res = await fetch(`/api/kesehatan/persentasekelahiran/${id}`);
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
persentasekelahiran.findUnique.data = data.data ?? null;
|
persentasekelahiran.findUnique.data = data.data ?? null;
|
||||||
@@ -98,13 +98,13 @@ const persentasekelahiran = proxy({
|
|||||||
},
|
},
|
||||||
|
|
||||||
update: {
|
update: {
|
||||||
uuid: "",
|
id: "",
|
||||||
form: { ...defaultForm },
|
form: { ...defaultForm },
|
||||||
loading: false,
|
loading: false,
|
||||||
async submit() {
|
async submit() {
|
||||||
const uuid = this.uuid;
|
const id = this.id;
|
||||||
if (!uuid) {
|
if (!id) {
|
||||||
toast.warn("UUID tidak valid");
|
toast.warn("ID tidak valid");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,7 +126,7 @@ update: {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
const res = await fetch(`/api/kesehatan/persentasekelahiran/${uuid}`, {
|
const res = await fetch(`/api/kesehatan/persentasekelahiran/${id}`, {
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
@@ -156,13 +156,13 @@ update: {
|
|||||||
|
|
||||||
delete: {
|
delete: {
|
||||||
loading: false,
|
loading: false,
|
||||||
async byId(uuid: string) {
|
async byId(id: string) {
|
||||||
if (!uuid) return toast.warn("UUID tidak valid");
|
if (!id) return toast.warn("ID tidak valid");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
persentasekelahiran.delete.loading = true;
|
persentasekelahiran.delete.loading = true;
|
||||||
|
|
||||||
const response = await fetch(`/api/kesehatan/persentasekelahiran/del/${uuid}`, {
|
const response = await fetch(`/api/kesehatan/persentasekelahiran/del/${id}`, {
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
@@ -177,7 +177,7 @@ update: {
|
|||||||
} else {
|
} else {
|
||||||
toast.error(result?.message || "Gagal menghapus persentase kelahiran");
|
toast.error(result?.message || "Gagal menghapus persentase kelahiran");
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Gagal delete:", error);
|
console.error("Gagal delete:", error);
|
||||||
toast.error("Terjadi kesalahan saat menghapus persentase kelahiran");
|
toast.error("Terjadi kesalahan saat menghapus persentase kelahiran");
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -11,15 +11,15 @@ import { useProxy } from 'valtio/utils';
|
|||||||
|
|
||||||
function EditGrafikHasilKepuasan() {
|
function EditGrafikHasilKepuasan() {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const params = useParams() as { uuid: string }
|
const params = useParams() as { id: string }
|
||||||
const stateGrafikKepuasan = useProxy(grafikkepuasan)
|
const stateGrafikKepuasan = useProxy(grafikkepuasan)
|
||||||
|
|
||||||
const uuid = params.uuid
|
const id = params.id
|
||||||
|
|
||||||
// Load data saat komponen mount
|
// Load data saat komponen mount
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (uuid) {
|
if (id) {
|
||||||
stateGrafikKepuasan.findUnique.load(uuid).then(() => {
|
stateGrafikKepuasan.findUnique.load(id).then(() => {
|
||||||
const data = stateGrafikKepuasan.findUnique.data
|
const data = stateGrafikKepuasan.findUnique.data
|
||||||
if (data) {
|
if (data) {
|
||||||
stateGrafikKepuasan.update.form = {
|
stateGrafikKepuasan.update.form = {
|
||||||
@@ -29,11 +29,11 @@ function EditGrafikHasilKepuasan() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}, [uuid])
|
}, [id])
|
||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
// Set the ID before submitting
|
// Set the ID before submitting
|
||||||
stateGrafikKepuasan.update.uuid = uuid;
|
stateGrafikKepuasan.update.id = id;
|
||||||
await stateGrafikKepuasan.update.submit();
|
await stateGrafikKepuasan.update.submit();
|
||||||
router.push('/admin/kesehatan/data-kesehatan-warga/grafik_hasil_kepuasan')
|
router.push('/admin/kesehatan/data-kesehatan-warga/grafik_hasil_kepuasan')
|
||||||
}
|
}
|
||||||
@@ -45,7 +45,7 @@ function GrafikHasilKepuasanMasyarakat() {
|
|||||||
setMounted(true);
|
setMounted(true);
|
||||||
if (stateGrafikKepuasan.findMany.data) {
|
if (stateGrafikKepuasan.findMany.data) {
|
||||||
setChartData(stateGrafikKepuasan.findMany.data.map((item) => ({
|
setChartData(stateGrafikKepuasan.findMany.data.map((item) => ({
|
||||||
id: item.uuid,
|
id: item.id,
|
||||||
label: item.label,
|
label: item.label,
|
||||||
jumlah: Number(item.jumlah),
|
jumlah: Number(item.jumlah),
|
||||||
})));
|
})));
|
||||||
@@ -82,11 +82,11 @@ function GrafikHasilKepuasanMasyarakat() {
|
|||||||
</TableThead>
|
</TableThead>
|
||||||
<TableTbody>
|
<TableTbody>
|
||||||
{stateGrafikKepuasan.findMany.data?.map((item) => (
|
{stateGrafikKepuasan.findMany.data?.map((item) => (
|
||||||
<TableTr key={item.uuid}>
|
<TableTr key={item.id}>
|
||||||
<TableTd>{item.label}</TableTd>
|
<TableTd>{item.label}</TableTd>
|
||||||
<TableTd>{item.jumlah}</TableTd>
|
<TableTd>{item.jumlah}</TableTd>
|
||||||
<TableTd>
|
<TableTd>
|
||||||
<Button color='green' onClick={() => router.push(`/admin/kesehatan/data-kesehatan-warga/grafik_hasil_kepuasan/${item.uuid}`)}>
|
<Button color='green' onClick={() => router.push(`/admin/kesehatan/data-kesehatan-warga/grafik_hasil_kepuasan/${item.id}`)}>
|
||||||
<IconEdit size={20} />
|
<IconEdit size={20} />
|
||||||
</Button>
|
</Button>
|
||||||
</TableTd>
|
</TableTd>
|
||||||
@@ -95,7 +95,7 @@ function GrafikHasilKepuasanMasyarakat() {
|
|||||||
color='red'
|
color='red'
|
||||||
disabled={stateGrafikKepuasan.delete.loading}
|
disabled={stateGrafikKepuasan.delete.loading}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setSelectedId(item.uuid)
|
setSelectedId(item.id)
|
||||||
setModalHapus(true)
|
setModalHapus(true)
|
||||||
}}>
|
}}>
|
||||||
<IconTrash size={20} />
|
<IconTrash size={20} />
|
||||||
|
|||||||
@@ -12,16 +12,16 @@ import { useProxy } from 'valtio/utils';
|
|||||||
|
|
||||||
function EditPersentaseDataKelahiranKematian() {
|
function EditPersentaseDataKelahiranKematian() {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const params = useParams() as { uuid: string }
|
const params = useParams() as { id: string }
|
||||||
const statePresentase = useProxy(persentasekelahiran)
|
const statePresentase = useProxy(persentasekelahiran)
|
||||||
|
|
||||||
const id = params.uuid
|
const id = params.id
|
||||||
|
|
||||||
// Load data saat komponen mount
|
// Load data saat komponen mount
|
||||||
// Di file page.tsx, ubah useEffect-nya menjadi:
|
// Di file page.tsx, ubah useEffect-nya menjadi:
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!id) return;
|
if (!id) return;
|
||||||
statePresentase.update.uuid = id;
|
statePresentase.update.id = id;
|
||||||
statePresentase.findUnique.load(id)
|
statePresentase.findUnique.load(id)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
const data = statePresentase.findUnique.data;
|
const data = statePresentase.findUnique.data;
|
||||||
@@ -43,7 +43,7 @@ useEffect(() => {
|
|||||||
// Di handleSubmit, ubah menjadi:
|
// Di handleSubmit, ubah menjadi:
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
try {
|
try {
|
||||||
statePresentase.update.uuid = id;
|
statePresentase.update.id = id;
|
||||||
await statePresentase.update.submit();
|
await statePresentase.update.submit();
|
||||||
toast.success('Data berhasil diperbarui');
|
toast.success('Data berhasil diperbarui');
|
||||||
router.push('/admin/kesehatan/data-kesehatan-warga/persentase_data_kelahiran_kematian');
|
router.push('/admin/kesehatan/data-kesehatan-warga/persentase_data_kelahiran_kematian');
|
||||||
@@ -13,7 +13,7 @@ import { ModalKonfirmasiHapus } from '../../../_com/modalKonfirmasiHapus';
|
|||||||
|
|
||||||
function PersentaseDataKelahiranKematian() {
|
function PersentaseDataKelahiranKematian() {
|
||||||
type PDKMGrafik = {
|
type PDKMGrafik = {
|
||||||
uuid: string;
|
id: string;
|
||||||
tahun: string;
|
tahun: string;
|
||||||
kematianKasar: number;
|
kematianKasar: number;
|
||||||
kematianBayi: number;
|
kematianBayi: number;
|
||||||
@@ -47,7 +47,7 @@ function PersentaseDataKelahiranKematian() {
|
|||||||
setMounted(true);
|
setMounted(true);
|
||||||
if (statePersentase.findMany.data) {
|
if (statePersentase.findMany.data) {
|
||||||
setChartData(statePersentase.findMany.data.map((item) => ({
|
setChartData(statePersentase.findMany.data.map((item) => ({
|
||||||
uuid: item.uuid,
|
id: item.id,
|
||||||
tahun: item.tahun,
|
tahun: item.tahun,
|
||||||
kematianKasar: Number(item.kematianKasar),
|
kematianKasar: Number(item.kematianKasar),
|
||||||
kematianBayi: Number(item.kematianBayi),
|
kematianBayi: Number(item.kematianBayi),
|
||||||
@@ -88,13 +88,13 @@ function PersentaseDataKelahiranKematian() {
|
|||||||
</TableThead>
|
</TableThead>
|
||||||
<TableTbody>
|
<TableTbody>
|
||||||
{statePersentase.findMany.data?.map((item) => (
|
{statePersentase.findMany.data?.map((item) => (
|
||||||
<TableTr key={item.uuid}>
|
<TableTr key={item.id}>
|
||||||
<TableTd>{item.tahun}</TableTd>
|
<TableTd>{item.tahun}</TableTd>
|
||||||
<TableTd>{item.kematianKasar}</TableTd>
|
<TableTd>{item.kematianKasar}</TableTd>
|
||||||
<TableTd>{item.kematianBayi}</TableTd>
|
<TableTd>{item.kematianBayi}</TableTd>
|
||||||
<TableTd>{item.kelahiranKasar}</TableTd>
|
<TableTd>{item.kelahiranKasar}</TableTd>
|
||||||
<TableTd>
|
<TableTd>
|
||||||
<Button color='green' onClick={() => router.push(`/admin/kesehatan/data-kesehatan-warga/persentase_data_kelahiran_kematian/${item.uuid}`)}>
|
<Button color='green' onClick={() => router.push(`/admin/kesehatan/data-kesehatan-warga/persentase_data_kelahiran_kematian/${item.id}`)}>
|
||||||
<IconEdit size={20} />
|
<IconEdit size={20} />
|
||||||
</Button>
|
</Button>
|
||||||
</TableTd>
|
</TableTd>
|
||||||
@@ -103,7 +103,7 @@ function PersentaseDataKelahiranKematian() {
|
|||||||
color='red'
|
color='red'
|
||||||
disabled={statePersentase.delete.loading}
|
disabled={statePersentase.delete.loading}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setSelectedId(item.uuid)
|
setSelectedId(item.id)
|
||||||
setModalHapus(true)
|
setModalHapus(true)
|
||||||
}}>
|
}}>
|
||||||
<IconTrash size={20} />
|
<IconTrash size={20} />
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ export default async function grafikKepuasanCreate(context: Context) {
|
|||||||
jumlah: body.jumlah,
|
jumlah: body.jumlah,
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
uuid: true,
|
id: true,
|
||||||
label: true,
|
label: true,
|
||||||
jumlah: true,
|
jumlah: true,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,35 +2,35 @@ import prisma from "@/lib/prisma";
|
|||||||
import { Context } from "elysia";
|
import { Context } from "elysia";
|
||||||
|
|
||||||
export default async function grafikKepuasanDelete(context: Context) {
|
export default async function grafikKepuasanDelete(context: Context) {
|
||||||
const uuid = context.params?.uuid;
|
const id = context.params?.id;
|
||||||
|
|
||||||
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 },
|
|
||||||
})
|
|
||||||
|
|
||||||
|
if (!id) {
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: false,
|
||||||
message: "Data berhasil dihapus",
|
message: "ID tidak ditemukan",
|
||||||
data: deleted,
|
};
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
const existing = await prisma.grafikKepuasan.findUnique({
|
||||||
|
where: {
|
||||||
|
id: id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!existing) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "Data tidak ditemukan",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const deleted = await prisma.grafikKepuasan.delete({
|
||||||
|
where: { id },
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
message: "Data berhasil dihapus",
|
||||||
|
data: deleted,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ import prisma from "@/lib/prisma";
|
|||||||
export default async function grafikKepuasanFindUnique(request: Request) {
|
export default async function grafikKepuasanFindUnique(request: Request) {
|
||||||
const url = new URL(request.url);
|
const url = new URL(request.url);
|
||||||
const pathSegments = url.pathname.split('/');
|
const pathSegments = url.pathname.split('/');
|
||||||
const uuid = pathSegments[pathSegments.length - 1];
|
const id = pathSegments[pathSegments.length - 1];
|
||||||
|
|
||||||
if (!uuid) {
|
if (!id) {
|
||||||
return Response.json({
|
return Response.json({
|
||||||
success: false,
|
success: false,
|
||||||
message: 'ID tidak boleh kosong',
|
message: 'ID tidak boleh kosong',
|
||||||
@@ -13,7 +13,7 @@ export default async function grafikKepuasanFindUnique(request: Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (typeof uuid !== 'string') {
|
if (typeof id !== 'string') {
|
||||||
return Response.json({
|
return Response.json({
|
||||||
success: false,
|
success: false,
|
||||||
message: "ID tidak valid",
|
message: "ID tidak valid",
|
||||||
@@ -21,7 +21,7 @@ export default async function grafikKepuasanFindUnique(request: Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const data = await prisma.grafikKepuasan.findUnique({
|
const data = await prisma.grafikKepuasan.findUnique({
|
||||||
where: { uuid },
|
where: { id },
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!data) {
|
if (!data) {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ const GrafikKepuasan = new Elysia({
|
|||||||
prefix: "/grafikkepuasan",
|
prefix: "/grafikkepuasan",
|
||||||
tags: ["Data Kesehatan/Grafik Kepuasan"]
|
tags: ["Data Kesehatan/Grafik Kepuasan"]
|
||||||
})
|
})
|
||||||
.get("/:uuid", async (context) => {
|
.get("/:id", async (context) => {
|
||||||
const response = await grafikKepuasanFindUnique(new Request(context.request));
|
const response = await grafikKepuasanFindUnique(new Request(context.request));
|
||||||
return response;
|
return response;
|
||||||
})
|
})
|
||||||
@@ -20,18 +20,18 @@ const GrafikKepuasan = new Elysia({
|
|||||||
jumlah: t.String(),
|
jumlah: t.String(),
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.put("/:uuid", grafikKepuasanUpdate, {
|
.put("/:id", grafikKepuasanUpdate, {
|
||||||
params: t.Object({
|
params: t.Object({
|
||||||
uuid: t.String(),
|
id: t.String(),
|
||||||
}),
|
}),
|
||||||
body: t.Object({
|
body: t.Object({
|
||||||
label: t.String(),
|
label: t.String(),
|
||||||
jumlah: t.String(),
|
jumlah: t.String(),
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.delete("/del/:uuid", grafikKepuasanDelete, {
|
.delete("/del/:id", grafikKepuasanDelete, {
|
||||||
params: t.Object({
|
params: t.Object({
|
||||||
uuid: t.String(),
|
id: t.String(),
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
export default GrafikKepuasan
|
export default GrafikKepuasan
|
||||||
@@ -2,9 +2,9 @@ import prisma from "@/lib/prisma";
|
|||||||
import { Context } from "elysia";
|
import { Context } from "elysia";
|
||||||
|
|
||||||
export default async function grafikKepuasanUpdate(context: Context) {
|
export default async function grafikKepuasanUpdate(context: Context) {
|
||||||
const uuid = context.params?.uuid;
|
const id = context.params?.id;
|
||||||
|
|
||||||
if (!uuid) {
|
if (!id) {
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: "ID tidak ditemukan"
|
message: "ID tidak ditemukan"
|
||||||
@@ -18,7 +18,7 @@ export default async function grafikKepuasanUpdate(context: Context) {
|
|||||||
|
|
||||||
const existing = await prisma.grafikKepuasan.findUnique({
|
const existing = await prisma.grafikKepuasan.findUnique({
|
||||||
where: {
|
where: {
|
||||||
uuid: uuid,
|
id: id,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ export default async function grafikKepuasanUpdate(context: Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const updated = await prisma.grafikKepuasan.update({
|
const updated = await prisma.grafikKepuasan.update({
|
||||||
where: { uuid },
|
where: { id },
|
||||||
data: {
|
data: {
|
||||||
label,
|
label,
|
||||||
jumlah,
|
jumlah,
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export default async function persentaseKelahiranKematianCreate(context: Context
|
|||||||
kelahiranKasar: body.kelahiranKasar,
|
kelahiranKasar: body.kelahiranKasar,
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
uuid: true,
|
id: true,
|
||||||
tahun: true,
|
tahun: true,
|
||||||
kematianKasar: true,
|
kematianKasar: true,
|
||||||
kematianBayi: true,
|
kematianBayi: true,
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ import prisma from "@/lib/prisma";
|
|||||||
import { Context } from "elysia";
|
import { Context } from "elysia";
|
||||||
|
|
||||||
export default async function persentaseKelahiranKematianDelete(context: Context) {
|
export default async function persentaseKelahiranKematianDelete(context: Context) {
|
||||||
const uuid = context.params?.uuid;
|
const id = context.params?.id;
|
||||||
|
|
||||||
if (!uuid) {
|
if (!id) {
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: "ID tidak ditemukan",
|
message: "ID tidak ditemukan",
|
||||||
@@ -13,7 +13,7 @@ export default async function persentaseKelahiranKematianDelete(context: Context
|
|||||||
|
|
||||||
const existing = await prisma.dataKematian_Kelahiran.findUnique({
|
const existing = await prisma.dataKematian_Kelahiran.findUnique({
|
||||||
where: {
|
where: {
|
||||||
uuid: uuid,
|
id: id,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ export default async function persentaseKelahiranKematianDelete(context: Context
|
|||||||
}
|
}
|
||||||
|
|
||||||
const deleted = await prisma.dataKematian_Kelahiran.delete({
|
const deleted = await prisma.dataKematian_Kelahiran.delete({
|
||||||
where: { uuid },
|
where: { id },
|
||||||
})
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ import prisma from "@/lib/prisma";
|
|||||||
export default async function persentaseKelahiranKematianFindUnique(request: Request) {
|
export default async function persentaseKelahiranKematianFindUnique(request: Request) {
|
||||||
const url = new URL(request.url);
|
const url = new URL(request.url);
|
||||||
const pathSegments = url.pathname.split('/');
|
const pathSegments = url.pathname.split('/');
|
||||||
const uuid = pathSegments[pathSegments.length - 1];
|
const id = pathSegments[pathSegments.length - 1];
|
||||||
|
|
||||||
if (!uuid) {
|
if (!id) {
|
||||||
return Response.json({
|
return Response.json({
|
||||||
success: false,
|
success: false,
|
||||||
message: "ID tidak boleh kosong",
|
message: "ID tidak boleh kosong",
|
||||||
@@ -13,7 +13,7 @@ export default async function persentaseKelahiranKematianFindUnique(request: Req
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (typeof uuid !== 'string') {
|
if (typeof id !== 'string') {
|
||||||
return Response.json({
|
return Response.json({
|
||||||
success: false,
|
success: false,
|
||||||
message: "ID tidak valid",
|
message: "ID tidak valid",
|
||||||
@@ -21,7 +21,7 @@ export default async function persentaseKelahiranKematianFindUnique(request: Req
|
|||||||
}
|
}
|
||||||
|
|
||||||
const data = await prisma.dataKematian_Kelahiran.findUnique({
|
const data = await prisma.dataKematian_Kelahiran.findUnique({
|
||||||
where: { uuid },
|
where: { id },
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!data) {
|
if (!data) {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ const PersentaseKelahiranKematian = new Elysia({
|
|||||||
prefix: "/persentasekelahiran",
|
prefix: "/persentasekelahiran",
|
||||||
tags: ["Data Kesehatan/Persentase Kelahiran Kematian"],
|
tags: ["Data Kesehatan/Persentase Kelahiran Kematian"],
|
||||||
})
|
})
|
||||||
.get("/:uuid", async (context) => {
|
.get("/:id", async (context) => {
|
||||||
const response = await persentaseKelahiranKematianFindUnique(new Request(context.request))
|
const response = await persentaseKelahiranKematianFindUnique(new Request(context.request))
|
||||||
return response
|
return response
|
||||||
})
|
})
|
||||||
@@ -22,9 +22,9 @@ const PersentaseKelahiranKematian = new Elysia({
|
|||||||
kelahiranKasar: t.String(),
|
kelahiranKasar: t.String(),
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.put("/:uuid", persentaseKelahiranKematianUpdate, {
|
.put("/:id", persentaseKelahiranKematianUpdate, {
|
||||||
params: t.Object({
|
params: t.Object({
|
||||||
uuid: t.String(),
|
id: t.String(),
|
||||||
}),
|
}),
|
||||||
body: t.Object({
|
body: t.Object({
|
||||||
tahun: t.String(),
|
tahun: t.String(),
|
||||||
@@ -33,9 +33,9 @@ const PersentaseKelahiranKematian = new Elysia({
|
|||||||
kelahiranKasar: t.String(),
|
kelahiranKasar: t.String(),
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.delete("/del/:uuid", persentaseKelahiranKematianDelete, {
|
.delete("/del/:id", persentaseKelahiranKematianDelete, {
|
||||||
params: t.Object({
|
params: t.Object({
|
||||||
uuid: t.String(),
|
id: t.String(),
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
export default PersentaseKelahiranKematian;
|
export default PersentaseKelahiranKematian;
|
||||||
@@ -2,9 +2,9 @@ import prisma from "@/lib/prisma";
|
|||||||
import { Context } from "elysia";
|
import { Context } from "elysia";
|
||||||
|
|
||||||
export default async function persentaseKelahiranKematianUpdate(context: Context) {
|
export default async function persentaseKelahiranKematianUpdate(context: Context) {
|
||||||
const uuid = context.params?.uuid;
|
const id = context.params?.id;
|
||||||
|
|
||||||
if (!uuid) {
|
if (!id) {
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: "ID tidak ditemukan",
|
message: "ID tidak ditemukan",
|
||||||
@@ -20,7 +20,7 @@ export default async function persentaseKelahiranKematianUpdate(context: Context
|
|||||||
|
|
||||||
const existing = await prisma.dataKematian_Kelahiran.findUnique({
|
const existing = await prisma.dataKematian_Kelahiran.findUnique({
|
||||||
where: {
|
where: {
|
||||||
uuid: uuid,
|
id: id,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@ export default async function persentaseKelahiranKematianUpdate(context: Context
|
|||||||
}
|
}
|
||||||
|
|
||||||
const updated = await prisma.dataKematian_Kelahiran.update({
|
const updated = await prisma.dataKematian_Kelahiran.update({
|
||||||
where: { uuid },
|
where: { id },
|
||||||
data: {
|
data: {
|
||||||
tahun,
|
tahun,
|
||||||
kematianKasar,
|
kematianKasar,
|
||||||
|
|||||||
Reference in New Issue
Block a user