diff --git a/apps/frontend/src/modules/aspectManagement/modals/AspectDeleteModal.tsx b/apps/frontend/src/modules/aspectManagement/modals/AspectDeleteModal.tsx
index c971a90..56fd575 100644
--- a/apps/frontend/src/modules/aspectManagement/modals/AspectDeleteModal.tsx
+++ b/apps/frontend/src/modules/aspectManagement/modals/AspectDeleteModal.tsx
@@ -1,5 +1,14 @@
import client from "@/honoClient";
-import { Button, Flex, Modal, Text } from "@mantine/core";
+import {
+ AlertDialog,
+ AlertDialogCancel,
+ AlertDialogContent,
+ AlertDialogDescription,
+ AlertDialogFooter,
+ AlertDialogHeader,
+ AlertDialogTitle,
+} from "@/shadcn/components/ui/alert-dialog";
+import { Button } from "@/shadcn/components/ui/button";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { getRouteApi, useSearch } from "@tanstack/react-router";
import { deleteAspect } from "../queries/aspectQueries";
@@ -9,89 +18,80 @@ import fetchRPC from "@/utils/fetchRPC";
const routeApi = getRouteApi("/_dashboardLayout/aspect/");
export default function AspectDeleteModal() {
- const queryClient = useQueryClient();
+ const queryClient = useQueryClient();
+ const searchParams = useSearch({ from: "/_dashboardLayout/aspect/" }) as {
+ delete: string;
+ };
- const searchParams = useSearch({ from: "/_dashboardLayout/aspect/" }) as {
- delete: string;
- };
+ const aspectId = searchParams.delete;
+ const navigate = routeApi.useNavigate();
- const aspectId = searchParams.delete;
- const navigate = routeApi.useNavigate();
+ const aspectQuery = useQuery({
+ queryKey: ["management-aspect", aspectId],
+ queryFn: async () => {
+ if (!aspectId) return null;
+ return await fetchRPC(
+ client["management-aspect"][":id"].$get({
+ param: { id: aspectId },
+ query: {},
+ })
+ );
+ },
+ });
- const aspectQuery = useQuery({
- queryKey: ["management-aspect", aspectId],
- queryFn: async () => {
- if (!aspectId) return null;
- return await fetchRPC(
- client["management-aspect"][":id"].$get({
- param: {
- id: aspectId,
- },
- query: {},
- })
- );
- },
- });
+ const mutation = useMutation({
+ mutationKey: ["deleteAspectMutation"],
+ mutationFn: async ({ id }: { id: string }) => {
+ return await deleteAspect(id);
+ },
+ onError: (error: unknown) => {
+ if (error instanceof Error) {
+ notifications.show({
+ message: error.message,
+ color: "red",
+ });
+ }
+ },
+ onSuccess: () => {
+ notifications.show({
+ message: "Aspek berhasil dihapus.",
+ color: "green",
+ });
+ queryClient.removeQueries({ queryKey: ["management-aspect", aspectId] });
+ queryClient.invalidateQueries({ queryKey: ["management-aspect"] });
+ navigate({ search: {} });
+ },
+ });
- const mutation = useMutation({
- mutationKey: ["deleteAspectMutation"],
- mutationFn: async ({ id }: { id: string }) => {
- return await deleteAspect(id);
- },
- onError: (error: unknown) => {
- if (error instanceof Error) {
- notifications.show({
- message: error.message,
- color: "red",
- });
- }
- },
- onSuccess: () => {
- notifications.show({
- message: "Aspek berhasil dihapus.",
- color: "green",
- });
- queryClient.removeQueries({ queryKey: ["management-aspect", aspectId] });
- queryClient.invalidateQueries({ queryKey: ["management-aspect"] });
- navigate({ search: {} });
- },
- });
+ const isModalOpen = Boolean(searchParams.delete && aspectQuery.data);
- const isModalOpen = Boolean(searchParams.delete && aspectQuery.data);
-
- return (
- navigate({ search: {} })}
- title={`Konfirmasi Hapus`}
- >
-
- Apakah Anda yakin ingin menghapus aspek{" "}
-
- {aspectQuery.data?.name}
-
- ? Tindakan ini tidak dapat diubah.
-
-
- {/* Buttons */}
-
-
-
-
-
- );
+ return (
+ navigate({ search: {} })}>
+
+
+ Konfirmasi Hapus
+
+ Apakah Anda yakin ingin menghapus aspek{" "}
+ {aspectQuery.data?.name}? Tindakan ini tidak dapat diubah.
+
+
+
+ navigate({ search: {} })}
+ disabled={mutation.isPending}
+ >
+ Batal
+
+
+
+
+
+ );
}
\ No newline at end of file