Skip to content

Commit

Permalink
Merge pull request #1548 from SocialGouv/build/bump-next15-react19
Browse files Browse the repository at this point in the history
Build/bump next15 react19
  • Loading branch information
arthurlbrjc authored Dec 12, 2024
2 parents e6c3351 + 7b9210e commit 0c5dfb5
Show file tree
Hide file tree
Showing 129 changed files with 1,383 additions and 1,255 deletions.
73 changes: 0 additions & 73 deletions .eslintrc.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function ConsentementCguPage({ returnTo }: ConsentementCguProps) {
try {
await modifierDateSignatureCGU(DateTime.now())
router.push(returnTo)
} catch (e) {
} catch {
setShowErrorValidation(true)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { Evenement } from 'interfaces/evenement'
import { Session, StatutBeneficiaire } from 'interfaces/session'
import { toFrenchDateTime } from 'utils/date'

type EmargementRdvPageProps = {
export type EmargementRdvPageProps = {
evenement: Evenement | Session
agence?: string
}
Expand Down
88 changes: 38 additions & 50 deletions app/(connected)/(full-page)/emargement/[idEvenement]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,84 +1,72 @@
import { Metadata } from 'next'
import { notFound, redirect } from 'next/navigation'

import EmargementRdvPage from 'app/(connected)/(full-page)/emargement/[idEvenement]/EmargementRdvPage'
import EmargementRdvPage, {
EmargementRdvPageProps,
} from 'app/(connected)/(full-page)/emargement/[idEvenement]/EmargementRdvPage'
import { PageHeaderPortal } from 'components/PageNavigationPortals'
import { Conseiller, estUserMilo } from 'interfaces/conseiller'
import { estUserMilo } from 'interfaces/conseiller'
import { Evenement } from 'interfaces/evenement'
import { Session } from 'interfaces/session'
import { getConseillerServerSide } from 'services/conseiller.service'
import { getDetailsEvenement } from 'services/evenements.service'
import { getDetailsSession } from 'services/sessions.service'
import { getMandatorySessionServerSide } from 'utils/auth/auth'

type EmargementRdvParams = { idEvenement: string }
type EmargementRdvSearchParams = { type: string }

export async function generateMetadata({
params,
searchParams,
}: {
type EmargementRdvParams = Promise<{ idEvenement: string }>
type EmargementRdvSearchParams = Promise<{ type: string }>
type RouteProps = {
params: EmargementRdvParams
searchParams: EmargementRdvSearchParams
}): Promise<Metadata> {
const evenementTypeSession = searchParams.type === 'session'
if (!params?.idEvenement) notFound()

const props = await buildProps(params.idEvenement, evenementTypeSession)

const titre = evenementTypeSession
? (props.evenement as Session).session.nom
: (props.evenement as Evenement).titre

return {
title: `Emargement - ${titre}`,
}
searchParams?: EmargementRdvSearchParams
}

export default async function EmargementRdv({
params,
searchParams,
}: {
params?: EmargementRdvParams
searchParams: EmargementRdvSearchParams
}) {
const evenementTypeSession = searchParams.type === 'session'
if (!params?.idEvenement) notFound()
export async function generateMetadata(
routeProps: RouteProps
): Promise<Metadata> {
const { titre } = await buildProps(routeProps)

const props = await buildProps(params.idEvenement, evenementTypeSession)
return { title: titre }
}

const titre = evenementTypeSession
? (props.evenement as Session).session.nom
: (props.evenement as Evenement).titre
export default async function EmargementRdv(routeProps: RouteProps) {
const { titre, ...props } = await buildProps(routeProps)

return (
<>
<PageHeaderPortal header={`Emargement - ${titre}`} />
<PageHeaderPortal header={titre} />

<EmargementRdvPage
evenement={props.evenement}
agence={props.conseiller.structureMilo?.nom}
/>
<EmargementRdvPage {...props} />
</>
)
}

async function buildProps(
idEvenement: string,
evenementSession: boolean
): Promise<{
evenement: Evenement | Session
conseiller: Conseiller
}> {
async function buildProps({
params,
searchParams,
}: {
params: EmargementRdvParams
searchParams?: EmargementRdvSearchParams
}): Promise<{ titre: string } & EmargementRdvPageProps> {
const { user, accessToken } = await getMandatorySessionServerSide()
if (!estUserMilo(user)) redirect('/mes-jeunes')

const { idEvenement } = await params
const { type } = (await searchParams) ?? {}
const isSession = type === 'session'

const conseiller = await getConseillerServerSide(user, accessToken)

const evenement = evenementSession
const evenement = isSession
? await getDetailsSession(user.id, idEvenement, accessToken)
: await getDetailsEvenement(idEvenement, accessToken)
if (!evenement) notFound()
const titreEvenement = isSession
? (evenement as Session).session.nom
: (evenement as Evenement).titre

return { evenement, conseiller }
return {
titre: 'Emargement - ' + titreEvenement,
evenement,
agence: conseiller.structureMilo?.nom,
}
}
27 changes: 13 additions & 14 deletions app/(connected)/(with-sidebar)/(with-chat)/(index)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,31 @@ import { getMandatorySessionServerSide } from 'utils/auth/auth'

export const metadata: Metadata = { title: 'Accueil' }

type HomeSearchParams = Partial<{
redirectUrl: string
source: string
onboarding: boolean
}>
type HomeSearchParams = Promise<
Partial<{
redirectUrl: string
source: string
onboarding: boolean
}>
>
export default async function Home({
searchParams,
}: {
searchParams?: HomeSearchParams
}) {
const { user, accessToken } = await getMandatorySessionServerSide()
const sourceQueryParam = searchParams?.source
? `?source=${searchParams.source}`
: ''

const conseiller = await getConseillerServerSide(user, accessToken)
if (doitSignerLesCGU(conseiller)) redirect('/consentement-cgu')

const redirectUrl =
searchParams?.redirectUrl ?? '/mes-jeunes' + sourceQueryParam
const { source, redirectUrl, onboarding } = (await searchParams) ?? {}
const sourceQueryParam = source ? `?source=${source}` : ''
const targetPage = redirectUrl ?? '/mes-jeunes' + sourceQueryParam

const afficherModaleOnboarding = Boolean(searchParams?.onboarding)
const afficherModaleOnboarding = Boolean(onboarding)
const emailEstManquant = estMilo(conseiller) && !conseiller.email
const agenceEstManquante = !aEtablissement(conseiller)
if (!afficherModaleOnboarding && !emailEstManquant && !agenceEstManquante)
redirect(`${redirectUrl}`)
redirect(targetPage)

let referentielAgences = undefined
if (!estMilo(conseiller)) {
Expand All @@ -57,7 +56,7 @@ export default async function Home({
afficherModaleOnboarding={afficherModaleOnboarding}
afficherModaleAgence={agenceEstManquante}
afficherModaleEmail={emailEstManquant}
redirectUrl={redirectUrl}
redirectUrl={targetPage}
referentielAgences={referentielAgences}
/>
</>
Expand Down
16 changes: 7 additions & 9 deletions app/(connected)/(with-sidebar)/(with-chat)/agenda/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ export const metadata: Metadata = {
title: 'Tableau de bord - Agenda',
}

type AgendaSearchParams = {
type AgendaSearchParams = Promise<{
periodeIndex?: string
onglet?: string
}
}>
export default async function Agenda({
searchParams,
}: {
Expand All @@ -22,17 +22,15 @@ export default async function Agenda({
const { user } = await getMandatorySessionServerSide()
if (!estUserMilo(user)) notFound()

const periodeIndex = searchParams?.periodeIndex
? parseInt(searchParams.periodeIndex)
: 0
const onglet =
searchParams?.onglet === 'conseiller' ? 'CONSEILLER' : 'ETABLISSEMENT'

const { periodeIndex, onglet } = (await searchParams) ?? {}
return (
<>
<PageHeaderPortal header='Agenda' />

<AgendaPage periodeIndexInitial={periodeIndex} onglet={onglet} />
<AgendaPage
periodeIndexInitial={periodeIndex ? parseInt(periodeIndex) : 0}
onglet={onglet === 'conseiller' ? 'CONSEILLER' : 'ETABLISSEMENT'}
/>
</>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ function EtablissementPage() {
</div>
</TD>
<TDLink
href={'etablissement/beneficiaires/' + jeune.base.id}
href={'/etablissement/beneficiaires/' + jeune.base.id}
labelPrefix='Accéder à la fiche de'
/>
</TR>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,16 @@ import { useConseiller } from 'utils/conseiller/conseillerContext'
import { usePortefeuille } from 'utils/portefeuilleContext'

const FicheBeneficiaireMilo = dynamic(
() => import('components/jeune/FicheBeneficiaireMilo'),
{ ssr: false }
() => import('components/jeune/FicheBeneficiaireMilo')
)
const FicheBeneficiairePasMilo = dynamic(
() => import('components/jeune/FicheBeneficiairePasMilo'),
{ ssr: false }
() => import('components/jeune/FicheBeneficiairePasMilo')
)
const DeleteBeneficiaireActifModal = dynamic(
() => import('components/jeune/DeleteBeneficiaireActifModal'),
{ ssr: false }
() => import('components/jeune/DeleteBeneficiaireActifModal')
)
const DeleteJeuneInactifModal = dynamic(
() => import('components/jeune/DeleteJeuneInactifModal'),
{ ssr: false }
() => import('components/jeune/DeleteJeuneInactifModal')
)

function FicheBeneficiairePage(props: FicheBeneficiaireProps) {
Expand Down Expand Up @@ -151,7 +147,7 @@ function FicheBeneficiairePage(props: FicheBeneficiaireProps) {

removeBeneficiaireFromPortefeuille(beneficiaire.id)
setShowModaleSuccesDeleteBeneficiaire(true)
} catch (e) {
} catch {
setShowSuppressionCompteBeneficiaireError(true)
setTrackingLabel(`${pageTracking} - Erreur suppr. compte`)
} finally {
Expand All @@ -168,7 +164,7 @@ function FicheBeneficiairePage(props: FicheBeneficiaireProps) {

removeBeneficiaireFromPortefeuille(beneficiaire.id)
setShowModaleSuccesDeleteBeneficiaire(true)
} catch (e) {
} catch {
setShowSuppressionCompteBeneficiaireError(true)
setTrackingLabel(`${pageTracking} - Erreur suppr. compte`)
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { toLongMonthDate } from 'utils/date'
import { unsafeRandomId } from 'utils/helpers'
import { usePortefeuille } from 'utils/portefeuilleContext'

type DetailActionProps = {
export type DetailActionProps = {
action: Action
jeune: BaseBeneficiaire
lectureSeule: boolean
Expand Down
Loading

0 comments on commit 0c5dfb5

Please sign in to comment.