import type { QuickEditModalBaseDisplayArgs } from './quick-edit-modal-base';
import PowerduckState from '../../app/powerduck-state';
import NotificationProvider from '../ui/notification';
import QuickEditModalBase from './quick-edit-modal-base';

interface QuickEditModalStatusBaseArgs {}

export default abstract class QuickEditModalStatusBase<T> extends QuickEditModalBase<QuickEditModalStatusBaseArgs> implements QuickEditModalStatusBaseArgs {
	abstract getFetchArgs(item): any;
	abstract getSaveModelArr(modelArr: any[]): any[];
	abstract getModelFromSaveArgs(item: any): any;
	abstract getItemName(item): string;
	abstract getAttractionType(): string;
	status: string = null;
	causeId: number = null;

	show(args: QuickEditModalBaseDisplayArgs<QuickEditModalStatusBaseArgs>): void {
		this.status = null;
		this.causeId = null;
		super.show(args);
	}

	getSelectedStatus(): string {
		return this.status;
	}

	validate() {
		if (this.status != 'OPEN' && this.causeId == null) {
			NotificationProvider.showErrorMessage(PowerduckState.getResourceValue('errorsOnForm'));
			return false;
		}

		if (this.status == null) {
			NotificationProvider.showErrorMessage(PowerduckState.getResourceValue('errorsOnForm'));
			return false;
		}

		return true;
	}

	protected postProcessSaveData(saveArr: any[]) {
		if (this.status != null) {
			for (const saveItem of saveArr) {
				this.getModelFromSaveArgs(saveItem).status = this.status;
			}
		}

		if (this.causeId != null) {
			for (const saveItem of saveArr) {
				// this.getModelFromSaveArgs(saveItem).causeID = CauseHelper.getCauseId(this.causeId, this.status);
			}
		}
	}

	render(h) {
		return super.render(h);
	}

	renderBody(h) {
		return (
			<div>
				{/* <StatusPicker
                    selected={this.status}
                    changed={(e) => {
                        this.status = e;
                    }}
                />

                {this.getAttractionType() != null && this.status != "OPEN"  && (
                    <CausePicker
                        attractionType={this.getAttractionType()}
                        selected={this.causeId}
                        mandatory={true}
                        changed={(e) => {
                            this.causeId = e.id;
                        }}
                    />
                )} */}
			</div>
		);
	}
}
