import {ISearchParam} from "./IPage";

export const TaskTypes = ['detail', 'sold', 'search', 'bid', 'buyItNow'] as const

export type TaskType = (typeof TaskTypes)[number]

export interface IResp<T extends ITask = any> {
	id?: number
	code: number
	message: string
	data?: T
}

export interface ITask {
	id: string | number
	type: TaskType
	word?: string | null
}

export interface IDetailTask extends ITask {
	type: 'detail' | 'sold'
}

export interface ISearchTask extends ITask {
	type: 'search'
	word: string
	params?: ISearchParam
}

export interface IBidParams {
	goodsId: string
	bid: string
}

export interface IBidTask extends ITask {
	type: 'bid' | 'buyItNow'
	params: IBidParams
}

export interface IBidTaskResult {
	id: string | number
	results: {
		success?: boolean,
		error?: string
	}
}
