"use client";

import { Alert } from "@/components/ui/alert";
import { PageHeader } from "@/components/shared/page-header";
import { DispatchSettingsScreen } from "@/features/dispatch/dispatch-settings";
import { useCan } from "@/features/auth/use-can";
import { useT } from "@/i18n";

/**
 * The dispatch algorithm's dials.
 *
 * Reading them is a dispatch view; changing one is its own permission, because these numbers decide
 * who gets every order — a wrong handoff buffer is not a display bug, it is a fleet routed badly
 * all day.
 */
export default function DispatchSettingsPage() {
  const t = useT();
  const { can } = useCan();

  return (
    <div className="mx-auto max-w-4xl">
      <PageHeader title={t("dispatchSettings.title")} subtitle={t("dispatchSettings.subtitle")} />

      {can("dispatch.view") ? (
        <DispatchSettingsScreen />
      ) : (
        <Alert variant="info" title={t("performance.noPermissionTitle")}>
          {t("performance.noPermissionBody")}
        </Alert>
      )}
    </div>
  );
}
