From 4b4ea2edf5e1e90b015d9608defb082f018d893e Mon Sep 17 00:00:00 2001 From: sajald77 Date: Thu, 1 Aug 2024 13:35:23 -0400 Subject: [PATCH] fix: update router paths --- src/config/routes/routeGroups.ts | 6 - src/config/routes/state/privateRoutesAtom.ts | 4 +- src/modules/navigation/topNavBar/index.ts | 7 +- .../navigation/topNavBar/topNavBarAtom.ts | 75 ------------ .../project/pages1/projectFunding/index.ts | 0 .../landing/components/LandingEntryCard.tsx | 4 +- .../components/ContributionActivityItem.tsx | 2 +- src/shared/constants/config/index.ts | 14 ++- src/shared/constants/config/routerPaths.ts | 112 ++++++++++++------ 9 files changed, 93 insertions(+), 131 deletions(-) create mode 100644 src/modules/project/pages1/projectFunding/index.ts diff --git a/src/config/routes/routeGroups.ts b/src/config/routes/routeGroups.ts index ab8c2bd47..58c21e793 100644 --- a/src/config/routes/routeGroups.ts +++ b/src/config/routes/routeGroups.ts @@ -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), diff --git a/src/config/routes/state/privateRoutesAtom.ts b/src/config/routes/state/privateRoutesAtom.ts index 931f4ec93..4c56e11d2 100644 --- a/src/config/routes/state/privateRoutesAtom.ts +++ b/src/config/routes/state/privateRoutesAtom.ts @@ -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' @@ -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) diff --git a/src/modules/navigation/topNavBar/index.ts b/src/modules/navigation/topNavBar/index.ts index 6d9d81692..aadc0539c 100644 --- a/src/modules/navigation/topNavBar/index.ts +++ b/src/modules/navigation/topNavBar/index.ts @@ -1,7 +1,2 @@ export { TopNavBar } from './TopNavBar' -export { - shouldShowProjectLogoAtom, - useIsProjectPage, - useRouteMatchesForTopNavBar, - useTopNavBarAnimate, -} from './topNavBarAtom' +export { shouldShowProjectLogoAtom, useIsProjectPage, useTopNavBarAnimate } from './topNavBarAtom' diff --git a/src/modules/navigation/topNavBar/topNavBarAtom.ts b/src/modules/navigation/topNavBar/topNavBarAtom.ts index 60707eaba..e0c4f5428 100644 --- a/src/modules/navigation/topNavBar/topNavBarAtom.ts +++ b/src/modules/navigation/topNavBar/topNavBarAtom.ts @@ -1,10 +1,6 @@ import { atom, useAtomValue } from 'jotai' import { - entryCreationRoutes, - fallBackRoutes, - grantRoutes, - landingRoutes, projectDashboardRoutes, projectPostCreatorRoutes, projectRewardCreatorRoutes, @@ -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, @@ -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) diff --git a/src/modules/project/pages1/projectFunding/index.ts b/src/modules/project/pages1/projectFunding/index.ts new file mode 100644 index 000000000..e69de29bb diff --git a/src/pages/landing/components/LandingEntryCard.tsx b/src/pages/landing/components/LandingEntryCard.tsx index b3edddaa7..42f4e5740 100644 --- a/src/pages/landing/components/LandingEntryCard.tsx +++ b/src/pages/landing/components/LandingEntryCard.tsx @@ -13,6 +13,8 @@ interface LandingEntryCardProps extends CardLayoutProps { export const LandingEntryCard = ({ entry, isMobile, ...rest }: LandingEntryCardProps) => { const navigate = useNavigate() + const projectName = entry.project?.name + if (!entry.project) { return null } @@ -20,7 +22,7 @@ export const LandingEntryCard = ({ entry, isMobile, ...rest }: LandingEntryCardP return ( navigate(getPath('entry', entry.id))} + onClick={() => projectName && navigate(getPath('projectPostView', projectName, entry.id))} imageSrc={toSmallImageUrl(`${entry.image}`)} title={entry.title} user={entry.creator} diff --git a/src/pages/landing/feed/components/ContributionActivityItem.tsx b/src/pages/landing/feed/components/ContributionActivityItem.tsx index c20018050..712c0fde4 100644 --- a/src/pages/landing/feed/components/ContributionActivityItem.tsx +++ b/src/pages/landing/feed/components/ContributionActivityItem.tsx @@ -57,7 +57,7 @@ export const ContributionActivityItem = ({ fundingTx, dateTime, count, showsProj return ( ) diff --git a/src/shared/constants/config/index.ts b/src/shared/constants/config/index.ts index 07c4b1ca3..0e426dd45 100644 --- a/src/shared/constants/config/index.ts +++ b/src/shared/constants/config/index.ts @@ -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' diff --git a/src/shared/constants/config/routerPaths.ts b/src/shared/constants/config/routerPaths.ts index 4a486668c..e0b488e0f 100644 --- a/src/shared/constants/config/routerPaths.ts +++ b/src/shared/constants/config/routerPaths.ts @@ -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', @@ -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}`, @@ -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) => @@ -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}`,