|
@@ -6,17 +6,14 @@ import TagCloudBox from './TagCloudBox';
|
|
|
|
|
|
|
|
import { useSWRxTagList } from '~/stores/tag';
|
|
import { useSWRxTagList } from '~/stores/tag';
|
|
|
import { toastError } from '~/client/util/apiNotification';
|
|
import { toastError } from '~/client/util/apiNotification';
|
|
|
-
|
|
|
|
|
import { ITagDataHasId } from '~/interfaces/tag';
|
|
import { ITagDataHasId } from '~/interfaces/tag';
|
|
|
|
|
|
|
|
-
|
|
|
|
|
const LIMIT = 10;
|
|
const LIMIT = 10;
|
|
|
|
|
|
|
|
const TagPage: FC = () => {
|
|
const TagPage: FC = () => {
|
|
|
-
|
|
|
|
|
const [offset, setOffset] = useState<number>(0);
|
|
const [offset, setOffset] = useState<number>(0);
|
|
|
|
|
|
|
|
- const { data: tagDataList, mutate } = useSWRxTagList(LIMIT, offset);
|
|
|
|
|
|
|
+ const { data: tagDataList, mutate: mutatetagDataList } = useSWRxTagList(LIMIT, offset);
|
|
|
const tagData: ITagDataHasId[] = tagDataList?.data || [];
|
|
const tagData: ITagDataHasId[] = tagDataList?.data || [];
|
|
|
const totalCount: number = tagDataList?.totalCount || 0;
|
|
const totalCount: number = tagDataList?.totalCount || 0;
|
|
|
|
|
|
|
@@ -26,7 +23,7 @@ const TagPage: FC = () => {
|
|
|
setOffset((selectedPageNumber - 1) * LIMIT);
|
|
setOffset((selectedPageNumber - 1) * LIMIT);
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
- mutate();
|
|
|
|
|
|
|
+ mutatetagDataList();
|
|
|
}
|
|
}
|
|
|
catch (error) {
|
|
catch (error) {
|
|
|
toastError(error);
|
|
toastError(error);
|
|
@@ -34,9 +31,11 @@ const TagPage: FC = () => {
|
|
|
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ if (!tagDataList) return <div>{t('Loading')}</div>;
|
|
|
|
|
+
|
|
|
return (
|
|
return (
|
|
|
<div className="grw-container-convertible mb-5 pb-5">
|
|
<div className="grw-container-convertible mb-5 pb-5">
|
|
|
- <h2 className="my-3">{`${t('Tags')}${totalCount}`}</h2>
|
|
|
|
|
|
|
+ <h2 className="my-3">{`${t('Tags')}(${totalCount})`}</h2>
|
|
|
<div className="px-3 text-center">
|
|
<div className="px-3 text-center">
|
|
|
<TagCloudBox tags={tagData} minSize={20} />
|
|
<TagCloudBox tags={tagData} minSize={20} />
|
|
|
</div>
|
|
</div>
|