updated appenders service
This commit is contained in:
parent
01f3e82a54
commit
0cde34a9bc
|
|
@ -30,3 +30,23 @@ def service_list_route(
|
|||
FoundCluster = ServiceEndpointRouterCluster.get_event_cluster("ServiceList")
|
||||
event_cluster_matched = FoundCluster.match_event(event_key=event_key)
|
||||
return event_cluster_matched.event_callable(data=data)
|
||||
|
||||
|
||||
@service_endpoint_route.post(
|
||||
path="/to/events",
|
||||
description="List events of a service endpoint given service UUID",
|
||||
operation_id="7b6b0c6a-e3db-4353-a7df-ea49d2a67f8a",
|
||||
)
|
||||
def service_to_events_route(
|
||||
data: PaginateOnly,
|
||||
headers: CommonHeaders = Depends(CommonHeaders.as_dependency),
|
||||
):
|
||||
"""
|
||||
List events of a service given service UUID
|
||||
"""
|
||||
token_object = TokenProvider.get_dict_from_redis(token=headers.token)
|
||||
event_founder_dict = dict(endpoint_code=headers.operation_id, token=token_object)
|
||||
event_key = TokenProvider.retrieve_event_codes(**event_founder_dict)
|
||||
FoundCluster = ServiceEndpointRouterCluster.get_event_cluster("ServiceToEvents")
|
||||
event_cluster_matched = FoundCluster.match_event(event_key=event_key)
|
||||
return event_cluster_matched.event_callable(data=data)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
from ApiControllers.abstracts.event_clusters import EventCluster, RouterCluster
|
||||
from .supers_events import (
|
||||
ServiceEndpointListEvent,
|
||||
ServiceEndpointToEventsEvent,
|
||||
)
|
||||
|
||||
ServiceEndpointRouterCluster = RouterCluster(name="ServiceEndpointRouterCluster")
|
||||
|
|
@ -8,4 +9,10 @@ ServiceEndpointEventClusterList = EventCluster(
|
|||
name="ServiceList", endpoint_uu_id="f4e4d332-70b1-4121-9fcc-a08850b72aaa"
|
||||
)
|
||||
ServiceEndpointEventClusterList.add_event(ServiceEndpointListEvent)
|
||||
|
||||
ServiceEndpointEventClusterToService = EventCluster(
|
||||
name="ServiceToEvents", endpoint_uu_id="7b6b0c6a-e3db-4353-a7df-ea49d2a67f8a"
|
||||
)
|
||||
ServiceEndpointEventClusterToService.add_event(ServiceEndpointToEventsEvent)
|
||||
|
||||
ServiceEndpointRouterCluster.set_event_cluster(ServiceEndpointEventClusterList)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
from ApiControllers.abstracts.event_clusters import Event
|
||||
from Controllers.Postgres.pagination import Pagination, PaginationResult, PaginateOnly
|
||||
from Controllers.Postgres.response import EndpointResponse
|
||||
from Schemas import Services
|
||||
from Schemas import Services, Service2Events
|
||||
|
||||
|
||||
# List endpoint
|
||||
|
|
@ -27,8 +27,35 @@ def service_endpoint_list_callable(data: PaginateOnly):
|
|||
pagination = Pagination(data=services_list)
|
||||
pagination.change(**data.model_dump())
|
||||
pagination_result = PaginationResult(data=services_list, pagination=pagination)
|
||||
print("service pagination_result", pagination_result)
|
||||
return EndpointResponse(message="MSG0003-LIST", pagination_result=pagination_result).response
|
||||
|
||||
|
||||
ServiceEndpointListEvent.event_callable = service_endpoint_list_callable
|
||||
|
||||
# To events endpoint
|
||||
ServiceEndpointToEventsEvent = Event(
|
||||
name="service_endpoint_to_events",
|
||||
key="7b6b0c6a-e3db-4353-a7df-ea49d2a67f8a",
|
||||
request_validator=None, # TODO: Add request validator
|
||||
response_validator=None, # TODO: Add response validator
|
||||
description="Super Users List events of a service endpoint given service UUID",
|
||||
)
|
||||
|
||||
|
||||
def service_endpoint_to_events_callable(data: PaginateOnly):
|
||||
"""
|
||||
List events of a service given service UUID
|
||||
"""
|
||||
list_options = PaginateOnly(**data.model_dump())
|
||||
with Service2Events.new_session() as db_session:
|
||||
if data.query:
|
||||
services_list = Service2Events.filter_all_system(*Service2Events.convert(data.query), db=db_session)
|
||||
else:
|
||||
services_list = Service2Events.filter_all_system(db=db_session)
|
||||
pagination = Pagination(data=services_list)
|
||||
pagination.change(**data.model_dump())
|
||||
pagination_result = PaginationResult(data=services_list, pagination=pagination)
|
||||
return EndpointResponse(message="MSG0003-LIST", pagination_result=pagination_result).response
|
||||
|
||||
|
||||
ServiceEndpointToEventsEvent.event_callable = service_endpoint_to_events_callable
|
||||
|
|
|
|||
|
|
@ -0,0 +1,84 @@
|
|||
"use server";
|
||||
|
||||
import { fetchDataWithToken } from "../api-fetcher";
|
||||
import { baseUrlApplication } from "../basics";
|
||||
import { PaginationParams } from "../schemas/list";
|
||||
import type { PaginatedApiResponse } from "@/app/api/utils/types";
|
||||
|
||||
const eventsListEndpoint = `${baseUrlApplication}/events/list`;
|
||||
|
||||
async function listEvents(payload: PaginationParams): Promise<PaginatedApiResponse<any>> {
|
||||
try {
|
||||
const response = await fetchDataWithToken(
|
||||
eventsListEndpoint,
|
||||
{
|
||||
page: payload.page,
|
||||
size: payload.size,
|
||||
order_field: payload.orderField,
|
||||
order_type: payload.orderType,
|
||||
query: payload.query,
|
||||
},
|
||||
"POST",
|
||||
false
|
||||
);
|
||||
|
||||
if (response?.status === 200 || response?.status === 202) {
|
||||
const responseData = response.data as PaginatedApiResponse<any>;
|
||||
return {
|
||||
data: responseData.data || [],
|
||||
pagination: {
|
||||
page: responseData.pagination?.page || 1,
|
||||
size: responseData.pagination?.size || 10,
|
||||
totalCount: responseData.pagination?.totalCount || 0,
|
||||
totalItems: responseData.pagination?.totalItems || 0,
|
||||
totalPages: responseData.pagination?.totalPages || 0,
|
||||
pageCount: responseData.pagination?.pageCount || 0,
|
||||
orderField: responseData.pagination?.orderField || ['name'],
|
||||
orderType: responseData.pagination?.orderType || ['asc'],
|
||||
query: responseData.pagination?.query || {},
|
||||
next: responseData.pagination?.next || false,
|
||||
back: responseData.pagination?.back || false
|
||||
}
|
||||
};
|
||||
}
|
||||
return {
|
||||
data: [],
|
||||
pagination: {
|
||||
page: 1,
|
||||
size: 10,
|
||||
totalCount: 0,
|
||||
totalItems: 0,
|
||||
totalPages: 0,
|
||||
pageCount: 0,
|
||||
orderField: ['name'],
|
||||
orderType: ['asc'],
|
||||
query: {},
|
||||
next: false,
|
||||
back: false
|
||||
}
|
||||
};
|
||||
} catch (error) {
|
||||
console.error("Error fetching events list:", error);
|
||||
// Return a default empty response instead of null to match the expected return type
|
||||
return {
|
||||
data: [],
|
||||
pagination: {
|
||||
page: 1,
|
||||
size: 10,
|
||||
totalCount: 0,
|
||||
totalItems: 0,
|
||||
totalPages: 0,
|
||||
pageCount: 0,
|
||||
orderField: ['name'],
|
||||
orderType: ['asc'],
|
||||
query: {},
|
||||
next: false,
|
||||
back: false
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
listEvents,
|
||||
};
|
||||
|
|
@ -6,6 +6,7 @@ import { PaginationParams } from "../schemas/list";
|
|||
import type { PaginatedApiResponse } from "@/app/api/utils/types";
|
||||
|
||||
const servicesListEndpoint = `${baseUrlApplication}/service/list`;
|
||||
const servicesToEventsEndpoint = `${baseUrlApplication}/service/to/events`;
|
||||
|
||||
async function listServices(payload: PaginationParams): Promise<PaginatedApiResponse<any>> {
|
||||
try {
|
||||
|
|
@ -79,6 +80,78 @@ async function listServices(payload: PaginationParams): Promise<PaginatedApiResp
|
|||
}
|
||||
}
|
||||
|
||||
async function listEventsToService(payload: PaginationParams): Promise<PaginatedApiResponse<any>> {
|
||||
try {
|
||||
const response = await fetchDataWithToken(
|
||||
servicesToEventsEndpoint,
|
||||
{
|
||||
page: payload.page,
|
||||
size: payload.size,
|
||||
order_field: payload.orderField,
|
||||
order_type: payload.orderType,
|
||||
query: payload.query,
|
||||
},
|
||||
"POST",
|
||||
false,
|
||||
);
|
||||
if (response?.status === 200 || response?.status === 202) {
|
||||
const responseData = response.data as PaginatedApiResponse<any>;
|
||||
return {
|
||||
data: responseData.data || [],
|
||||
pagination: {
|
||||
page: responseData.pagination?.page || 1,
|
||||
size: responseData.pagination?.size || 10,
|
||||
totalCount: responseData.pagination?.totalCount || 0,
|
||||
totalItems: responseData.pagination?.totalItems || 0,
|
||||
totalPages: responseData.pagination?.totalPages || 0,
|
||||
pageCount: responseData.pagination?.pageCount || 0,
|
||||
orderField: responseData.pagination?.orderField || ['name'],
|
||||
orderType: responseData.pagination?.orderType || ['asc'],
|
||||
query: responseData.pagination?.query || {},
|
||||
next: responseData.pagination?.next || false,
|
||||
back: responseData.pagination?.back || false
|
||||
}
|
||||
};
|
||||
}
|
||||
return {
|
||||
data: [],
|
||||
pagination: {
|
||||
page: 1,
|
||||
size: 10,
|
||||
totalCount: 0,
|
||||
totalItems: 0,
|
||||
totalPages: 0,
|
||||
pageCount: 0,
|
||||
orderField: ['name'],
|
||||
orderType: ['asc'],
|
||||
query: {},
|
||||
next: false,
|
||||
back: false
|
||||
}
|
||||
};
|
||||
} catch (error) {
|
||||
console.error("Error fetching application list:", error);
|
||||
// Return a default empty response instead of null to match the expected return type
|
||||
return {
|
||||
data: [],
|
||||
pagination: {
|
||||
page: 1,
|
||||
size: 10,
|
||||
totalCount: 0,
|
||||
totalItems: 0,
|
||||
totalPages: 0,
|
||||
pageCount: 0,
|
||||
orderField: ['name'],
|
||||
orderType: ['asc'],
|
||||
query: {},
|
||||
next: false,
|
||||
back: false
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
listServices,
|
||||
listEventsToService,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { listApplications } from "@/apicalls/application/endpoints";
|
||||
import { listEventsToService } from "@/apicalls/services/endpoints";
|
||||
import { createListHandler } from "@/app/api/utils";
|
||||
|
||||
export const POST = createListHandler(listApplications);
|
||||
export const POST = createListHandler(listEventsToService);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { listApplications } from "@/apicalls/application/endpoints";
|
||||
import { listEvents } from "@/apicalls/events/endpoints";
|
||||
import { createListHandler } from "@/app/api/utils";
|
||||
|
||||
export const POST = createListHandler(listApplications);
|
||||
export const POST = createListHandler(listEvents);
|
||||
|
|
|
|||
|
|
@ -6,10 +6,13 @@ import {
|
|||
ServiceBaseTranslationEn,
|
||||
ServiceBaseTranslationTr,
|
||||
} from "./schemaList/services";
|
||||
import {
|
||||
AppenderBaseTranslationEn,
|
||||
AppenderBaseTranslationTr,
|
||||
} from "./schemaList/appenders";
|
||||
|
||||
export const translations = {
|
||||
const translations = {
|
||||
en: {
|
||||
...ServiceBaseTranslationEn,
|
||||
// Page title
|
||||
mainTitle: "Services",
|
||||
|
||||
|
|
@ -74,7 +77,7 @@ export const translations = {
|
|||
},
|
||||
tr: {
|
||||
// Page title
|
||||
...ServiceBaseTranslationTr,
|
||||
|
||||
mainTitle: "Servisler",
|
||||
|
||||
// Common actions
|
||||
|
|
@ -137,6 +140,46 @@ export const translations = {
|
|||
},
|
||||
};
|
||||
|
||||
const translationsServices = {
|
||||
en: {
|
||||
...translations.en,
|
||||
...ServiceBaseTranslationEn,
|
||||
},
|
||||
tr: {
|
||||
...translations.tr,
|
||||
...ServiceBaseTranslationTr,
|
||||
},
|
||||
};
|
||||
|
||||
const translationsAppenders = {
|
||||
en: {
|
||||
...translations.en,
|
||||
...AppenderBaseTranslationEn,
|
||||
},
|
||||
tr: {
|
||||
...translations.tr,
|
||||
...AppenderBaseTranslationTr,
|
||||
},
|
||||
};
|
||||
|
||||
const translationsEvents = {
|
||||
en: {
|
||||
...translations.en,
|
||||
// ...EventBaseTranslationEn,
|
||||
},
|
||||
tr: {
|
||||
...translations.tr,
|
||||
// ...EventBaseTranslationTr,
|
||||
},
|
||||
};
|
||||
|
||||
export {
|
||||
translations,
|
||||
translationsServices,
|
||||
translationsAppenders,
|
||||
translationsEvents,
|
||||
};
|
||||
|
||||
export function getTranslation(lang: LanguageKey): TranslationSet {
|
||||
return translations[lang];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,11 +2,16 @@
|
|||
import React, { useState, useEffect } from "react";
|
||||
import { z } from "zod";
|
||||
|
||||
import * as schemaServices from "./schemaList/services";
|
||||
import {
|
||||
ServiceData,
|
||||
serviceViewFieldDefinitions,
|
||||
ServiceFieldDefinitionsType,
|
||||
ServiceSchema,
|
||||
} from "./schemaList/services";
|
||||
import * as schema from "./schemaList/schema";
|
||||
|
||||
import { ListComponentEvents, ListComponentServices } from "./listComponent";
|
||||
import { translations } from "./language";
|
||||
import { translations, translationsServices, translationsAppenders, translationsEvents } from "./language";
|
||||
|
||||
import { PageProps } from "@/validations/translations/translation";
|
||||
import { FormModeView, FormMode } from "@/components/common/FormDisplay/types";
|
||||
|
|
@ -26,7 +31,7 @@ const AppendersServicePage: React.FC<PageProps> = ({ lang }: { lang: Language })
|
|||
error: errorServices,
|
||||
updatePagination: updatePaginationServices,
|
||||
refetch: refetchServices
|
||||
} = useApiData<schemaServices.ServiceData>('/api/services');
|
||||
} = useApiData<ServiceData>('/api/services');
|
||||
const {
|
||||
data: dataEvents,
|
||||
pagination: paginationEvents,
|
||||
|
|
@ -47,11 +52,11 @@ const AppendersServicePage: React.FC<PageProps> = ({ lang }: { lang: Language })
|
|||
const [mode, setMode] = useState<FormModeView | FormMode>("list");
|
||||
const [gridCols, setGridCols] = useState<GridSize>(3);
|
||||
|
||||
const [selectedItemServices, setSelectedItemServices] = useState<schemaServices.ServiceData | null>(null);
|
||||
const [selectedItemServices, setSelectedItemServices] = useState<ServiceData | null>(null);
|
||||
const [selectedItemEvents, setSelectedItemEvents] = useState<schema.ApplicationData | null>(null);
|
||||
const [selectedItemAppenders, setSelectedItemAppenders] = useState<schema.ApplicationData | null>(null);
|
||||
|
||||
const [fieldDefinitionsServices, setFieldDefinitionsServices] = useState<schemaServices.FieldDefinitionsType | null>(null);
|
||||
const [fieldDefinitionsServices, setFieldDefinitionsServices] = useState<ServiceFieldDefinitionsType | null>(null);
|
||||
const [fieldDefinitionsEvents, setFieldDefinitionsEvents] = useState<schema.FieldDefinitionsType | null>(null);
|
||||
const [fieldDefinitionsAppenders, setFieldDefinitionsAppenders] = useState<schema.FieldDefinitionsType | null>(null);
|
||||
|
||||
|
|
@ -63,7 +68,7 @@ const AppendersServicePage: React.FC<PageProps> = ({ lang }: { lang: Language })
|
|||
const showFieldsEvents = ["description", "marketing_layer", "cost"];
|
||||
|
||||
useEffect(() => {
|
||||
setFieldDefinitionsServices(schemaServices.viewFieldDefinitions); setValidationSchemaServices(schemaServices.ViewServiceSchema);
|
||||
setFieldDefinitionsServices(serviceViewFieldDefinitions); setValidationSchemaServices(ServiceSchema);
|
||||
setFieldDefinitionsEvents(schema.viewFieldDefinitions); setValidationSchemaEvents(schema.ViewApplicationSchema);
|
||||
setFieldDefinitionsAppenders(schema.viewFieldDefinitions); setValidationSchemaAppenders(schema.ViewApplicationSchema);
|
||||
}, [lang]);
|
||||
|
|
@ -73,8 +78,8 @@ const AppendersServicePage: React.FC<PageProps> = ({ lang }: { lang: Language })
|
|||
if (value === null) { delete newQuery[key] } else if (value.trim() === "") { delete newQuery[key] } else { newQuery[key] = value }
|
||||
updatePaginationServices({ page: 1, query: newQuery })
|
||||
};
|
||||
const handleServicesCardClick = (item: schemaServices.ServiceData) => { setSelectedItemServices(item); setMode("list"); };
|
||||
const handleServicesViewClick = (item: schemaServices.ServiceData) => { setSelectedItemServices(item); setMode("view"); };
|
||||
const handleServicesCardClick = (item: ServiceData) => { setSelectedItemServices(item); setMode("list"); };
|
||||
const handleServicesViewClick = (item: ServiceData) => { setSelectedItemServices(item); setMode("view"); };
|
||||
|
||||
const handleEventsCardClick = (item: schema.ApplicationData) => { console.log("Events Card clicked:", item) };
|
||||
const handleEventsViewClick = (item: schema.ApplicationData) => { setSelectedItemEvents(item); setMode("view"); };
|
||||
|
|
@ -142,7 +147,7 @@ const AppendersServicePage: React.FC<PageProps> = ({ lang }: { lang: Language })
|
|||
setSelectedItem: setSelectedItemServices,
|
||||
onCancel: cancelAllSelections,
|
||||
lang: lang,
|
||||
translations: translations,
|
||||
translations: translationsServices,
|
||||
apiUrl: '/api/services',
|
||||
formProps: {
|
||||
fieldDefinitions: fieldDefinitionsServices,
|
||||
|
|
@ -159,7 +164,7 @@ const AppendersServicePage: React.FC<PageProps> = ({ lang }: { lang: Language })
|
|||
setSelectedItem: setSelectedItemEvents,
|
||||
onCancel: cancelAllSelections,
|
||||
lang: lang,
|
||||
translations: translations,
|
||||
translations: translationsEvents,
|
||||
apiUrl: '/api/events',
|
||||
formProps: {
|
||||
fieldDefinitions: fieldDefinitionsEvents,
|
||||
|
|
@ -168,6 +173,10 @@ const AppendersServicePage: React.FC<PageProps> = ({ lang }: { lang: Language })
|
|||
}
|
||||
};
|
||||
|
||||
const removeAppendersFromEvents = (events: schema.ApplicationData[], appenders: schema.ApplicationData[]) => {
|
||||
|
||||
}
|
||||
|
||||
const appendersFormProps = {
|
||||
initialData: selectedItemAppenders || undefined,
|
||||
mode: mode,
|
||||
|
|
@ -176,7 +185,7 @@ const AppendersServicePage: React.FC<PageProps> = ({ lang }: { lang: Language })
|
|||
setSelectedItem: setSelectedItemAppenders,
|
||||
onCancel: cancelAllSelections,
|
||||
lang: lang,
|
||||
translations: translations,
|
||||
translations: translationsAppenders,
|
||||
apiUrl: '/api/appenders',
|
||||
formProps: {
|
||||
fieldDefinitions: fieldDefinitionsAppenders,
|
||||
|
|
@ -209,7 +218,7 @@ const AppendersServicePage: React.FC<PageProps> = ({ lang }: { lang: Language })
|
|||
</div>
|
||||
) : (
|
||||
<div className="flex flex-col space-y-4">
|
||||
{selectedItemServices && <FormDisplay<schemaServices.ServiceData> {...serviceFormProps} />}
|
||||
{selectedItemServices && <FormDisplay<ServiceData> {...serviceFormProps} />}
|
||||
{selectedItemEvents && <FormDisplay<schema.ApplicationData> {...eventsFormProps} />}
|
||||
{selectedItemAppenders && <FormDisplay<schema.ApplicationData> {...appendersFormProps} />}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,171 @@
|
|||
import { z } from "zod";
|
||||
import { flattenFieldDefinitions } from "@/eventRouters/schemas/zodSchemas";
|
||||
|
||||
interface AppendersData {
|
||||
uu_id: string;
|
||||
service_uu_id: string;
|
||||
event_uu_id: string;
|
||||
is_confirmed: boolean;
|
||||
active: boolean;
|
||||
deleted?: boolean;
|
||||
created_at?: string;
|
||||
updated_at?: string;
|
||||
}
|
||||
|
||||
const errorMessages = {
|
||||
en: {
|
||||
serviceUuIdRequired: "Service UUID is required",
|
||||
eventUuIdRequired: "Event UUID is required",
|
||||
},
|
||||
tr: {
|
||||
serviceUuIdRequired: "Servis UUID'si gereklidir",
|
||||
eventUuIdRequired: "Etkinlik UUID'si gereklidir",
|
||||
},
|
||||
};
|
||||
|
||||
const getServiceBaseSchema = (lang: "en" | "tr" = "en") =>
|
||||
z.object({
|
||||
uu_id: z.string().optional(),
|
||||
service_uu_id: z.string().min(1, errorMessages[lang].serviceUuIdRequired),
|
||||
event_uu_id: z.string().min(1, errorMessages[lang].eventUuIdRequired),
|
||||
is_confirmed: z.boolean().default(false),
|
||||
active: z.boolean().default(true),
|
||||
deleted: z.boolean().default(false),
|
||||
created_at: z.string().optional(),
|
||||
updated_at: z.string().optional(),
|
||||
});
|
||||
|
||||
const AppenderBaseSchema = getServiceBaseSchema("en");
|
||||
|
||||
const AppenderBaseTranslationTr = {
|
||||
uu_id: "UUID",
|
||||
service_uu_id: "Servis UUID'si",
|
||||
event_uu_id: "Etkinlik UUID'si",
|
||||
is_confirmed: "Onaylandı",
|
||||
active: "Active",
|
||||
deleted: "Deleted",
|
||||
created_at: "Created At",
|
||||
updated_at: "Updated At",
|
||||
};
|
||||
|
||||
const AppenderBaseTranslationEn = {
|
||||
uu_id: "UUID",
|
||||
service_uu_id: "Service UUID",
|
||||
event_uu_id: "Event UUID",
|
||||
is_confirmed: "Confirmed",
|
||||
active: "Active",
|
||||
deleted: "Deleted",
|
||||
created_at: "Created At",
|
||||
updated_at: "Updated At",
|
||||
};
|
||||
|
||||
const serviceBaseFieldDefinitions = {
|
||||
identificationInfo: {
|
||||
title: "Service Information",
|
||||
order: 1,
|
||||
fields: {
|
||||
uu_id: {
|
||||
type: "text",
|
||||
label: {
|
||||
tr: AppenderBaseTranslationTr.uu_id,
|
||||
en: AppenderBaseTranslationEn.uu_id,
|
||||
},
|
||||
readOnly: true,
|
||||
required: false,
|
||||
},
|
||||
service_uu_id: {
|
||||
type: "text",
|
||||
label: {
|
||||
tr: AppenderBaseTranslationTr.service_uu_id,
|
||||
en: AppenderBaseTranslationEn.service_uu_id,
|
||||
},
|
||||
readOnly: false,
|
||||
required: true,
|
||||
},
|
||||
event_uu_id: {
|
||||
type: "text",
|
||||
label: {
|
||||
tr: AppenderBaseTranslationTr.event_uu_id,
|
||||
en: AppenderBaseTranslationEn.event_uu_id,
|
||||
},
|
||||
readOnly: false,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
statusInfo: {
|
||||
title: "Status Information",
|
||||
order: 3,
|
||||
fields: {
|
||||
active: {
|
||||
type: "checkbox",
|
||||
label: {
|
||||
tr: AppenderBaseTranslationTr.active,
|
||||
en: AppenderBaseTranslationEn.active,
|
||||
},
|
||||
readOnly: false,
|
||||
required: false,
|
||||
defaultValue: true,
|
||||
},
|
||||
deleted: {
|
||||
type: "checkbox",
|
||||
label: {
|
||||
tr: AppenderBaseTranslationTr.deleted,
|
||||
en: AppenderBaseTranslationEn.deleted,
|
||||
},
|
||||
readOnly: true,
|
||||
required: false,
|
||||
defaultValue: false,
|
||||
},
|
||||
is_confirmed: {
|
||||
type: "checkbox",
|
||||
label: {
|
||||
tr: AppenderBaseTranslationTr.is_confirmed,
|
||||
en: AppenderBaseTranslationEn.is_confirmed,
|
||||
},
|
||||
readOnly: false,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
systemInfo: {
|
||||
title: "System Information",
|
||||
order: 4,
|
||||
fields: {
|
||||
created_at: {
|
||||
type: "date",
|
||||
label: {
|
||||
tr: AppenderBaseTranslationTr.created_at,
|
||||
en: AppenderBaseTranslationEn.created_at,
|
||||
},
|
||||
readOnly: true,
|
||||
required: false,
|
||||
},
|
||||
updated_at: {
|
||||
type: "date",
|
||||
label: {
|
||||
tr: AppenderBaseTranslationTr.updated_at,
|
||||
en: AppenderBaseTranslationEn.updated_at,
|
||||
},
|
||||
readOnly: true,
|
||||
required: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
const ViewAppenderSchema = AppenderBaseSchema;
|
||||
const AppenderSchema = AppenderBaseSchema;
|
||||
const appenderFlatFieldDefinitions = flattenFieldDefinitions(
|
||||
serviceBaseFieldDefinitions
|
||||
);
|
||||
type AppenderFieldDefinitionsType = typeof appenderFlatFieldDefinitions;
|
||||
|
||||
export type { AppendersData, AppenderFieldDefinitionsType };
|
||||
export {
|
||||
AppenderSchema,
|
||||
appenderFlatFieldDefinitions,
|
||||
AppenderBaseTranslationEn,
|
||||
AppenderBaseTranslationTr,
|
||||
};
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
import { z } from "zod";
|
||||
import { flattenFieldDefinitions } from "@/eventRouters/schemas/zodSchemas";
|
||||
|
||||
export interface ServiceData {
|
||||
interface ServiceData {
|
||||
uu_id: string;
|
||||
module_uu_id: string;
|
||||
service_name: string;
|
||||
|
|
@ -44,8 +44,7 @@ const getServiceBaseSchema = (lang: "en" | "tr" = "en") =>
|
|||
});
|
||||
|
||||
const ServiceBaseSchema = getServiceBaseSchema("en");
|
||||
|
||||
export const ServiceBaseTranslationTr = {
|
||||
const ServiceBaseTranslationTr = {
|
||||
uu_id: "UUID",
|
||||
module_uu_id: "Modül UUID'si",
|
||||
service_name: "Servis Adı",
|
||||
|
|
@ -58,8 +57,7 @@ export const ServiceBaseTranslationTr = {
|
|||
created_at: "Created At",
|
||||
updated_at: "Updated At",
|
||||
};
|
||||
|
||||
export const ServiceBaseTranslationEn = {
|
||||
const ServiceBaseTranslationEn = {
|
||||
uu_id: "UUID",
|
||||
module_uu_id: "Module UUID",
|
||||
service_name: "Service Name",
|
||||
|
|
@ -72,21 +70,9 @@ export const ServiceBaseTranslationEn = {
|
|||
created_at: "Created At",
|
||||
updated_at: "Updated At",
|
||||
};
|
||||
|
||||
const ViewServiceSchema = ServiceBaseSchema;
|
||||
const ServiceSchema = ServiceBaseSchema;
|
||||
|
||||
export {
|
||||
ServiceBaseSchema,
|
||||
ServiceSchema,
|
||||
ViewServiceSchema,
|
||||
getServiceBaseSchema,
|
||||
};
|
||||
|
||||
export type ServiceFormData = z.infer<typeof ServiceSchema>;
|
||||
export type ViewServiceFormData = z.infer<typeof ViewServiceSchema>;
|
||||
|
||||
const baseFieldDefinitions = {
|
||||
const serviceBaseFieldDefinitions = {
|
||||
identificationInfo: {
|
||||
title: "Service Information",
|
||||
order: 1,
|
||||
|
|
@ -209,90 +195,100 @@ const baseFieldDefinitions = {
|
|||
},
|
||||
},
|
||||
};
|
||||
|
||||
const flatFieldDefinitions = flattenFieldDefinitions(baseFieldDefinitions);
|
||||
export const viewFieldDefinitions = {
|
||||
const serviceFlatFieldDefinitions = flattenFieldDefinitions(
|
||||
serviceBaseFieldDefinitions
|
||||
);
|
||||
const serviceViewFieldDefinitions = {
|
||||
uu_id: {
|
||||
...flatFieldDefinitions.uu_id,
|
||||
...serviceFlatFieldDefinitions.uu_id,
|
||||
readOnly: true,
|
||||
required: false,
|
||||
defaultValue: 0,
|
||||
},
|
||||
module_uu_id: {
|
||||
...flatFieldDefinitions.module_uu_id,
|
||||
...serviceFlatFieldDefinitions.module_uu_id,
|
||||
readOnly: true,
|
||||
required: false,
|
||||
defaultValue: "",
|
||||
},
|
||||
service_name: {
|
||||
...flatFieldDefinitions.service_name,
|
||||
...serviceFlatFieldDefinitions.service_name,
|
||||
readOnly: true,
|
||||
required: false,
|
||||
defaultValue: "",
|
||||
},
|
||||
service_description: {
|
||||
...flatFieldDefinitions.service_description,
|
||||
...serviceFlatFieldDefinitions.service_description,
|
||||
readOnly: true,
|
||||
required: false,
|
||||
defaultValue: "",
|
||||
},
|
||||
service_code: {
|
||||
...flatFieldDefinitions.service_code,
|
||||
...serviceFlatFieldDefinitions.service_code,
|
||||
readOnly: true,
|
||||
required: false,
|
||||
defaultValue: "",
|
||||
},
|
||||
related_responsibility: {
|
||||
...flatFieldDefinitions.related_responsibility,
|
||||
...serviceFlatFieldDefinitions.related_responsibility,
|
||||
readOnly: true,
|
||||
required: false,
|
||||
defaultValue: "",
|
||||
},
|
||||
active: {
|
||||
...flatFieldDefinitions.active,
|
||||
...serviceFlatFieldDefinitions.active,
|
||||
readOnly: true,
|
||||
required: false,
|
||||
defaultValue: true,
|
||||
},
|
||||
is_confirmed: {
|
||||
...flatFieldDefinitions.is_confirmed,
|
||||
...serviceFlatFieldDefinitions.is_confirmed,
|
||||
readOnly: true,
|
||||
required: false,
|
||||
defaultValue: true,
|
||||
},
|
||||
deleted: {
|
||||
...flatFieldDefinitions.deleted,
|
||||
...serviceFlatFieldDefinitions.deleted,
|
||||
readOnly: true,
|
||||
required: false,
|
||||
defaultValue: false,
|
||||
},
|
||||
created_at: {
|
||||
...flatFieldDefinitions.created_at,
|
||||
...serviceFlatFieldDefinitions.created_at,
|
||||
readOnly: true,
|
||||
required: false,
|
||||
defaultValue: "",
|
||||
},
|
||||
updated_at: {
|
||||
...flatFieldDefinitions.updated_at,
|
||||
...serviceFlatFieldDefinitions.updated_at,
|
||||
readOnly: true,
|
||||
required: false,
|
||||
defaultValue: "",
|
||||
},
|
||||
};
|
||||
|
||||
export const fieldDefinitions = {
|
||||
...baseFieldDefinitions,
|
||||
const serviceFieldDefinitions = {
|
||||
...serviceBaseFieldDefinitions,
|
||||
getDefinitionsByMode: (mode: "view") => {
|
||||
switch (mode) {
|
||||
case "view":
|
||||
return viewFieldDefinitions;
|
||||
return serviceViewFieldDefinitions;
|
||||
default:
|
||||
return baseFieldDefinitions;
|
||||
return serviceBaseFieldDefinitions;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export const fieldsByMode = {
|
||||
view: Object.keys(viewFieldDefinitions),
|
||||
const serviceFieldsByMode = {
|
||||
view: Object.keys(serviceViewFieldDefinitions),
|
||||
};
|
||||
|
||||
type ServiceFormData = z.infer<typeof ServiceSchema>;
|
||||
type ServiceViewFormData = z.infer<typeof ViewServiceSchema>;
|
||||
type ServiceFieldDefinitionsType = typeof serviceViewFieldDefinitions;
|
||||
|
||||
export type { ServiceData, ServiceFieldDefinitionsType };
|
||||
export {
|
||||
ServiceSchema,
|
||||
serviceViewFieldDefinitions,
|
||||
ServiceBaseTranslationEn,
|
||||
ServiceBaseTranslationTr,
|
||||
};
|
||||
export type FieldDefinitionsType = typeof viewFieldDefinitions;
|
||||
|
|
|
|||
Loading…
Reference in New Issue