fix: comprehensive TypeScript/build fixes and modernization

- Update tsconfig to ES2024 target and bundler moduleResolution
- Add dynamic imports for chart.js and recharts (bundle optimization)
- Consolidate 17 useState into useReducer in sessions page
- Fix 18 .js extension imports across lib files
- Add type declarations for @rapideditor/country-coder
- Fix platform user types (PlatformUserRole enum)
- Fix Calendar component prop types
- Centralize next-auth type augmentation
- Add force-dynamic to all API routes (prevent build-time prerender)
- Fix Prisma JSON null handling with Prisma.DbNull
- Fix various type mismatches (SessionMessage, ImportRecord, etc.)
- Export ButtonProps from button component
- Update next-themes import path
- Replace JSX.Element with React.ReactElement
- Remove obsolete debug scripts and pnpm lockfile
- Downgrade eslint to v8 for next compatibility
This commit is contained in:
2026-01-20 07:28:10 +01:00
parent 8b3846539f
commit 5bfd762e55
161 changed files with 14655 additions and 11682 deletions

43
types/next-auth.d.ts vendored Normal file
View File

@@ -0,0 +1,43 @@
import type { PlatformUserRole, UserRole } from "@prisma/client";
import "next-auth";
import "next-auth/jwt";
declare module "next-auth/jwt" {
interface JWT {
// Company user fields
companyId?: string;
role?: UserRole;
// Platform user fields
isPlatformUser?: boolean;
platformRole?: PlatformUserRole;
}
}
declare module "next-auth" {
interface Session {
user: {
id?: string;
email?: string;
name?: string | null;
image?: string | null;
// Company user fields
companyId?: string;
role?: UserRole;
// Platform user fields
isPlatformUser?: boolean;
platformRole?: PlatformUserRole;
};
}
interface User {
id: string;
email: string;
name?: string | null;
// Company user fields
companyId?: string;
role?: UserRole;
// Platform user fields
isPlatformUser?: boolean;
platformRole?: PlatformUserRole;
}
}

121
types/rapideditor-country-coder.d.ts vendored Normal file
View File

@@ -0,0 +1,121 @@
// Type declarations for @rapideditor/country-coder
// Re-exports types from the package's dist/country-coder.d.ts
declare module "@rapideditor/country-coder" {
import type { Feature, FeatureCollection, Geometry } from "geojson";
export type RegionFeatureProperties = {
id: string;
iso1A2: string | undefined;
iso1A3: string | undefined;
iso1N3: string | undefined;
m49: string | undefined;
wikidata: string;
emojiFlag: string | undefined;
ccTLD: string | undefined;
nameEn: string;
aliases: Array<string> | undefined;
country: string | undefined;
groups: Array<string>;
members: Array<string> | undefined;
level: string;
isoStatus: string | undefined;
driveSide: "left" | "right" | undefined;
roadSpeedUnit: "mph" | "km/h" | undefined;
roadHeightUnit: "ft" | "m" | undefined;
callingCodes: Array<string> | undefined;
};
export type RegionFeature = Feature<Geometry, RegionFeatureProperties>;
export type RegionFeatureCollection = FeatureCollection<
Geometry,
RegionFeatureProperties
>;
export type Vec2 = [number, number];
export type Bbox = [number, number, number, number];
export type PointGeometry = {
type: string;
coordinates: Vec2;
};
export type PointFeature = {
type: string;
geometry: PointGeometry;
properties: unknown;
};
export type Location = Vec2 | PointGeometry | PointFeature;
export type CodingOptions = {
level?: string | undefined;
maxLevel?: string | undefined;
withProp?: string | undefined;
};
export const borders: RegionFeatureCollection;
export function feature(
query: Location | string | number,
opts?: CodingOptions
): RegionFeature | null;
export function iso1A2Code(
query: Location | string | number,
opts?: CodingOptions
): string | null;
export function iso1A3Code(
query: Location | string | number,
opts?: CodingOptions
): string | null;
export function iso1N3Code(
query: Location | string | number,
opts?: CodingOptions
): string | null;
export function m49Code(
query: Location | string | number,
opts?: CodingOptions
): string | null;
export function wikidataQID(
query: Location | string | number,
opts?: CodingOptions
): string | null;
export function emojiFlag(
query: Location | string | number,
opts?: CodingOptions
): string | null;
export function ccTLD(
query: Location | string | number,
opts?: CodingOptions
): string | null;
export function nameEn(
query: Location | string | number,
opts?: CodingOptions
): string | null;
export function featuresContaining(
query: Location | string | number,
opts?: CodingOptions
): Array<RegionFeature>;
export function featuresIn(
query: Location | string | number,
opts?: CodingOptions
): Array<RegionFeature>;
export function aggregateFeature(
query: Location | string | number
): RegionFeature | null;
export function isIn(
query: Location | string | number,
bounds: Location | string | number
): boolean;
export function isInEuropeanUnion(query: Location | string | number): boolean;
export function isInUnitedNations(query: Location | string | number): boolean;
export function driveSide(
query: Location | string | number,
opts?: CodingOptions
): "left" | "right" | null;
export function roadSpeedUnit(
query: Location | string | number,
opts?: CodingOptions
): "mph" | "km/h" | null;
export function roadHeightUnit(
query: Location | string | number,
opts?: CodingOptions
): "ft" | "m" | null;
export function callingCodes(
query: Location | string | number,
opts?: CodingOptions
): Array<string>;
}