diff --git a/WebServices/client-frontend/src/app/(DashboardLayout)/management/budget/actions/page.tsx b/WebServices/client-frontend/src/app/(DashboardLayout)/management/budget/actions/page.tsx new file mode 100644 index 0000000..a0f6bd4 --- /dev/null +++ b/WebServices/client-frontend/src/app/(DashboardLayout)/management/budget/actions/page.tsx @@ -0,0 +1,27 @@ +"use server"; +import React from "react"; +import DashboardLayout from "@/components/layouts/DashboardLayout"; +import { useDashboardPage } from "@/components/common/hooks/useDashboardPage"; + +export default async function Dashboard({ + searchParams, +}: { + searchParams: Promise<{ [key: string]: string | undefined }>; +}) { + const { + activePage, + searchParamsInstance, + lang, + PageComponent, + siteUrlsList, + } = await useDashboardPage({ + pageUrl: "/management/budget/actions", + searchParams + }); + + return ( + + + + ); +} diff --git a/WebServices/client-frontend/src/app/(DashboardLayout)/management/budget/page.tsx b/WebServices/client-frontend/src/app/(DashboardLayout)/management/budget/status/page.tsx similarity index 94% rename from WebServices/client-frontend/src/app/(DashboardLayout)/management/budget/page.tsx rename to WebServices/client-frontend/src/app/(DashboardLayout)/management/budget/status/page.tsx index aa763f4..6a39d42 100644 --- a/WebServices/client-frontend/src/app/(DashboardLayout)/management/budget/page.tsx +++ b/WebServices/client-frontend/src/app/(DashboardLayout)/management/budget/status/page.tsx @@ -15,7 +15,7 @@ export default async function Dashboard({ PageComponent, siteUrlsList, } = await useDashboardPage({ - pageUrl: "/management/budget", + pageUrl: "/management/budget/status", searchParams }); diff --git a/WebServices/client-frontend/src/components/menu/IndexStore/store.tsx b/WebServices/client-frontend/src/components/menu/IndexStore/store.tsx index 3c18d2e..aa8602e 100644 --- a/WebServices/client-frontend/src/components/menu/IndexStore/store.tsx +++ b/WebServices/client-frontend/src/components/menu/IndexStore/store.tsx @@ -61,6 +61,24 @@ const ManagementAccounting = { siteUrl: "/management/accounting", }; +const BuildingBudgetActions = { + name: "BuildingBudgetActions", + lg: { + tr: "Son Bakiye", + en: "Last Balance", + }, + siteUrl: "/management/budget/actions", +}; + +const BuildingBudgetStatus = { + name: "BuildingBudgetStatus", + lg: { + tr: "Bakiye Durumu", + en: "Balance Status", + }, + siteUrl: "/management/budget/status", +}; + const ManagementBudget = { name: "ManagementBudget", lg: { @@ -207,7 +225,7 @@ const Menu = [ tr: "Cari işlemler", en: "Management Accounting", }, - subList: [ManagementAccounting, ManagementBudget, BuildPartsAccounting], + subList: [ManagementAccounting, ManagementBudget, BuildPartsAccounting, BuildingBudgetActions, BuildingBudgetStatus], }, { name: "Meetings", @@ -215,13 +233,7 @@ const Menu = [ tr: "Toplantılar", en: "Meetings", }, - subList: [ - AnnualMeeting, - AnnualMeetingClose, - EmergencyMeeting, - EmergencyMeetingClose, - MeetingParticipations, - ], + subList: [AnnualMeeting, AnnualMeetingClose, EmergencyMeeting, EmergencyMeetingClose, MeetingParticipations], }, ], }, diff --git a/WebServices/client-frontend/src/components/menu/NavigationMenu/index.tsx b/WebServices/client-frontend/src/components/menu/NavigationMenu/index.tsx index fc8a19b..b279cd9 100644 --- a/WebServices/client-frontend/src/components/menu/NavigationMenu/index.tsx +++ b/WebServices/client-frontend/src/components/menu/NavigationMenu/index.tsx @@ -29,19 +29,34 @@ const NavigationMenu: React.FC = ({ transformedMenu, lang, // Handle first level menu click const handleFirstLevelClick = (index: number) => { - // Only allow collapsing if we're not on an active page or if it's dashboard - if (activePage === "/dashboard" || !activeMenuPath) { - setFirstLayerIndex(index === firstLayerIndex ? -1 : index); - setSecondLayerIndex(-1); // Reset second layer selection when first layer changes + // If this is the active menu path and not dashboard, don't allow collapsing it + if (activeMenuPath && activeMenuPath.first === index && activePage !== "/dashboard") { + // Don't collapse the active menu item + return; + } + + // Otherwise allow expanding/collapsing any menu item + setFirstLayerIndex(index === firstLayerIndex ? -1 : index); + + // If we're clicking on a different first level, reset second level + if (index !== firstLayerIndex) { + setSecondLayerIndex(-1); } }; // Handle second level menu click const handleSecondLevelClick = (index: number) => { - // Only allow collapsing if we're not on an active page or if it's dashboard - if (activePage === "/dashboard" || !activeMenuPath) { - setSecondLayerIndex(index === secondLayerIndex ? -1 : index); + // If this is the active menu path and not dashboard, don't allow collapsing it + if (activeMenuPath && + activeMenuPath.first === firstLayerIndex && + activeMenuPath.second === index && + activePage !== "/dashboard") { + // Don't collapse the active menu item + return; } + + // Otherwise allow expanding/collapsing any menu item + setSecondLayerIndex(index === secondLayerIndex ? -1 : index); }; return ( diff --git a/WebServices/client-frontend/src/eventRouters/Pages/index.ts b/WebServices/client-frontend/src/eventRouters/Pages/index.ts deleted file mode 100644 index d54673e..0000000 --- a/WebServices/client-frontend/src/eventRouters/Pages/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { PageComponent } from "@/components/validations/translations/translation"; -import { peopleApplications } from "./people"; -import { dashboardApplications } from "./dashboard"; - -export const PageNavigator: Record> = { - "/individual": peopleApplications, - "/dashboard": dashboardApplications, -}; diff --git a/WebServices/client-frontend/src/eventRouters/Pages/tenantActions/index.ts b/WebServices/client-frontend/src/eventRouters/Pages/tenantActions/index.ts new file mode 100644 index 0000000..d6f044a --- /dev/null +++ b/WebServices/client-frontend/src/eventRouters/Pages/tenantActions/index.ts @@ -0,0 +1,6 @@ +import { PageComponent } from "@/components/validations/translations/translation"; +import TenantActionsSuperUserApp from "./superusers/app"; + +export const tenantBudgetActionsApplications: Record = { + app000023: TenantActionsSuperUserApp, +}; diff --git a/WebServices/client-frontend/src/eventRouters/Pages/tenantActions/superusers/app.tsx b/WebServices/client-frontend/src/eventRouters/Pages/tenantActions/superusers/app.tsx new file mode 100644 index 0000000..f01fd24 --- /dev/null +++ b/WebServices/client-frontend/src/eventRouters/Pages/tenantActions/superusers/app.tsx @@ -0,0 +1,9 @@ +import React from "react"; + +const TenantActionsSuperUserApp = () => { + return ( + <>

Tenant Budget Actions

+ ); +}; + +export default TenantActionsSuperUserApp; diff --git a/WebServices/client-frontend/src/eventRouters/Pages/tenantBudgetStatus/index.ts b/WebServices/client-frontend/src/eventRouters/Pages/tenantBudgetStatus/index.ts new file mode 100644 index 0000000..e2df46f --- /dev/null +++ b/WebServices/client-frontend/src/eventRouters/Pages/tenantBudgetStatus/index.ts @@ -0,0 +1,6 @@ +import { PageComponent } from "@/components/validations/translations/translation"; +import TenantBudgetStatusSuperUserApp from "./superusers/app"; + +export const tenantBudgetStatusApplications: Record = { + app000024: TenantBudgetStatusSuperUserApp, +}; diff --git a/WebServices/client-frontend/src/eventRouters/Pages/tenantBudgetStatus/superusers/app.tsx b/WebServices/client-frontend/src/eventRouters/Pages/tenantBudgetStatus/superusers/app.tsx new file mode 100644 index 0000000..17933c2 --- /dev/null +++ b/WebServices/client-frontend/src/eventRouters/Pages/tenantBudgetStatus/superusers/app.tsx @@ -0,0 +1,9 @@ +import React from "react"; + +const TenantBudgetStatusSuperUserApp = () => { + return ( + <>

Tenant Budget Status

+ ); +}; + +export default TenantBudgetStatusSuperUserApp; diff --git a/WebServices/client-frontend/src/eventRouters/index.tsx b/WebServices/client-frontend/src/eventRouters/index.tsx index fb8498e..b8de359 100644 --- a/WebServices/client-frontend/src/eventRouters/index.tsx +++ b/WebServices/client-frontend/src/eventRouters/index.tsx @@ -1,10 +1,12 @@ import { PageComponent } from "@/components/validations/translations/translation"; -import { peopleApplications } from "./Pages/people"; -import { dashboardApplications } from "./Pages/dashboard"; +import { peopleApplications } from "@/eventRouters/Pages/people"; +import { dashboardApplications } from "@/eventRouters/Pages/dashboard"; +import { tenantBudgetActionsApplications } from "@/eventRouters/Pages/tenantActions"; +import { tenantBudgetStatusApplications } from "@/eventRouters/Pages/tenantBudgetStatus"; export const menuPages: Record> = { "/individual": peopleApplications, "/dashboard": dashboardApplications, + "/management/budget/actions": tenantBudgetActionsApplications, + "/management/budget/status": tenantBudgetStatusApplications, }; - -export default menuPages; diff --git a/WebServices/client-frontend/src/eventRouters/pageRetriever.tsx b/WebServices/client-frontend/src/eventRouters/pageRetriever.tsx index d3286d9..d0b98db 100644 --- a/WebServices/client-frontend/src/eventRouters/pageRetriever.tsx +++ b/WebServices/client-frontend/src/eventRouters/pageRetriever.tsx @@ -1,6 +1,6 @@ import { PageProps } from "../validations/translations/translation"; import { UnAuthorizedPage } from "./unauthorizedpage"; -import menuPages from "./index"; +import { menuPages } from "@/eventRouters/index"; export function retrievePageByUrl(siteUrl: string, url: string): React.FC { console.log("siteUrl", siteUrl, "url", url); diff --git a/WebServices/client-frontend/src/webPages/auth/Select/page.tsx b/WebServices/client-frontend/src/webPages/auth/Select/page.tsx index 9b17cac..5c4e453 100644 --- a/WebServices/client-frontend/src/webPages/auth/Select/page.tsx +++ b/WebServices/client-frontend/src/webPages/auth/Select/page.tsx @@ -1,27 +1,23 @@ "use client"; +import { useState, useEffect } from "react"; import LoginOccupant from "./LoginOccupant"; import LoginEmployee from "./LoginEmployee"; -import { useState, useEffect } from "react"; -import { LanguageSelectionComponent } from "@/components/common/HeaderSelections/LanguageSelectionComponent"; import { Company, SelectListProps, BuildingMap } from "./types"; import { selectEmployeeTranslation, selectOccupantTranslation } from "./language"; +import { LanguageSelectionComponent } from "@/components/common/HeaderSelections/LanguageSelectionComponent"; const Select: React.FC = ({ selectionList, isEmployee, isOccupant, language }) => { - + const isEmployeeTrue = isEmployee && Array.isArray(selectionList) const isOccupantTrue = isOccupant && !Array.isArray(selectionList) const initTranslation = isEmployee ? selectEmployeeTranslation[language as "en" | "tr"] : selectOccupantTranslation[language as "en" | "tr"] - console.log("initTranslation", initTranslation); - const [lang, setLang] = useState(language); const [translation, setTranslation] = useState(initTranslation); const [listEmployeeSelection, setListEmployeeSelection] = useState(selectionList as Company[]); const [listOccupantSelection, setListOccupantSelection] = useState(selectionList as BuildingMap); - console.log("translation", translation); - useEffect(() => { if (isEmployee) { setListEmployeeSelection(selectionList as Company[]) } else if (isOccupant) { setListOccupantSelection(selectionList as BuildingMap) } @@ -43,7 +39,6 @@ const Select: React.FC = ({ selectionList, isEmployee, isOccupa
-

{translation?.select}

{isEmployeeTrue && } {isOccupantTrue && }
diff --git a/WebServices/management-frontend/src/apicalls/application/endpoints.tsx b/WebServices/management-frontend/src/apicalls/application/endpoints.tsx index 250aee5..7f87b8e 100644 --- a/WebServices/management-frontend/src/apicalls/application/endpoints.tsx +++ b/WebServices/management-frontend/src/apicalls/application/endpoints.tsx @@ -194,6 +194,7 @@ async function removeApplicationFromService(payload: RemoveApplicationFromServic } async function createApplication(payload: any) { + console.log("Creating application with payload:", payload); try { const response = await fetchDataWithToken( applicationCreateEndpoint, diff --git a/WebServices/management-frontend/src/app/api/utils/apiOperations.ts b/WebServices/management-frontend/src/app/api/utils/apiOperations.ts index dcfcafa..69a90fb 100644 --- a/WebServices/management-frontend/src/app/api/utils/apiOperations.ts +++ b/WebServices/management-frontend/src/app/api/utils/apiOperations.ts @@ -63,12 +63,13 @@ export async function handleCreateOperation( } if (createFunction) { + console.log("Body:", body); const result = await createFunction(body); return createResponse(result); } return createResponse({ - id: Math.floor(Math.random() * 1000), + uuid: Math.floor(Math.random() * 1000), ...body, }); } @@ -136,9 +137,15 @@ export function createCreateHandler( requiredFields: string[] = [] ) { console.log("Required fields:", requiredFields); - return withErrorHandling((body: any) => - handleCreateOperation(body, createFunction, requiredFields) - ); + // This handler only takes the body parameter, not the request + return withErrorHandling((body: any) => { + // Ensure we're only passing the actual body data to the create function + if (body && typeof body === 'object' && body.body) { + console.log("Extracting body from request body"); + return handleCreateOperation(body.body, createFunction, requiredFields); + } + return handleCreateOperation(body, createFunction, requiredFields); + }); } /** diff --git a/WebServices/management-frontend/src/app/api/utils/requestHandlers.ts b/WebServices/management-frontend/src/app/api/utils/requestHandlers.ts index 77a5be3..ec8ecda 100644 --- a/WebServices/management-frontend/src/app/api/utils/requestHandlers.ts +++ b/WebServices/management-frontend/src/app/api/utils/requestHandlers.ts @@ -1,6 +1,6 @@ import { NextRequest } from "next/server"; import { errorResponse } from "./responseHandlers"; -import { ValidationResult, ApiHandler } from "./types"; +import { ValidationResult, ApiHandler, ApiHandlerBodyOnly, ApiHandlerWithRequest } from "./types"; /** * Safely parse JSON request body with error handling @@ -30,7 +30,15 @@ export function withErrorHandling( return errorResponse("Invalid request body", 400); } - return await handler(request, body); + // Check handler parameter count to determine if it needs request object + // If handler has only 1 parameter, it's likely a create operation that only needs body + if (handler.length === 1) { + // Cast to the appropriate handler type + return await (handler as ApiHandlerBodyOnly)(body); + } else { + // Otherwise pass both request and body (for list, update, delete operations) + return await (handler as ApiHandlerWithRequest)(request, body); + } } catch (error: any) { return errorResponse( error.message || "Internal Server Error", diff --git a/WebServices/management-frontend/src/app/api/utils/types.ts b/WebServices/management-frontend/src/app/api/utils/types.ts index 9f6a914..990bf90 100644 --- a/WebServices/management-frontend/src/app/api/utils/types.ts +++ b/WebServices/management-frontend/src/app/api/utils/types.ts @@ -90,9 +90,11 @@ export const collectPaginationFromApiResponse = ( }; /** - * API handler function type + * API handler function types */ -export type ApiHandler = (request: NextRequest, body: any) => Promise; +export type ApiHandlerWithRequest = (request: NextRequest, body: any) => Promise; +export type ApiHandlerBodyOnly = (body: any) => Promise; +export type ApiHandler = ApiHandlerWithRequest | ApiHandlerBodyOnly; /** * List function type diff --git a/WebServices/management-frontend/src/components/common/FormDisplay/CreateComponent.tsx b/WebServices/management-frontend/src/components/common/FormDisplay/CreateComponent.tsx index 1a339bf..3e98437 100644 --- a/WebServices/management-frontend/src/components/common/FormDisplay/CreateComponent.tsx +++ b/WebServices/management-frontend/src/components/common/FormDisplay/CreateComponent.tsx @@ -103,7 +103,7 @@ export function CreateComponent({ const onSubmit: SubmitHandler> = async (data) => { try { if (apiUrl) { - const createUrl = `${apiUrl}/create`; + const createUrl = `${apiUrl}`; const response = await fetch(createUrl, { method: 'POST', headers: { @@ -252,7 +252,7 @@ export function CreateComponent({ return null; } }; - + return (
diff --git a/WebServices/management-frontend/src/components/common/FormDisplay/FormDisplay.tsx b/WebServices/management-frontend/src/components/common/FormDisplay/FormDisplay.tsx index ad50410..4518ac6 100644 --- a/WebServices/management-frontend/src/components/common/FormDisplay/FormDisplay.tsx +++ b/WebServices/management-frontend/src/components/common/FormDisplay/FormDisplay.tsx @@ -15,11 +15,10 @@ export function FormDisplay({ lang, translations, formProps = {}, - apiUrl, + apiUrls, }: FormDisplayProps) { const [enhancedFormProps, setEnhancedFormProps] = useState(formProps); - useEffect(() => { const updateFormProps = async () => { try { @@ -88,7 +87,7 @@ export function FormDisplay({ lang={lang} translations={translations} formProps={enhancedFormProps} - apiUrl={apiUrl} + apiUrl={apiUrls?.create} /> ); case "update": @@ -104,7 +103,7 @@ export function FormDisplay({ lang={lang} translations={translations} formProps={enhancedFormProps} - apiUrl={apiUrl} + apiUrl={apiUrls?.update} /> ) : null; case "view": diff --git a/WebServices/management-frontend/src/components/common/FormDisplay/UpdateComponent.tsx b/WebServices/management-frontend/src/components/common/FormDisplay/UpdateComponent.tsx index cebaa2c..1746998 100644 --- a/WebServices/management-frontend/src/components/common/FormDisplay/UpdateComponent.tsx +++ b/WebServices/management-frontend/src/components/common/FormDisplay/UpdateComponent.tsx @@ -180,7 +180,7 @@ export function UpdateComponent({ } }); - const updateUrl = `${apiUrl}/update?uuid=${uuid}`; + const updateUrl = `${apiUrl}?uuid=${uuid}`; console.log("Updating application with payload:", dataToSend, 'uuId:', uuid); try { let response = await fetch(updateUrl, { diff --git a/WebServices/management-frontend/src/components/common/FormDisplay/types.ts b/WebServices/management-frontend/src/components/common/FormDisplay/types.ts index af32e71..a23e5f9 100644 --- a/WebServices/management-frontend/src/components/common/FormDisplay/types.ts +++ b/WebServices/management-frontend/src/components/common/FormDisplay/types.ts @@ -47,5 +47,5 @@ export interface FormDisplayProps { lang: string; translations: Record>; formProps?: Record; - apiUrl: string; + apiUrls: Record; } diff --git a/WebServices/management-frontend/src/eventRouters/appenderApplication/page.tsx b/WebServices/management-frontend/src/eventRouters/appenderApplication/page.tsx index befab59..603accb 100644 --- a/WebServices/management-frontend/src/eventRouters/appenderApplication/page.tsx +++ b/WebServices/management-frontend/src/eventRouters/appenderApplication/page.tsx @@ -287,7 +287,7 @@ const AppendersApplicationPage: React.FC = ({ lang }: { lang: Languag onCancel: cancelAllSelections, lang: lang, translations: translationsServices, - apiUrl: '/api/services', + apiUrls: {}, formProps: { fieldDefinitions: fieldDefinitionsServices, validationSchema: validationSchemaServices, @@ -304,7 +304,7 @@ const AppendersApplicationPage: React.FC = ({ lang }: { lang: Languag onCancel: cancelAllSelections, lang: lang, translations: translationsApplications, - apiUrl: '/api/applications', + apiUrls: {}, formProps: { fieldDefinitions: fieldDefinitionsEvents, validationSchema: validationSchemaEvents, @@ -321,7 +321,7 @@ const AppendersApplicationPage: React.FC = ({ lang }: { lang: Languag onCancel: cancelAllSelections, lang: lang, translations: translationsAppenders, - apiUrl: '/api/appenders/applications', + apiUrls: {}, formProps: { fieldDefinitions: fieldDefinitionsAppenders, validationSchema: validationSchemaAppenders, @@ -329,7 +329,6 @@ const AppendersApplicationPage: React.FC = ({ lang }: { lang: Languag } }; - return (
@@ -343,19 +342,11 @@ const AppendersApplicationPage: React.FC = ({ lang }: { lang: Languag {mode === "list" ? (
- { - !selectedItemServices ?
: -
- -
- { - loadingEvents ? :
- } - { - loadingAppenders ? :
- } -
-
+ {!selectedItemServices ?
: +
+ {loadingEvents ? :
} + {loadingAppenders ? :
} +
}
) : ( diff --git a/WebServices/management-frontend/src/eventRouters/appendersEvents/page.tsx b/WebServices/management-frontend/src/eventRouters/appendersEvents/page.tsx index da5ce83..433240f 100644 --- a/WebServices/management-frontend/src/eventRouters/appendersEvents/page.tsx +++ b/WebServices/management-frontend/src/eventRouters/appendersEvents/page.tsx @@ -283,7 +283,7 @@ const AppendersEventsPage: React.FC = ({ lang }: { lang: Language }) onCancel: cancelAllSelections, lang: lang, translations: translationsServices, - apiUrl: '/api/services', + apiUrls: {}, formProps: { fieldDefinitions: fieldDefinitionsServices, validationSchema: validationSchemaServices, @@ -300,7 +300,7 @@ const AppendersEventsPage: React.FC = ({ lang }: { lang: Language }) onCancel: cancelAllSelections, lang: lang, translations: translationsEvents, - apiUrl: '/api/events', + apiUrls: {}, formProps: { fieldDefinitions: fieldDefinitionsEvents, validationSchema: validationSchemaEvents, @@ -317,7 +317,7 @@ const AppendersEventsPage: React.FC = ({ lang }: { lang: Language }) onCancel: cancelAllSelections, lang: lang, translations: translationsAppenders, - apiUrl: '/api/appenders', + apiUrls: {}, formProps: { fieldDefinitions: fieldDefinitionsAppenders, validationSchema: validationSchemaAppenders, diff --git a/WebServices/management-frontend/src/eventRouters/application/page.tsx b/WebServices/management-frontend/src/eventRouters/application/page.tsx index ad9caf6..a1a7ca2 100644 --- a/WebServices/management-frontend/src/eventRouters/application/page.tsx +++ b/WebServices/management-frontend/src/eventRouters/application/page.tsx @@ -118,7 +118,10 @@ const ApplicationPage: React.FC = ({ lang }: { lang: Language }) => { onCancel: cancelAllSelections, lang, translations, - apiUrl: '/api/applications', + apiUrls: { + create: '/api/applications/create', + update: '/api/applications/update', + }, formProps: { fieldDefinitions, validationSchema, diff --git a/WebServices/management-frontend/src/eventRouters/index.tsx b/WebServices/management-frontend/src/eventRouters/index.tsx index cb42453..e7d9992 100644 --- a/WebServices/management-frontend/src/eventRouters/index.tsx +++ b/WebServices/management-frontend/src/eventRouters/index.tsx @@ -7,7 +7,7 @@ const menuPages = { "/dashboard": DashboardPage, "/application": ApplicationPage, "/append/event": AppendersEventsPage, - "/append/service": AppendersServicePage + "/append/service": AppendersServicePage, }; export default menuPages; diff --git a/docker-compose.yml b/docker-compose.yml index 2f1fcc5..1d30cf4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,12 +10,9 @@ services: - "3000:3000" environment: - NODE_ENV=development - cpus: 1 + cpus: 2 mem_limit: 2048m - # volumes: - # - client-frontend:/WebServices/client-frontend - management_frontend: container_name: management_frontend build: @@ -117,7 +114,7 @@ services: context: . dockerfile: ApiServices/InitialService/Dockerfile environment: - - SET_ALEMBIC=1 + - SET_ALEMBIC=0 networks: - wag-services env_file: