mirror of
https://github.com/bitbaum/hirnli.git
synced 2026-12-05 10:38:44 +01:00
Quick wins (8): - Add overflow-x-auto to BudgetSection tables for mobile - Add sr-only text and aria-label for fit stars accessibility - Add role="dialog" and aria-modal to FilterDrawer - Add loading state for pipeline slugs fetch - Add loading fallback for GesuchPageClient (was blank) - Standardize focus-visible styles, 44px touch targets - Move hardcoded contact name to ORG_PROFILE - Delete 11 unused exports across config/domain files Medium effort (7): - Extract FieldRow from GesuchEditPanel (445→260 lines) - Create shared LoadingState + ErrorAlert components, replace 9 inline patterns - Dedup ResearchDepth type+function across 4 scripts → scripts/lib/utilities.ts - Dedup slugify across 4 scripts → scripts/lib/utilities.ts - Add .catch() to 7 async script main() calls - Make GesuchEditPanel header responsive (mobile stacking) - Add focus trapping + focus restore to Modal component Security (from bug hunt): - Constant-time comparison in middleware, share tokens, cron routes - Fix error.message leak in one-pager API - Fix rescore.ts overwriting existing priority values - Fix applications API missing input validation Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
48 lines
1.6 KiB
TypeScript
48 lines
1.6 KiB
TypeScript
/** Shared utilities for pipeline scripts */
|
|
|
|
export function sleep(ms: number): Promise<void> {
|
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
}
|
|
|
|
// ============================================================================
|
|
// Research Depth — SSOT for pipeline depth classification
|
|
// ============================================================================
|
|
|
|
export type ResearchDepth = 'rapid' | 'standard' | 'deep';
|
|
|
|
export function computeResearchDepth(opts: {
|
|
hasRealWebsite: boolean;
|
|
hasEmail: boolean;
|
|
hasPhone: boolean;
|
|
hasDeadline: boolean;
|
|
hasGrantRange: boolean;
|
|
}): ResearchDepth {
|
|
const { hasRealWebsite, hasEmail, hasPhone, hasDeadline, hasGrantRange } = opts;
|
|
const hasContactDetail = hasEmail || hasPhone;
|
|
|
|
if (hasRealWebsite && hasContactDetail && hasDeadline && hasGrantRange) return 'deep';
|
|
if (hasRealWebsite && hasContactDetail) return 'standard';
|
|
return 'rapid';
|
|
}
|
|
|
|
// ============================================================================
|
|
// Slugify — Canonical URL-safe slug generation
|
|
// ============================================================================
|
|
|
|
/**
|
|
* Generate a URL-safe slug from a foundation name.
|
|
* Handles Swiss German umlauts (ä→ae, ö→oe, ü→ue), French accents, and ß→ss.
|
|
*/
|
|
export function slugify(name: string): string {
|
|
return name
|
|
.toLowerCase()
|
|
.replace(/ä/g, 'ae')
|
|
.replace(/ö/g, 'oe')
|
|
.replace(/ü/g, 'ue')
|
|
.replace(/ß/g, 'ss')
|
|
.normalize('NFD')
|
|
.replace(/[\u0300-\u036f]/g, '')
|
|
.replace(/[^a-z0-9]+/g, '-')
|
|
.replace(/^-|-$/g, '');
|
|
}
|