diff --git a/WebServices/client-frontend/src/apicalls/cookies/token.tsx b/WebServices/client-frontend/src/apicalls/cookies/token.tsx index e4dc29e..33a1fd0 100644 --- a/WebServices/client-frontend/src/apicalls/cookies/token.tsx +++ b/WebServices/client-frontend/src/apicalls/cookies/token.tsx @@ -3,9 +3,11 @@ import { fetchDataWithToken, fetchData } from "../api-fetcher"; import { baseUrlAuth, tokenSecret } from "../basics"; import { cookies } from "next/headers"; import NextCrypto from "next-crypto"; -import { console } from "inspector"; const checkToken = `${baseUrlAuth}/authentication/token/check`; +const pageValid = `${baseUrlAuth}/authentication/page/valid`; +const siteUrls = `${baseUrlAuth}/authentication/page/list`; + const nextCrypto = new NextCrypto(tokenSecret); async function checkAccessTokenIsValid() { @@ -13,6 +15,27 @@ async function checkAccessTokenIsValid() { return response?.status === 200 || response?.status === 202 ? true : false; } +async function retrievePageList() { + const response = await fetchDataWithToken(siteUrls, {}, "GET", false); + return response?.status === 200 || response?.status === 202 + ? response.data?.site_urls + : null; +} + +async function retrievePagebyUrl(pageUrl: string) { + const response = await fetchDataWithToken( + pageValid, + { + page_url: pageUrl, + }, + "POST", + false + ); + return response?.status === 200 || response?.status === 202 + ? response.data?.application + : null; +} + async function retrieveAccessToken() { const cookieStore = await cookies(); const encrpytAccessToken = cookieStore.get("accessToken")?.value || ""; @@ -112,5 +135,7 @@ export { retrieveUserType, retrieveAccessObjects, retrieveUserSelection, + retrievePagebyUrl, + retrievePageList, // retrieveavailablePages, }; diff --git a/WebServices/client-frontend/src/app/(AuthLayout)/dashboard/page.tsx b/WebServices/client-frontend/src/app/(AuthLayout)/dashboard/page.tsx index ebd353e..edb72ed 100644 --- a/WebServices/client-frontend/src/app/(AuthLayout)/dashboard/page.tsx +++ b/WebServices/client-frontend/src/app/(AuthLayout)/dashboard/page.tsx @@ -1,9 +1,12 @@ import React from "react"; -import { checkAccessTokenIsValid } from "@/apicalls/cookies/token"; +import { + checkAccessTokenIsValid, + retrievePageList, + retrievePagebyUrl, +} from "@/apicalls/cookies/token"; import { redirect } from "next/navigation"; - -import LeftMenu from "./leftMenu"; -import MainPage from "./main"; +import { retrievePage } from "@/components/NavigatePages"; +import LeftMenu from "@/components/menu/leftMenu"; export default async function DashboardLayout({ searchParams, @@ -11,47 +14,43 @@ export default async function DashboardLayout({ searchParams: { [key: string]: string | undefined }; }) { const token_is_valid = await checkAccessTokenIsValid(); + const siteUrlsList = await retrievePageList(); if (!token_is_valid) { redirect("/auth/login"); } - const pageUuidList = [ - "6015129b-f665-479c-a440-04fb82ea6114", - "14a98ae7-c64e-403d-9b53-32e7ea867ab4", - "e368137d-d548-4ed4-90da-337bcc5d1559", - "d3d97973-41c6-4bad-881b-6bf77d837fa5", - ]; // Mock data of pageUUID list [] - const lang = "tr"; // Assuming you have a way to determine the current language - const queryParams = await searchParams; - const pageSelected = queryParams?.page || undefined; + const lang = "tr"; + const pageToDirect = await retrievePagebyUrl("/dashboard"); + const PageComponent = retrievePage(pageToDirect); return ( -
- {/* Sidebar */} - + <> +
+ {/* Sidebar */} + - {/* Main Content Area */} - -
- {/* Sticky Header */} -
-

Dashboard

-
- -
-
-
- + {/* Main Content Area */} +
+ {/* Sticky Header */} +
+

Dashboard

+
+ +
+
+
+ +
-
+ ); } diff --git a/WebServices/client-frontend/src/components/NavigatePages/app000001.tsx b/WebServices/client-frontend/src/components/NavigatePages/app000001.tsx new file mode 100644 index 0000000..4a856af --- /dev/null +++ b/WebServices/client-frontend/src/components/NavigatePages/app000001.tsx @@ -0,0 +1,29 @@ +import React from "react"; +import { PageProps } from "./interFaces"; + +function App000001({ lang, queryParams }: PageProps) { + return ( + <> +
+ {/* Sticky Header */} +
+

Dashboard

+
+ {JSON.stringify({ + lang, + queryParams, + })} + +
+
+
+
+ + ); +} + +export default App000001; diff --git a/WebServices/client-frontend/src/components/NavigatePages/index.tsx b/WebServices/client-frontend/src/components/NavigatePages/index.tsx index fac3e5a..138005d 100644 --- a/WebServices/client-frontend/src/components/NavigatePages/index.tsx +++ b/WebServices/client-frontend/src/components/NavigatePages/index.tsx @@ -1,8 +1,11 @@ -import { PageProps } from "./interFaces"; +import React from "react"; +import App000001 from "./app000001"; import Page0001 from "./page0001"; +import { PageProps } from "./interFaces"; -const PageIndexs = { +export const PageIndexs = { "6015129b-f665-479c-a440-04fb82ea6114": Page0001, + app000001: App000001, }; function UnAuthorizedPage({ lang }: PageProps) { diff --git a/WebServices/client-frontend/src/components/NavigatePages/interFaces.tsx b/WebServices/client-frontend/src/components/NavigatePages/interFaces.tsx index 8157413..df3635d 100644 --- a/WebServices/client-frontend/src/components/NavigatePages/interFaces.tsx +++ b/WebServices/client-frontend/src/components/NavigatePages/interFaces.tsx @@ -1,3 +1,6 @@ +import { LanguageTranslation } from "@/components/menu/runner"; + export interface PageProps { - lang: string; + lang: keyof LanguageTranslation; + queryParams: { [key: string]: string | undefined }; } diff --git a/WebServices/client-frontend/src/app/(AuthLayout)/dashboard/leftMenu.tsx b/WebServices/client-frontend/src/components/menu/leftMenu.tsx similarity index 95% rename from WebServices/client-frontend/src/app/(AuthLayout)/dashboard/leftMenu.tsx rename to WebServices/client-frontend/src/components/menu/leftMenu.tsx index 7dfc94f..cbaa308 100644 --- a/WebServices/client-frontend/src/app/(AuthLayout)/dashboard/leftMenu.tsx +++ b/WebServices/client-frontend/src/components/menu/leftMenu.tsx @@ -72,10 +72,10 @@ async function LeftMenu({
{subItem.subList.map((subSubItem) => ( { - return array1.some((item) => array2.includes(item)); - }; - +function transformMenu(siteUrls: string[]) { // Process the menu structure const filteredMenu: FilteredMenuFirstLevel[] = Menu.reduce( (acc: FilteredMenuFirstLevel[], firstLevel: MenuFirstLevel) => { @@ -78,28 +73,20 @@ function transformMenu(uuids: string[]) { // Process third level items secondLevel.subList.forEach((thirdLevel: MenuThirdLevel) => { - // Check if the third level's appList has an intersection with our UUIDs + // Check if the third level's siteUrl matches exactly if ( - thirdLevel.appList && - hasIntersection(thirdLevel.appList, uuids) + thirdLevel.siteUrl && + siteUrls.some((url) => url === thirdLevel.siteUrl) ) { - // Find the first matching UUID - const matchedUUID = thirdLevel.appList.find((uuid) => - uuids.includes(uuid) - ); + // Create a modified third level item + const newThirdLevel: FilteredMenuThirdLevel = { + name: thirdLevel.name, + lg: { ...thirdLevel.lg }, + siteUrl: thirdLevel.siteUrl, + }; - // Only proceed if we found a matching UUID (should always be true due to hasIntersection) - if (matchedUUID) { - // Create a modified third level item with the matched UUID - const newThirdLevel: FilteredMenuThirdLevel = { - name: thirdLevel.name, - lg: { ...thirdLevel.lg }, - appUUID: matchedUUID, - }; - - // Add the modified third level to the second level's subList - newSecondLevel.subList.push(newThirdLevel); - } + // Add the modified third level to the second level's subList + newSecondLevel.subList.push(newThirdLevel); } }); diff --git a/WebServices/client-frontend/src/components/menu/store.tsx b/WebServices/client-frontend/src/components/menu/store.tsx index c42f952..ed69428 100644 --- a/WebServices/client-frontend/src/components/menu/store.tsx +++ b/WebServices/client-frontend/src/components/menu/store.tsx @@ -4,10 +4,7 @@ const Individual = { tr: "Birey", en: "Individual", }, - appList: [ - "0362071d-90d9-48db-8fa0-3528aaf450bd", - "6015129b-f665-479c-a440-04fb82ea6114", - ], + siteUrl: "/individual", }; const User = { @@ -16,7 +13,7 @@ const User = { tr: "Kullanıcı", en: "User", }, - appList: ["14a98ae7-c64e-403d-9b53-32e7ea867ab4"], + siteUrl: "/user", }; const Build = { @@ -25,7 +22,7 @@ const Build = { tr: "Apartman", en: "Build", }, - appList: ["e368137d-d548-4ed4-90da-337bcc5d1559"], + siteUrl: "/build", }; const BuildParts = { @@ -34,7 +31,7 @@ const BuildParts = { tr: "Daire", en: "BuildParts", }, - appList: [], + siteUrl: "/build/parts", }; const BuildArea = { @@ -43,7 +40,7 @@ const BuildArea = { tr: "Daire", en: "BuildArea", }, - appList: [], + siteUrl: "/build/area", }; const ManagementAccounting = { @@ -52,7 +49,7 @@ const ManagementAccounting = { tr: "Yönetim Cari Hareketler", en: "ManagementAccounting", }, - appList: [], + siteUrl: "/management/accounting", }; const ManagementBudget = { @@ -61,7 +58,7 @@ const ManagementBudget = { tr: "Yönetim Bütçe İşlemleri", en: "Management Budget", }, - appList: [], + siteUrl: "/management/budget", }; const BuildPartsAccounting = { @@ -70,7 +67,7 @@ const BuildPartsAccounting = { tr: "Daire Cari Hareketler", en: "Build Parts Accounting", }, - appList: [], + siteUrl: "/build/parts/accounting", }; const AnnualMeeting = { @@ -79,7 +76,7 @@ const AnnualMeeting = { tr: "Yıllık Olağan Toplantı Tanımlama ve Davet", en: "Annual Meetings and Invitations", }, - appList: ["d3d97973-41c6-4bad-881b-6bf77d837fa5"], + siteUrl: "/annual/meeting", }; const AnnualMeetingClose = { @@ -88,7 +85,7 @@ const AnnualMeetingClose = { tr: "Yıllık Olağan Toplantı kapatma ve Cari Yaratma", en: "Annual Meeting Close and Accountings", }, - appList: [], + siteUrl: "/annual/meeting/close", }; const EmergencyMeeting = { @@ -97,7 +94,7 @@ const EmergencyMeeting = { tr: "Acil Toplantı Tanımlama ve Davet", en: "Emergency Meeting and Invitations", }, - appList: [], + siteUrl: "emergency/meeting", }; const EmergencyMeetingClose = { @@ -106,7 +103,7 @@ const EmergencyMeetingClose = { tr: "Acil Olağan Toplantı kapatma ve Cari Yaratma", en: "Emergency Meeting Close and Accountings", }, - appList: [], + siteUrl: "/emergency/meeting/close", }; const MeetingParticipations = { @@ -115,7 +112,7 @@ const MeetingParticipations = { tr: "Toplantı Katılım İşlemleri", en: "Meeting Participations", }, - appList: ["SomeUUID"], + siteUrl: "/meeting/participations", }; const Menu = [ diff --git a/docker-compose.yml b/docker-compose.yml index 367a591..ccbef27 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -49,19 +49,19 @@ services: ports: - "11222:6379" -# client_frontend: -# container_name: client_frontend -# build: -# context: . -# dockerfile: WebServices/client-frontend/Dockerfile -# networks: -# - wag-services -# ports: -# - "3000:3000" -# # volumes: -# # - client-frontend:/WebServices/client-frontend -# environment: -# - NODE_ENV=development + client_frontend: + container_name: client_frontend + build: + context: . + dockerfile: WebServices/client-frontend/Dockerfile + networks: + - wag-services + ports: + - "3000:3000" + # volumes: + # - client-frontend:/WebServices/client-frontend + environment: + - NODE_ENV=development # management_frontend: # container_name: management_frontend @@ -77,19 +77,19 @@ services: # environment: # - NODE_ENV=development -# initializer_service: -# container_name: initializer_service -# build: -# context: . -# dockerfile: ApiServices/InitialService/Dockerfile -# networks: -# - wag-services -# env_file: -# - api_env.env -# depends_on: -# - postgres-service -# - mongo_service -# - redis_service + # initializer_service: + # container_name: initializer_service + # build: + # context: . + # dockerfile: ApiServices/InitialService/Dockerfile + # networks: + # - wag-services + # env_file: + # - api_env.env + # depends_on: + # - postgres-service + # - mongo_service + # - redis_service dealer_service: container_name: dealer_service @@ -105,33 +105,33 @@ services: - mongo_service - redis_service -# template_service: -# container_name: template_service -# build: -# context: . -# dockerfile: ApiServices/TemplateService/Dockerfile -# networks: -# - wag-services -# env_file: -# - api_env.env -# environment: -# - API_PATH=app:app -# - API_HOST=0.0.0.0 -# - API_PORT=8000 -# - API_LOG_LEVEL=info -# - API_RELOAD=1 -# - API_ACCESS_TOKEN_TAG=1 -# - API_APP_NAME=evyos-template-api-gateway -# - API_TITLE=WAG API Template Api Gateway -# - API_FORGOT_LINK=https://template_service/forgot-password -# - API_DESCRIPTION=This api is serves as web template api gateway only to evyos web services. -# - API_APP_URL=https://template_service -# ports: -# - "8000:8000" -# depends_on: -# - postgres-service -# - mongo_service -# - redis_service + # template_service: + # container_name: template_service + # build: + # context: . + # dockerfile: ApiServices/TemplateService/Dockerfile + # networks: + # - wag-services + # env_file: + # - api_env.env + # environment: + # - API_PATH=app:app + # - API_HOST=0.0.0.0 + # - API_PORT=8000 + # - API_LOG_LEVEL=info + # - API_RELOAD=1 + # - API_ACCESS_TOKEN_TAG=1 + # - API_APP_NAME=evyos-template-api-gateway + # - API_TITLE=WAG API Template Api Gateway + # - API_FORGOT_LINK=https://template_service/forgot-password + # - API_DESCRIPTION=This api is serves as web template api gateway only to evyos web services. + # - API_APP_URL=https://template_service + # ports: + # - "8000:8000" + # depends_on: + # - postgres-service + # - mongo_service + # - redis_service auth_service: container_name: auth_service