diff --git a/packages/app-store/hitpay/components/KeyInput.tsx b/packages/app-store/hitpay/components/KeyInput.tsx index de829c0dee..8e560b4908 100644 --- a/packages/app-store/hitpay/components/KeyInput.tsx +++ b/packages/app-store/hitpay/components/KeyInput.tsx @@ -40,143 +40,144 @@ const Addon = ({ children, className, error }: AddonProps) => ( ); -export const KeyField = forwardRef( - function KeyField(props, ref) { - const id = useId(); - const [isPasswordVisible, setIsPasswordVisible] = useState(false); - const [currentValue, setCurrentValue] = useState(""); - const toggleIsPasswordVisible = useCallback( - () => setIsPasswordVisible(!isPasswordVisible), - [isPasswordVisible, setIsPasswordVisible] - ); +export const KeyField: React.FC = forwardRef< + HTMLInputElement, + InputFieldProps & { defaultValue: string } +>(function KeyField(props, ref) { + const id = useId(); + const [isPasswordVisible, setIsPasswordVisible] = useState(false); + const [currentValue, setCurrentValue] = useState(""); + const toggleIsPasswordVisible = useCallback( + () => setIsPasswordVisible(!isPasswordVisible), + [isPasswordVisible, setIsPasswordVisible] + ); - const { t: _t, isLocaleReady, i18n } = useLocale(); - const t = props.t || _t; - const name = props.name || ""; - const { - label = t(name), - labelProps, - labelClassName, - LockedIcon, - placeholder = isLocaleReady && i18n.exists(`${name}_placeholder`) ? t(`${name}_placeholder`) : "", - className, - addOnLeading, - addOnClassname, - inputIsFullWidth, - labelSrOnly, - noLabel, - containerClassName, - readOnly, - showAsteriskIndicator, - defaultValue, - ...passThrough - } = props; + const { t: _t, isLocaleReady, i18n } = useLocale(); + const t = props.t || _t; + const name = props.name || ""; + const { + label = t(name), + labelProps, + labelClassName, + LockedIcon, + placeholder = isLocaleReady && i18n.exists(`${name}_placeholder`) ? t(`${name}_placeholder`) : "", + className, + addOnLeading, + addOnClassname, + inputIsFullWidth, + labelSrOnly, + noLabel, + containerClassName, + readOnly, + showAsteriskIndicator, + defaultValue, + ...passThrough + } = props; - useEffect(() => { - if (currentValue.trim().length === 0) { - setIsPasswordVisible(true); - } - }, [currentValue]); + useEffect(() => { + if (currentValue.trim().length === 0) { + setIsPasswordVisible(true); + } + }, [currentValue]); - useEffect(() => { - setCurrentValue(defaultValue); - if (defaultValue.length > 0) { - setIsPasswordVisible(false); - } - }, [defaultValue]); + useEffect(() => { + setCurrentValue(defaultValue); + if (defaultValue.length > 0) { + setIsPasswordVisible(false); + } + }, [defaultValue]); - const getHiddenKey = (): string => { - let hiddenKey = currentValue; - const length = currentValue.length; - if (length > 6) { - const start = currentValue.slice(0, 3); - const end = currentValue.slice(length - 3); - hiddenKey = `${start}${"*".repeat(length - 6)}${end}`; - } + const getHiddenKey = (): string => { + let hiddenKey = currentValue; + const length = currentValue.length; + if (length > 6) { + const start = currentValue.slice(0, 3); + const end = currentValue.slice(length - 3); + hiddenKey = `${start}${"*".repeat(length - 6)}${end}`; + } - return hiddenKey; - }; + return hiddenKey; + }; - const onInput = (event: FormEvent) => { - const target = event.target as HTMLInputElement; - const fullValue = target.value; - setCurrentValue(fullValue); - target.value = fullValue; - }; + const onInput = (event: FormEvent) => { + const target = event.target as HTMLInputElement; + const fullValue = target.value; + setCurrentValue(fullValue); + target.value = fullValue; + }; - return ( -
- {!!label && !noLabel && ( - - {label} - {showAsteriskIndicator && !readOnly && passThrough.required ? ( - * - ) : null} - {LockedIcon} - - )} + return ( +
+ {!!label && !noLabel && ( + + {label} + {showAsteriskIndicator && !readOnly && passThrough.required ? ( + * + ) : null} + {LockedIcon} + + )} -
- {addOnLeading && ( - - {addOnLeading} - - )} - - - - +
+ {addOnLeading && ( + + {addOnLeading} -
+ )} + + + + +
- ); - } -); +
+ ); +}); export default KeyField; diff --git a/packages/app-store/routing-forms/pages/layout-handler/[...appPages].tsx b/packages/app-store/routing-forms/pages/layout-handler/[...appPages].tsx index c5370f7ae4..48ec8d4ed4 100644 --- a/packages/app-store/routing-forms/pages/layout-handler/[...appPages].tsx +++ b/packages/app-store/routing-forms/pages/layout-handler/[...appPages].tsx @@ -1,23 +1,27 @@ "use client"; -import type { GetServerSidePropsContext } from "next"; -import React from "react"; +import type { GetServerSidePropsContext, GetServerSideProps } from "next"; +import type { ReactElement, ReactNode, ComponentType } from "react"; import { FormProvider, useForm } from "react-hook-form"; import { useParamsWithFallback } from "@calcom/lib/hooks/useParamsWithFallback"; -import type { AppPrisma, AppSsrInit, AppUser } from "@calcom/types/AppGetServerSideProps"; - -import type { AppProps } from "@lib/app-providers"; import RoutingFormsRoutingConfig from "../app-routing.config"; const DEFAULT_ROUTE = "forms"; -type GetServerSidePropsRestArgs = [AppPrisma, AppUser, AppSsrInit]; -type Component = { - default: React.ComponentType & Pick; - getServerSideProps?: (context: GetServerSidePropsContext, ...rest: GetServerSidePropsRestArgs) => void; +type ComponentWithLayout = ComponentType & { + getLayout?: (page: ReactElement) => ReactNode; }; + +type Component = { + default: ComponentWithLayout; + getServerSideProps?: ( + context: GetServerSidePropsContext, + ...rest: Parameters + ) => ReturnType; +}; + const getComponent = (route: string): Component => { return (RoutingFormsRoutingConfig as unknown as Record)[route]; };