"use client";
import { jsx, jsxs } from "react/jsx-runtime";
import { useMemo } from "react";
import Link from "next/link";
import { Page, PageBody } from "@open-mercato/ui/backend/Page";
import { FormHeader } from "@open-mercato/ui/backend/forms";
import { Button } from "@open-mercato/ui/primitives/button";
import { useT } from "@open-mercato/shared/lib/i18n/context";
function useOrigin() {
  return typeof window !== "undefined" ? window.location.origin : "";
}
const DEMO_CREDENTIALS = [
  { email: "alice.johnson@example.com", password: "Password123!", role: "Portal Admin" },
  { email: "bob.smith@example.com", password: "Password123!", role: "Buyer" },
  { email: "carol.white@example.com", password: "Password123!", role: "Viewer" }
];
function CustomerAccountsSettingsPage() {
  const t = useT();
  const origin = useOrigin();
  const portalUrl = useMemo(() => `${origin}/[org-slug]/portal`, [origin]);
  return /* @__PURE__ */ jsxs(Page, { children: [
    /* @__PURE__ */ jsx("div", { className: "px-3 py-3 md:px-6 md:py-4", children: /* @__PURE__ */ jsx(
      FormHeader,
      {
        mode: "detail",
        title: t("customer_accounts.settings.title", "Portal Settings"),
        backHref: "/backend/customer_accounts/users",
        backLabel: t("customer_accounts.settings.back", "Customer Users")
      }
    ) }),
    /* @__PURE__ */ jsx(PageBody, { children: /* @__PURE__ */ jsxs("div", { className: "max-w-2xl space-y-6", children: [
      /* @__PURE__ */ jsxs("div", { className: "rounded-lg border p-4 space-y-3", children: [
        /* @__PURE__ */ jsx("h3", { className: "text-sm font-semibold", children: t("customer_accounts.settings.portal_access.title", "Portal Access") }),
        /* @__PURE__ */ jsxs("div", { children: [
          /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: t("customer_accounts.settings.portal_access.url_label", "Portal URL pattern:") }),
          /* @__PURE__ */ jsx("code", { className: "mt-1 block rounded bg-muted px-3 py-2 text-sm font-mono", children: portalUrl })
        ] }),
        /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Button, { type: "button", variant: "outline", size: "sm", asChild: true, children: /* @__PURE__ */ jsx("a", { href: `${origin}/portal`, target: "_blank", rel: "noopener noreferrer", children: t("customer_accounts.settings.portal_access.open_portal", "Open Portal") }) }) }),
        /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: t(
          "customer_accounts.settings.portal_access.slug_note",
          "The organization slug is auto-generated from the organization name. You can view and manage organizations in Directory \u2192 Organizations."
        ) }),
        /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: /* @__PURE__ */ jsx(Link, { href: "/backend/directory/organizations", className: "text-primary underline underline-offset-4 hover:text-primary/80", children: t("customer_accounts.settings.portal_access.manage_orgs", "Manage Organizations") }) })
      ] }),
      /* @__PURE__ */ jsxs("div", { className: "rounded-lg border p-4 space-y-3", children: [
        /* @__PURE__ */ jsx("h3", { className: "text-sm font-semibold", children: t("customer_accounts.settings.demo_credentials.title", "Demo Credentials") }),
        /* @__PURE__ */ jsx("div", { className: "overflow-x-auto", children: /* @__PURE__ */ jsxs("table", { className: "w-full text-sm", children: [
          /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { className: "border-b text-left", children: [
            /* @__PURE__ */ jsx("th", { className: "pb-2 pr-4 font-medium text-muted-foreground", children: t("customer_accounts.settings.demo_credentials.email", "Email") }),
            /* @__PURE__ */ jsx("th", { className: "pb-2 pr-4 font-medium text-muted-foreground", children: t("customer_accounts.settings.demo_credentials.password", "Password") }),
            /* @__PURE__ */ jsx("th", { className: "pb-2 font-medium text-muted-foreground", children: t("customer_accounts.settings.demo_credentials.role", "Role") })
          ] }) }),
          /* @__PURE__ */ jsx("tbody", { children: DEMO_CREDENTIALS.map((cred) => /* @__PURE__ */ jsxs("tr", { className: "border-b last:border-0", children: [
            /* @__PURE__ */ jsx("td", { className: "py-2 pr-4 font-mono text-xs", children: cred.email }),
            /* @__PURE__ */ jsx("td", { className: "py-2 pr-4 font-mono text-xs", children: cred.password }),
            /* @__PURE__ */ jsx("td", { className: "py-2 text-xs", children: cred.role })
          ] }, cred.email)) })
        ] }) }),
        /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: t(
          "customer_accounts.settings.demo_credentials.note",
          "These credentials are only available if example data was seeded during setup."
        ) })
      ] }),
      /* @__PURE__ */ jsxs("div", { className: "rounded-lg border p-4 space-y-3", children: [
        /* @__PURE__ */ jsx("h3", { className: "text-sm font-semibold", children: t("customer_accounts.settings.quick_links.title", "Quick Links") }),
        /* @__PURE__ */ jsxs("ul", { className: "space-y-2", children: [
          /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(Link, { href: "/backend/customer_accounts/users", className: "text-sm text-primary underline underline-offset-4 hover:text-primary/80", children: t("customer_accounts.settings.quick_links.manage_users", "Manage customer users") }) }),
          /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(Link, { href: "/backend/customer_accounts/roles", className: "text-sm text-primary underline underline-offset-4 hover:text-primary/80", children: t("customer_accounts.settings.quick_links.manage_roles", "Manage customer roles") }) }),
          /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(
            "a",
            {
              href: "https://docs.open-mercato.com/framework/modules/customer-portal",
              target: "_blank",
              rel: "noopener noreferrer",
              className: "text-sm text-primary underline underline-offset-4 hover:text-primary/80",
              children: t("customer_accounts.settings.quick_links.portal_docs", "Portal documentation")
            }
          ) })
        ] })
      ] })
    ] }) })
  ] });
}
export {
  CustomerAccountsSettingsPage as default
};
//# sourceMappingURL=page.js.map
