From c6062c9643a67d41981b6ae48521d086a63a586d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= Date: Tue, 12 Nov 2024 15:56:25 +0100 Subject: [PATCH 1/4] fix: empty state search only if no results --- webapp/src/pages/dashboard/search/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/src/pages/dashboard/search/index.tsx b/webapp/src/pages/dashboard/search/index.tsx index fe3ecfcd..9e738b7a 100644 --- a/webapp/src/pages/dashboard/search/index.tsx +++ b/webapp/src/pages/dashboard/search/index.tsx @@ -161,7 +161,7 @@ export default function DashboardSearch() { ))} )} - {!!debouncedSearch && ( + {!!debouncedSearch && !partners.length && ( Nous n'avons pas From e98cd605d011c1608bf063c2ab62bb59ac5dbeb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= Date: Tue, 12 Nov 2024 16:05:20 +0100 Subject: [PATCH 2/4] fix: getList order do not consider offer availability --- webapp/src/server/api/routers/order.ts | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/webapp/src/server/api/routers/order.ts b/webapp/src/server/api/routers/order.ts index 39d6d362..48c6957c 100644 --- a/webapp/src/server/api/routers/order.ts +++ b/webapp/src/server/api/routers/order.ts @@ -346,13 +346,7 @@ export const orderRouter = createTRPCRouter({ collection: "orders", depth: 3, where: { - and: [ - { user: { equals: ctx.session.id } }, - { ...statusQuery }, - { - ...payloadWhereOfferIsValid("offer"), - }, - ], + and: [{ user: { equals: ctx.session.id } }, { ...statusQuery }], }, }); From 9f05f1ddd421ee41cee6313bb03e622bb414fe83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= Date: Tue, 12 Nov 2024 16:13:40 +0100 Subject: [PATCH 3/4] fix: show & download pdf --- .../src/pages/dashboard/order/[id]/index.tsx | 57 ++++++++++++++----- 1 file changed, 42 insertions(+), 15 deletions(-) diff --git a/webapp/src/pages/dashboard/order/[id]/index.tsx b/webapp/src/pages/dashboard/order/[id]/index.tsx index 4d92c8ea..c2abf5d3 100644 --- a/webapp/src/pages/dashboard/order/[id]/index.tsx +++ b/webapp/src/pages/dashboard/order/[id]/index.tsx @@ -112,20 +112,38 @@ export default function OrderObizPage() { order.status !== "delivered" && isOlderThan24Hours(order.createdAt); - const showPDF = () => { - if (order.ticket && typeof order.ticket === "object" && order.ticket.url) { - window.open(order.ticket.url, "_blank", "noopener,noreferrer"); - } - }; + const handlePDFActions = async (isShare: boolean) => { + if (typeof order.ticket === "object" && order.ticket?.url) { + try { + const response = await fetch(order.ticket.url); + const blob = await response.blob(); + const filename = `bon-${order.offer.partner.name}-${order.number}.pdf`; - const downloadPDF = () => { - if (order.ticket && typeof order.ticket === "object" && order.ticket.url) { - const link = document.createElement("a"); - link.href = order.ticket.url; - link.download = ""; - document.body.appendChild(link); - link.click(); - document.body.removeChild(link); + const file = new File([blob], filename, { + type: response.headers.get("content-type") || "application/pdf", + }); + + if ( + isShare && + navigator.share && + navigator.canShare({ files: [file] }) + ) { + await navigator.share({ + files: [file], + }); + } else { + const downloadUrl = URL.createObjectURL(blob); + const a = document.createElement("a"); + a.href = downloadUrl; + a.download = filename; + document.body.appendChild(a); + a.click(); + document.body.removeChild(a); + URL.revokeObjectURL(downloadUrl); + } + } catch (error) { + console.error("Error sharing file:", error); + } } }; @@ -316,7 +334,14 @@ export default function OrderObizPage() { - @@ -329,7 +354,9 @@ export default function OrderObizPage() { flexGrow={0} p={5} h="auto" - onClick={downloadPDF} + onClick={() => { + handlePDFActions(true); + }} > From 37980fc436ffb9e6b05129793cf113a8fbc3da55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= Date: Tue, 12 Nov 2024 16:53:34 +0100 Subject: [PATCH 4/4] fix: number input pattern for iOS --- webapp/src/components/forms/FormInput.tsx | 1 + webapp/src/components/obiz/DiscountAmountBlock.tsx | 1 + 2 files changed, 2 insertions(+) diff --git a/webapp/src/components/forms/FormInput.tsx b/webapp/src/components/forms/FormInput.tsx index 7ef22936..d4790c95 100644 --- a/webapp/src/components/forms/FormInput.tsx +++ b/webapp/src/components/forms/FormInput.tsx @@ -89,6 +89,7 @@ const FormInput = ({ {...restInputProps} autoFocus={autoFocus} type={kind} + {...(kind === "number" && { pattern: "[0-9]*" })} placeholder={placeholder} borderRadius={16} border="none" diff --git a/webapp/src/components/obiz/DiscountAmountBlock.tsx b/webapp/src/components/obiz/DiscountAmountBlock.tsx index 461b8a62..5cb25084 100644 --- a/webapp/src/components/obiz/DiscountAmountBlock.tsx +++ b/webapp/src/components/obiz/DiscountAmountBlock.tsx @@ -209,6 +209,7 @@ const DiscountAmountBlock = (props: DiscountAmountBlockProps) => { >