diff --git a/packages/create-invoice-form/src/lib/invoice/form-view.svelte b/packages/create-invoice-form/src/lib/invoice/form-view.svelte index 9645da8a..27af66a7 100644 --- a/packages/create-invoice-form/src/lib/invoice/form-view.svelte +++ b/packages/create-invoice-form/src/lib/invoice/form-view.svelte @@ -48,45 +48,49 @@ const generateDetailParagraphs = (info: any) => { const details = []; - if (info.firstName) { - details.push({ label: "First Name", value: info.firstName }); + + if (info.firstName || info.lastName) { + details.push({ + value: `${info.firstName || ""} ${info.lastName || ""}`.trim(), + }); } + if (info.email) { - details.push({ label: "Email", value: info.email }); - } - if (info.lastName) { - details.push({ label: "Last Name", value: info.lastName }); + details.push({ + value: info.email, + isEmail: true, + }); } + if (info.businessName) { - details.push({ label: "Company Name", value: info.businessName }); - } - if (info.taxRegistration) { details.push({ - label: "Tax Identification Number (TIN)", - value: info.taxRegistration, + value: info.businessName, + isCompany: true, }); } - if (info.address["country-name"]) { - details.push({ label: "Country", value: info.address["country-name"] }); - } - if (info.address["street-address"]) { + + if (info.taxRegistration) { details.push({ - label: "Street Address", - value: info.address["street-address"], + value: info.taxRegistration, }); } - if (info.address["postal-code"]) { + + const addressParts = []; + if (info.address["street-address"]) + addressParts.push(info.address["street-address"]); + if (info.address["locality"]) addressParts.push(info.address["locality"]); + if (info.address["region"]) addressParts.push(info.address["region"]); + if (info.address["postal-code"]) + addressParts.push(info.address["postal-code"]); + if (info.address["country-name"]) + addressParts.push(info.address["country-name"]); + + if (addressParts.length > 0) { details.push({ - label: "Postal Code", - value: info.address["postal-code"], + value: addressParts.join(", "), }); } - if (info.address["locality"]) { - details.push({ label: "City", value: info.address["locality"] }); - } - if (info.address["region"]) { - details.push({ label: "Region", value: info.address["region"] }); - } + return details; }; @@ -137,30 +141,33 @@ From {formData.creatorId}

-
0 && "invoice-details-active"} `} - > - {#each sellerInfo as paragraph} -
- {paragraph.label} - {paragraph.value} -
+
+ {#each sellerInfo as { value, isEmail, isCompany }} +

+ {#if isEmail} + {value} + {:else} + {value} + {/if} +

{/each}
+

Billed to {formData.payerAddress}

-
0 && "invoice-details-active"} `} - > - {#each buyerInfo as paragraph} -
- {paragraph.label} - {paragraph.value} -
+
+ {#each buyerInfo as { value, isEmail, isCompany }} +

+ {#if isEmail} + {value} + {:else} + {value} + {/if} +

{/each}
@@ -490,4 +497,37 @@ fill: white; color: white; } + + .invoice-info { + display: flex; + flex-direction: column; + gap: 6px; + } + + .invoice-info p { + display: flex; + gap: 8px; + } + + .invoice-info span { + color: #6e7480; + } + + .invoice-info .company { + font-weight: 600 !important; + } + + .invoice-info a { + color: #6e7480; + } + + .invoice-info a:hover { + text-decoration: underline; + } + + .invoice-section-divider { + width: 100%; + height: 1px; + background-color: var(--mainColor); + } diff --git a/packages/invoice-dashboard/src/lib/dashboard/invoice-view.svelte b/packages/invoice-dashboard/src/lib/dashboard/invoice-view.svelte index 735aa603..76419657 100644 --- a/packages/invoice-dashboard/src/lib/dashboard/invoice-view.svelte +++ b/packages/invoice-dashboard/src/lib/dashboard/invoice-view.svelte @@ -31,6 +31,16 @@ import { getConversionPaymentValues } from "../../utils/getConversionPaymentValues"; import { getEthersSigner } from "../../utils"; + interface EntityInfo { + value: string; + isCompany?: boolean; + isEmail?: boolean; + } + + interface BuyerInfo extends EntityInfo {} + + interface SellerInfo extends EntityInfo {} + export let config; export let account: GetAccountReturnType; export let requestNetwork: RequestNetwork | null | undefined; @@ -40,7 +50,6 @@ export let wagmiConfig: any; let network: string | undefined = request?.currencyInfo?.network || "mainnet"; - // FIXME: Use a non deprecated function let currency: CurrencyTypes.CurrencyDefinition | undefined = getCurrencyFromManager(request.currencyInfo, currencyManager); let paymentCurrencies: (CurrencyTypes.CurrencyDefinition | undefined)[] = []; @@ -53,11 +62,11 @@ let address = account.address; let firstItems: any; let otherItems: any; - let sellerInfo: { label: string; value: string }[] = []; - let buyerInfo: { label: string; value: string }[] = []; + let sellerInfo: SellerInfo[] = []; + let buyerInfo: BuyerInfo[] = []; let isPayee = request?.payee?.value.toLowerCase() === address?.toLowerCase(); let unsupportedNetwork = false; - let hexStringChain = "0x" + account.chainId.toString(16); + let hexStringChain = "0x" + account?.chainId?.toString(16); let correctChain = hexStringChain === String(getNetworkIdFromNetworkName(network)); let paymentNetworkExtension: @@ -65,17 +74,32 @@ | undefined; const generateDetailParagraphs = (info: any) => { + const fullName = [info?.firstName, info?.lastName] + .filter(Boolean) + .join(" "); + const fullAddress = [ + info?.address?.["street-address"], + info?.address?.locality, + info?.address?.region, + info?.address?.["postal-code"], + info?.address?.["country-name"], + ] + .filter(Boolean) + .join(", "); + return [ - { label: "First Name", value: info?.firstName }, - { label: "Last Name", value: info?.lastName }, - { label: "Company Name", value: info?.businessName }, - { label: "Tax Registration", value: info?.taxRegistration }, - { label: "Country", value: info?.address?.["country-name"] }, - { label: "City", value: info?.address?.locality }, - { label: "Region", value: info?.address?.region }, - { label: "Postal Code", value: info?.address?.["postal-code"] }, - { label: "Street Address", value: info?.address?.["street-address"] }, - { label: "Email", value: info?.email }, + ...(fullName ? [{ value: fullName }] : []), + ...(info?.businessName + ? [ + { + value: info?.businessName, + isCompany: true, + }, + ] + : []), + ...(info?.taxRegistration ? [{ value: info?.taxRegistration }] : []), + ...(fullAddress ? [{ value: fullAddress }] : []), + ...(info?.email ? [{ value: info?.email, isEmail: true }] : []), ].filter((detail) => detail.value); }; @@ -107,7 +131,6 @@ $: { account = account; network = request?.currencyInfo?.network || "mainnet"; - // FIXME: Use a non deprecated function currency = getCurrencyFromManager(request.currencyInfo, currencyManager); } @@ -248,7 +271,7 @@ return ( (paymentNetworkExtension?.id && - await approvalCheckers[paymentNetworkExtension.id]?.()) || + (await approvalCheckers[paymentNetworkExtension.id]?.())) || false ); }; @@ -376,11 +399,16 @@

{request?.payee?.value || "-"}

{#if sellerInfo.length > 0} -
- {#each sellerInfo as { label, value }} +
+ {#each sellerInfo as { value, isCompany, isEmail }}

- {label || "-"}: - {value || "-"} + {#if isEmail} + + {:else if isCompany} + {value} + {:else} + {value} + {/if}

{/each}
@@ -391,11 +419,16 @@

{request?.payer?.value || "-"}

{#if buyerInfo.length > 0} -
- {#each buyerInfo as { label, value }} +
+ {#each buyerInfo as { value, isCompany, isEmail }}

- {label || "-"}: - {value || "-"} + {#if isEmail} + + {:else if isCompany} + {value} + {:else} + {value} + {/if}

{/each}
@@ -647,10 +680,11 @@ .invoice-info { display: flex; - flex-wrap: wrap; - gap: 18px; - padding: 0.75rem; + flex-direction: column; + gap: 6px; width: fit-content; + color: #6e7480; + font-size: 16px; } .invoice-info p { @@ -862,4 +896,16 @@ .bg-zinc-light { background-color: #f4f4f5; } + + .company-name { + font-weight: 600 !important; + } + + .email-link { + color: #6e7480; + } + + .email-link:hover { + text-decoration: underline; + }