Skip to content

Commit

Permalink
1659 - created termToTerm relationship. Added API's to create relatio…
Browse files Browse the repository at this point in the history
…n and to link term using definition
  • Loading branch information
Vladysl committed Apr 26, 2024
1 parent 1f3c4c3 commit 5b145c3
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useMemo } from 'react';
import React, { useCallback, useMemo, useState } from 'react';
import { Box, Grid, Typography } from '@mui/material';
import { useGetQueryExampleDetails } from 'lib/hooks/api/dataModelling/queryExamples';
import { useAppDateTime } from 'lib/hooks';
Expand Down Expand Up @@ -68,9 +68,7 @@ const QueryExampleDetailsContainer: React.FC = () => {
<QueryExampleDetailsTabs
linkedEntitiesHint={queryExampleDetails?.linkedEntities.pageInfo.total}
linkedTermsHint={
queryExampleDetails?.linkedTerms?.items
? queryExampleDetails?.linkedTerms?.items.length
: 0
queryExampleDetails?.linkedTerms?.items ? queryExampleDetails?.linkedTerms?.items.length : 0
}
/>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@ export const Tooltip = styled('div')(({ theme }) => ({
export const Definition = styled('div')(({ theme }) => ({
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
marginBottom: theme.spacing(1),
}));
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ const TermDefinition: FC<TermDefinitionProps> = ({ definition, termId, terms })
return (
<>
<S.Definition>
<Typography variant='h2' mb={1}>
<Typography variant='h2' mr={1}>
Definition
</Typography>
<AppTooltip title={tooltipInfoContent} checkForOverflow={false}>
<InformationIcon width={14} height={14} />
</AppTooltip>
</S.Definition>
<Markdown value={transformDescriptionToMarkdown(definition)} variant='subtitle1' />
<Markdown value={transformDescriptionToMarkdown(definition)} />
</>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ import {
getTermUpdatingStatuses,
} from 'redux/selectors';
import { termDetailsPath, useTermsRouteParams } from 'routes';
import { useQueryClient } from '@tanstack/react-query';

interface TermsFormDialogProps {
btnCreateEl: JSX.Element;
}

const TermsForm: FC<TermsFormDialogProps> = ({ btnCreateEl }) => {
const { t } = useTranslation();
const queryClient = useQueryClient();
const dispatch = useAppDispatch();
const navigate = useNavigate();
const { termId } = useTermsRouteParams();
Expand Down Expand Up @@ -68,7 +70,10 @@ const TermsForm: FC<TermsFormDialogProps> = ({ btnCreateEl }) => {
: dispatch(createTerm({ termFormData: parsedData }))
)
.unwrap()
.then((response: TermDetails) => {
.then(async (response: TermDetails) => {
await queryClient.invalidateQueries({
queryKey: ['term', termId],
});
clearState();
navigate(termDetailsPath(response.id));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { TermRef } from 'generated-sources';
import DialogWrapper from 'components/shared/elements/DialogWrapper/DialogWrapper';
import Markdown from 'components/shared/elements/Markdown/Markdown';

export interface AssignTermFormData {
interface AssignTermFormData {
termId: number;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,4 @@ export function useGetQueryExamplesByTermId({
queryFn: async () => queryExampleApi.getQueryExampleByTermId({ termId }),
});
}

0 comments on commit 5b145c3

Please sign in to comment.