Skip to content

Commit

Permalink
Merge branch 'lebihae/1190' into 'main'
Browse files Browse the repository at this point in the history
fix(signup): force opening major picker before anything else (closes #1190)

Closes #1190

See merge request churros/churros!282
  • Loading branch information
LeGmask committed Nov 19, 2024
2 parents ab7a9a9 + 0453154 commit d6a5120
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 47 deletions.
5 changes: 5 additions & 0 deletions .changeset/quick-buses-kneel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@churros/app': patch
---

don't trigger form submissions when picking an option in a modal picker
5 changes: 5 additions & 0 deletions .changeset/quiet-pans-train.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@churros/app': minor
---

fix(signup): force opening major picker before anything else (closes #1190)
11 changes: 10 additions & 1 deletion packages/app/src/lib/components/InputMajor.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
import LoadingText from '$lib/components/LoadingText.svelte';
import PickMajor from '$lib/components/PickMajor.svelte';
import { loading, type MaybeLoading } from '$lib/loading';
import { createEventDispatcher } from 'svelte';
import IconChevronRight from '~icons/msl/chevron-right';
const dispatch = createEventDispatcher<{ open: undefined }>();
/** Selected major uid */
export let major: string;
Expand Down Expand Up @@ -96,14 +99,20 @@
<slot name="clear-button">
<ButtonSecondary
on:click={() => {
dispatch('open');
major = '';
}}
>
<LoadingText value={clearLabel} />
</ButtonSecondary>
</slot>
{/if}
<ButtonSecondary on:click={open}>
<ButtonSecondary
on:click={() => {
open?.();
dispatch('open');
}}
>
{#if major || clearable}Changer{:else}Choisir{/if}
</ButtonSecondary>
</PickMajor>
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/lib/components/PickThings.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
{/if}
<li>
<button
type="button"
class:selected
on:click={() => {
if (!loaded(option.uid)) return;
Expand Down
116 changes: 70 additions & 46 deletions packages/app/src/routes/signup/FormSignup.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
$: selectedMajor = args.major ? $Data.majors.find((m) => m.uid === args.major) : null;
let majorWasChosen = false;
let loading = false;
let success = false;
</script>
Expand Down Expand Up @@ -172,61 +173,73 @@
>
<div class="curriculum">
<div class="major">
{#if !majorWasChosen}
<p class="major-first-title">Premièrement, à quelle école appartient-tu?</p>
{/if}
<InputMajor
on:open={() => {
setTimeout(() => {
majorWasChosen = true;
}, 200);
}}
clearable={!$dataQuickSignup}
clearLabel="Externe"
options={$Data}
bind:major={args.major}
initialSchool={$dataQuickSignup?.school ?? null}
/>
</div>
<div class="promotion">
<InputRadios
bind:value={args.graduationYear}
options={[
[fromYearTier(1), '1re année'],
[fromYearTier(2), '2e année'],
[fromYearTier(3), '3e année'],
]}
/>
</div>
<div class="apprenticeship">
<InputRadios
value={args.apprentice ? 1 : 0}
on:change={({ detail }) => {
args.apprentice = Boolean(detail);
}}
options={[
[0, 'FISE (Étudiant.e.s)'],
[1, 'FISA (Apprenti.e.s)'],
]}
/>
</div>
{#if majorWasChosen}
<div class="promotion">
<InputRadios
bind:value={args.graduationYear}
options={[
[fromYearTier(1), '1re année'],
[fromYearTier(2), '2e année'],
[fromYearTier(3), '3e année'],
]}
/>
</div>
<div class="apprenticeship">
<InputRadios
value={args.apprentice ? 1 : 0}
on:change={({ detail }) => {
args.apprentice = Boolean(detail);
}}
options={[
[0, 'FISE (Étudiant.e.s)'],
[1, 'FISA (Apprenti.e.s)'],
]}
/>
</div>
{/if}
</div>
<InputStudentEmail
major={selectedMajor ?? null}
usingQuickSignupCode={$dataQuickSignup !== null}
label="Ton email"
bind:value={args.email}
/>
<div class="side-by-side">
<InputText bind:value={args.firstName} required label="Prénom" />
<InputText bind:value={args.lastName} required label="Nom de famille" />
</div>
<InputPassword label="Un mot de passe" bind:value={args.password} />
<InputPassword
hint=""
label="Le même mot de passe"
bind:value={args.passwordConfirmation}
errors={args.password &&
args.passwordConfirmation &&
args.password !== args.passwordConfirmation
? ['Les mot de passes ne correspondent pas']
: []}
/>
<section class="submit">
<ButtonPrimary submits>M'inscrire</ButtonPrimary>
</section>
{#if majorWasChosen}
<InputStudentEmail
major={selectedMajor ?? null}
usingQuickSignupCode={$dataQuickSignup !== null}
label="Ton email"
bind:value={args.email}
/>
<div class="side-by-side">
<InputText bind:value={args.firstName} required label="Prénom" />
<InputText bind:value={args.lastName} required label="Nom de famille" />
</div>
<InputPassword label="Un mot de passe" bind:value={args.password} />
<InputPassword
hint=""
label="Le même mot de passe"
bind:value={args.passwordConfirmation}
errors={args.password &&
args.passwordConfirmation &&
args.password !== args.passwordConfirmation
? ['Les mot de passes ne correspondent pas']
: []}
/>
<section class="submit">
<ButtonPrimary submits>M'inscrire</ButtonPrimary>
</section>
{/if}
</form>
{/if}

Expand Down Expand Up @@ -277,6 +290,13 @@
align-items: center;
}
.major-first-title {
margin: 0 1rem 1rem;
font-weight: bold;
color: var(--primary);
text-align: center;
}
.major {
margin-bottom: 2rem;
}
Expand All @@ -296,6 +316,10 @@
max-height: 25vh;
}
header p {
text-align: center;
}
.check {
font-size: 5rem;
color: var(--primary);
Expand Down

0 comments on commit d6a5120

Please sign in to comment.