From ee51842ca052fd4f00b7595b0587fca7d9d989b5 Mon Sep 17 00:00:00 2001 From: Lucas Bracher Date: Fri, 6 Sep 2024 11:11:09 -0300 Subject: [PATCH] feat(dashboard): "Under Development" message - shows "Under Development" message when "Devices" and "Labs" labels are clicked - labels change when clicked Closes #223 --- .../src/components/SideMenu/SideMenu.tsx | 24 ++++++++++++------- dashboard/src/locales/messages/index.ts | 1 + dashboard/src/routeTree.gen.ts | 20 +++++++++++++++- dashboard/src/routes/underDevelopment.tsx | 22 +++++++++++++++++ 4 files changed, 58 insertions(+), 9 deletions(-) create mode 100644 dashboard/src/routes/underDevelopment.tsx diff --git a/dashboard/src/components/SideMenu/SideMenu.tsx b/dashboard/src/components/SideMenu/SideMenu.tsx index fae7e9fa..b71bce7e 100644 --- a/dashboard/src/components/SideMenu/SideMenu.tsx +++ b/dashboard/src/components/SideMenu/SideMenu.tsx @@ -1,3 +1,5 @@ +import { useState, useMemo } from 'react'; + import { MdOutlineMonitorHeart } from 'react-icons/md'; import { ImTree, ImImages } from 'react-icons/im'; @@ -5,8 +7,6 @@ import { HiOutlineDocumentSearch } from 'react-icons/hi'; import { useRouter, useSearch } from '@tanstack/react-router'; -import { useMemo } from 'react'; - import { MessagesKey } from '@/locales/messages'; import { zOrigin } from '@/types/tree/Tree'; @@ -26,6 +26,7 @@ import SendFeedback from './SendFeedback'; import NavLink from './NavLink'; type RouteMenuItems = { + id: number; onClick: () => void; idIntl: MessagesKey; icon: JSX.Element; @@ -46,9 +47,8 @@ const linkItems: LinkMenuItems[] = [ }, ]; -const emptyFunc = (): void => {}; - const SideMenu = (): JSX.Element => { + const [selectedItemId, setSelectedItemId] = useState(0); const selectedItemClassName = 'w-full flex pl-5 py-4 cursor-pointer text-sky-500 bg-black border-l-4 border-sky-500'; const notSelectedItemClassName = @@ -74,19 +74,22 @@ const SideMenu = (): JSX.Element => { const routeItems: RouteMenuItems[] = [ { + id: 0, onClick: useNavigateTo('/'), idIntl: 'routes.treeMonitor', icon: , selected: true, }, { - onClick: emptyFunc, + id: 1, + onClick: useNavigateTo('/underDevelopment'), idIntl: 'routes.deviceMonitor', icon: , selected: false, }, { - onClick: emptyFunc, + id: 2, + onClick: useNavigateTo('/underDevelopment'), idIntl: 'routes.labsMonitor', icon: , selected: false, @@ -126,10 +129,15 @@ const SideMenu = (): JSX.Element => { {routeItems.map(item => ( { + setSelectedItemId(item.id); // Atualizando o item selecionado + item.onClick(); // Navegando ao clicar + }} > diff --git a/dashboard/src/locales/messages/index.ts b/dashboard/src/locales/messages/index.ts index 69dc9015..74e7e19f 100644 --- a/dashboard/src/locales/messages/index.ts +++ b/dashboard/src/locales/messages/index.ts @@ -124,6 +124,7 @@ export const messages = { 'global.timing': 'Timing', 'global.total': 'Total', 'global.tree': 'Tree', + 'global.underDevelopment': 'Under Development', 'global.unknown': 'Unknown', 'global.url': 'URL', 'global.valid': 'Valid', diff --git a/dashboard/src/routeTree.gen.ts b/dashboard/src/routeTree.gen.ts index 277de9db..99739d14 100644 --- a/dashboard/src/routeTree.gen.ts +++ b/dashboard/src/routeTree.gen.ts @@ -11,6 +11,7 @@ // Import Routes import { Route as rootRoute } from './routes/__root' +import { Route as UnderDevelopmentImport } from './routes/underDevelopment' import { Route as TreeRouteImport } from './routes/tree/route' import { Route as IndexImport } from './routes/index' import { Route as TreeIndexImport } from './routes/tree/index' @@ -23,6 +24,11 @@ import { Route as TreeTreeIdBuildBuildIdIndexImport } from './routes/tree/$treeI // Create/Update Routes +const UnderDevelopmentRoute = UnderDevelopmentImport.update({ + path: '/underDevelopment', + getParentRoute: () => rootRoute, +} as any) + const TreeRouteRoute = TreeRouteImport.update({ path: '/tree', getParentRoute: () => rootRoute, @@ -87,6 +93,13 @@ declare module '@tanstack/react-router' { preLoaderRoute: typeof TreeRouteImport parentRoute: typeof rootRoute } + '/underDevelopment': { + id: '/underDevelopment' + path: '/underDevelopment' + fullPath: '/underDevelopment' + preLoaderRoute: typeof UnderDevelopmentImport + parentRoute: typeof rootRoute + } '/tree/$treeId': { id: '/tree/$treeId' path: '/$treeId' @@ -156,6 +169,7 @@ export const routeTree = rootRoute.addChildren({ }), TreeIndexRoute, }), + UnderDevelopmentRoute, }) /* prettier-ignore-end */ @@ -167,7 +181,8 @@ export const routeTree = rootRoute.addChildren({ "filePath": "__root.tsx", "children": [ "/", - "/tree" + "/tree", + "/underDevelopment" ] }, "/": { @@ -180,6 +195,9 @@ export const routeTree = rootRoute.addChildren({ "/tree/" ] }, + "/underDevelopment": { + "filePath": "underDevelopment.tsx" + }, "/tree/$treeId": { "filePath": "tree/$treeId/route.tsx", "parent": "/tree", diff --git a/dashboard/src/routes/underDevelopment.tsx b/dashboard/src/routes/underDevelopment.tsx new file mode 100644 index 00000000..703cb151 --- /dev/null +++ b/dashboard/src/routes/underDevelopment.tsx @@ -0,0 +1,22 @@ +import { createFileRoute } from '@tanstack/react-router'; + +import { z } from 'zod'; + +import { FormattedMessage } from 'react-intl'; + +import { zOrigin } from '@/types/tree/Tree'; + +export const HomeSearchSchema = z.object({ + origin: zOrigin, +}); + +export const Route = createFileRoute('/underDevelopment')({ + validateSearch: HomeSearchSchema, + component: () => { + return ( +
+ +
+ ); + }, +});