-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
datatables: added nullRepository
- Loading branch information
ivan
committed
May 1, 2023
1 parent
7822105
commit d66ab27
Showing
6 changed files
with
103 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
shesha-reactjs/src/providers/dataTable/repository/nullRepository.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { IConfigurableColumnsProps } from "providers/datatableColumnsConfigurator/models"; | ||
import React, { ComponentType, useMemo } from "react"; | ||
import { FC } from "react"; | ||
import { DataTableColumnDto, IGetListDataPayload, ITableDataInternalResponse } from "../interfaces"; | ||
import { IHasRepository, IRepository } from "./interfaces"; | ||
|
||
export interface IWithNullRepositoryArgs { | ||
value?: object; | ||
} | ||
|
||
const createRepository = (_args: IWithNullRepositoryArgs): IRepository => { | ||
const fetch = (_payload: IGetListDataPayload): Promise<ITableDataInternalResponse> => { | ||
return Promise.reject('NullRepository has no implementation'); | ||
}; | ||
|
||
const prepareColumns = (_configurableColumns: IConfigurableColumnsProps[]): Promise<DataTableColumnDto[]> => { | ||
return Promise.reject('NullRepository has no implementation'); | ||
}; | ||
|
||
const performUpdate = (_rowIndex: number, _data: any): Promise<any> => { | ||
return Promise.reject('NullRepository has no implementation'); | ||
}; | ||
|
||
const performDelete = (_rowIndex: number, _data: any): Promise<any> => { | ||
return Promise.reject('NullRepository has no implementation'); | ||
}; | ||
|
||
const performCreate = (_rowIndex: number, _data: any): Promise<any> => { | ||
return Promise.reject('NullRepository has no implementation'); | ||
}; | ||
|
||
const exportToExcel = (_payload: IGetListDataPayload): Promise<void> => { | ||
return Promise.reject('NullRepository has no implementation'); | ||
}; | ||
|
||
const repository: IRepository = { | ||
fetch, | ||
exportToExcel, | ||
prepareColumns, | ||
performCreate, | ||
performUpdate, | ||
performDelete, | ||
}; | ||
return repository; | ||
}; | ||
|
||
export const useNullRepository = (args: IWithNullRepositoryArgs): IRepository => useMemo<IRepository>(() => createRepository(args), []); | ||
|
||
export function withNullRepository<WrappedProps>(WrappedComponent: ComponentType<WrappedProps & IHasRepository>, args: IWithNullRepositoryArgs): FC<WrappedProps> { | ||
const { value } = args; | ||
|
||
return props => { | ||
const repository = useNullRepository({ value }); | ||
|
||
return (<WrappedComponent {...props} repository={repository} />); | ||
}; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters