Enables strict mode in nextjs apps (#2354)
- We need this so zod works correctly Co-authored-by: Peer Richelsen <[email protected]>
This commit is contained in:
1 parent
4ff21deb89
commit
a7f5250b4a
25 files changed
+178
-68
No files matched your search
@@ -21,7 +21,7 @@ import { AvatarSSR } from "@components/ui/AvatarSSR";
|
||||
import { ssrInit } from "@server/lib/ssr";
|
||||
|
||||
const EventTypeDescription = dynamic(() => import("@components/eventtype/EventTypeDescription"));
|
||||
const HeadSeo = dynamic(() => import("@components/seo/head-seo").then((mod) => mod.HeadSeo));
|
||||
const HeadSeo = dynamic(() => import("@components/seo/head-seo"));
|
||||
const CryptoSection = dynamic(() => import("../ee/components/web3/CryptoSection"));
|
||||
|
||||
interface EvtsToVerify {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { NextApiRequest, NextApiResponse } from "next";
|
||||
import { NextApiHandler, NextApiRequest, NextApiResponse } from "next";
|
||||
|
||||
import appStore from "@calcom/app-store";
|
||||
|
||||
@@ -26,7 +26,12 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
try {
|
||||
// TODO: Find a way to dynamically import these modules
|
||||
// const app = (await import(`@calcom/${appName}`)).default;
|
||||
const handler = appStore[appName].api[apiEndpoint];
|
||||
const app = appStore[appName as keyof typeof appStore];
|
||||
if (!(app && "api" in app && apiEndpoint in app.api))
|
||||
throw new HttpError({ statusCode: 404, message: `API handler not found` });
|
||||
|
||||
const handler = app.api[apiEndpoint as keyof typeof app.api] as NextApiHandler;
|
||||
|
||||
if (typeof handler !== "function")
|
||||
throw new HttpError({ statusCode: 404, message: `API handler not found` });
|
||||
|
||||
|
||||
@@ -16,13 +16,15 @@ import App from "@components/App";
|
||||
import Slider from "@components/apps/Slider";
|
||||
|
||||
const components = {
|
||||
a: ({ href, ...otherProps }) => (
|
||||
a: ({ href = "", ...otherProps }: JSX.IntrinsicElements["a"]) => (
|
||||
<Link href={href}>
|
||||
<a {...otherProps} />
|
||||
</Link>
|
||||
),
|
||||
img: ({ src, alt = "", ...rest }) => <Image src={src} alt={alt} {...rest} />,
|
||||
Slider: ({ items }) => {
|
||||
img: ({ src = "", alt = "", placeholder, ...rest }: JSX.IntrinsicElements["img"]) => (
|
||||
<Image src={src} alt={alt} {...rest} />
|
||||
),
|
||||
Slider: ({ items }: { items: string[] }) => {
|
||||
const isTabletAndUp = useMediaQuery("(min-width: 960px)");
|
||||
return (
|
||||
<Slider<string>
|
||||
|
||||
@@ -23,7 +23,7 @@ import utc from "dayjs/plugin/utc";
|
||||
import { GetServerSidePropsContext } from "next";
|
||||
import { useRouter } from "next/router";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
import { Controller, Noop, useForm } from "react-hook-form";
|
||||
import { FormattedNumber, IntlProvider } from "react-intl";
|
||||
import Select, { Props as SelectProps } from "react-select";
|
||||
import { JSONObject } from "superjson/dist/types";
|
||||
@@ -86,7 +86,21 @@ type OptionTypeBase = {
|
||||
disabled?: boolean;
|
||||
};
|
||||
|
||||
const AvailabilitySelect = ({ className, ...props }: SelectProps) => {
|
||||
type AvailabilityOption = {
|
||||
label: string;
|
||||
value: number;
|
||||
};
|
||||
|
||||
const AvailabilitySelect = ({
|
||||
className = "",
|
||||
...props
|
||||
}: {
|
||||
className?: string;
|
||||
name: string;
|
||||
value: number;
|
||||
onBlur: Noop;
|
||||
onChange: (value: AvailabilityOption | null) => void;
|
||||
}) => {
|
||||
const query = trpc.useQuery(["viewer.availability.list"]);
|
||||
|
||||
return (
|
||||
@@ -105,9 +119,9 @@ const AvailabilitySelect = ({ className, ...props }: SelectProps) => {
|
||||
);
|
||||
return (
|
||||
<Select
|
||||
{...props}
|
||||
options={options}
|
||||
isSearchable={false}
|
||||
onChange={props.onChange}
|
||||
classNamePrefix="react-select"
|
||||
className={classNames(
|
||||
"react-select-container focus:border-primary-500 focus:ring-primary-500 block w-full min-w-0 flex-1 rounded-sm border border-gray-300 sm:text-sm",
|
||||
@@ -972,10 +986,10 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => {
|
||||
control={formMethods.control}
|
||||
render={({ field }) => (
|
||||
<AvailabilitySelect
|
||||
{...field}
|
||||
onChange={(selected: { label: string; value: number }) =>
|
||||
field.onChange(selected.value)
|
||||
}
|
||||
value={field.value}
|
||||
onBlur={field.onBlur}
|
||||
name={field.name}
|
||||
onChange={(selected) => field.onChange(selected?.value || null)}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
|
||||
@@ -268,7 +268,7 @@ export default function Onboarding(props: inferSSRProps<typeof getServerSideProp
|
||||
|
||||
// Should update username on user when being redirected from sign up and doing google/saml
|
||||
useEffect(() => {
|
||||
async function validateAndSave(username) {
|
||||
async function validateAndSave(username: string) {
|
||||
const { data } = await fetchUsername(username);
|
||||
|
||||
// Only persist username if its available and not premium
|
||||
|
||||
Reference in new issue
Block a user