Skip to content

Commit

Permalink
[Adhesion] fix committee choice step
Browse files Browse the repository at this point in the history
  • Loading branch information
ottaviano committed Jan 24, 2025
1 parent d949fa5 commit 6e02ca5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
6 changes: 4 additions & 2 deletions assets/pages/adhesion_committee/components/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* @param {{
* committees: Array,
* defaultCommittee: string,
* defaultCommittee: Object,
* }} props
* @returns {AlpineComponent}
*/
Expand All @@ -19,7 +19,9 @@ const Form = (props) => ({
},

init() {
this.setSelectCommittee(props.defaultCommittee);
this.selectedCommittee = props.defaultCommittee;
this.committees = props.committees.filter((x) => x.uuid !== props.defaultCommittee.uuid);
this.isOpen = false;
},

/**
Expand Down
4 changes: 3 additions & 1 deletion src/Controller/Renaissance/Adhesion/CommitteeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ public function __invoke(Request $request): Response

$committees = $this->committeeRepository->findInAdherentZone($adherent);

if (!$defaultCommittee = $this->committeeManager->findCommitteeByAddress($adherent->getPostAddress())) {
if ($defaultCommittee = $this->committeeManager->findCommitteeByAddress($adherent->getPostAddress())) {
$committees = array_unique(array_merge($committees, [$defaultCommittee]));
} else {
$defaultCommittee = $committees[0] ?? null;
}

Expand Down
6 changes: 3 additions & 3 deletions templates/renaissance/adhesion/committee.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{% block content %}
<twig:ReStandaloneLayout class="bg-gradient-to-b from-slate-600 to-slate-500" x-data="xCommitteeForm({
committees: {{ committees|map(committee => {name: committee.name, uuid: committee.uuid, location: committee.getInlineFormattedAddress(), animator: committee.animator ? committee.animator.getFullName() : ''})|json_encode|e('html_attr') }},
defaultCommittee: '{{ default_committee.uuid }}',
defaultCommittee: {{ {name: default_committee.name, uuid: default_committee.uuid, location: default_committee.getInlineFormattedAddress(), animator: default_committee.animator ? default_committee.animator.getFullName() : ''}|json_encode|e('html_attr') }},
})">
<twig:Atoms:ReCard class="max-w-[500px] w-full flex-1 flex">
{{ include('renaissance/partials/flashes.html.twig', {slim: true}) }}
Expand Down Expand Up @@ -40,12 +40,12 @@
</p>
</div>
<ul x-show="isOpen" class="border-ui_gray-30 border border-b-0 overflow-hidden rounded-md">
<template x-for="committee in committees">
<template x-for="committee in committees" :key="committee.uuid">
<li class="text-ui_gray-80 flex gap-6 flex-col border-b border-inherit bg-white p-6 cursor-pointer transition-colors hover:bg-ui_blue-5"
@click="handleCommitteeClick(committee.uuid)">
<ul>
<li>Comité : <span class="font-medium" x-text="committee.name"></span></li>
<li>Responsable : <span class="font-medium" x-text="committee.animator"></span></li>
<li x-show="committee.animator">Responsable : <span class="font-medium" x-text="committee.animator"></span></li>
<li class="flex-row items-center flex text-ui_gray-60" x-show="committee.location">
<twig:ReIcon name="location" class="mr-1" />
<span x-text="committee.location"></span>
Expand Down

0 comments on commit 6e02ca5

Please sign in to comment.