@@ -22,14 +22,17 @@ import {
2222 QR ,
2323 CountdownCircleTimer ,
2424 Pressable ,
25- Modal
25+ Modal ,
26+ View
2627} from "@components" ;
2728import {
2829 faArrowLeft ,
2930 faArrowUpRightFromSquare ,
3031 faBolt ,
3132 faCheck ,
33+ faCircleDown ,
3234 faClock ,
35+ faFileDownload ,
3336 faGlobe ,
3437 faHandPointer ,
3538 faIdCard ,
@@ -55,6 +58,7 @@ import { FooterLine } from "./components/FooterLine";
5558import {
5659 DEFAULT_DECIMALS ,
5760 apiRootDomain ,
61+ apiRootUrl ,
5862 appRootUrl ,
5963 currencies ,
6064 rateUpdateDelay
@@ -162,13 +166,15 @@ const STATUS_ICON_SIZE = 120;
162166const MAX_QR_SIZE = 320 ;
163167const FOOTER_VALUE_ITEMS_SIZE = 18 ;
164168
169+ const REDIRECT_DELAY = 60 * 1000 ;
170+
165171export const Invoice = ( ) => {
166172 const navigate = useNavigate ( ) ;
167173 const { colors, gridSize } = useTheme ( ) ;
168174 const toast = useToast ( ) ;
169175 const versionTag = useVersionTag ( ) ;
170176 const printInvoiceTicket = usePrintInvoiceTicket ( ) ;
171- const { t } = useTranslation ( undefined , {
177+ const { t, i18n } = useTranslation ( undefined , {
172178 keyPrefix : "screens.invoice"
173179 } ) ;
174180 const { t : tRoot } = useTranslation ( ) ;
@@ -396,8 +402,6 @@ export const Invoice = () => {
396402 delay : springAnimationDelay
397403 } ) ;
398404
399- const REDIRECT_DELAY = 7000 ;
400-
401405 redirectProgressApi . start ( {
402406 to : { left : "0%" } ,
403407 config : { duration : REDIRECT_DELAY }
@@ -539,7 +543,10 @@ export const Invoice = () => {
539543 ) ;
540544 }
541545
542- setDescription ( getInvoiceData . description ) ;
546+ if ( getInvoiceData . description ) {
547+ // don't remove description if it already stored
548+ setDescription ( getInvoiceData . description ) ;
549+ }
543550 setAmount ( getInvoiceData . amount * 1000 ) ;
544551 setPaidAt ( getInvoiceData . paidAt ) ;
545552 setInvoiceCurrency ( getInvoiceData . input . unit || "CHF" ) ;
@@ -736,6 +743,12 @@ export const Invoice = () => {
736743 printInvoiceTicket
737744 ] ) ;
738745
746+ const downloadPdfLink = useMemo (
747+ ( ) =>
748+ `${ apiRootUrl } /pdf/${ invoiceId } ?lng=${ i18n . language } &tz=${ Intl . DateTimeFormat ( ) . resolvedOptions ( ) . timeZone } ` ,
749+ [ i18n . language , invoiceId ]
750+ ) ;
751+
739752 const getPageContainerProps = useCallback (
740753 ( isSuccessScreen = false ) => {
741754 return {
@@ -788,6 +801,13 @@ export const Invoice = () => {
788801 [ qrCodeSize , gridSize ]
789802 ) ;
790803
804+ const redirectDuration = useMemo ( ( ) => {
805+ if ( ! isExternalInvoice ) {
806+ return REDIRECT_DELAY / 1000 ;
807+ }
808+ return 7 ;
809+ } , [ isExternalInvoice ] ) ;
810+
791811 return (
792812 < >
793813 < Modal
@@ -811,6 +831,23 @@ export const Invoice = () => {
811831 >
812832 < S . InvoicePageContainer { ...getPageContainerProps ( true ) } >
813833 < S . SectionsContainer gapSize = { 2 } >
834+ { ! isWithdraw && (
835+ < S . InvoiceDownloadContainer isLarge = { isLarge } >
836+ < QR
837+ value = { downloadPdfLink }
838+ size = { S . INVOICE_DOWNLOAD_QR }
839+ icon = { faCircleDown }
840+ ecl = "M"
841+ backgroundColor = { colors . white }
842+ logoBackgroundColor = { colors . white }
843+ color = { colors . success }
844+ logoColor = { colors . success }
845+ />
846+ < Text centered weight = { 600 } color = { colors . success } h4 >
847+ { t ( "receipt" ) }
848+ </ Text >
849+ </ S . InvoiceDownloadContainer >
850+ ) }
814851 < S . Section grow >
815852 < >
816853 < S . TypeText color = "transparent" > _</ S . TypeText >
@@ -1025,7 +1062,7 @@ export const Invoice = () => {
10251062 < CountdownCircleTimer
10261063 isGrowing
10271064 isPlaying
1028- duration = { 7 }
1065+ duration = { redirectDuration }
10291066 strokeWidth = { 5 }
10301067 size = { STATUS_ICON_SIZE / 4 }
10311068 colors = { colors . white }
@@ -1143,6 +1180,21 @@ export const Invoice = () => {
11431180 </ ComponentStack >
11441181 </ ComponentStack >
11451182 ) }
1183+ { status === "settled" && ! isWithdraw && (
1184+ < View
1185+ style = { {
1186+ flex : 1 ,
1187+ justifyContent : "flex-end" ,
1188+ width : "100%"
1189+ } }
1190+ >
1191+ < Button
1192+ icon = { faFileDownload }
1193+ title = { t ( "downloadReceipt" ) }
1194+ onPress = { downloadPdfLink }
1195+ />
1196+ </ View >
1197+ ) }
11461198 { createdAt && delay && isAlive && ! isExternalInvoice && (
11471199 < S . ProgressBar
11481200 progress = { progress }
0 commit comments