|
1 | 1 | <script lang="ts"> |
2 | 2 | import { fade } from "svelte/transition"; |
| 3 | + import { exportToPDF } from "@requestnetwork/shared-utils/generateInvoice"; |
| 4 | + import { getCurrencyFromManager } from "@requestnetwork/shared-utils/getCurrency"; |
| 5 | + import { initializeCurrencyManager } from "@requestnetwork/shared-utils/initCurrencyManager"; |
| 6 | + import Toaster from "@requestnetwork/shared-components/sonner.svelte"; |
| 7 | + import { toast } from "svelte-sonner"; |
| 8 | +
|
| 9 | + export let createdRequest: any; |
| 10 | + export let enablePdfReceipt: boolean = true; |
| 11 | + export let enableRequestScanLink: boolean = true; |
| 12 | + export let sellerLogo: string = ""; |
| 13 | +
|
| 14 | + async function handleDownloadReceipt() { |
| 15 | + if (createdRequest) { |
| 16 | + try { |
| 17 | + const currencyManager = initializeCurrencyManager([]); |
| 18 | +
|
| 19 | + const currencyData = createdRequest?.inMemoryInfo?.requestData; |
| 20 | +
|
| 21 | + await exportToPDF( |
| 22 | + currencyData, |
| 23 | + getCurrencyFromManager(currencyData.currencyInfo, currencyManager), |
| 24 | + sellerLogo |
| 25 | + ); |
| 26 | + } catch (error) { |
| 27 | + toast.error(`Failed to export PDF`, { |
| 28 | + description: `${error}`, |
| 29 | + action: { |
| 30 | + label: "X", |
| 31 | + onClick: () => console.info("Close"), |
| 32 | + }, |
| 33 | + }); |
| 34 | + } |
| 35 | + } |
| 36 | + } |
3 | 37 | </script> |
4 | 38 |
|
| 39 | +<Toaster /> |
5 | 40 | <div class="payment-complete" transition:fade={{ duration: 300 }}> |
6 | 41 | <div class="checkmark-container"> |
7 | 42 | <svg |
|
19 | 54 | </div> |
20 | 55 | <h2>Payment Complete</h2> |
21 | 56 | <p>Thank you for your payment. Your transaction was successful.</p> |
| 57 | + |
| 58 | + {#if enablePdfReceipt || (enableRequestScanLink && createdRequest)} |
| 59 | + <div class="buttons-container"> |
| 60 | + {#if enablePdfReceipt} |
| 61 | + <button on:click={handleDownloadReceipt}>Download Receipt</button> |
| 62 | + {/if} |
| 63 | + {#if enableRequestScanLink && createdRequest} |
| 64 | + <a |
| 65 | + target="_blank" |
| 66 | + rel="noopener noreferrer" |
| 67 | + href={`https://scan.request.network/request/${createdRequest.requestId}`} |
| 68 | + > |
| 69 | + View on Request Scan |
| 70 | + </a> |
| 71 | + {/if} |
| 72 | + </div> |
| 73 | + {/if} |
22 | 74 | </div> |
23 | 75 |
|
24 | | -<style> |
| 76 | +<style lang="scss"> |
25 | 77 | .payment-complete { |
26 | 78 | display: flex; |
27 | 79 | flex-direction: column; |
|
41 | 93 | border-radius: 50%; |
42 | 94 | } |
43 | 95 |
|
| 96 | + .buttons-container { |
| 97 | + display: flex; |
| 98 | + gap: 16px; |
| 99 | + margin-top: 24px; |
| 100 | +
|
| 101 | + button, |
| 102 | + a { |
| 103 | + padding: 10px 20px; |
| 104 | + border-radius: 6px; |
| 105 | + font-size: 14px; |
| 106 | + font-weight: 500; |
| 107 | + text-decoration: none; |
| 108 | + transition: background-color 0.3s ease; |
| 109 | + } |
| 110 | +
|
| 111 | + button { |
| 112 | + background-color: #0bb489; |
| 113 | + color: white; |
| 114 | + border: none; |
| 115 | + cursor: pointer; |
| 116 | +
|
| 117 | + &:hover { |
| 118 | + background-color: darken(#0bb489, 10%); |
| 119 | + } |
| 120 | + } |
| 121 | +
|
| 122 | + a { |
| 123 | + background-color: #f5f5f5; |
| 124 | + color: #333; |
| 125 | +
|
| 126 | + &:hover { |
| 127 | + background-color: darken(#f5f5f5, 10%); |
| 128 | + } |
| 129 | + } |
| 130 | + } |
| 131 | +
|
44 | 132 | h2 { |
45 | 133 | margin-top: 1rem; |
46 | 134 | font-size: 1.5rem; |
|
0 commit comments