From 012ee27db6f5180cf1560823bf38da406f54691e Mon Sep 17 00:00:00 2001 From: Ivan <8611739+IRBorisov@users.noreply.github.com> Date: Sat, 22 Feb 2025 12:20:22 +0300 Subject: [PATCH] R: Remove redundant type --- rsconcept/frontend/src/features/oss/backend/api.ts | 8 +++----- .../src/features/oss/backend/useFindPredecessor.tsx | 2 +- rsconcept/frontend/src/features/rsform/backend/api.ts | 7 +++---- rsconcept/frontend/src/features/rsform/backend/types.ts | 5 ----- .../src/features/rsform/backend/useProduceStructure.tsx | 3 +-- .../src/features/rsform/pages/RSFormPage/MenuRSTabs.tsx | 2 +- 6 files changed, 9 insertions(+), 18 deletions(-) diff --git a/rsconcept/frontend/src/features/oss/backend/api.ts b/rsconcept/frontend/src/features/oss/backend/api.ts index 09824bb9..95279dcf 100644 --- a/rsconcept/frontend/src/features/oss/backend/api.ts +++ b/rsconcept/frontend/src/features/oss/backend/api.ts @@ -1,7 +1,5 @@ import { queryOptions } from '@tanstack/react-query'; -import { type ITargetCst } from '@/features/rsform/backend/types'; - import { axiosGet, axiosPatch, axiosPost } from '@/backend/apiTransport'; import { DELAYS, KEYS } from '@/backend/configuration'; import { infoMsg } from '@/utils/labels'; @@ -121,10 +119,10 @@ export const ossApi = { successMessage: infoMsg.changesSaved } }), - getPredecessor: (data: ITargetCst) => - axiosPost({ + getPredecessor: (cstID: number) => + axiosPost<{ target: number }, IConstituentaReference>({ schema: schemaConstituentaReference, endpoint: '/api/oss/get-predecessor', - request: { data: data } + request: { data: { target: cstID } } }) }; diff --git a/rsconcept/frontend/src/features/oss/backend/useFindPredecessor.tsx b/rsconcept/frontend/src/features/oss/backend/useFindPredecessor.tsx index 38689a75..fd7f5041 100644 --- a/rsconcept/frontend/src/features/oss/backend/useFindPredecessor.tsx +++ b/rsconcept/frontend/src/features/oss/backend/useFindPredecessor.tsx @@ -10,6 +10,6 @@ export const useFindPredecessor = () => { onError: () => client.invalidateQueries() }); return { - findPredecessor: (target: number) => mutation.mutateAsync({ target: target }) + findPredecessor: (target: number) => mutation.mutateAsync(target) }; }; diff --git a/rsconcept/frontend/src/features/rsform/backend/api.ts b/rsconcept/frontend/src/features/rsform/backend/api.ts index 2c122df4..d9b05f4d 100644 --- a/rsconcept/frontend/src/features/rsform/backend/api.ts +++ b/rsconcept/frontend/src/features/rsform/backend/api.ts @@ -19,7 +19,6 @@ import { type IProduceStructureResponse, type IRSFormDTO, type IRSFormUploadDTO, - type ITargetCst, schemaConstituentaBasics, schemaCstCreatedResponse, schemaExpressionParse, @@ -117,12 +116,12 @@ export const rsformsApi = { request: { data: data } }), - produceStructure: ({ itemID, data }: { itemID: number; data: ITargetCst }) => - axiosPatch({ + produceStructure: ({ itemID, cstID }: { itemID: number; cstID: number }) => + axiosPatch<{ target: number }, IProduceStructureResponse>({ schema: schemaProduceStructureResponse, endpoint: `/api/rsforms/${itemID}/produce-structure`, request: { - data: data, + data: { target: cstID }, successMessage: response => infoMsg.addedConstituents(response.cst_list.length) } }), diff --git a/rsconcept/frontend/src/features/rsform/backend/types.ts b/rsconcept/frontend/src/features/rsform/backend/types.ts index 24e42a8a..43b695ea 100644 --- a/rsconcept/frontend/src/features/rsform/backend/types.ts +++ b/rsconcept/frontend/src/features/rsform/backend/types.ts @@ -54,11 +54,6 @@ export interface IRSFormUploadDTO { fileName: string; } -/** Represents target {@link IConstituenta}. */ -export interface ITargetCst { - target: number; -} - /** Represents {@link IConstituenta} data, used in creation process. */ export type ICstCreateDTO = z.infer; diff --git a/rsconcept/frontend/src/features/rsform/backend/useProduceStructure.tsx b/rsconcept/frontend/src/features/rsform/backend/useProduceStructure.tsx index 08534dbb..b6026359 100644 --- a/rsconcept/frontend/src/features/rsform/backend/useProduceStructure.tsx +++ b/rsconcept/frontend/src/features/rsform/backend/useProduceStructure.tsx @@ -5,7 +5,6 @@ import { useUpdateTimestamp } from '@/features/library'; import { KEYS } from '@/backend/configuration'; import { rsformsApi } from './api'; -import { type ITargetCst } from './types'; export const useProduceStructure = () => { const client = useQueryClient(); @@ -28,7 +27,7 @@ export const useProduceStructure = () => { onError: () => client.invalidateQueries() }); return { - produceStructure: (data: { itemID: number; data: ITargetCst }) => + produceStructure: (data: { itemID: number; cstID: number }) => mutation.mutateAsync(data).then(response => response.cst_list) }; }; diff --git a/rsconcept/frontend/src/features/rsform/pages/RSFormPage/MenuRSTabs.tsx b/rsconcept/frontend/src/features/rsform/pages/RSFormPage/MenuRSTabs.tsx index a5eda8ed..198fdc2f 100644 --- a/rsconcept/frontend/src/features/rsform/pages/RSFormPage/MenuRSTabs.tsx +++ b/rsconcept/frontend/src/features/rsform/pages/RSFormPage/MenuRSTabs.tsx @@ -189,7 +189,7 @@ export function MenuRSTabs() { } void produceStructure({ itemID: schema.id, - data: { target: activeCst.id } + cstID: activeCst.id }).then(cstList => { if (cstList.length !== 0) { setSelected(cstList);