-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
78 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { ClasseModel, EtablissementModel, LigneBusModel, SessionPhase1Model } from "../models"; | ||
|
||
function formatLabel(data, key: string) { | ||
return data.reduce((acc, cur) => { | ||
acc[cur._id] = cur[key]; | ||
return acc; | ||
}, {}); | ||
} | ||
|
||
export async function getBus() { | ||
const data = await LigneBusModel.find({}, { busId: 1 }); | ||
return formatLabel(data, "busId"); | ||
} | ||
|
||
export async function getClasses() { | ||
// Pourquoi ça renvoit les patches ça ? | ||
const data = await ClasseModel.find({}, { uniqueKeyAndId: 1 }); | ||
return formatLabel(data, "uniqueKeyAndId"); | ||
} | ||
|
||
export async function getEtablissements() { | ||
const data = await EtablissementModel.find({}, { name: 1 }); | ||
return formatLabel(data, "name"); | ||
} | ||
|
||
export async function getSessions() { | ||
const data = await SessionPhase1Model.find({}, { codeCentre: 1 }); | ||
return formatLabel(data, "codeCentre"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { getBus, getClasses, getEtablissements, getSessions } from "./filterLabelRepository"; | ||
|
||
export const listTypes = { INSCRIPTION: "inscription", VOLONTAIRES: "volontaires" }; | ||
|
||
export async function getLabelVolontaires() { | ||
const sessions = await getSessions(); | ||
const bus = await getBus(); | ||
const classes = await getClasses(); | ||
const etablissements = await getEtablissements(); | ||
return { sessions, bus, classes, etablissements }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export type FilterLabelDto = Record<string, string>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { FilterLabelDto } from "src/dto/filterLabelDto"; | ||
import { BasicRoute, RouteResponseBody } from ".."; | ||
|
||
interface GetFilterLabelRoute extends BasicRoute { | ||
method: "GET"; | ||
path: "/filter-label/{listType}"; | ||
params: { listType: string }; | ||
response: RouteResponseBody<FilterLabelDto>; | ||
} | ||
|
||
export type FilterLabelRoutes = { | ||
Get: GetFilterLabelRoute; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters