fix: atoms useCheck and bump atoms version (#15390)

This commit is contained in:
Morgan
2024-06-11 13:38:39 +00:00
committed by GitHub
parent 33d7da88bf
commit 357a42b512
3 changed files with 6 additions and 8 deletions
@@ -6,7 +6,6 @@ import { Button } from "@calcom/ui";
import type { OnCheckErrorType } from "../hooks/connect/useCheck";
import { useCheck } from "../hooks/connect/useCheck";
import { useConnect } from "../hooks/connect/useConnect";
import { useAtomsContext } from "../hooks/useAtomsContext";
import { AtomsWrapper } from "../src/components/atoms-wrapper";
import { cn } from "../src/lib/utils";
@@ -28,16 +27,14 @@ export const OAuthConnect: FC<OAuthConnectProps & { calendar: (typeof CALENDARS)
calendar,
redir,
}) => {
const { isAuth } = useAtomsContext();
const { connect } = useConnect(calendar, redir);
const { allowConnect, checked } = useCheck({
isAuth,
onCheckError,
calendar: calendar,
});
const isChecking = !isAuth || !checked;
const isChecking = !checked;
const isDisabled = isChecking || !allowConnect;
let displayedLabel = label;
@@ -5,20 +5,21 @@ import { SUCCESS_STATUS, ERROR_STATUS } from "@calcom/platform-constants";
import type { ApiResponse, ApiErrorResponse } from "@calcom/platform-types";
import http from "../../lib/http";
import { useAtomsContext } from "../useAtomsContext";
export interface UseCheckProps {
isAuth: boolean;
onCheckError?: OnCheckErrorType;
calendar: (typeof CALENDARS)[number];
}
export type OnCheckErrorType = (err: ApiErrorResponse) => void;
export const getQueryKey = (calendar: (typeof CALENDARS)[number]) => [`get-${calendar}-check`];
export const useCheck = ({ isAuth, onCheckError, calendar }: UseCheckProps) => {
export const useCheck = ({ onCheckError, calendar }: UseCheckProps) => {
const { isInit } = useAtomsContext();
const { data: check } = useQuery({
queryKey: getQueryKey(calendar),
staleTime: 6000,
enabled: isAuth,
enabled: isInit,
queryFn: () => {
return http
?.get<ApiResponse<{ checked: boolean; allowConnect: boolean }>>(`/calendars/${calendar}/check`)
+1 -1
View File
@@ -4,7 +4,7 @@
"type": "module",
"description": "Customizable UI components to integrate scheduling into your product.",
"authors": "Cal.com, Inc.",
"version": "1.0.40",
"version": "1.0.52",
"scripts": {
"dev": "yarn vite build --watch & npx tailwindcss -i ./globals.css -o ./globals.min.css --postcss --minify --watch",
"build": "yarn vite build && npx tailwindcss -i ./globals.css -o ./globals.min.css --postcss --minify && mkdir ./dist/packages/prisma-client && cp -rf ../../../node_modules/.prisma/client/*.d.ts ./dist/packages/prisma-client",