Skip to content

Commit

Permalink
fix: update router paths
Browse files Browse the repository at this point in the history
  • Loading branch information
sajald77 committed Aug 1, 2024
1 parent 9552099 commit 4b4ea2e
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 131 deletions.
6 changes: 0 additions & 6 deletions src/config/routes/routeGroups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ export const creatorProjectCreationRoutes = [
getPath('launchProjectWallet', PathName.projectId),
]

export const entryCreationRoutes = [
getPath('projectEntryCreation', PathName.projectName),
getPath('projectEntryDetails', PathName.projectName, PathName.entryId),
getPath('projectEntryPreview', PathName.projectName, PathName.entryId),
]

export const ProjectPageDashboardInternalRoutes = [
getPath('dashboardAnalytics', PathName.projectName),
getPath('dashboardSales', PathName.projectName),
Expand Down
4 changes: 2 additions & 2 deletions src/config/routes/state/privateRoutesAtom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { atom, useAtomValue } from 'jotai'
import { getPath, PathName } from '../../../shared/constants'
import {
creatorProjectCreationRoutes as routesForPrivateProjectLaunch,
entryCreationRoutes as routesForEntryCreation,
projectCreatorRoutes as routesForProjectCreator,
projectPostCreatorRoutes,
routeMatchForAtom,
} from '../routeGroups'

Expand All @@ -14,7 +14,7 @@ export const routesForProjectCreatorAtom = atom(routeMatchForAtom(routesForProje

export const routeMatchForProjectPageAtom = atom(routeMatchForAtom([getPath('project', PathName.projectId)]))

const routesForEntryCreationAtom = atom(routeMatchForAtom(routesForEntryCreation))
const routesForEntryCreationAtom = atom(routeMatchForAtom(projectPostCreatorRoutes))

export const useRouteMatchesForPrivateRoute = () => {
const isProjectCreatorRoute = useAtomValue(routesForProjectCreatorAtom)
Expand Down
7 changes: 1 addition & 6 deletions src/modules/navigation/topNavBar/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
export { TopNavBar } from './TopNavBar'
export {
shouldShowProjectLogoAtom,
useIsProjectPage,
useRouteMatchesForTopNavBar,
useTopNavBarAnimate,
} from './topNavBarAtom'
export { shouldShowProjectLogoAtom, useIsProjectPage, useTopNavBarAnimate } from './topNavBarAtom'
75 changes: 0 additions & 75 deletions src/modules/navigation/topNavBar/topNavBarAtom.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import { atom, useAtomValue } from 'jotai'

import {
entryCreationRoutes,
fallBackRoutes,
grantRoutes,
landingRoutes,
projectDashboardRoutes,
projectPostCreatorRoutes,
projectRewardCreatorRoutes,
Expand All @@ -14,53 +10,8 @@ import {
import { getPath, PathName } from '../../../shared/constants'
import { profileSideNavAtom } from '../profileNav/profileSideNavAtom'

const routesForHidingTopNav = entryCreationRoutes
const routesForHidingTopNavAtom = atom(routeMatchForAtom(routesForHidingTopNav))

const routesForShowingProjectButton = projectDashboardRoutes
const routesForShowingProjectButtonAtom = atom(routeMatchForAtom(routesForShowingProjectButton))

const routesForHidingMyProjectsButton = [
getPath('userProfile', PathName.userId),
...projectRoutes,
...entryCreationRoutes,
...projectDashboardRoutes,
]
const routesForHidingMyProjectsButtonAtom = atom(routeMatchForAtom(routesForHidingMyProjectsButton))

const routesForProjectPage = atom(routeMatchForAtom(projectRoutes))

const routesForTransparentBackground = [getPath('index'), getPath('landingFeed')]
const routesForTransparentBackgroundAtom = atom(routeMatchForAtom(routesForTransparentBackground))

const routesForShowingNavItems = [`/`, getPath('landingFeed'), ...grantRoutes]
const routesForShowingNavItemsAtom = atom(routeMatchForAtom(routesForShowingNavItems))

const routesForCustomTitle = [
...projectRoutes,
...projectDashboardRoutes,
// `/${PathName.project}/:projectId/${PathName.entry}`,
getPath('entry', PathName.entryId),
]
const routesForCustomTitleAtom = atom(routeMatchForAtom(routesForCustomTitle))

const routesToShowProjectLaunchButton = [...landingRoutes, ...grantRoutes]
const routesToShowProjectLaunchButtonAtom = atom(routeMatchForAtom(routesToShowProjectLaunchButton))

const routesForHidingDropdownMenu = entryCreationRoutes
const routesForHidingDropdownMenuAtom = atom(routeMatchForAtom(routesForHidingDropdownMenu))

const routesToShowSignInButton = [
...projectRoutes,
...entryCreationRoutes,
...landingRoutes,
...fallBackRoutes,
...grantRoutes,
`/${PathName.userProfile}/:userId`,
`/${PathName.entry}/:entryId`,
]
const routesToShowSignInButtonAtom = atom(routeMatchForAtom(routesToShowSignInButton))

const isProjectRoutesAtom = atom(
routeMatchForAtom([
...projectRoutes,
Expand Down Expand Up @@ -108,30 +59,4 @@ const topNavBarAnimateAtom = atom((get) => {
})
export const useTopNavBarAnimate = () => useAtomValue(topNavBarAnimateAtom)

export const useRouteMatchesForTopNavBar = () => {
const hideTopNavBar = useAtomValue(routesForHidingTopNavAtom)
const showProjectButton = useAtomValue(routesForShowingProjectButtonAtom)
const hideMyProjectsButton = useAtomValue(routesForHidingMyProjectsButtonAtom)
const showLeftSideMenuButton = useAtomValue(routesForProjectPage)
const showNavItems = useAtomValue(routesForShowingNavItemsAtom)
const showCustomTitle = useAtomValue(routesForCustomTitleAtom)
const showProjectLaunchButton = useAtomValue(routesToShowProjectLaunchButtonAtom)
const showTransparentBackground = useAtomValue(routesForTransparentBackgroundAtom)
const hideDropdownMenu = useAtomValue(routesForHidingDropdownMenuAtom)
const showSignInButton = useAtomValue(routesToShowSignInButtonAtom)

return {
hideTopNavBar,
showProjectButton,
hideMyProjectsButton,
showLeftSideMenuButton,
showTransparentBackground,
showNavItems,
showCustomTitle,
showProjectLaunchButton,
hideDropdownMenu,
showSignInButton,
}
}

export const useIsProjectPage = () => useAtomValue(routesForProjectPage)
Empty file.
4 changes: 3 additions & 1 deletion src/pages/landing/components/LandingEntryCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@ interface LandingEntryCardProps extends CardLayoutProps {
export const LandingEntryCard = ({ entry, isMobile, ...rest }: LandingEntryCardProps) => {
const navigate = useNavigate()

const projectName = entry.project?.name

if (!entry.project) {
return null
}

return (
<LandingCardBase
isMobile={isMobile}
onClick={() => navigate(getPath('entry', entry.id))}
onClick={() => projectName && navigate(getPath('projectPostView', projectName, entry.id))}
imageSrc={toSmallImageUrl(`${entry.image}`)}
title={entry.title}
user={entry.creator}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const ContributionActivityItem = ({ fundingTx, dateTime, count, showsProj
return (
<AvatarLink
title={resource.title}
path={getPath('entry', resource.id)}
path={getPath('projectPostView', fundingTx.projectId, resource.id)}
imageSrc={toSmallImageUrl(`${resource.image}`)}
/>
)
Expand Down
14 changes: 12 additions & 2 deletions src/shared/constants/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
export * from './apollo'
export * from './env'
export { ApolloErrors } from './apollo'
export {
__development__,
__production__,
__staging__,
API_SERVICE_ENDPOINT,
AUTH_SERVICE_ENDPOINT,
BOLTZ_DOMAIN,
VITE_APP_FLODESK_API_KEY,
VITE_APP_GEYSER_NOSTR_PUBKEY,
VITE_APP_GIPHY_API_KEY,
} from './env'
export * from './routerPaths'
112 changes: 74 additions & 38 deletions src/shared/constants/config/routerPaths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@ export enum PathName {
dashboardNostr = 'nostr',
dashboardAffiliates = 'affiliate',

projectFunding = 'funding',
fundingDetails = 'details',
fundingPayment = 'payment',
fundingPaymentLightning = 'lightning',
fundingPaymentOnchain = 'onchain',
fundingPaymentOnchainProcessing = 'processing',
fundingPaymentOnchainRefund = 'refund',
fundingPaymentOnchainRefundInitiated = 'initiated',
fundingSuccess = 'success',
fundingFailed = 'failed',

badges = 'badges',
about = 'about',
projectId = ':projectId',
Expand Down Expand Up @@ -102,36 +113,81 @@ const pathsMap = {
projectNotFound: () => `/${PathName.projectNotFound}`,
_deprecatedPathForProject: (projectName: string) => `/${PathName._deprecatedPathNameForProject}/${projectName}`,

refundInitiated: () => `/${PathName.refund}/${PathName.refundInitiated}`,
refund: () => `/${PathName.refund}`,
/** Project base routes */

project: (projectName: string) => `/${PathName.project}/${projectName}`,
projectDraft: (projectName: string) => `/${PathName.project}/${projectName}/${PathName.projectDraft}`,
projectInsights: (projectName: string) => `/${PathName.project}/${projectName}/${PathName.projectInsights}`,
projectContributors: (projectName: string) => `/${PathName.project}/${projectName}/${PathName.projectContributors}`,
projectEntries: (projectName: string) => `/${PathName.project}/${projectName}/${PathName.projectEntries}`,
projectGoals: (projectName: string) => `/${PathName.project}/${projectName}/${PathName.projectGoals}`,
projectRewards: (projectName: string) => `/${PathName.project}/${projectName}/${PathName.projectRewards}`,
projectPosts: (projectName: string) => `/${PathName.project}/${projectName}/${PathName.projectPosts}`,
projectLeaderboard: (projectName: string) => `/${PathName.project}/${projectName}/${PathName.projectLeaderboard}`,
projectDashboard: (projectName: string) => `/${PathName.project}/${projectName}/${PathName.projectDashboard}`,

/** Project Rewards internal routes */

projectRewardCreate: (projectName: string) => `/${PathName.project}/${projectName}/${PathName.projectRewards}/create`,
projectRewardEdit: (projectName: string, rewardId: string) =>
`/${PathName.project}/${projectName}/${PathName.projectRewards}/edit/${rewardId}`,
projectRewardView: (projectName: string, rewardId: string) =>
`/${PathName.project}/${projectName}/${PathName.projectRewards}/view/${rewardId}`,
projectRewards: (projectName: string) => `/${PathName.project}/${projectName}/${PathName.projectRewards}`,

/** Project Post internal routes */

projectPostCreate: (projectName: string) => `/${PathName.project}/${projectName}/${PathName.projectPosts}/create`,
projectPostEdit: (projectName: string, postId: string) =>
`/${PathName.project}/${projectName}/${PathName.projectPosts}/edit/${postId}`,
projectPostView: (projectName: string, postId: string) =>
`/${PathName.project}/${projectName}/${PathName.projectPosts}/view/${postId}`,
projectPosts: (projectName: string) => `/${PathName.project}/${projectName}/${PathName.projectPosts}`,

projectGoals: (projectName: string) => `/${PathName.project}/${projectName}/${PathName.projectGoals}`,
projectLeaderboard: (projectName: string) => `/${PathName.project}/${projectName}/${PathName.projectLeaderboard}`,
projectManageRewards: (projectName: string) => `/${PathName.project}/${projectName}/${PathName.projectManageRewards}`,
projectCreateReward: (projectName: string) =>
`/${PathName.project}/${projectName}/${PathName.projectManageRewards}/${PathName.projectCreateReward}`,
projectEditReward: (projectName: string, rewardId: string) =>
`/${PathName.project}/${projectName}/${PathName.projectManageRewards}/${PathName.projectEditReward}/${rewardId}`,
/** Project Dasboard internal routes */

dashboardAnalytics: (projectName: string) =>
`/${PathName.project}/${projectName}/${PathName.projectDashboard}/${PathName.dashboardAnalytics}`,
dashboardSales: (projectName: string) =>
`/${PathName.project}/${projectName}/${PathName.projectDashboard}/${PathName.dashboardSales}`,
dashboardAccounting: (projectName: string) =>
`/${PathName.project}/${projectName}/${PathName.projectDashboard}/${PathName.dashboardAccounting}`,
dashboardInfo: (projectName: string) =>
`/${PathName.project}/${projectName}/${PathName.projectDashboard}/${PathName.dashboardInfo}`,
dashboardDetails: (projectName: string) =>
`/${PathName.project}/${projectName}/${PathName.projectDashboard}/${PathName.dashboardDetails}`,
dashboardStory: (projectName: string) =>
`/${PathName.project}/${projectName}/${PathName.projectDashboard}/${PathName.dashboardStory}`,
dashboardWallet: (projectName: string) =>
`/${PathName.project}/${projectName}/${PathName.projectDashboard}/${PathName.dashboardWallet}`,
dashboardNostr: (projectName: string) =>
`/${PathName.project}/${projectName}/${PathName.projectDashboard}/${PathName.dashboardNostr}`,
dashboardSettings: (projectName: string) =>
`/${PathName.project}/${projectName}/${PathName.projectDashboard}/${PathName.dashboardSettings}`,
dashboardAffiliates: (projectName: string) =>
`/${PathName.project}/${projectName}/${PathName.projectDashboard}/${PathName.dashboardAffiliates}`,

/** Project Funding Routes */

projectFunding: (projectName: string) => `/${PathName.project}/${projectName}/${PathName.projectFunding}`,
fundingDetails: (projectName: string) =>
`/${PathName.project}/${projectName}/${PathName.projectFunding}/${PathName.fundingDetails}`,
fundingPayment: (projectName: string) =>
`/${PathName.project}/${projectName}/${PathName.projectFunding}/${PathName.fundingPayment}`,
fundingPaymentLightning: (projectName: string) =>
`/${PathName.project}/${projectName}/${PathName.projectFunding}/${PathName.fundingPayment}/${PathName.fundingPaymentLightning}`,
fundingPaymentOnchain: (projectName: string) =>
`/${PathName.project}/${projectName}/${PathName.projectFunding}/${PathName.fundingPayment}/${PathName.fundingPaymentOnchain}`,
fundingPaymentOnchainProcessing: (projectName: string) =>
`/${PathName.project}/${projectName}/${PathName.projectFunding}/${PathName.fundingPayment}/${PathName.fundingPaymentOnchain}/${PathName.fundingPaymentOnchainProcessing}`,
fundingPaymentOnchainRefund: (projectName: string) =>
`/${PathName.project}/${projectName}/${PathName.projectFunding}/${PathName.fundingPayment}/${PathName.fundingPaymentOnchain}/${PathName.fundingPaymentOnchainRefund}`,
fundingPaymentOnchainRefundInitiated: (projectName: string) =>
`/${PathName.project}/${projectName}/${PathName.projectFunding}/${PathName.fundingPayment}/${PathName.fundingPaymentOnchain}/${PathName.fundingPaymentOnchainRefund}/${PathName.fundingPaymentOnchainRefundInitiated}`,
fundingSuccess: (projectName: string) =>
`/${PathName.project}/${projectName}/${PathName.projectFunding}/${PathName.fundingSuccess}`,
fundingFailed: (projectName: string) =>
`/${PathName.project}/${projectName}/${PathName.projectFunding}/${PathName.fundingFailed}`,

/** Refund Routes */

refund: () => `/${PathName.refund}`,
refundInitiated: () => `/${PathName.refund}/${PathName.refundInitiated}`,

entry: (entryID: string) => `/${PathName.entry}/${entryID}`,
entryRewards: (entryID: string) => `/${PathName.entry}/${entryID}/${PathName.projectRewards}`,
Expand All @@ -141,9 +197,10 @@ const pathsMap = {
projectEntryPreview: (projectName: string, entryID: string) =>
`/${PathName.project}/${projectName}/${PathName.entry}/${entryID}/preview`,

/** Project creation Routes */

launchStart: () => `/${PathName.launchProject}/${PathName.launchStart}`,
launch: () => `/${PathName.launchProject}`,

launchStartProject: (projectID: string) => `/${PathName.launchProject}/${PathName.launchStart}/${projectID}`,
launchProject: (projectID: string) => `/${PathName.launchProject}/${projectID}`,
launchProjectDetails: (projectID: string) =>
Expand All @@ -160,32 +217,11 @@ const pathsMap = {
projectLaunch: (projectName: string, state: 'draft' | 'launch' = 'launch') =>
`/${PathName.project}/${projectName}/?${state}`,

/** User Profile Routes */

userProfile: (userID: string) => `/${PathName.userProfile}/${userID}`,
userProfileSettings: (userID: string) => `/${PathName.userProfile}/${userID}/${PathName.userProfileSettings}`,

projectDashboard: (projectName: string) => `/${PathName.project}/${projectName}/${PathName.projectDashboard}`,

dashboardAnalytics: (projectName: string) =>
`/${PathName.project}/${projectName}/${PathName.projectDashboard}/${PathName.dashboardAnalytics}`,
dashboardSales: (projectName: string) =>
`/${PathName.project}/${projectName}/${PathName.projectDashboard}/${PathName.dashboardSales}`,
dashboardAccounting: (projectName: string) =>
`/${PathName.project}/${projectName}/${PathName.projectDashboard}/${PathName.dashboardAccounting}`,
dashboardInfo: (projectName: string) =>
`/${PathName.project}/${projectName}/${PathName.projectDashboard}/${PathName.dashboardInfo}`,
dashboardDetails: (projectName: string) =>
`/${PathName.project}/${projectName}/${PathName.projectDashboard}/${PathName.dashboardDetails}`,
dashboardStory: (projectName: string) =>
`/${PathName.project}/${projectName}/${PathName.projectDashboard}/${PathName.dashboardStory}`,
dashboardWallet: (projectName: string) =>
`/${PathName.project}/${projectName}/${PathName.projectDashboard}/${PathName.dashboardWallet}`,
dashboardNostr: (projectName: string) =>
`/${PathName.project}/${projectName}/${PathName.projectDashboard}/${PathName.dashboardNostr}`,
dashboardSettings: (projectName: string) =>
`/${PathName.project}/${projectName}/${PathName.projectDashboard}/${PathName.dashboardSettings}`,
dashboardAffiliates: (projectName: string) =>
`/${PathName.project}/${projectName}/${PathName.projectDashboard}/${PathName.dashboardAffiliates}`,

badges: () => `/${PathName.badges}`,

about: () => `${AboutGeyserOrigin}`,
Expand Down

0 comments on commit 4b4ea2e

Please sign in to comment.