import $ from 'jquery';
import { orderVerificationStep } from '../steps/orderVerificationStep';
import { returnItemsStep } from '../steps/returnItemsStep';

export const stepFormSubmitHandler = ( event: JQuery.SubmitEvent ) => {
	event.preventDefault();

	const form = $( event.currentTarget );
	const stepElement = form.parents('.wetail-return-portal__step');

	if (!stepElement.data( 'step' )) {
		return;
	}

	const step = Number( stepElement.data( 'step' ) );

	switch ( step ) {
		case 1:
			orderVerificationStep(form, step);
			break;
		case 2:
			returnItemsStep(form, step);
			break;
		default:
			return;
	}
};
