mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: enhance API request handling and improve type safety in auth layout
This commit is contained in:
parent
78cabbc665
commit
27c8e48578
3 changed files with 59 additions and 5 deletions
|
|
@ -1,8 +1,9 @@
|
|||
'use client'
|
||||
'use client';
|
||||
|
||||
import { OrgProvider } from '@components/Contexts/OrgContext'
|
||||
import ErrorUI from '@components/Objects/StyledElements/Error/Error'
|
||||
import { useSearchParams } from 'next/navigation'
|
||||
|
||||
import React from 'react'
|
||||
|
||||
export default function AuthLayout({
|
||||
children,
|
||||
|
|
@ -10,7 +11,8 @@ export default function AuthLayout({
|
|||
children: React.ReactNode
|
||||
}) {
|
||||
const searchParams = useSearchParams()
|
||||
const orgslug = searchParams.get('orgslug')
|
||||
// Use optional chaining and nullish coalescing for type safety
|
||||
const orgslug = searchParams?.get('orgslug') ?? null
|
||||
if (orgslug) {
|
||||
return <OrgProvider orgslug={orgslug}>{children}</OrgProvider>
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ export default function Document() {
|
|||
<Head>
|
||||
{/* Load runtime configuration before any app code */}
|
||||
<script src="/runtime-config.js" />
|
||||
{/* Load API interceptor to enforce correct domain */}
|
||||
<script src="/api-interceptor.js" />
|
||||
</Head>
|
||||
<body>
|
||||
<Main />
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue