Просмотр исходного кода

change interface name about ITagCount

yuto-oweseek 4 лет назад
Родитель
Сommit
b289902530

+ 2 - 2
packages/app/src/components/Sidebar/Tag.tsx

@@ -5,7 +5,7 @@ import TagList from '../TagList';
 import TagCloudBox from '../TagCloudBox';
 import TagCloudBox from '../TagCloudBox';
 
 
 import { useSWRxTagDataList } from '~/stores/tag';
 import { useSWRxTagDataList } from '~/stores/tag';
-import { ITagDataHasId } from '~/interfaces/tag';
+import { ITagCountHasId } from '~/interfaces/tag';
 
 
 const LIMIT = 10;
 const LIMIT = 10;
 
 
@@ -13,7 +13,7 @@ const Tag: FC = () => {
   const [offset, setOffset] = useState<number>(0);
   const [offset, setOffset] = useState<number>(0);
 
 
   const { data: tagDataList, mutate: mutateTagDataList } = useSWRxTagDataList(LIMIT, offset);
   const { data: tagDataList, mutate: mutateTagDataList } = useSWRxTagDataList(LIMIT, offset);
-  const tagData: ITagDataHasId[] = tagDataList?.data || [];
+  const tagData: ITagCountHasId[] = tagDataList?.data || [];
   const totalCount: number = tagDataList?.totalCount || 0;
   const totalCount: number = tagDataList?.totalCount || 0;
 
 
   const { t } = useTranslation('');
   const { t } = useTranslation('');

+ 2 - 2
packages/app/src/components/TagCloudBox.tsx

@@ -1,9 +1,9 @@
 import React, { FC } from 'react';
 import React, { FC } from 'react';
 import { TagCloud } from 'react-tagcloud';
 import { TagCloud } from 'react-tagcloud';
-import { ITagDataHasId } from '~/interfaces/tag';
+import { ITagCountHasId } from '~/interfaces/tag';
 
 
 type Props = {
 type Props = {
-  tags:ITagDataHasId[],
+  tags:ITagCountHasId[],
   minSize?: number,
   minSize?: number,
   maxSize?: number,
   maxSize?: number,
 }
 }

+ 2 - 2
packages/app/src/components/TagList.tsx

@@ -3,10 +3,10 @@ import React, {
 } from 'react';
 } from 'react';
 import { useTranslation } from 'react-i18next';
 import { useTranslation } from 'react-i18next';
 import PaginationWrapper from './PaginationWrapper';
 import PaginationWrapper from './PaginationWrapper';
-import { ITagDataHasId } from '~/interfaces/tag';
+import { ITagCountHasId } from '~/interfaces/tag';
 
 
 type TagListProps = {
 type TagListProps = {
-  tagData: ITagDataHasId[],
+  tagData: ITagCountHasId[],
   totalTags: number,
   totalTags: number,
   activePage: number,
   activePage: number,
   onChangePage?: (selectedPageNumber: number) => void,
   onChangePage?: (selectedPageNumber: number) => void,

+ 2 - 2
packages/app/src/components/TagPage.tsx

@@ -5,7 +5,7 @@ import TagList from './TagList';
 import TagCloudBox from './TagCloudBox';
 import TagCloudBox from './TagCloudBox';
 
 
 import { useSWRxTagDataList } from '~/stores/tag';
 import { useSWRxTagDataList } from '~/stores/tag';
-import { ITagDataHasId } from '~/interfaces/tag';
+import { ITagCountHasId } from '~/interfaces/tag';
 
 
 const LIMIT = 10;
 const LIMIT = 10;
 
 
@@ -13,7 +13,7 @@ const TagPage: FC = () => {
   const [offset, setOffset] = useState<number>(0);
   const [offset, setOffset] = useState<number>(0);
 
 
   const { data: tagDataList } = useSWRxTagDataList(LIMIT, offset);
   const { data: tagDataList } = useSWRxTagDataList(LIMIT, offset);
-  const tagData: ITagDataHasId[] = tagDataList?.data || [];
+  const tagData: ITagCountHasId[] = tagDataList?.data || [];
   const totalCount: number = tagDataList?.totalCount || 0;
   const totalCount: number = tagDataList?.totalCount || 0;
 
 
   const { t } = useTranslation('');
   const { t } = useTranslation('');

+ 4 - 5
packages/app/src/interfaces/tag.ts

@@ -4,8 +4,7 @@ export type ITag = {
   name: string,
   name: string,
   createdAt: Date;
   createdAt: Date;
 }
 }
-export type ITagData = {
-  name: string,
-  count: number,
-}
-export type ITagDataHasId = ITagData & HasObjectId
+
+export type ITagCount = Omit<ITag, 'createdAt'> & {count: number}
+
+export type ITagCountHasId = ITagCount & HasObjectId

+ 2 - 2
packages/app/src/stores/tag.tsx

@@ -1,9 +1,9 @@
 import useSWR, { SWRResponse } from 'swr';
 import useSWR, { SWRResponse } from 'swr';
-import { ITagDataHasId } from '~/interfaces/tag';
+import { ITagCountHasId } from '~/interfaces/tag';
 import { apiGet } from '~/client/util/apiv1-client';
 import { apiGet } from '~/client/util/apiv1-client';
 
 
 type ITagDataListResponse = {
 type ITagDataListResponse = {
-  data: ITagDataHasId[],
+  data: ITagCountHasId[],
   totalCount: number,
   totalCount: number,
 }
 }