feat: club filter
This commit is contained in:
parent
f297ae557b
commit
edcda185db
@ -277,15 +277,13 @@ public class AffiliationService {
|
||||
}
|
||||
|
||||
public Uni<List<SimpleAffiliation>> getCurrentSaisonAffiliation() {
|
||||
return repository.list("saison = ?1", Utils.getSaison())
|
||||
.map(models -> models.stream().map(SimpleAffiliation::fromModel).toList())
|
||||
.chain(aff -> repositoryRequest.list("saison = ?1", Utils.getSaison())
|
||||
.chain(models -> Uni.join().all(models.stream().map(model ->
|
||||
clubRepository.find("SIRET = ?1", model.getSiret()).firstResult()
|
||||
.map(c -> new SimpleAffiliation(model.getId() * -1, c.getId(),
|
||||
model.getSaison(), false)))
|
||||
.toList()).andFailFast()
|
||||
).map(aff2 -> Stream.concat(aff2.stream(), aff.stream()).toList())
|
||||
return repositoryRequest.list("saison = ?1 or saison = ?1 + 1", Utils.getSaison())
|
||||
.map(models -> models.stream()
|
||||
.map(model -> new SimpleAffiliation(model.getId() * -1, model.getSiret(), model.getSaison(),
|
||||
false)).toList())
|
||||
.chain(aff -> repository.list("saison = ?1", Utils.getSaison())
|
||||
.map(models -> models.stream().map(SimpleAffiliation::fromModel).toList())
|
||||
.map(aff2 -> Stream.concat(aff2.stream(), aff.stream()).toList())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -8,6 +8,7 @@ import fr.titionfire.ffsaf.data.repository.CombRepository;
|
||||
import fr.titionfire.ffsaf.net2.ServerCustom;
|
||||
import fr.titionfire.ffsaf.net2.data.SimpleClubModel;
|
||||
import fr.titionfire.ffsaf.net2.request.SReqClub;
|
||||
import fr.titionfire.ffsaf.rest.data.SimpleClubList;
|
||||
import fr.titionfire.ffsaf.rest.from.FullClubForm;
|
||||
import fr.titionfire.ffsaf.utils.Contact;
|
||||
import fr.titionfire.ffsaf.utils.PageResult;
|
||||
@ -74,7 +75,7 @@ public class ClubService {
|
||||
});
|
||||
}
|
||||
|
||||
public Uni<PageResult<SimpleClubModel>> search(Integer limit, int page, String search, String country) {
|
||||
public Uni<PageResult<SimpleClubList>> search(Integer limit, int page, String search, String country) {
|
||||
if (search == null)
|
||||
search = "";
|
||||
search = search + "%";
|
||||
@ -90,8 +91,8 @@ public class ClubService {
|
||||
return getPageResult(query, limit, page);
|
||||
}
|
||||
|
||||
private Uni<PageResult<SimpleClubModel>> getPageResult(PanacheQuery<ClubModel> query, int limit, int page) {
|
||||
return Uni.createFrom().item(new PageResult<SimpleClubModel>())
|
||||
private Uni<PageResult<SimpleClubList>> getPageResult(PanacheQuery<ClubModel> query, int limit, int page) {
|
||||
return Uni.createFrom().item(new PageResult<SimpleClubList>())
|
||||
.invoke(result -> result.setPage(page))
|
||||
.invoke(result -> result.setPage_size(limit))
|
||||
.call(result -> query.count().invoke(result::setResult_count))
|
||||
@ -101,7 +102,7 @@ public class ClubService {
|
||||
}))
|
||||
.invoke(result::setPage_count))
|
||||
.call(result -> query.page(Page.of(page, limit)).list()
|
||||
.map(membreModels -> membreModels.stream().map(SimpleClubModel::fromModel).toList())
|
||||
.map(membreModels -> membreModels.stream().map(SimpleClubList::fromModel).toList())
|
||||
.invoke(result::setResult));
|
||||
}
|
||||
|
||||
|
||||
@ -17,13 +17,12 @@ public class SimpleClubModel {
|
||||
String name;
|
||||
String country;
|
||||
String shieldURL;
|
||||
Long no_affiliation;
|
||||
|
||||
public static SimpleClubModel fromModel(ClubModel model) {
|
||||
if (model == null)
|
||||
return null;
|
||||
|
||||
return new SimpleClubModel(model.getId(), model.getName(), model.getCountry(),
|
||||
"/api/club/" + model.getClubId() + "/logo", model.getNo_affiliation());
|
||||
"/api/club/" + model.getClubId() + "/logo");
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import fr.titionfire.ffsaf.data.model.ClubModel;
|
||||
import fr.titionfire.ffsaf.domain.service.ClubService;
|
||||
import fr.titionfire.ffsaf.net2.data.SimpleClubModel;
|
||||
import fr.titionfire.ffsaf.rest.data.SimpleClub;
|
||||
import fr.titionfire.ffsaf.rest.data.SimpleClubList;
|
||||
import fr.titionfire.ffsaf.rest.from.FullClubForm;
|
||||
import fr.titionfire.ffsaf.utils.Contact;
|
||||
import fr.titionfire.ffsaf.utils.GroupeUtils;
|
||||
@ -60,10 +61,10 @@ public class ClubEndpoints {
|
||||
@Path("/find")
|
||||
@RolesAllowed({"federation_admin"})
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Uni<PageResult<SimpleClubModel>> getFindAdmin(@QueryParam("limit") Integer limit,
|
||||
@QueryParam("page") Integer page,
|
||||
@QueryParam("search") String search,
|
||||
@QueryParam("country") String country) {
|
||||
public Uni<PageResult<SimpleClubList>> getFindAdmin(@QueryParam("limit") Integer limit,
|
||||
@QueryParam("page") Integer page,
|
||||
@QueryParam("search") String search,
|
||||
@QueryParam("country") String country) {
|
||||
if (limit == null)
|
||||
limit = 50;
|
||||
if (page == null || page < 1)
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
package fr.titionfire.ffsaf.rest.data;
|
||||
|
||||
import fr.titionfire.ffsaf.data.model.ClubModel;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@RegisterForReflection
|
||||
public class SimpleClubList {
|
||||
Long id;
|
||||
String name;
|
||||
String country;
|
||||
Long siret;
|
||||
Long no_affiliation;
|
||||
|
||||
public static SimpleClubList fromModel(ClubModel model) {
|
||||
if (model == null)
|
||||
return null;
|
||||
|
||||
return new SimpleClubList(model.getId(), model.getName(), model.getCountry(), model.getSIRET(),
|
||||
model.getNo_affiliation());
|
||||
}
|
||||
}
|
||||
@ -38,9 +38,9 @@ export function ClubList() {
|
||||
id: e.id,
|
||||
name: e.name,
|
||||
country: e.country,
|
||||
shieldURL: e.shieldURL,
|
||||
siret: e.siret,
|
||||
no_affiliation: e.no_affiliation,
|
||||
affiliation: showAffiliationState ? affiliationData.find(licence => licence.club === e.id) : null
|
||||
affiliation: showAffiliationState ? affiliationData.find(aff => (aff.id >= 0) ? aff.club === e.id : aff.club === e.siret) : null
|
||||
})
|
||||
}
|
||||
setClubData(data2);
|
||||
@ -76,7 +76,7 @@ export function ClubList() {
|
||||
<div className="col-lg-9">
|
||||
<SearchBar search={search}/>
|
||||
{data
|
||||
? <MakeCentralPanel data={data} visibleclub={clubData} navigate={navigate} showLicenceState={showAffiliationState}
|
||||
? <MakeCentralPanel data={data} visibleclub={clubData} navigate={navigate} showAffiliationState={showAffiliationState}
|
||||
page={page}/>
|
||||
: error
|
||||
? <AxiosError error={error}/>
|
||||
@ -91,7 +91,7 @@ export function ClubList() {
|
||||
<div className="card mb-4">
|
||||
<div className="card-header">Filtre</div>
|
||||
<div className="card-body">
|
||||
<FiltreBar showAffiliationState={showAffiliationState} setShowLAffiliationState={setShowAffiliationState} data={data}
|
||||
<FiltreBar showAffiliationState={showAffiliationState} setShowAffiliationState={setShowAffiliationState} data={data}
|
||||
countryFilter={countryFilter} setCountryFilter={setCountryFilter}/>
|
||||
</div>
|
||||
</div>
|
||||
@ -161,13 +161,14 @@ function FiltreBar({showAffiliationState, setShowAffiliationState, data, country
|
||||
useEffect(() => {
|
||||
if (!data)
|
||||
return;
|
||||
allCountry.push(...data.result.map((e) => e.club?.name))
|
||||
allCountry.push(...data.result.map((e) => e.country))
|
||||
allCountry = allCountry.filter((value, index, self) => self.indexOf(value) === index).filter(value => value != null).sort()
|
||||
}, [data]);
|
||||
|
||||
return <div>
|
||||
<div className="mb-3">
|
||||
<Checkbox value={showAffiliationState} onChange={setShowAffiliationState} label="Afficher l'état des affiliation"/>
|
||||
<Checkbox value={showAffiliationState} onChange={setShowAffiliationState}
|
||||
label="Afficher l'état des affiliation"/>
|
||||
</div>
|
||||
<div className="mb-3">
|
||||
<select className="form-select" value={countryFilter} onChange={event => setCountryFilter(event.target.value)}>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user