|
9 | 9 | // Icons |
10 | 10 | import Trash from "@requestnetwork/shared-icons/trash.svelte"; |
11 | 11 | import Plus from "@requestnetwork/shared-icons/plus.svelte"; |
12 | | - import Close from "@requestnetwork/shared-icons/close.svelte"; |
13 | 12 |
|
14 | 13 | // Types |
15 | 14 | import type { IConfig, CustomFormData } from "@requestnetwork/shared-types"; |
|
50 | 49 | }, |
51 | 50 | }; |
52 | 51 |
|
53 | | - let creatorId = formData.creatorId || ""; |
54 | | - let showPayeeAddressInput = false; |
| 52 | + let creatorId = ""; |
| 53 | +
|
| 54 | + $: { |
| 55 | + creatorId = formData.creatorId; |
| 56 | + } |
55 | 57 |
|
56 | 58 | const validateEmail = (email: string, type: "sellerInfo" | "buyerInfo") => { |
57 | 59 | validationErrors[`${type}`].email = !isEmail(email); |
|
152 | 154 | const removeInvoiceItem = (index: number) => { |
153 | 155 | formData.invoiceItems = formData.invoiceItems.filter((_, i) => i !== index); |
154 | 156 | }; |
155 | | -
|
156 | | - const togglePayeeAddress = () => { |
157 | | - showPayeeAddressInput = !showPayeeAddressInput; |
158 | | - if (!showPayeeAddressInput) { |
159 | | - formData.payeeAddress = creatorId; |
160 | | - } |
161 | | - }; |
162 | | -
|
163 | | - $: if (!showPayeeAddressInput && creatorId) { |
164 | | - formData.payeeAddress = creatorId; |
165 | | - } |
166 | 157 | </script> |
167 | 158 |
|
168 | 159 | <form class="invoice-form"> |
|
191 | 182 | label="From" |
192 | 183 | placeholder="Connect wallet to populate" |
193 | 184 | /> |
194 | | - {#if !showPayeeAddressInput} |
195 | | - <Button |
196 | | - text="+ Add Recipient Address" |
197 | | - type="button" |
198 | | - onClick={togglePayeeAddress} |
199 | | - className="invoice-form-add-recipient-button" |
200 | | - /> |
201 | | - {:else} |
202 | | - <div class="payee-address-container"> |
203 | | - <Input |
204 | | - label="Where do you want to receive your payment?" |
205 | | - id="payeeAddress" |
206 | | - type="text" |
207 | | - value={formData.payeeAddress} |
208 | | - placeholder="0x..." |
209 | | - {handleInput} |
210 | | - onBlur={checkPayeeAddress} |
211 | | - error={validationErrors.payeeAddress |
212 | | - ? "Please enter a valid Ethereum address" |
213 | | - : ""} |
214 | | - /> |
215 | | - <Button |
216 | | - type="button" |
217 | | - onClick={togglePayeeAddress} |
218 | | - className="invoice-form-close-recipient-button" |
219 | | - > |
220 | | - <div slot="icon" style="padding: 7px;"> |
221 | | - <Close /> |
222 | | - </div> |
223 | | - </Button> |
224 | | - </div> |
225 | | - {/if} |
226 | 185 | <Accordion title="Add Your Info"> |
227 | 186 | <div class="invoice-form-info"> |
228 | 187 | <Input |
|
440 | 399 | }))} |
441 | 400 | onchange={handleCurrencyChange} |
442 | 401 | /> |
| 402 | + <Input |
| 403 | + label="Where do you want to receive your payment?" |
| 404 | + id="payeeAddress" |
| 405 | + type="text" |
| 406 | + value={formData.payeeAddress} |
| 407 | + placeholder="0x..." |
| 408 | + {handleInput} |
| 409 | + onBlur={checkPayeeAddress} |
| 410 | + error={validationErrors.payeeAddress |
| 411 | + ? "Please enter a valid Ethereum address" |
| 412 | + : ""} |
| 413 | + /> |
443 | 414 | </div> |
444 | 415 | </div> |
445 | 416 | <div class="invoice-form-dates"> |
|
668 | 639 | gap: 20px; |
669 | 640 | } |
670 | 641 |
|
671 | | - :global(.invoice-form-add-recipient-button) { |
672 | | - background-color: transparent !important; |
673 | | - color: var(--mainColor) !important; |
674 | | - text-transform: uppercase; |
675 | | - transform: none !important; |
676 | | - font-weight: 500; |
677 | | - font-size: 14px !important; |
678 | | - width: fit-content; |
679 | | - } |
680 | | -
|
681 | | - :global(.invoice-form-add-recipient-button:hover) { |
682 | | - color: var(--secondaryColor) !important; |
683 | | - } |
684 | | -
|
685 | 642 | .invoice-form-section { |
686 | 643 | display: flex; |
687 | 644 | flex-direction: column; |
|
838 | 795 | width: 12px; |
839 | 796 | height: 12px; |
840 | 797 | } |
841 | | -
|
842 | | - .payee-address-container { |
843 | | - position: relative; |
844 | | - display: flex; |
845 | | - align-items: flex-start; |
846 | | - gap: 10px; |
847 | | - } |
848 | | -
|
849 | | - .payee-address-container :global(.input-wrapper) { |
850 | | - flex: 1; |
851 | | - } |
852 | | -
|
853 | | - :global(.invoice-form-close-recipient-button) { |
854 | | - position: absolute; |
855 | | - right: 0; |
856 | | - top: -4px; |
857 | | - } |
858 | | -
|
859 | | - :global(.invoice-form-close-recipient-button div) { |
860 | | - padding: 4px !important; |
861 | | - } |
862 | 798 | </style> |
0 commit comments