From 115540ba4ac2cd559486dd8227b59e13d0039016 Mon Sep 17 00:00:00 2001 From: Sepehr Safari Date: Tue, 30 Jan 2024 20:58:23 +0330 Subject: [PATCH 1/3] feat: add page for link-to-project widget --- src/pages/widgets/index.ts | 1 + src/pages/widgets/linkToProject/index.tsx | 25 +++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 src/pages/widgets/index.ts create mode 100644 src/pages/widgets/linkToProject/index.tsx diff --git a/src/pages/widgets/index.ts b/src/pages/widgets/index.ts new file mode 100644 index 000000000..69af18dd6 --- /dev/null +++ b/src/pages/widgets/index.ts @@ -0,0 +1 @@ +export * from './linkToProject' diff --git a/src/pages/widgets/linkToProject/index.tsx b/src/pages/widgets/linkToProject/index.tsx new file mode 100644 index 000000000..d0f489f69 --- /dev/null +++ b/src/pages/widgets/linkToProject/index.tsx @@ -0,0 +1,25 @@ +import { useParams } from 'react-router-dom' + +import { useColorMode } from '@chakra-ui/react' +import { useEffect } from 'react' +import { ButtonComponent } from '../../../components/ui' + +export const LinkToProject = () => { + document.documentElement.style.background = 'transparent' + document.body.style.background = 'transparent' + + const { projectId } = useParams() + const { colorMode, toggleColorMode } = useColorMode() + + useEffect(() => { + colorMode === 'dark' && toggleColorMode() + }, [toggleColorMode, colorMode]) + + return ( +
+ + Go to project + +
+ ) +} From 078bbed93f1297e4f16aade0f1a6cd9aee474453 Mon Sep 17 00:00:00 2001 From: Sepehr Safari Date: Tue, 30 Jan 2024 20:58:53 +0330 Subject: [PATCH 2/3] fix: allow cors for widgets --- server.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/server.ts b/server.ts index 5b232f88e..dddfcda84 100644 --- a/server.ts +++ b/server.ts @@ -28,6 +28,17 @@ app.use((request, response) => { return handler(request, response, { public: './dist', rewrites: [{ source: '*', destination: '/index.html' }], + headers: [ + { + source: '/widgets/**', + headers: [ + { + key: 'Access-Control-Allow-Origin', + value: '*', + }, + ], + }, + ], }) }) From c17f112ea3a58a4b5fc998381e9e2cbc49b7f3fe Mon Sep 17 00:00:00 2001 From: Sepehr Safari Date: Tue, 30 Jan 2024 20:59:18 +0330 Subject: [PATCH 3/3] feat: add routes for widgets --- src/config/routes/routes.tsx | 38 ++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/src/config/routes/routes.tsx b/src/config/routes/routes.tsx index 84f54ce62..df2ebd605 100644 --- a/src/config/routes/routes.tsx +++ b/src/config/routes/routes.tsx @@ -18,6 +18,7 @@ const ProfilePage = () => import('../../pages/profile/Profile') const Badges = () => import('../../pages/badges/BadgesPage') const Landing = () => import('../../pages/landing') const AboutPage = () => import('../../pages/about/About') +const Widgets = () => import('../../pages/widgets') export const platformRoutes: RouteObject[] = [ { @@ -316,7 +317,7 @@ export const platformRoutes: RouteObject[] = [ path: getPath('projectManageRewards', PathName.projectId), async lazy() { const ProjectManageRewards = await Project().then( - (m) => m.ProjectManageRewards, + (m) => m.ProjectManageRewards, ) return { element: renderPrivateRoute(ProjectManageRewards), @@ -326,18 +327,24 @@ export const platformRoutes: RouteObject[] = [ { path: getPath('projectCreateReward', PathName.projectId), async lazy() { - const ProjectCreateReward = await Project() - .then((m) => m.ProjectCreateReward) + const ProjectCreateReward = await Project().then( + (m) => m.ProjectCreateReward, + ) return { element: renderPrivateRoute(ProjectCreateReward), } }, }, { - path: getPath('projectEditReward', PathName.projectId, PathName.rewardId), + path: getPath( + 'projectEditReward', + PathName.projectId, + PathName.rewardId, + ), async lazy() { - const ProjectEditReward = await Project() - .then((m) => m.ProjectEditReward) + const ProjectEditReward = await Project().then( + (m) => m.ProjectEditReward, + ) return { element: renderPrivateRoute(ProjectEditReward), } @@ -443,6 +450,16 @@ export const platformRoutes: RouteObject[] = [ }, ] +export const widgetsRoutesV1: RouteObject[] = [ + { + path: '/widgets/v1/link-to-project/:projectId', + async lazy() { + const LinkToProject = await Widgets().then((m) => m.LinkToProject) + return { Component: LinkToProject } + }, + }, +] + export const router = createBrowserRouter([ { path: '/', @@ -455,6 +472,15 @@ export const router = createBrowserRouter([ ErrorBoundary, // , }, + { + path: '/widgets', + children: [ + { + path: '/widgets/v1', + children: widgetsRoutesV1, + }, + ], + }, ], }, ])