"use client"

import { Lock } from "lucide-react"
import { useOrgSettingsStore } from "@/lib/admin-settings/org-settings-store"
import { isDeployFieldLocked } from "@/lib/admin/deploy-runtime"

export function DeployLockedHint({
  section,
  field,
}: {
  section: string
  field: string
}) {
  const deployLocked = useOrgSettingsStore((s) => s.meta?.deployLocked)
  if (!isDeployFieldLocked(deployLocked, section, field)) return null

  return (
    <p className="flex items-center gap-1.5 text-xs text-muted-foreground">
      <Lock className="size-3 shrink-0" aria-hidden />
      Géré par Docker Compose — modifier les variables d&apos;environnement du déploiement.
    </p>
  )
}

export function useDeployFieldLocked(section: string, field: string): boolean {
  const deployLocked = useOrgSettingsStore((s) => s.meta?.deployLocked)
  return isDeployFieldLocked(deployLocked, section, field)
}
