View Issue Details

IDProjectCategoryView StatusLast Update
0000131CAMAP/InterAMAP44CAMAPpublic2023-10-15 15:21
ReporterAmaury Assigned ToAmaury  
PrioritynormalSeveritymajorReproducibilitysometimes
Status closedResolutionfixed 
PlatformGandiVPSOSDebianOS Version11
Product Versionv1.0.3 
Fixed in Versionv1.0.4 
Summary0000131: Problème d'affichage du calendrier de permanences
Description

Le calendrier de permanence n'affiche pas toutes les dates.

Additional Information

Il semblerait que le bug apparaisse sur les cycles mensuels par exemple

TagsNo tags attached.

Relationships

related to 0000085 closedAmaury Bug d'affichage du calendrier de permanences 

Activities

Amaury

2023-10-10 23:16

administrator   ~0000185

Last edited: 2023-10-10 23:16

Modification dans \camap-ts\packages\front-core\src\modules\volunteersCalendar\VolunteersCalendar.module.tsx à partir de la ligne 138

La période utilisée pour définir aMonthBefore va de 2 mois en 2 mois, passage de 4 mois en 4 mois (variables aMonthLater & aMonthBefore)

Lignes 140, 141, 177, 186

  React.useEffect(() => {
    const now = new Date();
    const aMonthBefore = subMonths(now, 4);
    const aMonthLater = addMonths(now, 4);
    doGetVolunteerMultiDistribs(aMonthBefore, aMonthLater);
  }, [doGetVolunteerMultiDistribs]);

  const didGetNextDistributionIndexOnce = React.useRef(false);

  const nextDistributionIndex = React.useMemo(() => {
    if (didGetNextDistributionIndexOnce.current) return;
    if (!multiDistribs?.length) return 0;
    const now = new Date();
    const index = multiDistribs.findIndex((d) =>
      isAfter(new Date(d.distribStartDate), now),
    );
    didGetNextDistributionIndexOnce.current = true;
    return index !== -1 ? index : 0;
  }, [multiDistribs]);

  React.useEffect(() => {
    if (nextDistributionIndex === undefined) return;
    setFirstDistributionIndex(nextDistributionIndex);
    if (
      nextDistributionIndex + maxNbDistribToShow >=
      multiDistribs.length - 2
    ) {
      loadMoreMultiDistribsAfter();
    }
    if (nextDistributionIndex <= 2) {
      loadMoreMultiDistribsBefore();
    }
    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, [nextDistributionIndex]);

  const loadMoreMultiDistribsAfter = React.useCallback(() => {
    if (!multiDistribs?.length) return;
    const lastMultiDistrib = multiDistribs[multiDistribs.length - 1];
    const distribStartDate = new Date(lastMultiDistrib.distribStartDate);
    const aMonthLater = addMonths(distribStartDate, 4);
    setLastClickedButton('next');
    doGetVolunteerMultiDistribs(distribStartDate, aMonthLater);
  }, [doGetVolunteerMultiDistribs, multiDistribs]);

  const loadMoreMultiDistribsBefore = React.useCallback(() => {
    if (!multiDistribs?.length) return;
    const firstMultiDistrib = multiDistribs[0];
    const distribStartDate = new Date(firstMultiDistrib.distribStartDate);
    const aMonthBefore = subMonths(distribStartDate, 4);
    setLastClickedButton('previous');
    doGetVolunteerMultiDistribs(aMonthBefore, distribStartDate);
  }, [doGetVolunteerMultiDistribs, multiDistribs]);

Amaury

2023-10-15 15:21

administrator   ~0000196

v1.0.4

Issue History

Date Modified Username Field Change
2023-10-10 23:12 Amaury New Issue
2023-10-10 23:12 Amaury Status new => assigned
2023-10-10 23:12 Amaury Assigned To => Amaury
2023-10-10 23:16 Amaury Note Added: 0000185
2023-10-10 23:16 Amaury Note Edited: 0000185
2023-10-10 23:19 Amaury Relationship added related to 0000085
2023-10-10 23:19 Amaury Status assigned => resolved
2023-10-10 23:19 Amaury Resolution open => fixed
2023-10-13 17:18 Amaury Fixed in Version => v1.0.4
2023-10-15 15:21 Amaury Note Added: 0000196
2023-10-15 15:21 Amaury Status resolved => closed