updated app page and site urls
This commit is contained in:
parent
7c2150a8b0
commit
9b02620d1d
|
|
@ -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,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
<div className="flex h-screen overflow-hidden">
|
||||
{/* Sidebar */}
|
||||
<aside className="w-1/4 border-r p-4 overflow-y-auto">
|
||||
<LeftMenu
|
||||
pageUuidList={pageUuidList}
|
||||
lang={lang}
|
||||
searchParams={queryParams}
|
||||
/>
|
||||
</aside>
|
||||
<>
|
||||
<div className="flex h-screen overflow-hidden">
|
||||
{/* Sidebar */}
|
||||
<aside className="w-1/4 border-r p-4 overflow-y-auto">
|
||||
<LeftMenu
|
||||
pageUuidList={siteUrlsList}
|
||||
lang={lang}
|
||||
searchParams={searchParams}
|
||||
/>
|
||||
</aside>
|
||||
|
||||
{/* Main Content Area */}
|
||||
|
||||
<div className="flex flex-col w-3/4">
|
||||
{/* Sticky Header */}
|
||||
<header className="sticky top-0 bg-white shadow-md z-10 p-4 flex justify-between items-center">
|
||||
<h1 className="text-2xl font-semibold">Dashboard</h1>
|
||||
<div className="flex items-center space-x-4">
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Search..."
|
||||
className="border px-3 py-2 rounded-lg"
|
||||
/>
|
||||
<div className="w-10 h-10 bg-gray-300 rounded-full"></div>
|
||||
</div>
|
||||
</header>
|
||||
<MainPage pageSelected={pageSelected} lang={lang} />
|
||||
{/* Main Content Area */}
|
||||
<div className="flex flex-col w-3/4">
|
||||
{/* Sticky Header */}
|
||||
<header className="sticky top-0 bg-white shadow-md z-10 p-4 flex justify-between items-center">
|
||||
<h1 className="text-2xl font-semibold">Dashboard</h1>
|
||||
<div className="flex items-center space-x-4">
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Search..."
|
||||
className="border px-3 py-2 rounded-lg"
|
||||
/>
|
||||
<div className="w-10 h-10 bg-gray-300 rounded-full"></div>
|
||||
</div>
|
||||
</header>
|
||||
<PageComponent lang={lang} queryParams={searchParams} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
import React from "react";
|
||||
import { PageProps } from "./interFaces";
|
||||
|
||||
function App000001({ lang, queryParams }: PageProps) {
|
||||
return (
|
||||
<>
|
||||
<div className="flex flex-col w-3/4">
|
||||
{/* Sticky Header */}
|
||||
<header className="sticky top-0 bg-white shadow-md z-10 p-4 flex justify-between items-center">
|
||||
<h1 className="text-2xl font-semibold">Dashboard</h1>
|
||||
<div className="flex items-center space-x-4">
|
||||
{JSON.stringify({
|
||||
lang,
|
||||
queryParams,
|
||||
})}
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Search..."
|
||||
className="border px-3 py-2 rounded-lg"
|
||||
/>
|
||||
<div className="w-10 h-10 bg-gray-300 rounded-full"></div>
|
||||
</div>
|
||||
</header>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default App000001;
|
||||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
import { LanguageTranslation } from "@/components/menu/runner";
|
||||
|
||||
export interface PageProps {
|
||||
lang: string;
|
||||
lang: keyof LanguageTranslation;
|
||||
queryParams: { [key: string]: string | undefined };
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,10 +72,10 @@ async function LeftMenu({
|
|||
<div className="ml-5">
|
||||
{subItem.subList.map((subSubItem) => (
|
||||
<Link
|
||||
key={subSubItem.appUUID}
|
||||
href={`/dashboard?page=${subSubItem.appUUID}&menu=${firstIndex}*${secondIndex}`}
|
||||
key={subSubItem.name}
|
||||
href={`/dashboard?page=${subSubItem.name}&menu=${firstIndex}*${secondIndex}`}
|
||||
className={`flex flex-row text-xl py-4 my-4 w-full space-x-2 p-2 rounded ${
|
||||
pageSelected === subSubItem.appUUID
|
||||
pageSelected === subSubItem.name
|
||||
? " bg-gray-100 cursor-not-allowed"
|
||||
: "hover:bg-gray-200"
|
||||
}`}
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
* @param {Array} menu - The original menu structure
|
||||
* @returns {Array} - Filtered menu structure with only matching items
|
||||
*/
|
||||
import Menu from "@/menu/store"; // Assuming you have a menu structure imported
|
||||
import Menu from "@/components/menu/store"; // Assuming you have a menu structure imported
|
||||
|
||||
// Define TypeScript interfaces for menu structure
|
||||
interface LanguageTranslation {
|
||||
|
|
@ -15,7 +15,7 @@ interface LanguageTranslation {
|
|||
interface MenuThirdLevel {
|
||||
name: string;
|
||||
lg: LanguageTranslation;
|
||||
appList: string[];
|
||||
siteUrl: string;
|
||||
}
|
||||
|
||||
interface MenuSecondLevel {
|
||||
|
|
@ -34,7 +34,7 @@ interface MenuFirstLevel {
|
|||
interface FilteredMenuThirdLevel {
|
||||
name: string;
|
||||
lg: LanguageTranslation;
|
||||
appUUID: string;
|
||||
siteUrl: string;
|
||||
}
|
||||
|
||||
interface FilteredMenuSecondLevel {
|
||||
|
|
@ -51,12 +51,7 @@ interface FilteredMenuFirstLevel {
|
|||
|
||||
export type { LanguageTranslation };
|
||||
|
||||
function transformMenu(uuids: string[]) {
|
||||
// Helper function to check if arrays have at least one common element
|
||||
const hasIntersection = (array1: string[], array2: string[]): boolean => {
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -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 = [
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue