// src/Components/FormPO/FormFooter.jsx

import React from 'react';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faChevronLeft, faChevronRight, faCheck } from '@fortawesome/free-solid-svg-icons';

const FormFooter = ({ currentStep, totalSteps, handlePrev, handleNext, handleSubmit, processing, theme }) => {
    return (
        <div className="flex justify-between pt-6 border-t mt-8">
            {currentStep > 1 && (
                <button
                    type="button"
                    onClick={handlePrev}
                    className="flex items-center px-6 py-2 bg-gray-200 text-gray-700 rounded-xl font-semibold hover:bg-gray-300 transition duration-150 shadow-md"
                    disabled={processing}
                >
                    <FontAwesomeIcon icon={faChevronLeft} className="mr-2 h-4 w-4"/> Sebelumnya
                </button>
            )}
            
            {currentStep < totalSteps && (
                <button
                    type="button"
                    onClick={handleNext}
                    className={`${currentStep === 1 ? 'ml-auto' : ''} flex items-center px-6 py-2 ${theme.primary} text-white rounded-xl font-semibold ${theme.primaryHover} transition duration-150 shadow-md`}
                    disabled={processing}
                >
                    Lanjutkan <FontAwesomeIcon icon={faChevronRight} className="ml-2 h-4 w-4"/>
                </button>
            )}
            
            {currentStep === totalSteps && (
                <button
                    type="submit" 
                    // Menggunakan type="submit" akan memicu form onSubmit, tapi onClick juga dipanggil untuk validasi dan Swal.
                    onClick={handleSubmit} 
                    className={`ml-auto flex items-center px-6 py-2 ${theme.primary} text-white rounded-xl font-semibold ${theme.primaryHover} transition duration-150 shadow-lg disabled:bg-indigo-400`}
                    disabled={processing}
                >
                    {processing ? (
                        'Memproses...'
                    ) : (
                        <>Kirim Pendaftaran <FontAwesomeIcon icon={faCheck} className="ml-2 h-4 w-4"/></>
                    )}
                </button>
            )}

            {/* Untuk memastikan tombol next/submit tetap di kanan pada Step 1 */}
            {currentStep === 1 && <div className='w-full'></div>} 
        </div>
    );
};

export default FormFooter;