Créneaux types : paramétrage + génération auto des créneaux
Le paramétrage des créneaux se fait dans « Règles & édition » : la coordination
définit des créneaux types (DayPart). À la création d'un poste, un créneau à
besoin 0/0 est généré pour chaque jour de l'édition et chaque créneau type ;
les coordinateurs ajustent ensuite min/idéal.
Back-end :
- DayPart CRUD (GET/POST/PATCH/DELETE /editions/{id}/day-parts). Code figé
après création (slugifié depuis le libellé si absent), unique par édition.
- Shift.day_part_id (nullable, SET NULL) + migration 0004.
- create_position génère les créneaux ; POST .../positions/{pid}/generate-shifts
recrée les manquants (idempotent, ne touche pas aux besoins déjà réglés).
- 13 tests (day-parts, génération, extension d'édition, ajout de type).
Front-end :
- api/hooks/mock : dayParts CRUD + positions.generateShifts.
- ConfigRules : panneau « Créneaux types » (libellé + horaires éditables,
ajout, suppression).
- ConfigGrid : bouton « Générer les créneaux » sur l'en-tête du poste.
- GrillePage : case « à définir » (gris, glyphe ·) quand min=idéal=0, avec
entrée de légende.
155 tests back OK ; typecheck + lint + build + smoke front OK.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017uUsRg7XzopkCPWimwg9ZM
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
cee581b832
commit
f58ec00e30
@@ -10,6 +10,8 @@ import type {
|
||||
AssignmentCreate,
|
||||
AssignmentUpdate,
|
||||
AssignmentValidateResult,
|
||||
DayPartCreate,
|
||||
DayPartUpdate,
|
||||
EditionUpdate,
|
||||
PlanningNotificationRequest,
|
||||
PositionCreate,
|
||||
@@ -41,6 +43,10 @@ export function useEdition() {
|
||||
return useQuery({ queryKey: queryKeys.edition, queryFn: () => api.editions.get(edition) });
|
||||
}
|
||||
|
||||
export function useDayParts() {
|
||||
return useQuery({ queryKey: ['dayParts', edition], queryFn: () => api.dayParts.list(edition) });
|
||||
}
|
||||
|
||||
export function useVolunteers(options?: { enabled?: boolean }) {
|
||||
return useQuery({
|
||||
queryKey: queryKeys.volunteers,
|
||||
@@ -122,6 +128,47 @@ export function useUpdateEdition() {
|
||||
});
|
||||
}
|
||||
|
||||
export function useCreateDayPart() {
|
||||
const client = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: (body: DayPartCreate) => api.dayParts.create(edition, body),
|
||||
onSuccess: () => client.invalidateQueries({ queryKey: ['dayParts', edition] }),
|
||||
});
|
||||
}
|
||||
|
||||
export function useUpdateDayPart() {
|
||||
const client = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: ({ id, body }: { id: string; body: DayPartUpdate }) =>
|
||||
api.dayParts.update(edition, id, body),
|
||||
onSuccess: () => client.invalidateQueries({ queryKey: ['dayParts', edition] }),
|
||||
});
|
||||
}
|
||||
|
||||
export function useDeleteDayPart() {
|
||||
const client = useQueryClient();
|
||||
const invalidate = useInvalidate();
|
||||
return useMutation({
|
||||
mutationFn: (id: string) => api.dayParts.remove(edition, id),
|
||||
onSuccess: () => {
|
||||
client.invalidateQueries({ queryKey: ['dayParts', edition] });
|
||||
invalidate.shifts();
|
||||
invalidate.planning();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useGenerateShifts() {
|
||||
const invalidate = useInvalidate();
|
||||
return useMutation({
|
||||
mutationFn: (positionId: string) => api.positions.generateShifts(edition, positionId),
|
||||
onSuccess: () => {
|
||||
invalidate.shifts();
|
||||
invalidate.planning();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useCreateVolunteer() {
|
||||
const invalidate = useInvalidate();
|
||||
return useMutation({
|
||||
@@ -156,6 +203,7 @@ export function useCreatePosition() {
|
||||
mutationFn: (body: PositionCreate) => api.positions.create(edition, body),
|
||||
onSuccess: () => {
|
||||
invalidate.positions();
|
||||
invalidate.shifts();
|
||||
invalidate.planning();
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user