import MainForm from '@/Pages/Admin/Budget/Form/MainForm';
import FormPage from '@/Components/Default/FormPage';
import { Link, usePage } from '@inertiajs/react';

export default function Index(props) {
  const handleSubmit = (e, form) => {
    e.preventDefault()
    return form.post(props.page.url)
  }

  return (
    <FormPage customBreadcrumb={Breadcrumb} >
      <MainForm {...props}
        isEdit={true}
        isRevision={true}
        label={"Edit Revisi Anggaran"}
        onSubmit={handleSubmit}
        BackButton={() => {
          return <Link href={"/admin/budgets"} className="btn btn-primary btn-sm btn-outline"><i className="fas fa-arrow-left"></i> Kembali</Link>
        }}
      />
    </FormPage>
  );
}

const Breadcrumb = ({ currentLabel }) => {
  const { props } = usePage()

  return (
    <div className='text-sm text-gray-500 breadcrumbs overflow-auto scrollbar-none'>
      <ul>
        <li><Link href={"/admin/budgets"} className="text-primary hover:underline">Anggaran</Link></li>
        <li><Link href={props.location} className="hover:underline">{currentLabel}</Link></li>
      </ul>
    </div>
  )
}