Skip to content

Commit 6d235fe

Browse files
committed
feat: added new statuses, styles and logic
1 parent b885555 commit 6d235fe

File tree

1 file changed

+126
-30
lines changed

1 file changed

+126
-30
lines changed

packages/invoice-dashboard/src/lib/dashboard/invoice-view.svelte

Lines changed: 126 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
// Icons
2222
import Check from "@requestnetwork/shared-icons/check.svelte";
2323
import Download from "@requestnetwork/shared-icons/download.svelte";
24+
import InfoCircle from "@requestnetwork/shared-icons/info-circle.svelte";
2425
// Utils
2526
import { formatDate } from "@requestnetwork/shared-utils/formatDate";
2627
import { calculateItemTotal } from "@requestnetwork/shared-utils/invoiceTotals";
@@ -53,7 +54,6 @@
5354
let currency: CurrencyTypes.CurrencyDefinition | undefined =
5455
getCurrencyFromManager(request.currencyInfo, currencyManager);
5556
let paymentCurrencies: (CurrencyTypes.CurrencyDefinition | undefined)[] = [];
56-
let statuses: any = [];
5757
let isPaid = false;
5858
let loading = false;
5959
let requestData: any = null;
@@ -72,6 +72,23 @@
7272
let paymentNetworkExtension:
7373
| Types.Extension.IPaymentNetworkState<any>
7474
| 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+
];
7592
7693
const generateDetailParagraphs = (info: any) => {
7794
const fullName = [info?.firstName, info?.lastName]
@@ -124,6 +141,7 @@
124141
125142
onMount(() => {
126143
checkInvoice();
144+
updateStatuses();
127145
});
128146
129147
$: request, checkInvoice();
@@ -193,7 +211,7 @@
193211
unsupportedNetwork = true;
194212
}
195213
} finally {
196-
loading = false;
214+
// loading = false;
197215
}
198216
};
199217
@@ -204,7 +222,7 @@
204222
requestData?.requestId!
205223
);
206224
207-
statuses = [...statuses, "Waiting for payment"];
225+
// statuses = [...statuses, "SIGN_TRANSACTION"];
208226
209227
let paymentSettings = undefined;
210228
if (
@@ -233,13 +251,14 @@
233251
);
234252
await paymentTx.wait();
235253
236-
statuses = [...statuses, "Payment detected"];
254+
// statuses = [...statuses, "PAYMENT_DETECTED"];
255+
237256
while (requestData.balance?.balance! < requestData.expectedAmount) {
238257
requestData = await _request?.refresh();
239258
await new Promise((resolve) => setTimeout(resolve, 1000));
240259
}
241260
242-
statuses = [...statuses, "Payment confirmed"];
261+
// statuses = [...statuses, "CORRECT_NETWORK"];
243262
isPaid = true;
244263
loading = false;
245264
statuses = [];
@@ -351,6 +370,28 @@
351370
? `${integerPart}.${decimalPart.substring(0, maxDecimalDigits)}`
352371
: value;
353372
}
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+
};
354395
</script>
355396

356397
<div
@@ -572,23 +613,30 @@
572613
<div class="status-container">
573614
<div class="statuses">
574615
{#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>
585635
{/if}
586636
</div>
587637

588638
<div class="invoice-view-actions">
589-
{#if loading}
590-
<div class="loading">Loading...</div>
591-
{:else if !correctChain && !isPayee}
639+
{#if !correctChain && !isPayee}
592640
<Button
593641
type="button"
594642
text="Switch Network"
@@ -812,7 +860,7 @@
812860
display: flex;
813861
align-items: center;
814862
gap: 10px;
815-
justify-content: space-between;
863+
justify-content: center;
816864
margin-top: 1rem;
817865
}
818866
@@ -851,17 +899,6 @@
851899
height: fit-content !important;
852900
}
853901
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-
865902
.unsupported-network {
866903
font-size: 12px;
867904
color: #e89e14ee;
@@ -908,4 +945,63 @@
908945
.email-link:hover {
909946
text-decoration: underline;
910947
}
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+
}
9111007
</style>

0 commit comments

Comments
 (0)