diff --git a/src/components/buyer-tasks/mark-ready-modal.test.tsx b/src/components/buyer-tasks/mark-ready-modal.test.tsx new file mode 100644 index 0000000..e785e31 --- /dev/null +++ b/src/components/buyer-tasks/mark-ready-modal.test.tsx @@ -0,0 +1,37 @@ +import { describe, it, expect, vi } from "vitest"; +import { render, screen, fireEvent } from "@testing-library/react"; +import { MarkReadyModal } from "./mark-ready-modal"; + +describe("MarkReadyModal", () => { + it("renders the confirmation text", () => { + render( + + ); + expect( + screen.getByText(/i spoke to this person and the stock is ready for collection/i) + ).toBeInTheDocument(); + }); + + it("calls onConfirm when confirm is clicked", () => { + const onConfirm = vi.fn(); + render(); + fireEvent.click(screen.getByRole("button", { name: /confirm/i })); + expect(onConfirm).toHaveBeenCalledOnce(); + }); + + it("calls onCancel when cancel is clicked", () => { + const onCancel = vi.fn(); + render(); + fireEvent.click(screen.getByRole("button", { name: /cancel/i })); + expect(onCancel).toHaveBeenCalledOnce(); + }); + + it("does not render when closed", () => { + render(); + expect(screen.queryByText(/i spoke to this person/i)).not.toBeInTheDocument(); + }); +}); diff --git a/src/components/buyer-tasks/mark-ready-modal.tsx b/src/components/buyer-tasks/mark-ready-modal.tsx new file mode 100644 index 0000000..c03af25 --- /dev/null +++ b/src/components/buyer-tasks/mark-ready-modal.tsx @@ -0,0 +1,60 @@ +"use client"; + +import { + Dialog, + DialogContent, + DialogDescription, + DialogFooter, + DialogHeader, + DialogTitle, + DialogClose, +} from "@/components/ui/dialog"; +import { Button } from "@/components/ui/button"; + +export function MarkReadyModal({ + open, + onConfirm, + onCancel, + busy, +}: { + open: boolean; + onConfirm: () => void; + onCancel: () => void; + busy?: boolean; +}) { + return ( + !o && onCancel()}> + + + Mark ready for collection? + + I spoke to this person and the stock is ready for collection. + + + + + } + > + Cancel + + + + + + ); +}