|
55 | 55 | let error = $state<string | null>(null); |
56 | 56 | let addressLoadingError = $state<string | null>(null); |
57 | 57 | let blockCheckInterval = $state<NodeJS.Timeout | null>(null); |
| 58 | + let showManualPrimaryInput = $state(false); |
58 | 59 | |
59 | 60 | // Connection state for chain parameter |
60 | 61 | let connectionState = $state<any>(); |
|
126 | 127 | clearInterval(blockCheckInterval); |
127 | 128 | blockCheckInterval = null; |
128 | 129 | } |
| 130 | + // Reset manual input state |
| 131 | + showManualPrimaryInput = false; |
129 | 132 | } |
130 | 133 |
|
131 | 134 | async function loadControlAddresses() { |
|
338 | 341 | } |
339 | 342 | } |
340 | 343 |
|
| 344 | + function handlePrimaryAddressDropdownChange(event: Event) { |
| 345 | + const target = event.target as HTMLSelectElement; |
| 346 | + if (target.value === '__MANUAL__') { |
| 347 | + showManualPrimaryInput = true; |
| 348 | + formData.primaryAddresses[0] = ''; |
| 349 | + } else { |
| 350 | + showManualPrimaryInput = false; |
| 351 | + formData.primaryAddresses[0] = target.value; |
| 352 | + } |
| 353 | + } |
| 354 | +
|
| 355 | + function switchToDropdown() { |
| 356 | + showManualPrimaryInput = false; |
| 357 | + formData.primaryAddresses[0] = ''; |
| 358 | + } |
| 359 | +
|
341 | 360 | async function handleNameReservation(event: SubmitEvent) { |
342 | 361 | event.preventDefault(); |
343 | 362 | |
|
958 | 977 | {#each formData.primaryAddresses as _, index} |
959 | 978 | <div class="flex space-x-2 mb-2"> |
960 | 979 | {#if index === 0} |
961 | | - <!-- First address: dropdown from loaded addresses --> |
962 | | - <select |
963 | | - bind:value={formData.primaryAddresses[index]} |
964 | | - required |
965 | | - disabled={isLoadingControlAddresses} |
966 | | - class="flex-1 p-3 border border-verusidx-mountain-mist dark:border-verusidx-stone-medium rounded-lg bg-white dark:bg-verusidx-stone-dark text-verusidx-stone-dark dark:text-white disabled:opacity-50" |
967 | | - > |
968 | | - <option value=""> |
969 | | - {#if isLoadingControlAddresses} |
970 | | - Loading addresses... |
971 | | - {:else if hasLoadedControlAddresses && controlAddresses.length === 0} |
972 | | - No addresses available |
973 | | - {:else if !hasLoadedControlAddresses} |
974 | | - Failed to load addresses |
975 | | - {:else} |
976 | | - Select address... |
977 | | - {/if} |
978 | | - </option> |
979 | | - {#each controlAddresses as addr} |
980 | | - <option value={addr}>{addr}{addr.startsWith('z') ? ' (Private)' : ' (Transparent)'}</option> |
981 | | - {/each} |
982 | | - </select> |
| 980 | + <!-- First address: dropdown or manual input --> |
| 981 | + {#if !showManualPrimaryInput} |
| 982 | + <select |
| 983 | + onchange={handlePrimaryAddressDropdownChange} |
| 984 | + value={formData.primaryAddresses[index]} |
| 985 | + required |
| 986 | + disabled={isLoadingControlAddresses} |
| 987 | + class="flex-1 p-3 border border-verusidx-mountain-mist dark:border-verusidx-stone-medium rounded-lg bg-white dark:bg-verusidx-stone-dark text-verusidx-stone-dark dark:text-white disabled:opacity-50" |
| 988 | + > |
| 989 | + <option value=""> |
| 990 | + {#if isLoadingControlAddresses} |
| 991 | + Loading addresses... |
| 992 | + {:else if hasLoadedControlAddresses && controlAddresses.length === 0} |
| 993 | + No addresses available |
| 994 | + {:else if !hasLoadedControlAddresses} |
| 995 | + Failed to load addresses |
| 996 | + {:else} |
| 997 | + Select address... |
| 998 | + {/if} |
| 999 | + </option> |
| 1000 | + <option value="__MANUAL__">Input address manually</option> |
| 1001 | + {#each controlAddresses as addr} |
| 1002 | + <option value={addr}>{addr}{addr.startsWith('z') ? ' (Private)' : ' (Transparent)'}</option> |
| 1003 | + {/each} |
| 1004 | + </select> |
| 1005 | + {:else} |
| 1006 | + <div class="flex-1"> |
| 1007 | + <input |
| 1008 | + type="text" |
| 1009 | + bind:value={formData.primaryAddresses[index]} |
| 1010 | + required |
| 1011 | + placeholder="Enter primary address (R-address)" |
| 1012 | + class="w-full p-3 border border-verusidx-mountain-mist dark:border-verusidx-stone-medium rounded-lg bg-white dark:bg-verusidx-stone-dark text-verusidx-stone-dark dark:text-white" |
| 1013 | + /> |
| 1014 | + <button |
| 1015 | + type="button" |
| 1016 | + onclick={switchToDropdown} |
| 1017 | + class="mt-1 text-xs text-verusidx-turquoise-deep hover:text-verusidx-turquoise-bright" |
| 1018 | + > |
| 1019 | + ← Use address dropdown |
| 1020 | + </button> |
| 1021 | + </div> |
| 1022 | + {/if} |
983 | 1023 | {:else} |
984 | 1024 | <!-- Additional addresses: manual text input --> |
985 | 1025 | <input |
|
1093 | 1133 | <label class="block text-sm font-medium text-verusidx-stone-dark dark:text-white mb-2"> |
1094 | 1134 | Source of Funds (Optional) |
1095 | 1135 | </label> |
1096 | | - <select |
| 1136 | + <select |
1097 | 1137 | bind:value={formData.sourceOfFunds} |
1098 | 1138 | disabled={isLoadingSourceAddresses} |
1099 | 1139 | class="w-full p-3 border border-verusidx-mountain-mist dark:border-verusidx-stone-medium rounded-lg bg-white dark:bg-verusidx-stone-dark text-verusidx-stone-dark dark:text-white disabled:opacity-50" |
1100 | 1140 | > |
1101 | 1141 | <option value=""> |
1102 | 1142 | {#if isLoadingSourceAddresses} |
1103 | 1143 | Loading source addresses... |
1104 | | - {:else if hasLoadedSourceAddresses && sourceAddresses.length === 0} |
1105 | | - Default (transparent wildcard "*") - No addresses found |
1106 | | - {:else if !hasLoadedSourceAddresses} |
1107 | | - Default (transparent wildcard "*") - Failed to load |
1108 | 1144 | {:else} |
1109 | | - Default (transparent wildcard "*") |
| 1145 | + Select address |
1110 | 1146 | {/if} |
1111 | 1147 | </option> |
1112 | 1148 | {#each sourceAddresses as address} |
|
1115 | 1151 | </option> |
1116 | 1152 | {/each} |
1117 | 1153 | </select> |
1118 | | - <p class="text-xs text-verusidx-mountain-grey dark:text-verusidx-mountain-mist mt-1"> |
1119 | | - Address to source funds for registration fees. Leave empty to use transparent wildcard "*" |
1120 | | - </p> |
1121 | 1154 | </div> |
1122 | 1155 |
|
1123 | 1156 |
|
|
0 commit comments