Skip to content

Commit

Permalink
Fix routing for hubspot
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonyec committed Sep 18, 2024
1 parent 7d7927d commit 42a5682
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion plugins/hubspot/src/pages/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Logo } from "../components/Logo"
import { ChartIcon, FormsIcon, PersonIcon, MessageIcon, LightningIcon, WidgetsIcon } from "../components/Icons"
import { framer } from "framer-plugin"
import cx from "classnames"
import { BASE_PATH } from "../router"

const MenuOption = ({
icon,
Expand All @@ -22,7 +23,7 @@ const MenuOption = ({
return (
<button
className={cx("h-[110px] w-full tile col items-center justify-center rounded-md", className)}
onClick={() => (onClick ? onClick() : navigate(to))}
onClick={() => (onClick ? onClick() : navigate(`${BASE_PATH}${to}`))}
>
{icon}
<p className="font-semibold text-tertiary">{title}</p>
Expand Down
5 changes: 3 additions & 2 deletions plugins/hubspot/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useLocation } from "wouter"
import auth from "../auth"
import { Button } from "../components/Button"
import { Logo } from "../components/Logo"
import { BASE_PATH } from "../router"

export function AuthenticatePage() {
const [, navigate] = useLocation()
Expand All @@ -15,7 +16,7 @@ export function AuthenticatePage() {
const isAuth = await auth.isAuthenticated()

if (isAuth) {
navigate("/menu")
navigate(`${BASE_PATH}/menu`)
}
}

Expand Down Expand Up @@ -53,7 +54,7 @@ export function AuthenticatePage() {
// Poll the auth server and wait for tokens
await pollForTokens(authorization.readKey)

navigate("/menu")
navigate(`${BASE_PATH}/menu`)
} catch (e) {
framer.notify(e instanceof Error ? e.message : "An unknown error occurred.", { variant: "error" })
} finally {
Expand Down
3 changes: 2 additions & 1 deletion plugins/hubspot/src/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { WidgetsPage } from "./pages/Widgets"
import { PageErrorBoundaryFallback } from "./components/PageErrorBoundaryFallback"
import { isLocal } from "./auth"

const BASE_PATH = isLocal() ? "" : "/hubspot"
export const BASE_PATH = isLocal() ? "" : "/hubspot"

interface PluginRoute {
path: string
Expand Down Expand Up @@ -108,6 +108,7 @@ function useRoutes(routes: PluginRoute[]) {

const addToMatch = (route: PluginRoute, parentPath = "") => {
const fullPath = BASE_PATH + parentPath + route.path

// eslint-disable-next-line react-hooks/rules-of-hooks
const match = useRoute(fullPath)
matches.push({ match, route: { ...route, path: fullPath } })
Expand Down

0 comments on commit 42a5682

Please sign in to comment.