diff --git a/src/components/client-form/client-form.tsx b/src/components/client-form/client-form.tsx index c75737d..a9f0dec 100644 --- a/src/components/client-form/client-form.tsx +++ b/src/components/client-form/client-form.tsx @@ -4,12 +4,18 @@ import { Profile } from '@/types'; import { useEffect, useState } from 'react'; import { retrieveApiRequest, RetrieveResponse } from '@/pages/api/retrieve'; import Card from '../card/card'; +import Portal from '../portal/portal'; const ClientForm = () => { const [profile, setProfile] = useState( Object.keys(PROFILES)[0] as Profile, ); const [destinations, setDestinations] = useState(); + const [isMounted, setIsMounted] = useState(false); + + useEffect(() => { + setIsMounted(true); + }, []); function retrieveRelevantDestinations() { retrieveApiRequest().then((response) => { @@ -32,17 +38,19 @@ const ClientForm = () => {
- - + {isMounted && ( + + + )}
{destinations != null && ( diff --git a/src/components/header/header.tsx b/src/components/header/header.tsx index 19f8711..2fdb51c 100644 --- a/src/components/header/header.tsx +++ b/src/components/header/header.tsx @@ -1,7 +1,7 @@ -import styles from './header.module.css'; import Image from 'next/image'; import Link from 'next/link'; import { useRouter } from 'next/router'; +import styles from './header.module.css'; const routes = [ { @@ -20,27 +20,30 @@ const Header = () => { return (
- Iberia logo -
- {routes.map((route, index) => ( - - - {route.name} - - {index < routes.length - 1 && ( - | - )} - - ))} +
+ Iberia logo +
+ {routes.map((route, index) => ( + + + {route.name} + + {index < routes.length - 1 && ( + | + )} + + ))} +
+ {/* ({profile}) */} +
); diff --git a/src/components/portal/portal.js b/src/components/portal/portal.js new file mode 100644 index 0000000..21e7ad9 --- /dev/null +++ b/src/components/portal/portal.js @@ -0,0 +1,8 @@ +import React from 'react'; +import ReactDOM from 'react-dom'; + +const Portal = ({ children }) => { + const portalRoot = typeof document !== 'undefined' ? document.getElementById('profile-form') : null; + return portalRoot ? ReactDOM.createPortal(children, portalRoot) : null; +}; +export default Portal; \ No newline at end of file diff --git a/src/pages/admin/index.tsx b/src/pages/admin/index.tsx index b0f7c85..676dbc2 100644 --- a/src/pages/admin/index.tsx +++ b/src/pages/admin/index.tsx @@ -1,12 +1,12 @@ import Header from '@/components/header/header'; import { DESTINATIONS, ENGINES, PROFILES } from '@/constants'; -import { useEffect, useState } from 'react'; -import { useLocalStorage } from 'usehooks-ts'; +import { generateApiRequest } from '@/pages/api/generate'; +import { saveApiRequest } from '@/pages/api/save'; import { Engine, LocalStorageImgUrls, Profile } from '@/types'; import { addUrl } from '@/utils'; +import { useEffect, useState } from 'react'; +import { useLocalStorage } from 'usehooks-ts'; import styles from './index.module.css'; -import { saveApiRequest } from '@/pages/api/save'; -import { generateApiRequest } from '@/pages/api/generate'; function getPrompt(profileKey: Profile, destination: string): string { const profile = PROFILES[profileKey]; @@ -82,7 +82,7 @@ const AdminPage = () => { return ( <> -
+

PĆ”gina de administraciĆ³n de Gen-AI