Skip to content

Commit

Permalink
Corrections lors du fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
mariheck committed Jan 22, 2024
1 parent 2435048 commit 6993dfd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions packages/site/app/programme/[uid]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {notFound} from 'next/navigation';
import {getServiceStrapiData} from './utils';
import {InfoData, ListeData, ParagrapheData} from './types';
import ParagrapheService from './ParagrapheService';
Expand All @@ -11,7 +12,7 @@ type ServiceProgrammeProps = {
const ServiceProgramme = async ({params: {uid}}: ServiceProgrammeProps) => {
const data = await getServiceStrapiData(uid);

if (!data || data.contenu.length === 0) return null;
if (!data || data.contenu.length === 0) return notFound();

return (
<>
Expand All @@ -24,7 +25,7 @@ const ServiceProgramme = async ({params: {uid}}: ServiceProgrammeProps) => {
case 'info':
return <InfoService {...(c as InfoData)} />;
default:
return null;
return notFound();
}
})}
</>
Expand Down
4 changes: 2 additions & 2 deletions packages/site/app/programme/[uid]/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const getServiceStrapiData = async (uid: string) => {
['populate[5]', 'contenu.boutons'],
]);

if (data) {
if (data && data.length > 0 && data[0].attributes.contenu) {
const serviceData = data[0].attributes;

return {
Expand Down Expand Up @@ -67,5 +67,5 @@ export const getServiceStrapiData = async (uid: string) => {
},
),
};
} else return data;
} else return null;
};

0 comments on commit 6993dfd

Please sign in to comment.