All files / src/features/Merchants/MerchantSidePanel/GiveMerchantFile/hooks useTagHandler.tsx

44.44% Statements 4/9
0% Branches 0/2
50% Functions 1/2
50% Lines 4/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28          52x 691x 691x                                 691x      
import { updateFile } from "@hooks/common/documents/utils";
import { useQueryClient } from "react-query";
import { MERCHANT_SIDE_PANEL_PREVIEW_API_KEYS } from "../../constants";
import { QKEY_CHALLENGE_FILES } from "@constants/queryKeys";
 
const useTagHandler = () => {
  const queryClient = useQueryClient();
  const editTagHandler = async ({
    merchantID,
    documentID,
    data,
  }: {
    merchantID: number;
    documentID?: number;
    data?: any;
  }) => {
    if (!documentID) return;
    await updateFile(merchantID, documentID, data);
    queryClient.invalidateQueries([
      MERCHANT_SIDE_PANEL_PREVIEW_API_KEYS.GET_FILES,
      merchantID,
    ]);
    queryClient.invalidateQueries([QKEY_CHALLENGE_FILES, merchantID]);
  };
  return { editTagHandler };
};
export default useTagHandler;