Skip to content

Commit

Permalink
hotfix: empty file input and sort pictures by date
Browse files Browse the repository at this point in the history
  • Loading branch information
ledouxm committed Nov 22, 2024
1 parent 3c7040d commit 1d18638
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/frontend/src/features/upload/UploadImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export const UploadImage = ({ reportId }: { reportId: string }) => {

const uploadImageMutation = useMutation(async (file: File) => {
const picId = v4();
ref.current!.value = "";
const buffer = await processImage(file);

await db.tmp_pictures.create({ data: { id: picId, reportId, createdAt: new Date() } });
Expand Down Expand Up @@ -161,7 +162,7 @@ export const UploadImage = ({ reportId }: { reportId: string }) => {
<Button
type="button"
iconId="ri-add-line"
disabled={!canUploadImage}
// disabled={!canUploadImage}
priority="secondary"
nativeButtonProps={{
type: "button",
Expand Down
7 changes: 6 additions & 1 deletion packages/pdf/src/report.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ Font.registerHyphenationCallback((word) => {
});

export const ReportPDFDocument = ({ udap, htmlString, images, pictures }: ReportPDFDocumentProps) => {
console.log(pictures);
return (
<Document onRender={console.log}>
<Page
Expand Down Expand Up @@ -184,6 +183,12 @@ export const ReportPDFDocument = ({ udap, htmlString, images, pictures }: Report
{pictures
? pictures
.filter((pic) => !!pic.url)
.sort((pic1, pic2) => {
const pic1Date = pic1.createdAt ? new Date(pic1.createdAt) : new Date();
const pic2Date = pic2.createdAt ? new Date(pic2.createdAt) : new Date();

return pic1Date.getTime() - pic2Date.getTime();
})
.map((pic, index) => (
<Page
break={index > 0}
Expand Down

0 comments on commit 1d18638

Please sign in to comment.