Skip to content

Commit 37f3d67

Browse files
authored
fix: added dash when an invoice is not using our format (#78)
1 parent 060f93f commit 37f3d67

File tree

1 file changed

+39
-24
lines changed

1 file changed

+39
-24
lines changed

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

Lines changed: 39 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -212,52 +212,54 @@
212212
--secondaryColor: {config.colors.secondary};"
213213
>
214214
<div class="dates">
215-
<p>Issued on: {formatDate(request?.contentData?.creationDate)}</p>
216-
<p>Due by: {formatDate(request?.contentData?.paymentTerms?.dueDate)}</p>
215+
<p>Issued on: {formatDate(request?.contentData?.creationDate || "-")}</p>
216+
<p>
217+
Due by: {formatDate(request?.contentData?.paymentTerms?.dueDate || "-")}
218+
</p>
217219
</div>
218220
<h2 class="invoice-number">
219-
Invoice #{request?.contentData?.invoiceNumber}
221+
Invoice #{request?.contentData?.invoiceNumber || "-"}
220222
<p class={`invoice-status ${isPaid ? "bg-green" : "bg-zinc"}`}>
221223
{isPaid ? "Paid" : "Created"}
222224
</p>
223225
</h2>
224226
<div class="invoice-address">
225227
<h2>From:</h2>
226-
<p>{request?.payee?.value}</p>
228+
<p>{request?.payee?.value || "-"}</p>
227229
</div>
228230
{#if sellerInfo.length > 0}
229231
<div class={`invoice-info bg-zinc-light`}>
230232
{#each sellerInfo as { label, value }}
231233
<p>
232-
<span>{label}:</span>
233-
{value}
234+
<span>{label || "-"}:</span>
235+
{value || "-"}
234236
</p>
235237
{/each}
236238
</div>
237239
{/if}
238240
<div class="invoice-border"></div>
239241
<div class="invoice-address">
240242
<h2>Billed to:</h2>
241-
<p>{request?.payer?.value}</p>
243+
<p>{request?.payer?.value || "-"}</p>
242244
</div>
243245
{#if buyerInfo.length > 0}
244246
<div class={`invoice-info bg-zinc-light`}>
245247
{#each buyerInfo as { label, value }}
246248
<p>
247-
<span>{label}:</span>
248-
{value}
249+
<span>{label || "-"}:</span>
250+
{value || "-"}
249251
</p>
250252
{/each}
251253
</div>
252254
{/if}
253255

254256
<h3 class="invoice-info-payment">
255257
<span style="font-weight: 500;">Payment Chain:</span>
256-
{currency?.network}
258+
{currency?.network || "-"}
257259
</h3>
258260
<h3 class="invoice-info-payment">
259261
<span style="font-weight: 500;">Invoice Currency:</span>
260-
{currency?.symbol}
262+
{currency?.symbol || "-"}
261263
</h3>
262264

263265
{#if request?.contentData?.invoiceItems}
@@ -279,12 +281,20 @@
279281
{#each firstItems as item, index (index)}
280282
<tr class="table-row item-row">
281283
<th scope="row" class="item-description">
282-
<p class="truncate description-text">{item.name}</p>
284+
<p class="truncate description-text">{item.name || "-"}</p>
283285
</th>
284-
<td>{item.quantity}</td>
285-
<td>{formatUnits(item.unitPrice, currency?.decimals ?? 18)}</td>
286-
<td>{formatUnits(item.discount, currency?.decimals ?? 18)}</td>
287-
<td>{Number(item.tax.amount)}</td>
286+
<td>{item.quantity || "-"}</td>
287+
<td
288+
>{item.unitPrice
289+
? formatUnits(item.unitPrice, currency?.decimals ?? 18)
290+
: "-"}</td
291+
>
292+
<td
293+
>{item.discount
294+
? formatUnits(item.discount, currency?.decimals ?? 18)
295+
: "-"}</td
296+
>
297+
<td>{Number(item.tax.amount || "-")}</td>
288298
<td
289299
>{truncateNumberString(
290300
formatUnits(
@@ -319,16 +329,21 @@
319329
<tr class="table-row item-row">
320330
<th scope="row" class="item-description">
321331
<p class="truncate description-text" style="margin: 4px 0;">
322-
{item.name}
332+
{item.name || "-"}
323333
</p>
324334
</th>
325-
<td>{item.quantity}</td>
335+
<td>{item.quantity || "-"}</td>
326336
<td
327-
>{formatUnits(item.unitPrice, currency?.decimals ?? 18)}</td
337+
>{item.unitPrice
338+
? formatUnits(item.unitPrice, currency?.decimals ?? 18)
339+
: "-"}</td
328340
>
329-
<td>{formatUnits(item.discount, currency?.decimals ?? 18)}</td
341+
<td
342+
>{item.discount
343+
? formatUnits(item.discount, currency?.decimals ?? 18)
344+
: "-"}</td
330345
>
331-
<td>{Number(item.tax.amount)}</td>
346+
<td>{Number(item.tax.amount || "-")}</td>
332347
<td
333348
>{truncateNumberString(
334349
formatUnits(
@@ -351,15 +366,15 @@
351366
<div class="note-container">
352367
<p class="note-content">
353368
<span class="note-title">Memo:</span> <br />
354-
{request.contentData.note}
369+
{request.contentData.note || "-"}
355370
</p>
356371
</div>
357372
{/if}
358373
<div class="labels-container">
359374
{#if request?.contentData?.miscellaneous?.labels}
360375
{#each request?.contentData?.miscellaneous?.labels as label, index (index)}
361376
<div class="label">
362-
{label}
377+
{label || "-"}
363378
</div>
364379
{/each}
365380
{/if}
@@ -369,7 +384,7 @@
369384
{#if statuses.length > 0 && loading}
370385
{#each statuses as status, index (index)}
371386
<div class="status">
372-
{status}
387+
{status || "-"}
373388
{#if (index === 0 && statuses.length === 2) || (index === 1 && statuses.length === 3)}
374389
<i>
375390
<Check />

0 commit comments

Comments
 (0)