-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor frontend imports and improve type definitions
- Updated import paths to use absolute imports with @/ prefix - Simplified and improved type definitions in Layout and inertiaConfig - Adjusted component props and type annotations for better type safety - Cleaned up import statements across multiple frontend components
- Loading branch information
Showing
11 changed files
with
33 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
app/frontend/components/pages/auth/connection/ConnectionForm.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,31 @@ | ||
import { createElement } from 'react' | ||
import type { ResolvedComponent } from '@inertiajs/react' | ||
import { createElement, ReactElement } from 'react' | ||
import type { PageResolver } from '@inertiajs/core' | ||
import Layout from '@/Layout' | ||
|
||
interface ResolvedComponent { | ||
default: { | ||
layout: (pageContent: ReactElement & { props: { flash?: any } }) => ReactElement | ||
} | ||
} | ||
|
||
export const getTitle = (title: string | null): string => | ||
title ? `${title} | Benefactorum` : 'Benefactorum' | ||
title !== null ? `${title} | Benefactorum` : 'Benefactorum' | ||
|
||
export const resolvePage = (name: string): ResolvedComponent => { | ||
export const resolvePage: PageResolver = (name) => { | ||
const pages = import.meta.glob<ResolvedComponent>( | ||
'../pages/**/!(*.test).tsx', | ||
{ eager: true } | ||
) | ||
const page = pages[`../pages/${name}.tsx`] as { | ||
default: { layout?: (page: JSX.Element) => JSX.Element } | ||
} | ||
if (!page) { | ||
const page = pages[`../pages/${name}.tsx`] | ||
|
||
if (page === undefined) { | ||
console.error(`Missing Inertia page component: '${name}.tsx'`) | ||
} | ||
page.default.layout = (page) => | ||
createElement( | ||
Layout, | ||
{ | ||
showSidebar: name.startsWith('Contribution/'), | ||
flash: page.props.flash | ||
}, | ||
page | ||
) | ||
|
||
page.default.layout = (pageContent) => | ||
createElement(Layout, { | ||
showSidebar: name.startsWith('Contribution/'), | ||
flash: pageContent.props?.flash | ||
}, pageContent) | ||
return page | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters