-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
72 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Systems } from '@tapis/tapis-typescript'; | ||
import { apiGenerator, errorDecoder } from '../utils'; | ||
|
||
const createUserCredential = ( | ||
params: Systems.CreateUserCredentialRequest, | ||
basePath: string, | ||
jwt: string | ||
) => { | ||
const api: Systems.CredentialsApi = apiGenerator<Systems.CredentialsApi>( | ||
Systems, | ||
Systems.CredentialsApi, | ||
basePath, | ||
jwt | ||
); | ||
return errorDecoder<Systems.RespBasic>(() => | ||
api.createUserCredential(params) | ||
); | ||
}; | ||
|
||
export default createUserCredential; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,56 @@ | ||
// import { useMutation, MutateOptions, useQueryClient } from 'react-query'; | ||
// import { Systems } from '@tapis/tapis-typescript'; | ||
// import { Systems as API } from '@tapis/tapisui-api'; | ||
// import { useTapisConfig } from '../../'; | ||
// import QueryKeys from './queryKeys'; | ||
import { useMutation, MutateOptions, useQueryClient } from 'react-query'; | ||
import { Systems } from '@tapis/tapis-typescript'; | ||
import { Systems as API } from '@tapis/tapisui-api'; | ||
import { useTapisConfig } from '../../'; | ||
import QueryKeys from './queryKeys'; | ||
|
||
// type CreateUserCredentialHookParams = { | ||
// systemId: string; | ||
// username: string; | ||
// reqUpdateCredential: Systems.ReqUpdateCredential | ||
// }; | ||
type CreateUserCredentialHookParams = { | ||
systemId: string; | ||
userName: string; | ||
reqUpdateCredential: Systems.ReqUpdateCredential | ||
}; | ||
|
||
// const useCreate = () => { | ||
// const { basePath, accessToken } = useTapisConfig(); | ||
// const jwt = accessToken?.access_token || ''; | ||
// const queryClient = useQueryClient(); | ||
const useCreate = () => { | ||
const { basePath, accessToken } = useTapisConfig(); | ||
const jwt = accessToken?.access_token || ''; | ||
const queryClient = useQueryClient(); | ||
|
||
// // The useMutation react-query hook is used to call operations that make server-side changes | ||
// // (Other hooks would be used for data retrieval) | ||
// // | ||
// // In this case, create helper is called to perform the operation | ||
// const { mutate, isLoading, isError, isSuccess, data, error, reset } = | ||
// useMutation<Systems.RespBasic, Error, CreateUserCredentialHookParams>( | ||
// [QueryKeys.createUserCredential, basePath, jwt], | ||
// (params) => API.createUserCredential({ reqGroup: params }, basePath, jwt) | ||
// ); | ||
// The useMutation react-query hook is used to call operations that make server-side changes | ||
// (Other hooks would be used for data retrieval) | ||
// | ||
// In this case, create helper is called to perform the operation | ||
const { mutate, isLoading, isError, isSuccess, data, error, reset } = | ||
useMutation<Systems.RespBasic, Error, CreateUserCredentialHookParams>( | ||
[QueryKeys.createUserCredential, basePath, jwt], | ||
(params) => API.createUserCredentials(params, basePath, jwt) | ||
); | ||
|
||
// const invalidate = () => { | ||
// queryClient.invalidateQueries(QueryKeys.list); | ||
// }; | ||
const invalidate = () => { | ||
queryClient.invalidateQueries(QueryKeys.list); | ||
}; | ||
|
||
// // Return hook object with loading states and login function | ||
// return { | ||
// isLoading, | ||
// isError, | ||
// isSuccess, | ||
// data, | ||
// error, | ||
// reset, | ||
// invalidate, | ||
// create: ( | ||
// params: CreateGroupHookParams, | ||
// // react-query options to allow callbacks such as onSuccess | ||
// options?: MutateOptions< | ||
// Systems.RespResourceURL, | ||
// Error, | ||
// CreateGroupHookParams | ||
// > | ||
// ) => { | ||
// // Call mutate to trigger a single post-like API operation | ||
// return mutate(params, options); | ||
// }, | ||
// }; | ||
// }; | ||
// Return hook object with loading states and login function | ||
return { | ||
isLoading, | ||
isError, | ||
isSuccess, | ||
data, | ||
error, | ||
reset, | ||
invalidate, | ||
create: ( | ||
params: CreateUserCredentialHookParams, | ||
// react-query options to allow callbacks such as onSuccess | ||
options?: MutateOptions< | ||
Systems.RespBasic, | ||
Error, | ||
CreateUserCredentialHookParams | ||
> | ||
) => { | ||
// Call mutate to trigger a single post-like API operation | ||
return mutate(params, options); | ||
}, | ||
}; | ||
}; | ||
|
||
// export default useCreate; | ||
export {}; | ||
export default useCreate; |