add all suppress modal
All checks were successful
Deploy Amap / deploy (push) Successful in 41s

This commit is contained in:
Julien Aldon
2026-03-06 16:48:38 +01:00
parent 74bf1474e2
commit 46b369ecd9
39 changed files with 654 additions and 372 deletions

View File

@@ -7,50 +7,48 @@ import { Link } from "react-router";
export type DeleteModalProps = ModalBaseProps & {
handleSubmit: (id: number) => void;
entityType: string;
entity?: {name: string, id: number} | undefined;
}
entity?: { name: string; id: number } | undefined;
};
export function DeleteModal({
opened,
onClose,
handleSubmit,
opened,
onClose,
handleSubmit,
entityType,
entity,
}: DeleteModalProps) {
if (!entity) {
return null
return null;
}
const {data: deleteDependencies} = useGetDeleteDependencies(entityType, entity.id);
const { data: deleteDependencies } = useGetDeleteDependencies(entityType, entity.id);
return (
<Modal
opened={opened}
onClose={onClose}
title={t("delete entity", { capfirst: true, entity: t(entityType)})}
title={t("delete entity", { capfirst: true, entity: t(entityType) })}
>
<Text>{`${t("are you sure you want to delete", {capfirst: true})} : "${entity.name}"`}</Text>
{deleteDependencies && deleteDependencies.length > 0 ? <Text>{`${t("this will also delete", {capfirst: true})} :`}</Text> : null}
<Text>{`${t("are you sure you want to delete", { capfirst: true })} : "${entity.name}"`}</Text>
{deleteDependencies && deleteDependencies.length > 0 ? (
<Text>{`${t("this will also delete", { capfirst: true })} :`}</Text>
) : null}
{
<List>
{
deleteDependencies?.map((dependency) => (
<List.Item
key={dependency.id}
>
{
dependency.type === 'contract' ? `${t(dependency.type, {capfirst: true})} - ${dependency.name}` :
<Link
to={`/dashboard/${dependency.type}s/${dependency.id}/edit`}
target="_blank"
rel="noopener noreferrer"
>
{`${t(dependency.type, {capfirst: true})} - ${dependency.name}`}
</Link>
}
</List.Item>
))
}
{deleteDependencies?.map((dependency) => (
<List.Item key={dependency.id}>
{dependency.type === "contract" ? (
`${t(dependency.type, { capfirst: true })} - ${dependency.name}`
) : (
<Link
to={`/dashboard/${dependency.type}s/${dependency.id}/edit`}
target="_blank"
rel="noopener noreferrer"
>
{`${t(dependency.type, { capfirst: true })} - ${dependency.name}`}
</Link>
)}
</List.Item>
))}
</List>
}
<Group mt="sm" justify="space-between">
@@ -65,16 +63,16 @@ export function DeleteModal({
</Button>
<Button
variant="filled"
aria-label={t("delete entity", { capfirst: true, entity: t(entityType)})}
aria-label={t("delete entity", { capfirst: true, entity: t(entityType) })}
leftSection={<IconCheck />}
onClick={() => {
handleSubmit(entity.id);
onClose();
}}
>
{t("delete", { capfirst: true})}
{t("delete", { capfirst: true })}
</Button>
</Group>
</Modal>
);
}
}