Skip to content

Commit

Permalink
Merge branch 'development' into feat/2641-chat-and-marketplace-header…
Browse files Browse the repository at this point in the history
…-buttons
  • Loading branch information
Derikyan authored Nov 26, 2024
2 parents d544c9a + cbf7eb1 commit 03f5282
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 9 deletions.
30 changes: 23 additions & 7 deletions apps/chat/src/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { SessionProvider, SessionProviderProps } from 'next-auth/react';
import { ReactElement, ReactNode } from 'react';
import { Provider } from 'react-redux';

import { NextPage } from 'next';
import { appWithTranslation } from 'next-i18next';
import type { AppProps } from 'next/app';
import { Inconsolata, Inter } from 'next/font/google';

import { SettingsState } from '@/src/store/settings/settings.reducers';

import Layout from '../components/Layout';
import { Toasts } from '../components/Toasts/Toasts';

Expand All @@ -13,6 +17,14 @@ import { HomeProps } from '.';
import { createStore } from '@/src/store';
import '@/src/styles/globals.css';

export type NextPageWithLayout<P = object, IP = P> = NextPage<P, IP> & {
getLayout?: (page: ReactElement, settings: SettingsState) => ReactNode;
};

export function getLayout(page: ReactElement, settings: SettingsState) {
return <Layout settings={settings}>{page}</Layout>;
}

export const inter = Inter({
subsets: ['latin'],
weight: 'variable',
Expand All @@ -24,22 +36,26 @@ export const inconsolata = Inconsolata({
variable: '--font-inconsolata',
});

function App({
Component,
...rest
}: AppProps<SessionProviderProps & HomeProps>) {
type AppPropsWithLayout = AppProps<SessionProviderProps & HomeProps> & {
Component: NextPageWithLayout;
};

function App({ Component, ...rest }: AppPropsWithLayout) {
const store = createStore({
settings: rest.pageProps.initialState?.settings,
});

const getPage = Component.getLayout ?? ((page) => page);

return (
<SessionProvider session={rest.pageProps.session} basePath={'api/auth'}>
<Provider store={store}>
<div className={`${inter.variable} font`}>
<Toasts />
<Layout settings={rest.pageProps.initialState?.settings}>
<Component {...rest.pageProps} />
</Layout>
{getPage(
<Component {...rest.pageProps} />,
rest.pageProps.initialState?.settings,
)}
</div>
</Provider>
</SessionProvider>
Expand Down
8 changes: 7 additions & 1 deletion apps/chat/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import {
selectShowSelectToMigrateWindow,
} from '@/src/store/ui/ui.reducers';

import { getLayout } from '@/src/pages/_app';

import ShareModal from '../components/Chat/ShareModal';
import { ImportExportLoader } from '../components/Chatbar/ImportExportLoader';
import { AnnouncementsBanner } from '../components/Common/AnnouncementBanner';
Expand All @@ -34,7 +36,7 @@ export interface HomeProps {
};
}

export default function Home() {
function Home() {
useCustomizations();

const isProfileOpen = useAppSelector(UISelectors.selectIsProfileOpen);
Expand Down Expand Up @@ -120,4 +122,8 @@ export default function Home() {
);
}

Home.getLayout = getLayout;

export default Home;

export const getServerSideProps = getCommonPageProps;
8 changes: 7 additions & 1 deletion apps/chat/src/pages/marketplace/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { MarketplaceActions } from '@/src/store/marketplace/marketplace.reducers
import { SettingsSelectors } from '@/src/store/settings/settings.reducers';
import { UISelectors } from '@/src/store/ui/ui.reducers';

import { getLayout } from '@/src/pages/_app';

import Loader from '@/src/components/Common/Loader';
import { UserMobile } from '@/src/components/Header/User/UserMobile';
import { Marketplace as MarketplaceView } from '@/src/components/Marketplace/Marketplace';
Expand All @@ -17,7 +19,7 @@ import { MarketplaceHeader } from '@/src/components/Marketplace/MarketplaceHeade

import { Feature } from '@epam/ai-dial-shared';

export default function Marketplace() {
function Marketplace() {
const dispatch = useAppDispatch();

const isProfileOpen = useAppSelector(UISelectors.selectIsProfileOpen);
Expand Down Expand Up @@ -53,4 +55,8 @@ export default function Marketplace() {
);
}

Marketplace.getLayout = getLayout;

export default Marketplace;

export const getServerSideProps = getCommonPageProps;

0 comments on commit 03f5282

Please sign in to comment.