|
8 | 8 | import type { HTTPValidationError } from "$lib/client/types.gen"; |
9 | 9 | import { handleError } from "$lib/misc"; |
10 | 10 | import type { UserSignupPayload } from "$lib/client/types.gen"; |
| 11 | + import { countries, } from 'countries-list' |
11 | 12 | // rest is the extra props passed to the component |
12 | 13 | let { ...rest } = $props(); |
13 | 14 |
|
14 | 15 | let isLoading = $state(false); |
15 | 16 | let showSignupFields = $state(false); |
| 17 | + $inspect(showSignupFields); |
16 | 18 | let expandedDueTo = ""; |
17 | 19 | let userInfo: UserSignupPayload = $state({ |
18 | 20 | email: "", |
|
27 | 29 | // https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date |
28 | 30 | dob: "", |
29 | 31 | }); |
30 | | -
|
31 | 32 | let redirectUrl: string; |
32 | 33 |
|
| 34 | + // Convert countries to a list of objects with name and code |
| 35 | + const countryList = Object.entries(countries).map(([code, data]) => ({ |
| 36 | + code, |
| 37 | + name: data.name, |
| 38 | + })).sort((a, b) => a.name.localeCompare(b.name)); |
| 39 | +
|
33 | 40 | async function eitherLoginOrSignUp() { |
34 | 41 | // If showSignupFields is true, the user is signing up and signupAndLogin should be called. Otherwise, the user is logging in and login should be called. |
35 | 42 | if (!showSignupFields) { |
|
314 | 321 | <label class="form-control"> |
315 | 322 | <div class="label"> |
316 | 323 | <span class="label-text">Country</span> |
317 | | - <span class="label-text-alt"> |
| 324 | + <!-- <span class="label-text-alt"> |
318 | 325 | <a |
319 | 326 | href="https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2" |
320 | 327 | class="underline">ISO 3166-1 alpha-2</a |
321 | 328 | > |
322 | | - </span> |
| 329 | + </span> --> |
323 | 330 | </div> |
324 | | - <input |
| 331 | + <select |
325 | 332 | id="country" |
326 | | - type="text" |
327 | | - class="input input-bordered grow" |
328 | | - placeholder="US" |
| 333 | + class="select select-bordered grow" |
329 | 334 | bind:value={userInfo.country} |
330 | | - /> |
| 335 | + > |
| 336 | + {#each countryList as { code, name } (code)} |
| 337 | + <option value={code} selected={userInfo.country == code}> |
| 338 | + {name} |
| 339 | + </option> |
| 340 | + {/each} |
| 341 | + </select> |
331 | 342 | </label> |
332 | 343 | <label class="form-control"> |
333 | 344 | <div class="label"> |
|
0 commit comments