diff --git a/lib/context/HubOneContext.tsx b/lib/context/HubOneContext.tsx index 7f63a9e6..7fba03e9 100644 --- a/lib/context/HubOneContext.tsx +++ b/lib/context/HubOneContext.tsx @@ -8,6 +8,7 @@ export type Settings = { links: Link[]; linkGroups: LinkGroup[]; footerLinks: FooterLink[]; + createModalOpened: boolean; }; const defaultSettings: Settings = { @@ -16,6 +17,7 @@ const defaultSettings: Settings = { links: [], linkGroups: [], footerLinks: [], + createModalOpened: false, }; const HubOneContext = React.createContext({ @@ -25,6 +27,7 @@ const HubOneContext = React.createContext({ setLinks: (link: Link[]) => {}, setLinkGroups: (linkGroups: LinkGroup[]) => {}, setFooterLinks: (footerLinks: FooterLink[]) => {}, + setCreateModalOpened: (createModalOpened: boolean) => {}, }); export const useHubOneContext = () => useContext(HubOneContext); @@ -64,6 +67,12 @@ export function HubOneContextProvider({ footerLinks, })); }; + const setCreateModalOpened = (createModalOpened: boolean) => { + setState((prevState) => ({ + ...prevState, + createModalOpened, + })); + }; const initState = { ...defaultSettings, @@ -72,6 +81,7 @@ export function HubOneContextProvider({ setLinks, setLinkGroups, setFooterLinks, + setCreateModalOpened, }; const [state, setState] = useState(initState); diff --git a/package.json b/package.json index 4b6506d8..ee392d9f 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "@mantine/next": "^6.0.0", "@mantine/notifications": "^6.0.0", "@prisma/client": "^4.5.0", + "@tabler/icons-react": "^2.17.0", "@tanstack/react-query": "^4.12.0", "@tanstack/react-query-devtools": "^4.12.0", "axios": "^1.1.3", @@ -32,8 +33,7 @@ "prettier": "^2.6.2", "react": "18.2.0", "react-dom": "18.2.0", - "react-scroll": "^1.8.8", - "tabler-icons-react": "^1.55.0" + "react-scroll": "^1.8.8" }, "devDependencies": { "@babel/core": "^7.19.6", diff --git a/pages/[[...hubPaths]].tsx b/pages/[[...hubPaths]].tsx index f151e290..98619bc7 100644 --- a/pages/[[...hubPaths]].tsx +++ b/pages/[[...hubPaths]].tsx @@ -5,16 +5,25 @@ import { useRouter } from "next/router"; import { useHubOneContext } from "../lib/context/HubOneContext"; import { getHubWithPath } from "../lib/requests/hub/getHub"; +import { getHubs } from "../lib/requests/hub/getHubs"; import { useFetchByHubId } from "../lib/useQueries"; import { Footer } from "../ui/components/Footer"; import { HeaderBar } from "../ui/components/Header"; +import AddHubModal from "../ui/components/HubModals/CreateHubModal/CreateHubModal"; import Hero from "../ui/sections/Hero"; +import HubMenu from "../ui/sections/HubMenu"; import LinkSection from "../ui/sections/LinkSection"; export default function Home() { const router = useRouter(); - const { setHub, setLinks, setLinkGroups, setFooterLinks } = - useHubOneContext(); + const { + setHub, + setLinks, + setLinkGroups, + setFooterLinks, + createModalOpened, + setCreateModalOpened, + } = useHubOneContext(); // use `|| [""]` for root hub that has no set path by the router const hubPaths = (router.query.hubPaths as string[]) || [""]; const { @@ -24,8 +33,8 @@ export default function Home() { } = useQuery(["hubs", hubPaths[0]], () => getHubWithPath(hubPaths[0]), { onSuccess: setHub, }); - const hubId = Number(hub?.id); + const hubId = Number(hub?.id); const config = (onSuccess: (data: T) => void) => ({ enabled: !!hubId, onSuccess, @@ -34,6 +43,8 @@ export default function Home() { useFetchByHubId("linkgroups", hubId, config(setLinkGroups)); useFetchByHubId("footerlinks", hubId, config(setFooterLinks)); + const { data: hubs } = useQuery(["hubs"], () => getHubs()); + if (isLoading) { return (
+ {hubs && }