Skip to content

Commit 3938e44

Browse files
committed
fix(mimoquage): show declaration owner in /avis-cse banner
`/avis-cse/layout.tsx` also resolved SIREN from `session.user.siret`, so during impersonation the banner showed the admin's own company (or redirected to `/` if the admin had no SIRET). Apply the same fallback as the declaration-remuneration layout: prefer `session.user.impersonation.siren` when the admin is impersonating, so the banner always reflects the declaration owner.
1 parent 28af7ae commit 3938e44

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

packages/app/src/app/avis-cse/layout.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,20 @@ export default async function CseOpinionRootLayout({
1515
redirect("/login");
1616
}
1717

18-
const siret = session.user.siret;
19-
if (!siret) {
18+
// In mimoquage, the admin's own SIRET is typically empty — the banner must
19+
// show the impersonated company (owner of the declaration being viewed),
20+
// mirrors the declaration-remuneration layout.
21+
const siren =
22+
session.user.isAdmin && session.user.impersonation
23+
? session.user.impersonation.siren
24+
: session.user.siret
25+
? extractSiren(session.user.siret)
26+
: null;
27+
28+
if (!siren) {
2029
redirect("/");
2130
}
2231

23-
const siren = extractSiren(siret);
2432
const [company, declarationData] = await Promise.all([
2533
api.company.get({ siren }),
2634
api.declaration.getOrCreate(),

0 commit comments

Comments
 (0)