Fix Dibagian Data Kesehatan Warga

This commit is contained in:
2025-06-28 00:10:45 +08:00
parent 6d5b8dcf64
commit 41181d4cb3
18 changed files with 184 additions and 118 deletions

View File

@@ -39,15 +39,15 @@ const grafikkepuasan = proxy({
const res = await ApiFetch.api.kesehatan.grafikkepuasan["create"].post(grafikkepuasan.create.form);
if (res.status === 200) {
const uuid = res.data?.data?.uuid;
if (uuid) {
const id = res.data?.data?.id;
if (id) {
toast.success("Success create");
grafikkepuasan.create.form = {
label: "",
jumlah: "",
};
grafikkepuasan.findMany.load();
return uuid;
return id;
}
}
toast.error("failed create");
@@ -77,9 +77,9 @@ const grafikkepuasan = proxy({
data: null as Prisma.GrafikKepuasanGetPayload<{
omit: { isActive: true }
}> | null,
async load(uuid: string) {
async load(id: string) {
try {
const res = await fetch(`/api/kesehatan/grafikkepuasan/${uuid}`);
const res = await fetch(`/api/kesehatan/grafikkepuasan/${id}`);
if (res.ok) {
const data = await res.json();
grafikkepuasan.findUnique.data = data.data ?? null;
@@ -94,14 +94,14 @@ const grafikkepuasan = proxy({
},
},
update: {
uuid: "",
id: "",
form: {...defaultForm},
loading: false,
async byId() {
},
async submit() {
const uuid = this.uuid;
if (!uuid) {
const id = this.id;
if (!id) {
toast.warn("ID tidak valid");
return null;
}
@@ -114,7 +114,7 @@ const grafikkepuasan = proxy({
}
try {
this.loading = true;
const response = await fetch(`/api/kesehatan/grafikkepuasan/${uuid}`, {
const response = await fetch(`/api/kesehatan/grafikkepuasan/${id}`, {
method: "PUT",
headers: {
"Content-Type": "application/json",
@@ -143,14 +143,14 @@ const grafikkepuasan = proxy({
},
delete: {
loading: false,
async byId(uuid: string) {
if (!uuid) {
async byId(id: string) {
if (!id) {
return toast.warn("ID tidak valid");
}
try {
grafikkepuasan.delete.loading = true;
const response = await fetch(`/api/kesehatan/grafikkepuasan/del/${uuid}`, {
const response = await fetch(`/api/kesehatan/grafikkepuasan/del/${id}`, {
method: "DELETE",
headers: {
"Content-Type": "application/json",

View File

@@ -45,12 +45,12 @@ const persentasekelahiran = proxy({
);
if (res.status === 200) {
const uuid = res.data?.data?.uuid;
if (uuid) {
const id = res.data?.data?.id;
if (id) {
toast.success("Success create");
persentasekelahiran.create.form = { ...defaultForm };
persentasekelahiran.findMany.load();
return uuid;
return id;
}
}
toast.error("failed create");
@@ -80,9 +80,9 @@ const persentasekelahiran = proxy({
data: null as Prisma.DataKematian_KelahiranGetPayload<{
omit: { isActive: true };
}> | null,
async load(uuid: string) {
async load(id: string) {
try {
const res = await fetch(`/api/kesehatan/persentasekelahiran/${uuid}`);
const res = await fetch(`/api/kesehatan/persentasekelahiran/${id}`);
if (res.ok) {
const data = await res.json();
persentasekelahiran.findUnique.data = data.data ?? null;
@@ -98,13 +98,13 @@ const persentasekelahiran = proxy({
},
update: {
uuid: "",
id: "",
form: { ...defaultForm },
loading: false,
async submit() {
const uuid = this.uuid;
if (!uuid) {
toast.warn("UUID tidak valid");
const id = this.id;
if (!id) {
toast.warn("ID tidak valid");
return null;
}
@@ -126,7 +126,7 @@ update: {
try {
this.loading = true;
const res = await fetch(`/api/kesehatan/persentasekelahiran/${uuid}`, {
const res = await fetch(`/api/kesehatan/persentasekelahiran/${id}`, {
method: "PUT",
headers: {
"Content-Type": "application/json",
@@ -156,13 +156,13 @@ update: {
delete: {
loading: false,
async byId(uuid: string) {
if (!uuid) return toast.warn("UUID tidak valid");
async byId(id: string) {
if (!id) return toast.warn("ID tidak valid");
try {
persentasekelahiran.delete.loading = true;
const response = await fetch(`/api/kesehatan/persentasekelahiran/del/${uuid}`, {
const response = await fetch(`/api/kesehatan/persentasekelahiran/del/${id}`, {
method: "DELETE",
headers: {
"Content-Type": "application/json",
@@ -177,7 +177,7 @@ update: {
} else {
toast.error(result?.message || "Gagal menghapus persentase kelahiran");
}
} catch (error) {
} catch (error) {
console.error("Gagal delete:", error);
toast.error("Terjadi kesalahan saat menghapus persentase kelahiran");
} finally {