web service tenant first try
This commit is contained in:
parent
aee9d59750
commit
4d7a6e6ec0
|
|
@ -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 (
|
||||
<DashboardLayout lang={lang} activePage={activePage} siteUrls={siteUrlsList} >
|
||||
<PageComponent lang={lang} queryParams={searchParamsInstance} />
|
||||
</DashboardLayout>
|
||||
);
|
||||
}
|
||||
|
|
@ -15,7 +15,7 @@ export default async function Dashboard({
|
|||
PageComponent,
|
||||
siteUrlsList,
|
||||
} = await useDashboardPage({
|
||||
pageUrl: "/management/budget",
|
||||
pageUrl: "/management/budget/status",
|
||||
searchParams
|
||||
});
|
||||
|
||||
|
|
@ -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],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
|
|||
|
|
@ -29,19 +29,34 @@ const NavigationMenu: React.FC<NavigationMenuProps> = ({ 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 (
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
import { PageComponent } from "@/components/validations/translations/translation";
|
||||
import { peopleApplications } from "./people";
|
||||
import { dashboardApplications } from "./dashboard";
|
||||
|
||||
export const PageNavigator: Record<string, Record<string, PageComponent>> = {
|
||||
"/individual": peopleApplications,
|
||||
"/dashboard": dashboardApplications,
|
||||
};
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
import { PageComponent } from "@/components/validations/translations/translation";
|
||||
import TenantActionsSuperUserApp from "./superusers/app";
|
||||
|
||||
export const tenantBudgetActionsApplications: Record<string, PageComponent> = {
|
||||
app000023: TenantActionsSuperUserApp,
|
||||
};
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
import React from "react";
|
||||
|
||||
const TenantActionsSuperUserApp = () => {
|
||||
return (
|
||||
<><h1>Tenant Budget Actions</h1></>
|
||||
);
|
||||
};
|
||||
|
||||
export default TenantActionsSuperUserApp;
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
import { PageComponent } from "@/components/validations/translations/translation";
|
||||
import TenantBudgetStatusSuperUserApp from "./superusers/app";
|
||||
|
||||
export const tenantBudgetStatusApplications: Record<string, PageComponent> = {
|
||||
app000024: TenantBudgetStatusSuperUserApp,
|
||||
};
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
import React from "react";
|
||||
|
||||
const TenantBudgetStatusSuperUserApp = () => {
|
||||
return (
|
||||
<><h1>Tenant Budget Status</h1></>
|
||||
);
|
||||
};
|
||||
|
||||
export default TenantBudgetStatusSuperUserApp;
|
||||
|
|
@ -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<string, Record<string, PageComponent>> = {
|
||||
"/individual": peopleApplications,
|
||||
"/dashboard": dashboardApplications,
|
||||
"/management/budget/actions": tenantBudgetActionsApplications,
|
||||
"/management/budget/status": tenantBudgetStatusApplications,
|
||||
};
|
||||
|
||||
export default menuPages;
|
||||
|
|
|
|||
|
|
@ -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<PageProps> {
|
||||
console.log("siteUrl", siteUrl, "url", url);
|
||||
|
|
|
|||
|
|
@ -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<SelectListProps> = ({ 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<Company[]>(selectionList as Company[]);
|
||||
const [listOccupantSelection, setListOccupantSelection] = useState<BuildingMap>(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<SelectListProps> = ({ selectionList, isEmployee, isOccupa
|
|||
|
||||
<div className="flex h-full min-h-[inherit] flex-col items-center justify-center gap-4">
|
||||
<div className="w-full max-w-md rounded-lg bg-white p-8 shadow-md">
|
||||
<h2 className="mb-6 text-center text-2xl font-bold text-gray-900">{translation?.select}</h2>
|
||||
{isEmployeeTrue && <LoginEmployee translation={translation} selectionList={listEmployeeSelection} />}
|
||||
{isOccupantTrue && <LoginOccupant translation={translation} selectionList={listOccupantSelection} />}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -90,9 +90,11 @@ export const collectPaginationFromApiResponse = (
|
|||
};
|
||||
|
||||
/**
|
||||
* API handler function type
|
||||
* API handler function types
|
||||
*/
|
||||
export type ApiHandler = (request: NextRequest, body: any) => Promise<Response>;
|
||||
export type ApiHandlerWithRequest = (request: NextRequest, body: any) => Promise<Response>;
|
||||
export type ApiHandlerBodyOnly = (body: any) => Promise<Response>;
|
||||
export type ApiHandler = ApiHandlerWithRequest | ApiHandlerBodyOnly;
|
||||
|
||||
/**
|
||||
* List function type
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ export function CreateComponent<T>({
|
|||
const onSubmit: SubmitHandler<Record<string, any>> = 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<T>({
|
|||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return (
|
||||
<form onSubmit={handleSubmit(onSubmit)}>
|
||||
<div className="grid grid-cols-2 gap-4 pt-6 my-4">
|
||||
|
|
|
|||
|
|
@ -15,11 +15,10 @@ export function FormDisplay<T>({
|
|||
lang,
|
||||
translations,
|
||||
formProps = {},
|
||||
apiUrl,
|
||||
apiUrls,
|
||||
}: FormDisplayProps<T>) {
|
||||
const [enhancedFormProps, setEnhancedFormProps] = useState(formProps);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
const updateFormProps = async () => {
|
||||
try {
|
||||
|
|
@ -88,7 +87,7 @@ export function FormDisplay<T>({
|
|||
lang={lang}
|
||||
translations={translations}
|
||||
formProps={enhancedFormProps}
|
||||
apiUrl={apiUrl}
|
||||
apiUrl={apiUrls?.create}
|
||||
/>
|
||||
);
|
||||
case "update":
|
||||
|
|
@ -104,7 +103,7 @@ export function FormDisplay<T>({
|
|||
lang={lang}
|
||||
translations={translations}
|
||||
formProps={enhancedFormProps}
|
||||
apiUrl={apiUrl}
|
||||
apiUrl={apiUrls?.update}
|
||||
/>
|
||||
) : null;
|
||||
case "view":
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ export function UpdateComponent<T>({
|
|||
}
|
||||
});
|
||||
|
||||
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, {
|
||||
|
|
|
|||
|
|
@ -47,5 +47,5 @@ export interface FormDisplayProps<T> {
|
|||
lang: string;
|
||||
translations: Record<string, Record<string, string>>;
|
||||
formProps?: Record<string, any>;
|
||||
apiUrl: string;
|
||||
apiUrls: Record<string, string>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -287,7 +287,7 @@ const AppendersApplicationPage: React.FC<PageProps> = ({ 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<PageProps> = ({ 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<PageProps> = ({ 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<PageProps> = ({ lang }: { lang: Languag
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
return (
|
||||
<div className="container mx-auto p-4 overflow-y-auto" >
|
||||
<div className="mb-4 flex justify-between items-center">
|
||||
|
|
@ -343,19 +342,11 @@ const AppendersApplicationPage: React.FC<PageProps> = ({ lang }: { lang: Languag
|
|||
</Card>
|
||||
{mode === "list" ? (
|
||||
<div className="flex flex-col space-y-4">
|
||||
{
|
||||
!selectedItemServices ? <div className="w-full h-1/2"><ListComponentServices {...serviceListProps} /></div> :
|
||||
<div className="w-full h-1/2">
|
||||
|
||||
<div className="flex flex-row space-x-4">
|
||||
{
|
||||
loadingEvents ? <Loader /> : <div className="flex-1"><ListComponentEvents {...eventsListProps} /></div>
|
||||
}
|
||||
{
|
||||
loadingAppenders ? <Loader /> : <div className="flex-1"><ListComponentEvents {...appendersListProps} /></div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
{!selectedItemServices ? <div className="w-full h-1/2"><ListComponentServices {...serviceListProps} /></div> :
|
||||
<div className="w-full h-1/2"><div className="flex flex-row space-x-4">
|
||||
{loadingEvents ? <Loader /> : <div className="flex-1"><ListComponentEvents {...eventsListProps} /></div>}
|
||||
{loadingAppenders ? <Loader /> : <div className="flex-1"><ListComponentEvents {...appendersListProps} /></div>}
|
||||
</div></div>
|
||||
}
|
||||
</div>
|
||||
) : (
|
||||
|
|
|
|||
|
|
@ -283,7 +283,7 @@ const AppendersEventsPage: React.FC<PageProps> = ({ 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<PageProps> = ({ 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<PageProps> = ({ lang }: { lang: Language })
|
|||
onCancel: cancelAllSelections,
|
||||
lang: lang,
|
||||
translations: translationsAppenders,
|
||||
apiUrl: '/api/appenders',
|
||||
apiUrls: {},
|
||||
formProps: {
|
||||
fieldDefinitions: fieldDefinitionsAppenders,
|
||||
validationSchema: validationSchemaAppenders,
|
||||
|
|
|
|||
|
|
@ -118,7 +118,10 @@ const ApplicationPage: React.FC<PageProps> = ({ lang }: { lang: Language }) => {
|
|||
onCancel: cancelAllSelections,
|
||||
lang,
|
||||
translations,
|
||||
apiUrl: '/api/applications',
|
||||
apiUrls: {
|
||||
create: '/api/applications/create',
|
||||
update: '/api/applications/update',
|
||||
},
|
||||
formProps: {
|
||||
fieldDefinitions,
|
||||
validationSchema,
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ const menuPages = {
|
|||
"/dashboard": DashboardPage,
|
||||
"/application": ApplicationPage,
|
||||
"/append/event": AppendersEventsPage,
|
||||
"/append/service": AppendersServicePage
|
||||
"/append/service": AppendersServicePage,
|
||||
};
|
||||
|
||||
export default menuPages;
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Reference in New Issue