mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-07 06:59:01 +00:00
fix(work-orders): align Extra Docs and Photos copy with AAP
This commit is contained in:
parent
47f78fec89
commit
1607bac8ad
4 changed files with 24 additions and 10 deletions
|
|
@ -93,13 +93,16 @@ function ExtraDocRow({
|
||||||
/>
|
/>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
|
disabled={workOrderId == null}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (workOrderId == null) return;
|
if (workOrderId == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
void openExtraDocContent(workOrderId, file.id).catch(() => {
|
void openExtraDocContent(workOrderId, file.id).catch(() => {
|
||||||
toast.error("Unable to open this document.");
|
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)" }}
|
style={{ fontSize: 12, color: "var(--foreground)" }}
|
||||||
>
|
>
|
||||||
{file.name}
|
{file.name}
|
||||||
|
|
@ -214,7 +217,7 @@ export function SlideOverExtrasTab({
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
addFiles(event.dataTransfer.files);
|
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={{
|
style={{
|
||||||
minHeight: 100,
|
minHeight: 100,
|
||||||
border: "1px dashed var(--color-border)",
|
border: "1px dashed var(--color-border)",
|
||||||
|
|
@ -229,7 +232,8 @@ export function SlideOverExtrasTab({
|
||||||
{pending ? "Uploading…" : "Upload documents, photos or videos"}
|
{pending ? "Uploading…" : "Upload documents, photos or videos"}
|
||||||
</span>
|
</span>
|
||||||
<span style={{ fontSize: 11, color: "var(--color-text-muted)" }}>
|
<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>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
<input
|
<input
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ export function MediaUploaderDropzone({
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
onFilesSelected(e.dataTransfer.files);
|
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={{
|
style={{
|
||||||
minHeight: 120,
|
minHeight: 120,
|
||||||
border: "1px dashed var(--color-border)",
|
border: "1px dashed var(--color-border)",
|
||||||
|
|
@ -39,8 +39,7 @@ export function MediaUploaderDropzone({
|
||||||
{pending ? "Uploading…" : "Drag files here or click to browse"}
|
{pending ? "Uploading…" : "Drag files here or click to browse"}
|
||||||
</span>
|
</span>
|
||||||
<span style={{ fontSize: 11, color: "var(--color-text-muted)" }}>
|
<span style={{ fontSize: 11, color: "var(--color-text-muted)" }}>
|
||||||
Accepted: JPG, PNG, MP4, MOV · Max {formatMediaSizeLimit()} per file · categorize after
|
Accepted: JPG, PNG, MP4, MOV · Max {formatMediaSizeLimit().replace(" ", "")} per file
|
||||||
upload
|
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</button>
|
||||||
<input
|
<input
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import { workOrderMediaAcceptAttribute } from "@/domain/work-orders/utils/work-o
|
||||||
import { renderWithProviders } from "@/test/test-utils";
|
import { renderWithProviders } from "@/test/test-utils";
|
||||||
|
|
||||||
describe("MediaUploaderDropzone", () => {
|
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(
|
renderWithProviders(
|
||||||
<MediaUploaderDropzone
|
<MediaUploaderDropzone
|
||||||
inputRef={createRef<HTMLInputElement>()}
|
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(/PDF/)).not.toBeInTheDocument();
|
||||||
expect(screen.queryByText(/DOC/)).not.toBeInTheDocument();
|
expect(screen.queryByText(/DOC/)).not.toBeInTheDocument();
|
||||||
const input = document.querySelector('input[type="file"]');
|
const input = document.querySelector('input[type="file"]');
|
||||||
|
|
|
||||||
|
|
@ -112,11 +112,19 @@ describe("SlideOverExtrasTab Aveta", () => {
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(
|
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();
|
).toBeInTheDocument();
|
||||||
const input = document.querySelector('input[type="file"]');
|
const input = document.querySelector('input[type="file"]');
|
||||||
expect(input?.getAttribute("accept")).toContain(".pdf");
|
expect(input?.getAttribute("accept")).toContain(".pdf");
|
||||||
expect(input?.getAttribute("accept")).toContain(".doc");
|
expect(input?.getAttribute("accept")).toContain(".doc");
|
||||||
expect(input?.getAttribute("accept")).toContain(".docx");
|
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();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue