mirror of
https://github.com/khairul169/vaulterm.git
synced 2026-09-15 17:03:30 +07:00
feat: team access control
This commit is contained in:
@@ -1,8 +1,13 @@
|
||||
import api, { queryClient } from "@/lib/api";
|
||||
import api from "@/lib/api";
|
||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||
import { FormSchema } from "../schema/form";
|
||||
import queryClient from "@/lib/queryClient";
|
||||
import { useTeamId } from "@/stores/auth";
|
||||
|
||||
export const useKeychains = (params?: any) => {
|
||||
const teamId = useTeamId();
|
||||
const query = { teamId, ...params };
|
||||
|
||||
export const useKeychains = (query?: any) => {
|
||||
return useQuery({
|
||||
queryKey: ["keychains", query],
|
||||
queryFn: () => api("/keychains", { query }),
|
||||
@@ -11,8 +16,11 @@ export const useKeychains = (query?: any) => {
|
||||
};
|
||||
|
||||
export const useSaveKeychain = () => {
|
||||
const teamId = useTeamId();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async (body: FormSchema) => {
|
||||
mutationFn: async (payload: FormSchema) => {
|
||||
const body = { teamId, ...payload };
|
||||
return body.id
|
||||
? api(`/keychains/${body.id}`, { method: "PUT", body })
|
||||
: api(`/keychains`, { method: "POST", body });
|
||||
|
||||
Reference in New Issue
Block a user