refactor : merge Inventory_frontend submodule into frontend/ directory

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>
This commit is contained in:
Matthieu
2026-04-01 14:17:57 +02:00
226 changed files with 56920 additions and 4 deletions

View File

@@ -0,0 +1,39 @@
/**
* Basic helpers around email formatting shared across components and composables.
*/
/**
* Normalises an email by trimming whitespace and converting it to lowercase.
*/
export const normalizeEmail = (rawValue: string): string => {
const value = (rawValue || '').trim()
return value.toLowerCase()
}
/**
* Masks an email address by hiding the characters between the first and last letters
* of the local part. Useful for UI fragments where we want partial obfuscation.
*/
export const maskEmail = (rawValue: string): string => {
const value = normalizeEmail(rawValue)
if (!value) {
return ''
}
const parts = value.split('@')
const localPart = parts[0] ?? ''
const domain = parts[1]
if (!domain || !localPart) {
return value
}
if (localPart.length <= 2) {
return `${localPart[0] ?? ''}·@${domain}`
}
const start = localPart[0] ?? ''
const end = localPart.slice(-1)
const masked = '·'.repeat(Math.max(0, localPart.length - 2))
return `${start}${masked}${end}@${domain}`
}

View File

@@ -0,0 +1,90 @@
/**
* Utilities to normalize and format phone numbers without relying on external libraries.
* The helpers keep the behaviour permissive to avoid breaking existing flows while
* still providing a single place where formatting rules live.
*/
/** Matches characters that should be kept when normalising a phone number. */
const PHONE_CHAR_PATTERN = /[^+\d]/g
/**
* Normalises a phone number by trimming whitespace, removing spacing/separators and
* converting international prefixes written with `00` to their `+` variant.
*/
export const normalizePhone = (rawValue: string | null | undefined): string => {
const trimmed = typeof rawValue === 'string' ? rawValue.trim() : ''
if (!trimmed) {
return ''
}
const cleaned = trimmed.replace(PHONE_CHAR_PATTERN, '')
if (cleaned.startsWith('00')) {
return `+${cleaned.slice(2)}`
}
return cleaned
}
/**
* Formats a phone number by grouping digits by two and joining them with dots while
* keeping any international prefix. The function remains tolerant to partially
* entered numbers and returns an empty string for nullish inputs.
*/
export const formatPhone = (rawValue: string | null | undefined): string => {
if (rawValue == null) {
return ''
}
const normalized = normalizePhone(rawValue)
if (!normalized) {
return ''
}
if (normalized.startsWith('+33')) {
let nationalNumber = normalized.slice(3)
if (nationalNumber.startsWith('0')) {
nationalNumber = nationalNumber.slice(1)
}
if (nationalNumber.length % 2 !== 0) {
nationalNumber = `0${nationalNumber}`
}
const groups = nationalNumber.match(/\d{1,2}/g) ?? []
if (groups.length === 0) {
return '+33'
}
return ['+33', ...groups].join('.')
}
const hasInternationalPrefix = normalized.startsWith('+')
const prefix = hasInternationalPrefix ? normalized.slice(0, 1) : ''
const digits = hasInternationalPrefix ? normalized.slice(1) : normalized
const groups = digits.match(/\d{1,2}/g) ?? []
const grouped = groups.join('.')
return prefix ? `${prefix}${grouped}` : grouped
}
/**
* Masks a phone number for display purposes by replacing the middle digits with ·.
* Useful for UI fragments where the full number should not be exposed.
*/
export const maskPhone = (rawValue: string | null | undefined): string => {
const normalized = normalizePhone(rawValue)
if (!normalized) {
return ''
}
if (normalized.length <= 4) {
return normalized
}
const start = normalized.slice(0, 2)
const end = normalized.slice(-2)
const maskedMiddle = '·'.repeat(Math.max(0, normalized.length - 4))
return `${start}${maskedMiddle}${end}`
}