feat: add ItemOverviewDto for enriched item data in items list

feat: implement CustomerDetailPage for detailed customer view and editing

feat: create CustomersPage for listing and managing customers with filters

feat: add ColumnsMenu component for customizable table columns visibility

feat: implement CSV export functionality for data download

feat: add customer code generation logic for unique customer identifiers
This commit is contained in:
Dhananjaya99
2026-09-22 00:32:40 +05:30
parent 72819e5f7b
commit fdd104284e
44 changed files with 2186 additions and 381 deletions
+18
View File
@@ -0,0 +1,18 @@
/** First word of the name, uppercased and stripped to alphanumerics — falls back to "CU"
* so an empty/punctuation-only name still yields a usable base. Mirrors the vendor code
* generator (lib/vendor-code.ts). */
function customerCodeBase(name: string): string {
const firstWord = name.trim().split(/\s+/)[0] ?? ""
const cleaned = firstWord.toUpperCase().replace(/[^A-Z0-9]/g, "")
return cleaned.slice(0, 10) || "CU"
}
/** Appends a numeric suffix until the code doesn't collide with an existing one — the
* backend enforces global uniqueness but has no generation of its own. */
export function generateCustomerCode(name: string, existingCodes: string[]): string {
const base = `CU-${customerCodeBase(name)}`
if (!existingCodes.includes(base)) return base
let suffix = 2
while (existingCodes.includes(`${base}${suffix}`)) suffix += 1
return `${base}${suffix}`
}