|
21 | 21 | // Icons |
22 | 22 | import Check from "@requestnetwork/shared-icons/check.svelte"; |
23 | 23 | import Download from "@requestnetwork/shared-icons/download.svelte"; |
| 24 | + import InfoCircle from "@requestnetwork/shared-icons/info-circle.svelte"; |
24 | 25 | // Utils |
25 | 26 | import { formatDate } from "@requestnetwork/shared-utils/formatDate"; |
26 | 27 | import { calculateItemTotal } from "@requestnetwork/shared-utils/invoiceTotals"; |
|
53 | 54 | let currency: CurrencyTypes.CurrencyDefinition | undefined = |
54 | 55 | getCurrencyFromManager(request.currencyInfo, currencyManager); |
55 | 56 | let paymentCurrencies: (CurrencyTypes.CurrencyDefinition | undefined)[] = []; |
56 | | - let statuses: any = []; |
57 | 57 | let isPaid = false; |
58 | 58 | let loading = false; |
59 | 59 | let requestData: any = null; |
|
72 | 72 | let paymentNetworkExtension: |
73 | 73 | | Types.Extension.IPaymentNetworkState<any> |
74 | 74 | | undefined; |
| 75 | + let statuses: any[] = [ |
| 76 | + { |
| 77 | + name: "SIGN_TRANSACTION", |
| 78 | + message: "Sign Transaction", |
| 79 | + done: false, |
| 80 | + }, |
| 81 | + { |
| 82 | + name: "PAYMENT_DETECTED", |
| 83 | + message: "Payment Detected", |
| 84 | + done: false, |
| 85 | + }, |
| 86 | + { |
| 87 | + name: "CORRECT_NETWORK", |
| 88 | + message: "Correct Network", |
| 89 | + done: false, |
| 90 | + }, |
| 91 | + ]; |
75 | 92 |
|
76 | 93 | const generateDetailParagraphs = (info: any) => { |
77 | 94 | const fullName = [info?.firstName, info?.lastName] |
|
124 | 141 |
|
125 | 142 | onMount(() => { |
126 | 143 | checkInvoice(); |
| 144 | + updateStatuses(); |
127 | 145 | }); |
128 | 146 |
|
129 | 147 | $: request, checkInvoice(); |
|
193 | 211 | unsupportedNetwork = true; |
194 | 212 | } |
195 | 213 | } finally { |
196 | | - loading = false; |
| 214 | + // loading = false; |
197 | 215 | } |
198 | 216 | }; |
199 | 217 |
|
|
204 | 222 | requestData?.requestId! |
205 | 223 | ); |
206 | 224 |
|
207 | | - statuses = [...statuses, "Waiting for payment"]; |
| 225 | + // statuses = [...statuses, "SIGN_TRANSACTION"]; |
208 | 226 |
|
209 | 227 | let paymentSettings = undefined; |
210 | 228 | if ( |
|
233 | 251 | ); |
234 | 252 | await paymentTx.wait(); |
235 | 253 |
|
236 | | - statuses = [...statuses, "Payment detected"]; |
| 254 | + // statuses = [...statuses, "PAYMENT_DETECTED"]; |
| 255 | +
|
237 | 256 | while (requestData.balance?.balance! < requestData.expectedAmount) { |
238 | 257 | requestData = await _request?.refresh(); |
239 | 258 | await new Promise((resolve) => setTimeout(resolve, 1000)); |
240 | 259 | } |
241 | 260 |
|
242 | | - statuses = [...statuses, "Payment confirmed"]; |
| 261 | + // statuses = [...statuses, "CORRECT_NETWORK"]; |
243 | 262 | isPaid = true; |
244 | 263 | loading = false; |
245 | 264 | statuses = []; |
|
351 | 370 | ? `${integerPart}.${decimalPart.substring(0, maxDecimalDigits)}` |
352 | 371 | : value; |
353 | 372 | } |
| 373 | +
|
| 374 | + const currentStatusIndex = statuses.length - 1; |
| 375 | +
|
| 376 | + const getStatusColor = (index: number) => { |
| 377 | + if (statuses[index].done) return "green"; |
| 378 | + return "blue"; |
| 379 | + }; |
| 380 | +
|
| 381 | + const updateStatuses = async () => { |
| 382 | + statuses[0].done = true; |
| 383 | + statuses = statuses; |
| 384 | +
|
| 385 | + await new Promise((resolve) => setTimeout(resolve, 2000)); |
| 386 | +
|
| 387 | + statuses[1].done = true; |
| 388 | + statuses = statuses; |
| 389 | +
|
| 390 | + await new Promise((resolve) => setTimeout(resolve, 2000)); |
| 391 | +
|
| 392 | + statuses[2].done = true; |
| 393 | + statuses = statuses; |
| 394 | + }; |
354 | 395 | </script> |
355 | 396 |
|
356 | 397 | <div |
|
572 | 613 | <div class="status-container"> |
573 | 614 | <div class="statuses"> |
574 | 615 | {#if statuses.length > 0 && loading} |
575 | | - {#each statuses as status, index (index)} |
576 | | - <div class="status"> |
577 | | - {status || "-"} |
578 | | - {#if (index === 0 && statuses.length === 2) || (index === 1 && statuses.length === 3)} |
579 | | - <i> |
580 | | - <Check /> |
581 | | - </i> |
582 | | - {/if} |
583 | | - </div> |
584 | | - {/each} |
| 616 | + <div class="status-wrapper"> |
| 617 | + <ol class="status-list"> |
| 618 | + {#each statuses as status, index} |
| 619 | + <li class="status-item"> |
| 620 | + <span class={`status-icon-wrapper ${getStatusColor(index)}`}> |
| 621 | + {#if status.done} |
| 622 | + <Check /> |
| 623 | + {:else} |
| 624 | + <InfoCircle /> |
| 625 | + {/if} |
| 626 | + </span> |
| 627 | + <span class="status-text">{status.message}</span> |
| 628 | + {#if index < 2} |
| 629 | + <div class={`progress-line ${getStatusColor(index)}`}></div> |
| 630 | + {/if} |
| 631 | + </li> |
| 632 | + {/each} |
| 633 | + </ol> |
| 634 | + </div> |
585 | 635 | {/if} |
586 | 636 | </div> |
587 | 637 |
|
588 | 638 | <div class="invoice-view-actions"> |
589 | | - {#if loading} |
590 | | - <div class="loading">Loading...</div> |
591 | | - {:else if !correctChain && !isPayee} |
| 639 | + {#if !correctChain && !isPayee} |
592 | 640 | <Button |
593 | 641 | type="button" |
594 | 642 | text="Switch Network" |
|
812 | 860 | display: flex; |
813 | 861 | align-items: center; |
814 | 862 | gap: 10px; |
815 | | - justify-content: space-between; |
| 863 | + justify-content: center; |
816 | 864 | margin-top: 1rem; |
817 | 865 | } |
818 | 866 |
|
|
851 | 899 | height: fit-content !important; |
852 | 900 | } |
853 | 901 |
|
854 | | - .loading { |
855 | | - padding: 0.75rem 1rem; |
856 | | - font-size: 0.875rem; |
857 | | - font-weight: 500; |
858 | | - text-align: center; |
859 | | - border-radius: 0.5rem; |
860 | | - background-color: var(--mainColor); |
861 | | - color: white; |
862 | | - animation: pulse 1s infinite; |
863 | | - } |
864 | | -
|
865 | 902 | .unsupported-network { |
866 | 903 | font-size: 12px; |
867 | 904 | color: #e89e14ee; |
|
908 | 945 | .email-link:hover { |
909 | 946 | text-decoration: underline; |
910 | 947 | } |
| 948 | +
|
| 949 | + .status-wrapper { |
| 950 | + margin-bottom: 32px; |
| 951 | + } |
| 952 | +
|
| 953 | + .status-list { |
| 954 | + display: flex; |
| 955 | + align-items: center; |
| 956 | + list-style: none; |
| 957 | + padding: 0; |
| 958 | + } |
| 959 | +
|
| 960 | + .status-item { |
| 961 | + display: flex; |
| 962 | + align-items: center; |
| 963 | + position: relative; |
| 964 | + text-align: center; /* Center text under icons */ |
| 965 | + width: 150px; |
| 966 | + } |
| 967 | +
|
| 968 | + .progress-line { |
| 969 | + position: absolute; |
| 970 | + top: 50%; |
| 971 | + left: 50%; |
| 972 | + height: 6px; |
| 973 | + background-color: #759aff; /* Default line color */ |
| 974 | + z-index: 0; |
| 975 | + transform: translateX(-50%); |
| 976 | + width: 180px; |
| 977 | + border-radius: 100px; |
| 978 | + z-index: 10; |
| 979 | + } |
| 980 | +
|
| 981 | + .status-icon-wrapper { |
| 982 | + display: flex; |
| 983 | + justify-content: center; |
| 984 | + align-items: center; |
| 985 | + width: 29px; |
| 986 | + height: 29px; |
| 987 | + background-color: #dbeafe; |
| 988 | + border-radius: 9999px; |
| 989 | + padding: 4px; |
| 990 | + box-shadow: 0 0 0 8px white; |
| 991 | + position: relative; |
| 992 | + z-index: 20; |
| 993 | + } |
| 994 | +
|
| 995 | + .status-text { |
| 996 | + font-size: 14px; /* Adjust font size */ |
| 997 | + color: #272d41; /* Text color */ |
| 998 | + position: absolute; |
| 999 | + top: -30px; |
| 1000 | + left: -25px; |
| 1001 | + } |
| 1002 | +
|
| 1003 | + .checkmark { |
| 1004 | + margin-left: 5px; /* Space between icon and checkmark */ |
| 1005 | + color: #58e1a5; /* Checkmark color */ |
| 1006 | + } |
911 | 1007 | </style> |
0 commit comments