fix delete modal
All checks were successful
Deploy Amap / deploy (push) Successful in 41s

This commit is contained in:
Julien Aldon
2026-03-06 15:50:30 +01:00
parent 61710a0347
commit 74bf1474e2
8 changed files with 35 additions and 31 deletions

View File

@@ -1,5 +1,5 @@
import { t } from "@/config/i18n";
import type { DeleteDependencies } from "@/services/resources/common";
import { useGetDeleteDependencies } from "@/services/api";
import { Button, Group, List, Modal, Text, type ModalBaseProps } from "@mantine/core";
import { IconCancel, IconCheck } from "@tabler/icons-react";
import { Link } from "react-router";
@@ -7,8 +7,7 @@ import { Link } from "react-router";
export type DeleteModalProps = ModalBaseProps & {
handleSubmit: (id: number) => void;
entityType: string;
entity: {name: string, id: number};
dependencies: DeleteDependencies[];
entity?: {name: string, id: number} | undefined;
}
export function DeleteModal({
@@ -17,8 +16,12 @@ export function DeleteModal({
handleSubmit,
entityType,
entity,
dependencies
}: DeleteModalProps) {
if (!entity) {
return null
}
const {data: deleteDependencies} = useGetDeleteDependencies(entityType, entity.id);
return (
<Modal
opened={opened}
@@ -26,11 +29,11 @@ export function DeleteModal({
title={t("delete entity", { capfirst: true, entity: t(entityType)})}
>
<Text>{`${t("are you sure you want to delete", {capfirst: true})} : "${entity.name}"`}</Text>
<Text>{`${t("this will also delete", {capfirst: true})} :`}</Text>
{deleteDependencies && deleteDependencies.length > 0 ? <Text>{`${t("this will also delete", {capfirst: true})} :`}</Text> : null}
{
<List>
{
dependencies?.map((dependency) => (
deleteDependencies?.map((dependency) => (
<List.Item
key={dependency.id}
>
@@ -66,6 +69,7 @@ export function DeleteModal({
leftSection={<IconCheck />}
onClick={() => {
handleSubmit(entity.id);
onClose();
}}
>
{t("delete", { capfirst: true})}