Skip to content

Commit

Permalink
refactor: UX and issue in cache key (#1278)
Browse files Browse the repository at this point in the history
* refactor: UX and issue in cache key

* fix: justificatifs anchors
  • Loading branch information
XavierJp authored Oct 16, 2024
1 parent bbda80a commit 9257785
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const AvisSituationNonDiffusible = () => (

const AvisSituationSection: React.FC<IProps> = ({ uniteLegale, session }) => (
<Section
id="insee"
id="justificatifs-insee"
title="Justificatif d’inscription à l’Insee"
sources={[EAdministration.INSEE]}
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use client';

import React from 'react';
import AssociationCreationNotFoundAlert from '#components-ui/alerts-with-explanations/association-creation-not-found-alert';
import ButtonLink from '#components-ui/button';
import { Icon } from '#components-ui/icon/wrapper';
Expand All @@ -10,6 +9,7 @@ import { EAdministration } from '#models/administrations/EAdministration';
import { IAssociation } from '#models/core/types';
import { formatDate, formatIntFr } from '#utils/helpers';
import { useFetchJOAFE } from 'hooks';
import React from 'react';
import { TwoColumnTable } from '../../../../../../components/table/simple';

type IProps = {
Expand All @@ -23,7 +23,7 @@ export const JustificatifImmatriculationJOAFE: React.FC<IProps> = ({

return (
<AsyncDataSectionClient
id="joafe"
id="justificatifs"
title="Enregistrement au JOAFE"
sources={[EAdministration.DILA]}
data={annoncesJOAFE}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const JustificatifImmatriculationRNE = ({
}) => (
<Section
title="Justificatif d’immatriculation au RNE"
id="justificatif-immatriculation-rne"
id="justificatifs"
sources={[EAdministration.INPI]}
>
<DataInpiLinkWithExplanations uniteLegale={uniteLegale} session={session} />
Expand Down
2 changes: 1 addition & 1 deletion components/search-results/map/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const SearchResultsMap: React.FC<{
results: ISearchResults;
searchFilterParams?: IParams;
}> = ({ results, searchTerm = '', searchFilterParams = {} }) => {
const height = 'calc(100vh - 265px)';
const height = 'calc(100vh - 230px)';

if (searchTerm && results.notEnoughParams) {
return (
Expand Down
30 changes: 12 additions & 18 deletions components/subventions-association-section/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { DataSectionClient } from '#components/section/data-section';
import { FullTable } from '#components/table/full';
import { EAdministration } from '#models/administrations/EAdministration';
import { IAssociation } from '#models/core/types';
import { isUnauthorized } from '#models/data-fetching';
import { ISubventions } from '#models/subventions/association';
import { AppScope, hasRights } from '#models/user/rights';
import { ISession } from '#models/user/session';
import { formatCurrency } from '#utils/helpers';
import { useAPIRouteData } from 'hooks/fetch/use-API-route-data';
Expand All @@ -23,8 +23,8 @@ const DataSubventionLink = () => (
Data.subvention est un outil développé par la <DJEPVA />. Il recense les
subventions demandées et reçues par une association.
<br />
Les données sont issues de Chorus et du Fonjep (Fonds de
coopération de la jeunesse et de l’éducation populaire).
Les données sont issues de Chorus et du Fonjep (Fonds de coopération de la
jeunesse et de l’éducation populaire).
</FAQLink>
);

Expand Down Expand Up @@ -66,7 +66,7 @@ const SubventionDetails: React.FC<{ subventions: ISubventions }> = ({
);
};

const SubventionsAssociation: React.FC<{
export const SubventionsAssociationSection: React.FC<{
uniteLegale: IAssociation;
session: ISession | null;
}> = ({ uniteLegale, session }) => {
Expand All @@ -76,6 +76,14 @@ const SubventionsAssociation: React.FC<{
session
);

if (isUnauthorized(subventions)) {
// for a start lets hide it first before Data subvention validation
return null;
// return (
// <AgentWall id="detail-des-subventions" title="Détail des subventions" />
// );
}

return (
<DataSectionClient
id="detail-des-subventions"
Expand Down Expand Up @@ -127,17 +135,3 @@ const SubventionsAssociation: React.FC<{
</DataSectionClient>
);
};

export const SubventionsAssociationSection: React.FC<{
uniteLegale: IAssociation;
session: ISession | null;
}> = ({ uniteLegale, session }) => {
if (!hasRights(session, AppScope.subventionsAssociation)) {
// for a start lets hide it first before Data subvention validation
return null;
// return (
// <AgentWall id="detail-des-subventions" title="Détail des subventions" />
// );
}
return <SubventionsAssociation uniteLegale={uniteLegale} session={session} />;
};
6 changes: 3 additions & 3 deletions utils/server-side-helper/app/cached-methods.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { redirect } from 'next/navigation';
import { cache } from 'react';
import { HttpNotFound } from '#clients/exceptions';
import { Exception } from '#models/exceptions';
import { extractSirenOrSiretSlugFromUrl } from '#utils/helpers';
import { logFatalErrorInSentry, logWarningInSentry } from '#utils/sentry';
import { redirect } from 'next/navigation';
import { cache } from 'react';
import { getEtablissementWithUniteLegaleFromSlug } from '../../../models/core/etablissement';
import {
FetchRechercheEntrepriseException,
Expand Down Expand Up @@ -58,7 +58,7 @@ const handleException = (e: any, slug: string) => {
* Call this function to rely on react cache when using an unite legale
*/
export const cachedGetUniteLegale = cache(
async (slug: string, isBot: boolean, page = 0) => {
async (slug: string, isBot: boolean, page = 1) => {
const sirenSlug = extractSirenOrSiretSlugFromUrl(slug);
try {
return await getUniteLegaleFromSlug(sirenSlug, {
Expand Down

0 comments on commit 9257785

Please sign in to comment.