import FormShell from "@/components/app/FormShell"
import PageHeader from "@/components/app/PageHeader"
import PageShell from "@/components/app/PageShell"
import { Button } from "@/components/ui/button"
import PayrollForm from "@/features/payroll/components/PayrollForm"
import { listEmployeesForPayroll } from "@/features/payroll/service"
import { getCountryConfig } from "@/lib/shared/country"
import { listBranches } from "@/features/employees/service"

export default async function CreatePayrollPage() {
  const [employees, countryConfig, branches] = await Promise.all([
    listEmployeesForPayroll(),
    getCountryConfig(),
    listBranches(),
  ])

  return (
    <PageShell>
      <PageHeader
        title="Add Payroll"
        actions={
          <Button asChild variant="secondary">
            <a href="/payroll">Back</a>
          </Button>
        }
      />
      <FormShell>
        <PayrollForm
          employees={employees}
          currencyCode={countryConfig.currencyCode}
          decimalPlaces={countryConfig.decimalPlaces}
          branches={branches}
        />
      </FormShell>
    </PageShell>
  )
}
