chore: fixed error with typings

This commit is contained in:
Ebezer Igbinoba
2023-08-23 16:36:48 +01:00
parent 9a1b453c86
commit ac66834daa
12 changed files with 297 additions and 437 deletions
+7 -7
View File
@@ -7,9 +7,7 @@ import {
CreateTagRes,
DeleteTagDTO,
DeleteWsTagRes,
QueryTag,
UserWsTags,
WsTag
} from "./types";
const workspaceTags = {
@@ -32,33 +30,35 @@ export const useGetWsTags = (workspaceID: string) => {
});
}
export const useCreateWsTag = () => {
const queryClient = useQueryClient();
return useMutation<CreateTagRes, {}, CreateTagDTO>({
mutationFn: async ({ workspaceID, tagName, tagColor, tagSlug }: QueryTag) => {
mutationFn: async ({ workspaceID, tagName, tagColor, tagSlug }) => {
const { data } = await apiRequest.post(`/api/v2/workspace/${workspaceID}/tags`, {
name: tagName,
tagColor: tagColor,
tagColor,
slug: tagSlug
})
return data;
},
onSuccess: (tagData: WsTag) => {
onSuccess: (tagData) => {
queryClient.invalidateQueries(workspaceTags.getWsTags(tagData?.workspace));
}
});
};
export const useDeleteWsTag = () => {
const queryClient = useQueryClient();
return useMutation<DeleteWsTagRes, {}, DeleteTagDTO>({
mutationFn: async ({ tagID }: {tagID: string}) => {
mutationFn: async ({ tagID }) => {
const { data } = await apiRequest.delete(`/api/v2/workspace/tags/${tagID}`);
return data
},
onSuccess: (tagData: WsTag) => {
onSuccess: (tagData) => {
queryClient.invalidateQueries(workspaceTags.getWsTags(tagData?.workspace));
}
});
+3 -7
View File
@@ -4,6 +4,7 @@ export type WsTag = {
_id: string;
name: string;
slug: string;
tagColor?: string;
workspace: string;
createdAt: string;
updatedAt: string;
@@ -16,6 +17,7 @@ export type CreateTagDTO = {
workspaceID: string;
tagSlug: string;
tagName: string;
tagColor: string;
};
export type CreateTagRes = {
@@ -23,6 +25,7 @@ export type CreateTagRes = {
slug: string;
workspace: string;
createdAt: string;
tagColor?: string;
user: string;
_id: string;
};
@@ -51,11 +54,4 @@ export type TagColor = {
rgba: string
name: string
selected: boolean
}
export type QueryTag = {
workspaceID: string;
tagName: string;
tagColor: string;
tagSlug: string
}