2019-06-19 14:40:52 +00:00
|
|
|
import { MutationResult } from "react-apollo";
|
|
|
|
|
|
|
|
import { FilterContentSubmitData } from "./components/Filter";
|
|
|
|
import { Filter } from "./components/TableFilter";
|
|
|
|
|
|
|
|
export interface UserError {
|
|
|
|
field: string;
|
|
|
|
message: string;
|
|
|
|
}
|
|
|
|
|
2019-08-09 11:14:35 +00:00
|
|
|
export interface ListSettings<TColumn extends string = string> {
|
|
|
|
columns?: TColumn[];
|
|
|
|
rowNumber: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
export enum ListViews {
|
|
|
|
ATTRIBUTE_LIST = "ATTRIBUTE_LIST",
|
|
|
|
CATEGORY_LIST = "CATEGORY_LIST",
|
|
|
|
COLLECTION_LIST = "COLLECTION_LIST",
|
|
|
|
CUSTOMER_LIST = "CUSTOMER_LIST",
|
|
|
|
DRAFT_LIST = "DRAFT_LIST",
|
|
|
|
NAVIGATION_LIST = "NAVIGATION_LIST",
|
|
|
|
ORDER_LIST = "ORDER_LIST",
|
|
|
|
PAGES_LIST = "PAGES_LIST",
|
2019-08-27 12:36:19 +00:00
|
|
|
PLUGINS_LIST = "PLUGIN_LIST",
|
2019-08-09 11:14:35 +00:00
|
|
|
PRODUCT_LIST = "PRODUCT_LIST",
|
2019-09-12 13:00:25 +00:00
|
|
|
PRODUCT_TYPE_LIST = "PRODUCT_TYPE_LIST",
|
2019-08-09 11:14:35 +00:00
|
|
|
SALES_LIST = "SALES_LIST",
|
|
|
|
SHIPPING_METHODS_LIST = "SHIPPING_METHODS_LIST",
|
|
|
|
STAFF_MEMBERS_LIST = "STAFF_MEMBERS_LIST",
|
|
|
|
VOUCHER_LIST = "VOUCHER_LIST"
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface ListProps<TColumns extends string = string> {
|
2019-06-19 14:40:52 +00:00
|
|
|
disabled: boolean;
|
|
|
|
pageInfo?: {
|
|
|
|
hasNextPage: boolean;
|
|
|
|
hasPreviousPage: boolean;
|
|
|
|
};
|
2019-08-09 11:14:35 +00:00
|
|
|
settings?: ListSettings<TColumns>;
|
2019-06-19 14:40:52 +00:00
|
|
|
onNextPage: () => void;
|
|
|
|
onPreviousPage: () => void;
|
|
|
|
onRowClick: (id: string) => () => void;
|
2019-08-09 11:14:35 +00:00
|
|
|
onUpdateListSettings?: (
|
|
|
|
key: keyof ListSettings<TColumns>,
|
|
|
|
value: any
|
|
|
|
) => void;
|
|
|
|
onListSettingsReset?: () => void;
|
2019-06-19 14:40:52 +00:00
|
|
|
}
|
2019-09-13 11:33:42 +00:00
|
|
|
|
|
|
|
export interface SortPage<TSortKey extends string> {
|
2019-09-13 14:17:12 +00:00
|
|
|
sort: Sort<TSortKey>;
|
2019-09-26 10:14:07 +00:00
|
|
|
onSort: (field: TSortKey, id?: string) => void;
|
2019-09-13 11:33:42 +00:00
|
|
|
}
|
2019-06-19 14:40:52 +00:00
|
|
|
export interface ListActionsWithoutToolbar {
|
|
|
|
toggle: (id: string) => void;
|
|
|
|
toggleAll: (items: React.ReactNodeArray, selected: number) => void;
|
|
|
|
isChecked: (id: string) => boolean;
|
|
|
|
selected: number;
|
|
|
|
}
|
|
|
|
export type TabListActions<
|
|
|
|
TToolbars extends string
|
|
|
|
> = ListActionsWithoutToolbar &
|
|
|
|
Record<TToolbars, React.ReactNode | React.ReactNodeArray>;
|
|
|
|
export interface ListActions extends ListActionsWithoutToolbar {
|
|
|
|
toolbar: React.ReactNode | React.ReactNodeArray;
|
|
|
|
}
|
2019-08-09 11:14:35 +00:00
|
|
|
export interface PageListProps<TColumns extends string = string>
|
|
|
|
extends ListProps<TColumns> {
|
|
|
|
defaultSettings?: ListSettings<TColumns>;
|
2019-06-19 14:40:52 +00:00
|
|
|
onAdd: () => void;
|
|
|
|
}
|
2019-09-10 15:14:11 +00:00
|
|
|
|
|
|
|
export interface SearchPageProps {
|
2019-06-19 14:40:52 +00:00
|
|
|
initialSearch: string;
|
|
|
|
onSearchChange: (value: string) => void;
|
|
|
|
}
|
2019-09-12 14:22:42 +00:00
|
|
|
export interface FilterPageProps<TKeys = string>
|
|
|
|
extends SearchPageProps,
|
|
|
|
TabPageProps {
|
2019-09-10 15:14:11 +00:00
|
|
|
currencySymbol: string;
|
|
|
|
filtersList: Filter[];
|
2019-09-12 14:22:42 +00:00
|
|
|
onFilterAdd: (filter: FilterContentSubmitData<TKeys>) => void;
|
2019-09-10 15:14:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface SearchProps {
|
|
|
|
searchPlaceholder: string;
|
|
|
|
}
|
2019-09-12 14:22:42 +00:00
|
|
|
export interface FilterProps<TKeys = string>
|
|
|
|
extends FilterPageProps<TKeys>,
|
|
|
|
SearchProps {
|
2019-06-19 14:40:52 +00:00
|
|
|
allTabLabel: string;
|
|
|
|
filterLabel: string;
|
2019-09-10 15:14:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface TabPageProps {
|
|
|
|
currentTab: number;
|
|
|
|
tabs: string[];
|
|
|
|
onAll: () => void;
|
|
|
|
onTabChange: (tab: number) => void;
|
|
|
|
onTabDelete: () => void;
|
|
|
|
onTabSave: () => void;
|
2019-06-19 14:40:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface PartialMutationProviderOutput<
|
|
|
|
TData extends {} = {},
|
|
|
|
TVariables extends {} = {}
|
|
|
|
> {
|
|
|
|
opts: MutationResult<TData>;
|
|
|
|
mutate: (variables: TVariables) => void;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface Node {
|
|
|
|
id: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export type FormErrors<TKeys extends string> = Partial<Record<TKeys, string>>;
|
|
|
|
|
|
|
|
export type Pagination = Partial<{
|
|
|
|
after: string;
|
|
|
|
before: string;
|
|
|
|
}>;
|
|
|
|
|
|
|
|
export type Dialog<TDialog extends string> = Partial<{
|
|
|
|
action: TDialog;
|
|
|
|
}>;
|
|
|
|
export type ActiveTab<TTab extends string = string> = Partial<{
|
|
|
|
activeTab: TTab;
|
|
|
|
}>;
|
|
|
|
export type Filters<TFilters extends string> = Partial<
|
|
|
|
Record<TFilters, string>
|
|
|
|
>;
|
2019-09-05 13:05:12 +00:00
|
|
|
export type FiltersWithMultipleValues<TFilters extends string> = Partial<
|
|
|
|
Record<TFilters, string | string[]>
|
|
|
|
>;
|
2019-06-19 14:40:52 +00:00
|
|
|
export type SingleAction = Partial<{
|
|
|
|
id: string;
|
|
|
|
}>;
|
2019-09-13 11:33:42 +00:00
|
|
|
export type Sort<TSort extends string = string> = Partial<{
|
|
|
|
asc: boolean;
|
|
|
|
sort: TSort;
|
|
|
|
}>;
|
2019-06-19 14:40:52 +00:00
|
|
|
export type BulkAction = Partial<{
|
|
|
|
ids: string[];
|
|
|
|
}>;
|
2019-08-09 11:14:35 +00:00
|
|
|
|
|
|
|
export interface ReorderEvent {
|
|
|
|
oldIndex: number;
|
|
|
|
newIndex: number;
|
|
|
|
}
|
|
|
|
export type ReorderAction = (event: ReorderEvent) => void;
|
|
|
|
|
2019-08-12 14:11:10 +00:00
|
|
|
export interface FetchMoreProps {
|
2019-08-09 11:14:35 +00:00
|
|
|
loading: boolean;
|
|
|
|
hasMore: boolean;
|
|
|
|
onFetchMore: () => void;
|
|
|
|
}
|
2019-09-10 15:14:11 +00:00
|
|
|
|
|
|
|
export type TabActionDialog = "save-search" | "delete-search";
|