Skip to content

Commit

Permalink
refactor: UX and issue in cache key
Browse files Browse the repository at this point in the history
  • Loading branch information
XavierJp committed Oct 15, 2024
1 parent 08f8511 commit 5af021b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 22 deletions.
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 5af021b

Please sign in to comment.