"use client";

import { Example } from "@/components/design-system/example";
import { Section } from "@/components/design-system/section";
import { ActivityLog, type ActivityEntry } from "@/components/medora/activity-log";

const ENTRIES: ActivityEntry[] = [
  { id: "a9", at: "2026-10-20T16:12", user: "Kevin Mutua", branch: "Westlands Main", module: "Point of sale", action: "Closed shift", record: "SH-2026-1042", changes: [{ field: "Cash counted", after: "KES 11,760.00" }, { field: "Cash difference", after: "KES 50.00 short" }, { field: "Note", after: "Gave change from own float at lunch", long: true }] },
  { id: "a8", at: "2026-10-20T10:12", user: "Grace Wanjiru", branch: "Westlands Main", module: "Inventory", action: "Changed price", record: "Augmentin 625 mg, 14s", changes: [{ field: "Selling price", before: "KES 1,190.00", after: "KES 1,260.00" }, { field: "Minimum margin", before: "15%", after: "20%" }] },
  { id: "a7", at: "2026-10-20T09:40", user: "Faith Njeri", branch: "Westlands Main", module: "Inventory", action: "Raised purchase order", record: "PO-2026-0145", changes: [{ field: "Supplier", after: "Surgipharm" }, { field: "Total", after: "KES 43,500.00" }] },
  { id: "a6", at: "2026-10-19T15:04", user: "Grace Wanjiru", branch: "Westlands Main", module: "Point of sale", action: "Deleted held sale", record: "HLD-0092", changes: [{ field: "Reason", after: "Customer left" }] },
  { id: "a5", at: "2026-10-19T11:30", user: "Grace Wanjiru", branch: "Kilimani", module: "Users and roles", action: "Reset password", record: "Peter Kamau", changes: [{ field: "Password", sensitive: true }] },
  { id: "a4", at: "2026-10-18T18:05", user: "Peter Kamau", branch: "Westlands Main", module: "Inventory", action: "Posted GRN", record: "GRN-2026-0318", changes: [{ field: "Received value", after: "KES 15,567.60" }, { field: "Not accepted", after: "6 × Nivea Soft cream 200 ml (Damaged)" }] },
  { id: "a3", at: "2026-10-18T15:40", user: "Peter Kamau", branch: "Westlands Main", module: "Inventory", action: "Moved shelf", record: "Augmentin 625 mg, 14s", changes: [{ field: "Shelf", before: "B1 Antibiotics", after: "B2 Antibiotics" }] },
  { id: "a2", at: "2026-10-17T08:15", user: "Grace Wanjiru", branch: "Westlands Main", module: "Settings", action: "Replaced M-Pesa keys", record: "Kilimani", changes: [{ field: "Consumer key", sensitive: true }, { field: "Consumer secret", sensitive: true }] },
  { id: "a1", at: "2026-10-16T12:00", user: "Grace Wanjiru", branch: "Westlands Main", module: "Users and roles", action: "Deactivated user", record: "John Kamau", changes: [{ field: "Status", before: "Active", after: "Deactivated" }] },
];

export function ActivityLogSection() {
  return (
    <Section id="activity-log" title="Activity log" description="ST-15: module, action, user, branch and time, filtered by user, branch, module and date, and exported as shown. View opens the change as old → new values; passwords and keys only ever say Changed, in the export too.">
      <Example title="Activity, 16–20 Oct 2026" description="Open the password reset or the M-Pesa keys entry: the values are never shown">
        <ActivityLog entries={ENTRIES} />
      </Example>
    </Section>
  );
}
