Merges the full git history of Inventory_frontend into the monorepo under frontend/. Removes the submodule in favor of a unified repo. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
19 lines
1.1 KiB
TypeScript
19 lines
1.1 KiB
TypeScript
export const resolveDeleteImpact = (entity: Record<string, any>): string[] => {
|
|
const impacts: string[] = []
|
|
const machineLinks = Array.isArray(entity?.machineLinks) ? entity.machineLinks.length : entity?.machineLinksCount ?? 0
|
|
const documents = Array.isArray(entity?.documents) ? entity.documents.length : entity?.documentsCount ?? 0
|
|
const customFields = Array.isArray(entity?.customFieldValues) ? entity.customFieldValues.length : entity?.customFieldValuesCount ?? 0
|
|
if (machineLinks > 0) impacts.push(`${machineLinks} liaison${machineLinks > 1 ? 's' : ''} machine`)
|
|
if (documents > 0) impacts.push(`${documents} document${documents > 1 ? 's' : ''}`)
|
|
if (customFields > 0) impacts.push(`${customFields} valeur${customFields > 1 ? 's' : ''} de champs personnalisés`)
|
|
return impacts
|
|
}
|
|
|
|
export const buildDeleteMessage = (entityName: string, impacts: string[]): string => {
|
|
const lines = [`Voulez-vous vraiment supprimer « ${entityName} » ?`]
|
|
if (impacts.length) {
|
|
lines.push(`Cela supprimera également :\n• ${impacts.join('\n• ')}`)
|
|
}
|
|
lines.push('Cette action est irréversible.')
|
|
return lines.join('\n\n')
|
|
} |