Vue bénévole mobile : responsable, téléphone et repère « maintenant »
La vue bénévole reprenait les infos essentielles (poste, jour, horaire,
lieu) mais affichait un badge de validation factice (« TU ES ATTENDU
SUR CE CRÉNEAU ») sans plus-value, sans jamais donner le nom ni le
téléphone du référent du poste à contacter — pourtant déjà modélisés
(`Position.lead_account_id`) depuis la gestion des référents.
Un compte VOLUNTEER n'a pas accès à `positions`/`shifts` (403, cf. § 2
matrice des accès) : ces infos ne pouvaient donc pas être jointes côté
front à partir des listes existantes. Nouvel endpoint dédié et
minimal, réservé à la lecture du planning propre du bénévole :
GET /editions/{id}/volunteers/{vid}/planning
Renvoie, par affectation : poste, lieu, et référent (nom + téléphone,
`null` si le poste n'a pas de référent ou si son compte n'est pas
rattaché à une fiche bénévole) — sans exposer la liste complète des
postes/créneaux de l'édition. Tests : accès (soi-même / autre
bénévole 403 / COORD+LEAD), présence/absence du référent, tri par
heure de début.
Front : retrait du badge de validation, ajout des lignes responsable/
téléphone par créneau, et un repère horizontal « MAINTENANT » qui se
positionne dans la liste triée des créneaux selon l'heure réelle (juste
avant le prochain créneau à venir) pour situer le bénévole dans son
planning.
Non inclus dans ce commit (édités en parallèle par l'utilisateur,
laissés en l'état) : backend/app/seed.py, frontend/tailwind.config.js.
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
8fcc22115f
commit
a78aad58e2
@@ -83,6 +83,15 @@ export function useVolunteer(id: string | null | undefined) {
|
||||
});
|
||||
}
|
||||
|
||||
/** Planning enrichi (poste, lieu, référent) d'un bénévole — écran bénévole. */
|
||||
export function useVolunteerPlanning(volunteerId: string | null | undefined) {
|
||||
return useQuery({
|
||||
queryKey: ['volunteer-planning', edition, volunteerId ?? null],
|
||||
queryFn: () => api.volunteers.planning(edition, volunteerId as string),
|
||||
enabled: Boolean(volunteerId),
|
||||
});
|
||||
}
|
||||
|
||||
export function useShifts(positionId?: string) {
|
||||
return useQuery({
|
||||
queryKey: queryKeys.shifts(positionId),
|
||||
|
||||
@@ -110,6 +110,8 @@ export function createHttpApi(baseUrl: string): PlanningApi {
|
||||
request(`${base(editionId)}/volunteers/${id}`, { method: 'PATCH', body: JSON.stringify(body) }),
|
||||
remove: (editionId, id) =>
|
||||
request(`${base(editionId)}/volunteers/${id}`, { method: 'DELETE' }),
|
||||
planning: (editionId, id) =>
|
||||
request(`${base(editionId)}/volunteers/${id}/planning`),
|
||||
},
|
||||
accounts: {
|
||||
list: (editionId) => request(`${base(editionId)}/accounts`),
|
||||
|
||||
@@ -835,6 +835,33 @@ export function createMockApi(): PlanningApi {
|
||||
});
|
||||
return delay(undefined);
|
||||
},
|
||||
planning: (_edition, id) => {
|
||||
if (!state.volunteers.some((v) => v.id === id)) return notFound();
|
||||
const entries = state.assignments
|
||||
.filter((a) => a.volunteer_id === id)
|
||||
.map((a) => {
|
||||
const shift = state.shifts.find((s) => s.id === a.shift_id);
|
||||
const position = shift ? state.positions.find((p) => p.id === shift.position_id) : undefined;
|
||||
const referentAccount = position?.lead_account_id
|
||||
? state.accounts.find((acc) => acc.id === position.lead_account_id)
|
||||
: undefined;
|
||||
const referent = referentAccount?.volunteer_id
|
||||
? state.volunteers.find((v) => v.id === referentAccount.volunteer_id)
|
||||
: undefined;
|
||||
return {
|
||||
assignment_id: a.id,
|
||||
shift_id: a.shift_id,
|
||||
starts_at: shift?.starts_at ?? '',
|
||||
ends_at: shift?.ends_at ?? '',
|
||||
position_name: position?.name ?? '',
|
||||
position_location: position?.location ?? null,
|
||||
referent_name: referent ? `${referent.first_name} ${referent.last_name}` : null,
|
||||
referent_phone: referent?.phone ?? null,
|
||||
};
|
||||
})
|
||||
.sort((a, b) => a.starts_at.localeCompare(b.starts_at));
|
||||
return delay(entries);
|
||||
},
|
||||
},
|
||||
|
||||
accounts: {
|
||||
|
||||
@@ -135,6 +135,24 @@ export interface VolunteerUpdate {
|
||||
wished_companion_ids?: string[] | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Un créneau affecté, enrichi (poste, lieu, référent à contacter) — pour
|
||||
* l'écran bénévole. Évite de donner à un compte VOLUNTEER un accès en
|
||||
* lecture aux postes/créneaux de toute l'édition (réservé à COORD/LEAD).
|
||||
*/
|
||||
export interface VolunteerPlanningEntry {
|
||||
assignment_id: string;
|
||||
shift_id: string;
|
||||
starts_at: string;
|
||||
ends_at: string;
|
||||
position_name: string;
|
||||
position_location: string | null;
|
||||
/** null si le poste n'a pas de référent, ou si son compte n'est pas
|
||||
* rattaché à une fiche bénévole (pas de téléphone à donner alors). */
|
||||
referent_name: string | null;
|
||||
referent_phone: string | null;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------- //
|
||||
// Availability (disponibilités déclarées par le bénévole) //
|
||||
// --------------------------------------------------------------------------- //
|
||||
|
||||
@@ -38,6 +38,7 @@ import type {
|
||||
VerifyRequest,
|
||||
Violation,
|
||||
VolunteerCreate,
|
||||
VolunteerPlanningEntry,
|
||||
VolunteerRead,
|
||||
VolunteerUpdate,
|
||||
} from './schema';
|
||||
@@ -69,6 +70,8 @@ export interface PlanningApi {
|
||||
create(editionId: string, body: VolunteerCreate): Promise<VolunteerRead>;
|
||||
update(editionId: string, id: string, body: VolunteerUpdate): Promise<VolunteerRead>;
|
||||
remove(editionId: string, id: string): Promise<void>;
|
||||
/** Planning enrichi (poste, lieu, référent) — écran bénévole. */
|
||||
planning(editionId: string, id: string): Promise<VolunteerPlanningEntry[]>;
|
||||
};
|
||||
accounts: {
|
||||
/** Comptes de connexion (mot de passe ou lien magique) de l'édition. */
|
||||
|
||||
Reference in New Issue
Block a user