Skip to content

Commit

Permalink
feat: change default state for login form
Browse files Browse the repository at this point in the history
  • Loading branch information
Thibault Ballier committed Oct 16, 2023
1 parent 9837d18 commit 9d1b992
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions web-app/src/routes/GenerateUrl/LoginForm.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,45 @@
import { dataToRequestParam } from './dataToRequestParam';
import { fetchTeamsGet, fetchTeamsIsLoading, dataParams } from './store';
import Loader from './Loader.svelte';
let usernameTranslation = $t('generateUrl.form.username');
let passwordTranslation = $t('generateUrl.form.password');
let teamIdTranslation = $t('generateUrl.form.teamId');
let username = '';
let password = '';
let teamId = '';
let invalidUsername = null;
let invalidPassword = null;
function clicked() {
invalidUsername = username === '';
invalidPassword = password === '';
}
function listTeams() {
clickedOnce = true;
if (username !== '' && password !== '') fetchTeamsGet(username, password);
clicked();
}
function generateUrl() {
if (username !== '' && password !== '') {
const data = dataToRequestParam(username, password, teamId);
dataParams.set(data);
}
clicked();
}
function reset() {
username = '';
password = '';
teamId = '';
clickedOnce = true;
clicked();
}
let clickedOnce = false;
</script>

<article>
Expand Down Expand Up @@ -65,7 +72,7 @@
placeholder={usernameTranslation}
required
bind:value={username}
aria-invalid={clickedOnce && username === ''}
aria-invalid={invalidUsername}
/>
</label>
<label for="password">
Expand All @@ -77,7 +84,7 @@
placeholder={passwordTranslation}
required
bind:value={password}
aria-invalid={clickedOnce && password === ''}
aria-invalid={invalidPassword}
/>
</label>
<label for="teamId">
Expand Down

0 comments on commit 9d1b992

Please sign in to comment.