feat: enhance import/export functionality with detailed results dialog and improved data handling

This commit is contained in:
2026-05-15 11:34:23 +04:00
parent fcbba6247d
commit 54d11f01b4
18 changed files with 312 additions and 59 deletions
+21 -1
View File
@@ -60,7 +60,7 @@ export abstract class CrudClient<
return this.delete<ByIdRoute>(this.byIdRoute as ByIdRoute, { params: { id } } as never) as never
}
async importData(file: File): Promise<{ message?: string }> {
async importData(file: File): Promise<ImportDataResponse> {
const formData = new FormData()
formData.append("file", file)
const route = (this.importRoute ?? `${this.indexRoute}/import`) as string
@@ -78,6 +78,26 @@ export abstract class CrudClient<
export type BaseCrudItem = { id: number }
export type ImportFailureRow = {
row: number
errors: {
field: string
label: string
value: unknown
message: string
valid_examples?: string[]
}[]
}
export type ImportDataResponse = {
message?: string
data?: {
imported_count: number
failed_count: number
failed_rows: ImportFailureRow[]
}
}
type ClientMethodReturn<C, TMethod extends PropertyKey> =
C extends { [K in TMethod]: (...args: any[]) => infer TResult }
? Awaited<TResult>