R: Remove redundant type

This commit is contained in:
Ivan 2025-02-22 12:20:22 +03:00
parent 25f2768445
commit 012ee27db6
6 changed files with 9 additions and 18 deletions

View File

@ -1,7 +1,5 @@
import { queryOptions } from '@tanstack/react-query'; import { queryOptions } from '@tanstack/react-query';
import { type ITargetCst } from '@/features/rsform/backend/types';
import { axiosGet, axiosPatch, axiosPost } from '@/backend/apiTransport'; import { axiosGet, axiosPatch, axiosPost } from '@/backend/apiTransport';
import { DELAYS, KEYS } from '@/backend/configuration'; import { DELAYS, KEYS } from '@/backend/configuration';
import { infoMsg } from '@/utils/labels'; import { infoMsg } from '@/utils/labels';
@ -121,10 +119,10 @@ export const ossApi = {
successMessage: infoMsg.changesSaved successMessage: infoMsg.changesSaved
} }
}), }),
getPredecessor: (data: ITargetCst) => getPredecessor: (cstID: number) =>
axiosPost<ITargetCst, IConstituentaReference>({ axiosPost<{ target: number }, IConstituentaReference>({
schema: schemaConstituentaReference, schema: schemaConstituentaReference,
endpoint: '/api/oss/get-predecessor', endpoint: '/api/oss/get-predecessor',
request: { data: data } request: { data: { target: cstID } }
}) })
}; };

View File

@ -10,6 +10,6 @@ export const useFindPredecessor = () => {
onError: () => client.invalidateQueries() onError: () => client.invalidateQueries()
}); });
return { return {
findPredecessor: (target: number) => mutation.mutateAsync({ target: target }) findPredecessor: (target: number) => mutation.mutateAsync(target)
}; };
}; };

View File

@ -19,7 +19,6 @@ import {
type IProduceStructureResponse, type IProduceStructureResponse,
type IRSFormDTO, type IRSFormDTO,
type IRSFormUploadDTO, type IRSFormUploadDTO,
type ITargetCst,
schemaConstituentaBasics, schemaConstituentaBasics,
schemaCstCreatedResponse, schemaCstCreatedResponse,
schemaExpressionParse, schemaExpressionParse,
@ -117,12 +116,12 @@ export const rsformsApi = {
request: { data: data } request: { data: data }
}), }),
produceStructure: ({ itemID, data }: { itemID: number; data: ITargetCst }) => produceStructure: ({ itemID, cstID }: { itemID: number; cstID: number }) =>
axiosPatch<ITargetCst, IProduceStructureResponse>({ axiosPatch<{ target: number }, IProduceStructureResponse>({
schema: schemaProduceStructureResponse, schema: schemaProduceStructureResponse,
endpoint: `/api/rsforms/${itemID}/produce-structure`, endpoint: `/api/rsforms/${itemID}/produce-structure`,
request: { request: {
data: data, data: { target: cstID },
successMessage: response => infoMsg.addedConstituents(response.cst_list.length) successMessage: response => infoMsg.addedConstituents(response.cst_list.length)
} }
}), }),

View File

@ -54,11 +54,6 @@ export interface IRSFormUploadDTO {
fileName: string; fileName: string;
} }
/** Represents target {@link IConstituenta}. */
export interface ITargetCst {
target: number;
}
/** Represents {@link IConstituenta} data, used in creation process. */ /** Represents {@link IConstituenta} data, used in creation process. */
export type ICstCreateDTO = z.infer<typeof schemaCstCreate>; export type ICstCreateDTO = z.infer<typeof schemaCstCreate>;

View File

@ -5,7 +5,6 @@ import { useUpdateTimestamp } from '@/features/library';
import { KEYS } from '@/backend/configuration'; import { KEYS } from '@/backend/configuration';
import { rsformsApi } from './api'; import { rsformsApi } from './api';
import { type ITargetCst } from './types';
export const useProduceStructure = () => { export const useProduceStructure = () => {
const client = useQueryClient(); const client = useQueryClient();
@ -28,7 +27,7 @@ export const useProduceStructure = () => {
onError: () => client.invalidateQueries() onError: () => client.invalidateQueries()
}); });
return { return {
produceStructure: (data: { itemID: number; data: ITargetCst }) => produceStructure: (data: { itemID: number; cstID: number }) =>
mutation.mutateAsync(data).then(response => response.cst_list) mutation.mutateAsync(data).then(response => response.cst_list)
}; };
}; };

View File

@ -189,7 +189,7 @@ export function MenuRSTabs() {
} }
void produceStructure({ void produceStructure({
itemID: schema.id, itemID: schema.id,
data: { target: activeCst.id } cstID: activeCst.id
}).then(cstList => { }).then(cstList => {
if (cstList.length !== 0) { if (cstList.length !== 0) {
setSelected(cstList); setSelected(cstList);