fix(work-orders): align Extra Docs and Photos copy with AAP

This commit is contained in:
Arthur Bassi 2026-09-08 13:48:02 -03:00
parent 47f78fec89
commit 1607bac8ad
4 changed files with 24 additions and 10 deletions

View file

@ -93,13 +93,16 @@ function ExtraDocRow({
/>
<button
type="button"
disabled={workOrderId == null}
onClick={() => {
if (workOrderId == null) return;
if (workOrderId == null) {
return;
}
void openExtraDocContent(workOrderId, file.id).catch(() => {
toast.error("Unable to open this document.");
});
}}
className="min-w-0 flex-1 truncate text-left hover:underline"
className="min-w-0 flex-1 truncate text-left hover:underline disabled:cursor-not-allowed disabled:opacity-50"
style={{ fontSize: 12, color: "var(--foreground)" }}
>
{file.name}
@ -214,7 +217,7 @@ export function SlideOverExtrasTab({
event.preventDefault();
addFiles(event.dataTransfer.files);
}}
className="flex w-full flex-col items-center justify-center gap-1.5 transition-colors hover:bg-[var(--color-bg-muted)] disabled:opacity-60"
className="flex w-full flex-col items-center justify-center gap-1.5 transition-colors hover:bg-(--color-bg-muted) disabled:opacity-60"
style={{
minHeight: 100,
border: "1px dashed var(--color-border)",
@ -229,7 +232,8 @@ export function SlideOverExtrasTab({
{pending ? "Uploading…" : "Upload documents, photos or videos"}
</span>
<span style={{ fontSize: 11, color: "var(--color-text-muted)" }}>
Accepted: JPG, PNG, MP4, MOV, PDF, DOC · Max {formatMediaSizeLimit()}
Accepted: JPG, PNG, MP4, MOV, PDF, DOC · Max {formatMediaSizeLimit().replace(" ", "")}{" "}
per file
</span>
</button>
<input

View file

@ -27,7 +27,7 @@ export function MediaUploaderDropzone({
e.preventDefault();
onFilesSelected(e.dataTransfer.files);
}}
className="flex w-full flex-col items-center justify-center gap-1.5 transition-colors hover:bg-[var(--color-bg-muted)] disabled:opacity-60"
className="flex w-full flex-col items-center justify-center gap-1.5 transition-colors hover:bg-(--color-bg-muted) disabled:opacity-60"
style={{
minHeight: 120,
border: "1px dashed var(--color-border)",
@ -39,8 +39,7 @@ export function MediaUploaderDropzone({
{pending ? "Uploading…" : "Drag files here or click to browse"}
</span>
<span style={{ fontSize: 11, color: "var(--color-text-muted)" }}>
Accepted: JPG, PNG, MP4, MOV · Max {formatMediaSizeLimit()} per file · categorize after
upload
Accepted: JPG, PNG, MP4, MOV · Max {formatMediaSizeLimit().replace(" ", "")} per file
</span>
</button>
<input

View file

@ -6,7 +6,7 @@ import { workOrderMediaAcceptAttribute } from "@/domain/work-orders/utils/work-o
import { renderWithProviders } from "@/test/test-utils";
describe("MediaUploaderDropzone", () => {
it("keeps Photos accept copy media-only at 50 MB", () => {
it("matches the AAP Photos accept copy and keeps it media-only", () => {
renderWithProviders(
<MediaUploaderDropzone
inputRef={createRef<HTMLInputElement>()}
@ -15,7 +15,10 @@ describe("MediaUploaderDropzone", () => {
/>,
);
expect(screen.getByText(/Accepted: JPG, PNG, MP4, MOV · Max 50 MB/)).toBeInTheDocument();
expect(
screen.getByText("Accepted: JPG, PNG, MP4, MOV · Max 50MB per file"),
).toBeInTheDocument();
expect(screen.queryByText(/categorize after upload/i)).not.toBeInTheDocument();
expect(screen.queryByText(/PDF/)).not.toBeInTheDocument();
expect(screen.queryByText(/DOC/)).not.toBeInTheDocument();
const input = document.querySelector('input[type="file"]');

View file

@ -112,11 +112,19 @@ describe("SlideOverExtrasTab Aveta", () => {
);
expect(
screen.getByText("Accepted: JPG, PNG, MP4, MOV, PDF, DOC · Max 50 MB"),
screen.getByText("Accepted: JPG, PNG, MP4, MOV, PDF, DOC · Max 50MB per file"),
).toBeInTheDocument();
const input = document.querySelector('input[type="file"]');
expect(input?.getAttribute("accept")).toContain(".pdf");
expect(input?.getAttribute("accept")).toContain(".doc");
expect(input?.getAttribute("accept")).toContain(".docx");
});
it("disables document opening until the work order id is available", () => {
renderWithProviders(
<SlideOverExtrasTab uploads={[photo]} isReadOnly onUpload={vi.fn()} onRemove={vi.fn()} />,
);
expect(screen.getByRole("button", { name: "safety-form.pdf" })).toBeDisabled();
});
});