diff --git a/app/api/READ-ONLY-generated-actions/Asset.ts b/app/api/READ-ONLY-generated-actions/Asset.ts new file mode 100644 index 0000000..32defb4 --- /dev/null +++ b/app/api/READ-ONLY-generated-actions/Asset.ts @@ -0,0 +1,39 @@ +'use server'; +import { AssetDto } from '../dtos/AssetDtoSchema'; +import { generateBaseEndpointSet } from '../actions/template-base-endpoints'; +import { generateWithTypeEndpointSet } from '../actions/template-type-endpoints'; +import { generateGraphEndpointSet } from '../actions/template-graph-endpoints'; + +export const { + getPage, + getAll, + deleteIdList, + postList, + putList, + getOne, + postOne, + putOne, + deleteOne, + getDtoListByBodyList, + getDtoListByParamList +} = generateBaseEndpointSet< + AssetDto, + number +>( + '/api/v2/assets' +); + + +export const { getByTypeIdList } = generateWithTypeEndpointSet( + '/api/v2/assets' +); + + +export const { getGraph, getGraphByNodeList, getGraphByRootId, putGraph } = + generateGraphEndpointSet< + AssetDto +>( + '/api/v2/assets' +); + + diff --git a/app/api/READ-ONLY-generated-actions/AssetRoleTypeWorkTaskTypeSuitability.ts b/app/api/READ-ONLY-generated-actions/AssetRoleTypeWorkTaskTypeSuitability.ts new file mode 100644 index 0000000..07fb06a --- /dev/null +++ b/app/api/READ-ONLY-generated-actions/AssetRoleTypeWorkTaskTypeSuitability.ts @@ -0,0 +1,38 @@ +'use server'; +import { AssetRoleWorkTaskSuitabilityDto } from '../dtos/AssetRoleWorkTaskSuitabilityDtoSchema'; +import { generateBaseEndpointSet } from '../actions/template-base-endpoints'; +import { generateTriIntersectionEndpointSet } from '../actions/template-tri-intersection-endpoints'; + +export const { + getPage, + getAll, + deleteIdList, + postList, + putList, + getOne, + postOne, + putOne, + deleteOne, + getDtoListByBodyList, + getDtoListByParamList +} = generateBaseEndpointSet< + AssetRoleWorkTaskSuitabilityDto, + number +>( + '/api/v2/workTaskTypes/assetRoleSuitabilities' +); + + + +export const { + getByRowIdListAndColumnIdListAndLayerId, + getByRowIdListAndLayerId, + getColumnIdListAndLayerId, + getTriIntersectionTable +} = generateTriIntersectionEndpointSet< + AssetRoleWorkTaskSuitabilityDto, + number, + number, + number +>('/api/v2/workTaskTypes/assetRoleSuitabilities'); + diff --git a/app/api/READ-ONLY-generated-actions/AssetType.ts b/app/api/READ-ONLY-generated-actions/AssetType.ts new file mode 100644 index 0000000..f16006f --- /dev/null +++ b/app/api/READ-ONLY-generated-actions/AssetType.ts @@ -0,0 +1,34 @@ +'use server'; +import { AssetTypeDto } from '../dtos/AssetTypeDtoSchema'; +import { generateBaseEndpointSet } from '../actions/template-base-endpoints'; +import { generateGraphEndpointSet } from '../actions/template-graph-endpoints'; + +export const { + getPage, + getAll, + deleteIdList, + postList, + putList, + getOne, + postOne, + putOne, + deleteOne, + getDtoListByBodyList, + getDtoListByParamList +} = generateBaseEndpointSet< + AssetTypeDto, + number +>( + '/api/v2/assets/types' +); + + + +export const { getGraph, getGraphByNodeList, getGraphByRootId, putGraph } = + generateGraphEndpointSet< + AssetTypeDto +>( + '/api/v2/assets/types' +); + + diff --git a/app/api/READ-ONLY-generated-actions/OrganizationType.ts b/app/api/READ-ONLY-generated-actions/OrganizationType.ts index 147a631..26696bb 100644 --- a/app/api/READ-ONLY-generated-actions/OrganizationType.ts +++ b/app/api/READ-ONLY-generated-actions/OrganizationType.ts @@ -28,7 +28,7 @@ export const { OrganizationTypeDto, number >( - '/api/v2/organizations' + '/api/v2/organizations/types' ); diff --git a/app/api/READ-ONLY-generated-actions/ProviderRoleType.ts b/app/api/READ-ONLY-generated-actions/ProviderRoleType.ts index f30178f..10dc853 100644 --- a/app/api/READ-ONLY-generated-actions/ProviderRoleType.ts +++ b/app/api/READ-ONLY-generated-actions/ProviderRoleType.ts @@ -19,7 +19,7 @@ export const { ProviderRoleTypeDto, number >( - '/api/v2/providerRoles' + '/api/v2/providerRoles/types' ); diff --git a/app/api/READ-ONLY-generated-actions/ProviderRoleTypeWorkTaskTypeSuitability.ts b/app/api/READ-ONLY-generated-actions/ProviderRoleTypeWorkTaskTypeSuitability.ts index 4d5c92e..b84a22a 100644 --- a/app/api/READ-ONLY-generated-actions/ProviderRoleTypeWorkTaskTypeSuitability.ts +++ b/app/api/READ-ONLY-generated-actions/ProviderRoleTypeWorkTaskTypeSuitability.ts @@ -19,7 +19,7 @@ export const { ProviderRoleTypeWorkTaskTypeSuitabilityDto, number >( - '/api/v2/workTaskType/providerRoleTypeSuitability' + '/api/v2/workTaskType/providerRoleTypeSuitabilities' ); @@ -34,5 +34,5 @@ export const { number, number, number ->('/api/v2/workTaskType/providerRoleTypeSuitability'); +>('/api/v2/workTaskType/providerRoleTypeSuitabilities'); diff --git a/app/api/actions/custom/premises.ts b/app/api/actions/custom/premises.ts index 9608990..99c8055 100644 --- a/app/api/actions/custom/premises.ts +++ b/app/api/actions/custom/premises.ts @@ -11,23 +11,6 @@ import { GraphDto, GraphDtoPutRequestBody } from '../../zod-mods'; import { AssetDto } from '../../dtos/AssetDtoSchema'; import { API_BASE_URL } from '../../main'; import { AssetRoleWorkTaskSuitabilityDto } from '../../dtos/AssetRoleWorkTaskSuitabilityDtoSchema'; - -const premisesUrl = `${API_BASE_URL}/assets/premises`; - -const premisesGraphUrl = `${premisesUrl}/graph`; - -export async function getPremises(): ActionResponsePromise> { - return await getWithoutBody(premisesGraphUrl); -} -export async function getPremisesWithRoot( - rootId: string -): ActionResponsePromise> { - return await getWithoutBody(`${premisesUrl}/graph/byRootId/${rootId}`); -} - -export async function patchPremises(premises: AssetDto[]) { - return patchEntityList(premises, premisesUrl); -} export async function patchAssetRoleWorkTaskSuitabilities( suitabilityList: AssetRoleWorkTaskSuitabilityDto[] ) { @@ -36,27 +19,3 @@ export async function patchAssetRoleWorkTaskSuitabilities( `${API_BASE_URL}/assets/assetRoleSuitabilities` ); } - -export async function putPremisesGraph( - request: GraphDtoPutRequestBody -) { - return putRequestWithDifferentReturnType< - GraphDtoPutRequestBody, - GraphDto - >(request, premisesGraphUrl); -} - -export async function getAssetSuitabilities( - assetIdList: number[], - workTaskTypeIdList: number[] -) { - return postIntersectionTableRequest< - number, - number, - AssetRoleWorkTaskSuitabilityDto - >({ - idsForHasIdTypeT: assetIdList, - idsForHasIdTypeU: workTaskTypeIdList, - url: `${API_BASE_URL}/assets/assetRoleSuitabilities/intersectionTable` - }); -} diff --git a/app/api/main.ts b/app/api/main.ts index 6d964c7..8e39684 100644 --- a/app/api/main.ts +++ b/app/api/main.ts @@ -6,6 +6,7 @@ export const API_V2_URL = `${process.env.API_BASE_URL!}/v2`; export const API_ACADEMIC_URL = process.env.API_ACADEMIC_URL!; export const SECONDARY_EDUCATION_CATEGORY_ID = 2; +export const CLASSROOM_ROLE_TYPE_ID: number = 1; // Spring Web Pagination interface export interface Page { diff --git a/app/premises/asset-string-map-context-provider.tsx b/app/premises/asset-string-map-context-provider.tsx index 673fb83..8d7e7f6 100644 --- a/app/premises/asset-string-map-context-provider.tsx +++ b/app/premises/asset-string-map-context-provider.tsx @@ -9,13 +9,12 @@ import { } from './asset-string-map-context-creator'; import { StringMap } from '../contexts/string-map-context/string-map-reducer'; import { PropsWithChildren, useCallback } from 'react'; -import { - patchAssetRoleWorkTaskSuitabilities, - patchPremises -} from '../api/actions/custom/premises'; +import { patchAssetRoleWorkTaskSuitabilities } from '../api/actions/custom/premises'; import { AssetSuitabilityListSelectiveContext } from '../contexts/selective-context/selective-context-creators'; import { useSelectiveContextListenerReadAll } from '../selective-context/components/base/generic-selective-context-creator'; import { isNotUndefined } from '../api/main'; +import { putList as putAssetList } from '../api/READ-ONLY-generated-actions/Asset'; +import { putList } from '../api/READ-ONLY-generated-actions/AssetRoleTypeWorkTaskTypeSuitability'; const Provider = WriteableStringMapContextProvider; export default function AssetStringMapContextProvider({ @@ -31,8 +30,8 @@ export default function AssetStringMapContextProvider({ .map((assetDto) => selectiveContextReadAll(assetDto.id.toString())) .filter(isNotUndefined) .reduce((prev, curr) => [...prev, ...curr], []); - await patchAssetRoleWorkTaskSuitabilities(updatedSuitabilityLists); - return await patchPremises(changedAssetDtoList); + await putList(updatedSuitabilityLists); + return await putAssetList(changedAssetDtoList); }, [selectiveContextReadAll] ); diff --git a/app/premises/classroom-suitability/page.tsx b/app/premises/classroom-suitability/page.tsx index 713b3e2..a58f791 100644 --- a/app/premises/classroom-suitability/page.tsx +++ b/app/premises/classroom-suitability/page.tsx @@ -1,15 +1,10 @@ import { ActionResponsePromise } from '../../api/actions/actionResponse'; import { GraphDto } from '../../api/zod-mods'; import { AssetDto } from '../../api/dtos/AssetDtoSchema'; -import { - getAssetSuitabilities, - getPremises, - getPremisesWithRoot -} from '../../api/actions/custom/premises'; import { Card } from '@nextui-org/card'; import { AssetSuitabilityTableWrapper } from './asset-suitability-table-wrapper'; import { getWorkTaskTypes } from '../../api/actions/custom/work-task-types'; -import { isNotUndefined } from '../../api/main'; +import { CLASSROOM_ROLE_TYPE_ID, isNotUndefined } from '../../api/main'; import { WorkTaskTypeContextProvider } from '../../curriculum/delivery-models/contexts/work-task-type-context-provider'; import { convertListToStringMap } from '../../contexts/string-map-context/convert-list-to-string-map'; import AssetStringMapContextProvider from '../asset-string-map-context-provider'; @@ -28,6 +23,11 @@ import { KnowledgeDomainFilterSelector } from './knowledge-domain-filter-selecto import { KnowledgeLevelFilterSelector } from './knowledge-level-filter-selector'; import { AssetRootIdFilterSelector } from './asset-root-id-filter-selector'; import { getWorkTaskTypeIdsAlphabetical } from './get-work-task-type-ids-alphabetical'; +import { + getGraph, + getGraphByRootId +} from '../../api/READ-ONLY-generated-actions/Asset'; +import { getTriIntersectionTable } from '../../api/READ-ONLY-generated-actions/AssetRoleTypeWorkTaskTypeSuitability'; export default async function Page({ searchParams: { rootId, ...workTaskParams } @@ -41,9 +41,9 @@ export default async function Page({ }) { let premisesPromises: ActionResponsePromise>; if (isNotUndefined(rootId)) { - premisesPromises = getPremisesWithRoot(rootId); + premisesPromises = getGraphByRootId({ rootId: parseTen(rootId) }); } else { - premisesPromises = getPremises(); + premisesPromises = getGraph(); } const actionResponse = await premisesPromises; @@ -72,9 +72,10 @@ export default async function Page({ const assetIds = Object.keys(assetStringMap).map(parseTen); const workTaskTypeIds = getWorkTaskTypeIdsAlphabetical(wttStringMap); - const { data: assetSuitabilities } = await getAssetSuitabilities( + const { data: assetSuitabilities } = await getTriIntersectionTable( assetIds, - workTaskTypeIds + workTaskTypeIds, + CLASSROOM_ROLE_TYPE_ID ); if (!isNotUndefined(assetSuitabilities)) { diff --git a/app/premises/page.tsx b/app/premises/page.tsx index a40b439..78deed4 100644 --- a/app/premises/page.tsx +++ b/app/premises/page.tsx @@ -1,15 +1,11 @@ -import { Title, Card } from '@tremor/react'; - -import { getPremises } from '../api/actions/custom/premises'; +import { Card, Title } from '@tremor/react'; import { GraphDto } from '../api/zod-mods'; import { AssetDto } from '../api/dtos/AssetDtoSchema'; import { ActionResponsePromise } from '../api/actions/actionResponse'; -import ForceGraphPage, { NodePayload } from '../graphing/force-graph-page'; +import ForceGraphPage from '../graphing/force-graph-page'; import { PremisesHierarchyGraph } from './premises-hierarchy-graph'; -import { OrganizationDto } from '../api/dtos/OrganizationDtoSchema'; -import CurriculumDeliveryDetails from '../graphing/graph-types/organization/curriculum-delivery-details'; import React from 'react'; -import PremisesDetails from './premises-details'; +import { getGraph } from '../api/READ-ONLY-generated-actions/Asset'; export const dynamic = 'force-dynamic'; @@ -17,7 +13,7 @@ export default async function PremisesPage({}: { searchParams: { q: string }; }) { const premisesPromises: ActionResponsePromise> = - getPremises(); + getGraph(); const actionResponse = await premisesPromises; diff --git a/app/premises/premises-hierarchy-graph.tsx b/app/premises/premises-hierarchy-graph.tsx index 3d43970..64cb9e6 100644 --- a/app/premises/premises-hierarchy-graph.tsx +++ b/app/premises/premises-hierarchy-graph.tsx @@ -6,12 +6,12 @@ import { NodeLinkRefWrapper } from '../graphing/graph/node-link-ref-wrapper'; import { useNodeAndLinkRefs } from '../graphing/graph/use-node-and-link-refs'; import { useNodeEditing } from '../graphing/editing/functions/use-node-editing'; import { incrementCloneSuffix } from '../graphing/editing/functions/increment-clone-suffix'; -import { putPremisesGraph } from '../api/actions/custom/premises'; import { NodePayload } from '../graphing/force-graph-page'; import PremisesDetails from './premises-details'; import React from 'react'; import NodeDetails from '../graphing/components/node-details'; import { UnsavedChangesModal } from '../generic/components/modals/unsaved-changes-modal'; +import { putGraph } from '../api/READ-ONLY-generated-actions/Asset'; export function PremisesHierarchyGraph() { const { nodes, nodesRef, linksRef } = useNodeAndLinkRefs(); @@ -20,7 +20,7 @@ export function PremisesHierarchyGraph() { nodesRef, linksRef, AssetCloneFunctionWrapper, - putPremisesGraph + putGraph ); const classList: string[] = [];