teko-file-history
Version:
File history component for Teko system
224 lines (223 loc) • 6.01 kB
TypeScript
import { TableProps } from 'antd/es/table';
import { UploadFile, UploadProps } from 'antd/es/upload/interface';
import { ProcessingFile } from './fileProcessing';
import { ReactNode } from 'react';
export type BaseProps = {
/**
* Accepted values: [vi, en, fr, id, km, ms, zh]
*/
language: string;
/**
* FPS client ID
*/
clientId?: number;
/**
* List of FPS client IDs
* Get import history of multiple clients
* This field does not replace clientId and you need to render the download template button by yourself
*/
clientIds?: number[];
/**
* Filter current user's uploaded files
*/
isUploadedByMe?: boolean;
/**
* Filter files by createdByEmails
*/
createdByEmails?: string[];
/**
* Filter files by processingFileIds
*/
processingFileIds?: number[];
/**
* Filter files by file name
*/
searchFileName?: string;
/**
* Environment, used for handling internal API requests and download files from file service.
* Possible values: [DEV, STAG, PROD]
*/
env?: string;
/**
* Custom class names for the components
*/
classNames?: ClassName;
/**
* Config whether component props should overwrite responses from get-client-config API.
* This field is used for development purposes only and should be set to false or unset in production.
* Default value is false
*/
isOverwriteDBConfig?: boolean;
/**
* Extra content under the uploader component
*/
extra?: ReactNode;
/**
* Custom function to handle file download
*/
downloadFile?: (url: string) => Promise<void>;
/**
* Function to get parent app's access token, used for handling internal API requests.
* Require prefix 'Bearer ' in the result
*/
getAccessToken?: () => string;
/**
* X-Request-ID header for the [GET] processing-files API
*/
filterRequestID?: string;
};
export type BaseUIConfig = {
/**
* Show debug button, default value is true, require prop env
*/
isShowDebug?: boolean;
/**
* Show created by column, default value is true
*/
isShowCreatedBy?: boolean;
/**
* Show reload button, default value is true
*/
isShowReload?: boolean;
};
/**
* Could be configured in the client config, or passed in directly to the Uploader component
*/
export type BaseUploaderProps = {
/**
* Template file URL, used for download template file.
* If not configured, the download button will not be displayed
*/
importFileTemplateUrl?: string;
/**
* Max file size in MB, default value is 5
*/
maxFileSize?: number;
/**
* Accepted file types, accept lowercase letters, default value is ['xlsx'].
* Currently support xlsx, xls, csv
*/
inputFileTypes?: string[];
/**
* Show uploader, default value is true
*/
isShowUploader?: boolean;
/**
* Uploader position, default is right
*/
uploaderPosition?: 'left' | 'right';
};
export type HistoryTableProps = TableProps<ProcessingFile> & BaseUIConfig & {
tableTitle?: string | ReactNode;
/**
* Default value is 'DD/MM/YYYY HH:mm:ss'
*/
dateFormat?: string;
/**
* Column ordering, view/ hide columns
* Default ordering and possible values is ['id', 'name', 'createdAt', 'status', 'progressStatus']
*/
orderColumn?: string[];
/**
* Reload table function
*/
onReload?: () => void;
/**
* Whether to concat result file name with dateTime
* Require dateFormat prop
*/
shouldAppendDateToFileName?: boolean;
};
export type UploaderProps = UploadProps & BaseUploaderProps & {
onUploadFile?: (file: UploadFile, setFile?: (file?: UploadFile) => void) => Promise<void>;
/**
* Custom download template button
*/
downloadTemplateButton?: ReactNode;
/**
* Additional parameters for the upload file API
*/
parameters?: Object;
/**
* Extra content above the drag and drop section
*/
extra?: ReactNode;
};
/**
* !!! IMPORTANT !!! Read the README please 🤞
*/
export type FileHistoryProps = BaseProps & {
tableProps?: HistoryTableProps;
uploaderProps?: UploaderProps;
};
export type ClientConfig = Omit<BaseUploaderProps, 'isShowUploader' | 'uploaderPosition'> & {
clientId?: number;
uiConfig?: {
importHistoryTable?: BaseUIConfig;
};
};
export type ImportRules = {
maxSize: number;
types: Array<{
extension: string;
mimeType: string;
}>;
maxLine: number;
};
type IMap<T> = {
[key: string]: T;
};
/**
* The library add classNames to the components.
* Styles then added based on the CSS values of the className in the parent's application.
* You can override the default className to match your application's one or add a new className with different styles.
*/
export type ClassName = {
/**
* 'd-flex'
*/
displayFlex?: string;
/**
* 'flex-column'
*/
flexColumn?: string;
/**
* 'gap-base'
*/
gapBase?: string;
/**
* 'gap-half'
*/
gapHalf?: string;
/**
* 'mb-0'
*/
marginBottomZero?: string;
/**
* 'mt-half'
*/
marginTopHalf?: string;
/**
* 'mx-base'
*/
marginHorizontalBase?: string;
/**
* 'px-base'
*/
paddingHorizontalBase?: string;
/**
* 'py-half'
*/
paddingVerticalHalf?: string;
/**
* 'text-error'
*/
textErrorColor?: string;
/**
* 'text-primary'
*/
textPrimaryColor?: string;
};
export type AnyObject = IMap<any>;
export * from './fileProcessing';
export * from './debug';