Use gql for "mangas" V - update manga categories
This commit is contained in:
@@ -29,7 +29,7 @@ export default function CategorySelect(props: IProps) {
|
|||||||
|
|
||||||
const { open, setOpen, mangaId } = props;
|
const { open, setOpen, mangaId } = props;
|
||||||
|
|
||||||
const { data: mangaCategoriesData, mutate } = requestManager.useGetMangaCategories(mangaId);
|
const { data: mangaResult } = requestManager.useGetManga(mangaId);
|
||||||
const { data } = requestManager.useGetCategories();
|
const { data } = requestManager.useGetCategories();
|
||||||
const categoriesData = data?.categories.nodes;
|
const categoriesData = data?.categories.nodes;
|
||||||
const [triggerMutate] = requestManager.useUpdateMangaCategories();
|
const [triggerMutate] = requestManager.useUpdateMangaCategories();
|
||||||
@@ -42,7 +42,7 @@ export default function CategorySelect(props: IProps) {
|
|||||||
return cats;
|
return cats;
|
||||||
}, [categoriesData]);
|
}, [categoriesData]);
|
||||||
|
|
||||||
const selectedIds = mangaCategoriesData?.map((c) => c.id) ?? [];
|
const selectedIds = mangaResult?.manga.categories.nodes.map((c) => c.id) ?? [];
|
||||||
|
|
||||||
const handleCancel = () => {
|
const handleCancel = () => {
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
@@ -66,7 +66,7 @@ export default function CategorySelect(props: IProps) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}).then(() => mutate());
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ import { OperationVariables } from '@apollo/client/core';
|
|||||||
import { useEffect, useRef, useState } from 'react';
|
import { useEffect, useRef, useState } from 'react';
|
||||||
import {
|
import {
|
||||||
BackupValidationResult,
|
BackupValidationResult,
|
||||||
ICategory,
|
|
||||||
IChapter,
|
IChapter,
|
||||||
IMangaChapter,
|
IMangaChapter,
|
||||||
ISourceFilters,
|
ISourceFilters,
|
||||||
@@ -1292,13 +1291,6 @@ export class RequestManager {
|
|||||||
return this.getValidImgUrlFor(`manga/${mangaId}/thumbnail`);
|
return this.getValidImgUrlFor(`manga/${mangaId}/thumbnail`);
|
||||||
}
|
}
|
||||||
|
|
||||||
public useGetMangaCategories(
|
|
||||||
mangaId: number,
|
|
||||||
swrOptions?: SWROptions<ICategory[]>,
|
|
||||||
): AbortableSWRResponse<ICategory[]> {
|
|
||||||
return this.doRequest(HttpMethod.SWR_GET, `manga/${mangaId}/category`, { swrOptions });
|
|
||||||
}
|
|
||||||
|
|
||||||
public useUpdateMangaCategories(
|
public useUpdateMangaCategories(
|
||||||
options?: MutationHookOptions<UpdateMangaCategoriesMutation, UpdateMangaCategoriesMutationVariables>,
|
options?: MutationHookOptions<UpdateMangaCategoriesMutation, UpdateMangaCategoriesMutationVariables>,
|
||||||
): AbortableApolloUseMutationResponse<UpdateMangaCategoriesMutation, UpdateMangaCategoriesMutationVariables> {
|
): AbortableApolloUseMutationResponse<UpdateMangaCategoriesMutation, UpdateMangaCategoriesMutationVariables> {
|
||||||
|
|||||||
Reference in New Issue
Block a user