feat : smart tree component (#2865)

Co-authored-by: Andrew Bastin <andrewbastin.k@gmail.com>
Co-authored-by: Liyas Thomas <liyascthomas@gmail.com>
This commit is contained in:
Nivedin
2023-01-31 17:15:03 +05:30
committed by GitHub
parent b95e2b365a
commit 2910164d5a
39 changed files with 4483 additions and 4142 deletions

View File

@@ -0,0 +1,76 @@
import { runMutation } from "../GQLClient"
import {
CreateChildCollectionDocument,
CreateChildCollectionMutation,
CreateChildCollectionMutationVariables,
CreateNewRootCollectionDocument,
CreateNewRootCollectionMutation,
CreateNewRootCollectionMutationVariables,
DeleteCollectionDocument,
DeleteCollectionMutation,
DeleteCollectionMutationVariables,
ImportFromJsonDocument,
ImportFromJsonMutation,
ImportFromJsonMutationVariables,
RenameCollectionDocument,
RenameCollectionMutation,
RenameCollectionMutationVariables,
} from "../graphql"
type CreateNewRootCollectionError = "team_coll/short_title"
type CreateChildCollectionError = "team_coll/short_title"
type RenameCollectionError = "team_coll/short_title"
type DeleteCollectionError = "team/invalid_coll_id"
export const createNewRootCollection = (title: string, teamID: string) =>
runMutation<
CreateNewRootCollectionMutation,
CreateNewRootCollectionMutationVariables,
CreateNewRootCollectionError
>(CreateNewRootCollectionDocument, {
title,
teamID,
})
export const createChildCollection = (
childTitle: string,
collectionID: string
) =>
runMutation<
CreateChildCollectionMutation,
CreateChildCollectionMutationVariables,
CreateChildCollectionError
>(CreateChildCollectionDocument, {
childTitle,
collectionID,
})
/** Can be used to rename both collection and folder (considered same in BE) */
export const renameCollection = (collectionID: string, newTitle: string) =>
runMutation<
RenameCollectionMutation,
RenameCollectionMutationVariables,
RenameCollectionError
>(RenameCollectionDocument, {
collectionID,
newTitle,
})
/** Can be used to delete both collection and folder (considered same in BE) */
export const deleteCollection = (collectionID: string) =>
runMutation<
DeleteCollectionMutation,
DeleteCollectionMutationVariables,
DeleteCollectionError
>(DeleteCollectionDocument, {
collectionID,
})
export const importJSONToTeam = (collectionJSON: string, teamID: string) =>
runMutation<ImportFromJsonMutation, ImportFromJsonMutationVariables, "">(
ImportFromJsonDocument,
{
jsonString: collectionJSON,
teamID,
}
)