Skip to content

Commit 3324305

Browse files
committed
feat: make country selection a dropdown
fix: the loading animation reset components after a form submission, excluded loads caused by forms
1 parent 1be453b commit 3324305

File tree

4 files changed

+28
-11
lines changed

4 files changed

+28
-11
lines changed

frontend/package-lock.json

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
},
2929
"dependencies": {
3030
"@hey-api/client-fetch": "^0.5.7",
31+
"countries-list": "^3.1.1",
3132
"svelte-sonner": "^0.3.28",
3233
"theme-change": "^2.5.0"
3334
}

frontend/src/routes/+layout.svelte

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@
3838
</div>
3939
</nav>
4040

41-
42-
{#if navigating.to}
41+
{#if navigating.to && navigating.type != "form"}
4342
<div class="flex items-center justify-center min-h-screen flex-col">
4443
<span class="loading loading-ball loading-lg mb-2"></span>
4544
{returnLoadingText()}
@@ -48,7 +47,6 @@
4847
{@render children()}
4948
{/if}
5049

51-
5250
<div class="fixed bottom-4 left-4">
5351
<!-- Info Button -->
5452
<button

frontend/src/routes/login/+page.svelte

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88
import type { HTTPValidationError } from "$lib/client/types.gen";
99
import { handleError } from "$lib/misc";
1010
import type { UserSignupPayload } from "$lib/client/types.gen";
11+
import { countries, } from 'countries-list'
1112
// rest is the extra props passed to the component
1213
let { ...rest } = $props();
1314
1415
let isLoading = $state(false);
1516
let showSignupFields = $state(false);
17+
$inspect(showSignupFields);
1618
let expandedDueTo = "";
1719
let userInfo: UserSignupPayload = $state({
1820
email: "",
@@ -27,9 +29,14 @@
2729
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date
2830
dob: "",
2931
});
30-
3132
let redirectUrl: string;
3233
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+
3340
async function eitherLoginOrSignUp() {
3441
// 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.
3542
if (!showSignupFields) {
@@ -314,20 +321,24 @@
314321
<label class="form-control">
315322
<div class="label">
316323
<span class="label-text">Country</span>
317-
<span class="label-text-alt">
324+
<!-- <span class="label-text-alt">
318325
<a
319326
href="https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2"
320327
class="underline">ISO 3166-1 alpha-2</a
321328
>
322-
</span>
329+
</span> -->
323330
</div>
324-
<input
331+
<select
325332
id="country"
326-
type="text"
327-
class="input input-bordered grow"
328-
placeholder="US"
333+
class="select select-bordered grow"
329334
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>
331342
</label>
332343
<label class="form-control">
333344
<div class="label">

0 commit comments

Comments
 (0)