forked from calcom/cal.com
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add trpc * trpc specific * fix deps * lint fix * upgrade prisma * nativeTypes * nope, not needed * fix app propviders * Revert "upgrade prisma" This reverts commit e6f2d25. * rev * up trpc * simplify * wip - bookings page with trpc * bookings using trpc * fix `Shell` props * call it viewerRouter instead * cleanuop * ssg helper * fix lint * fix types * skip * add `useRedirectToLoginIfUnauthenticated` * exhaustive-deps * fix callbackUrl * rewrite `/availability` using trpc Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
- Loading branch information
1 parent
0938f6f
commit 3430065
Showing
18 changed files
with
483 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
describe("cancel", () => { | ||
describe.skip("cancel", () => { | ||
describe("Admin user can cancel events", () => { | ||
before(() => { | ||
cy.visit("/bookings"); | ||
cy.login("[email protected]", "pro"); | ||
}); | ||
it.skip("can cancel bookings", () => { | ||
it("can cancel bookings", () => { | ||
cy.visit("/bookings"); | ||
cy.get("[data-testid=bookings]").children().should("have.length.at.least", 1); | ||
cy.get("[data-testid=cancel]").click(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,56 @@ | ||
import { IdProvider } from "@radix-ui/react-id"; | ||
import { httpBatchLink } from "@trpc/client/links/httpBatchLink"; | ||
import { loggerLink } from "@trpc/client/links/loggerLink"; | ||
import { withTRPC } from "@trpc/next"; | ||
import { Provider } from "next-auth/client"; | ||
import { AppProps } from "next/dist/shared/lib/router/router"; | ||
import React from "react"; | ||
import { HydrateProps, QueryClient, QueryClientProvider } from "react-query"; | ||
import { Hydrate } from "react-query/hydration"; | ||
|
||
import DynamicIntercomProvider from "@ee/lib/intercom/providerDynamic"; | ||
|
||
import { Session } from "@lib/auth"; | ||
import { createTelemetryClient, TelemetryProvider } from "@lib/telemetry"; | ||
|
||
export const queryClient = new QueryClient(); | ||
|
||
type AppProviderProps = { | ||
pageProps: { | ||
session?: Session; | ||
dehydratedState?: HydrateProps; | ||
}; | ||
}; | ||
|
||
const AppProviders: React.FC<AppProviderProps> = ({ pageProps, children }) => { | ||
const AppProviders = (props: AppProps) => { | ||
return ( | ||
<TelemetryProvider value={createTelemetryClient()}> | ||
<QueryClientProvider client={queryClient}> | ||
<IdProvider> | ||
<DynamicIntercomProvider> | ||
<Hydrate state={pageProps.dehydratedState}> | ||
<Provider session={pageProps.session}>{children}</Provider> | ||
</Hydrate> | ||
</DynamicIntercomProvider> | ||
</IdProvider> | ||
</QueryClientProvider> | ||
<IdProvider> | ||
<DynamicIntercomProvider> | ||
<Provider session={props.pageProps.session}>{props.children}</Provider> | ||
</DynamicIntercomProvider> | ||
</IdProvider> | ||
</TelemetryProvider> | ||
); | ||
}; | ||
|
||
export default AppProviders; | ||
export default withTRPC({ | ||
config() { | ||
/** | ||
* If you want to use SSR, you need to use the server's full URL | ||
* @link https://trpc.io/docs/ssr | ||
*/ | ||
return { | ||
/** | ||
* @link https://trpc.io/docs/links | ||
*/ | ||
links: [ | ||
// adds pretty logs to your console in development and logs errors in production | ||
loggerLink({ | ||
enabled: (opts) => | ||
process.env.NODE_ENV === "development" || | ||
(opts.direction === "down" && opts.result instanceof Error), | ||
}), | ||
httpBatchLink({ | ||
url: `/api/trpc`, | ||
}), | ||
], | ||
/** | ||
* @link https://react-query.tanstack.com/reference/QueryClient | ||
*/ | ||
// queryClientConfig: { defaultOptions: { queries: { staleTime: 6000 } } }, | ||
}; | ||
}, | ||
/** | ||
* @link https://trpc.io/docs/ssr | ||
*/ | ||
ssr: false, | ||
})(AppProviders); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// ℹ️ Type-only import: | ||
// https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export | ||
import type { AppRouter } from "@server/routers/_app"; | ||
import { createReactQueryHooks } from "@trpc/react"; | ||
import type { inferProcedureOutput, inferProcedureInput } from "@trpc/server"; | ||
|
||
/** | ||
* A set of strongly-typed React hooks from your `AppRouter` type signature with `createReactQueryHooks`. | ||
* @link https://trpc.io/docs/react#3-create-trpc-hooks | ||
*/ | ||
export const trpc = createReactQueryHooks<AppRouter>(); | ||
|
||
// export const transformer = superjson; | ||
/** | ||
* This is a helper method to infer the output of a query resolver | ||
* @example type HelloOutput = inferQueryOutput<'hello'> | ||
*/ | ||
export type inferQueryOutput<TRouteKey extends keyof AppRouter["_def"]["queries"]> = inferProcedureOutput< | ||
AppRouter["_def"]["queries"][TRouteKey] | ||
>; | ||
|
||
export type inferQueryInput<TRouteKey extends keyof AppRouter["_def"]["queries"]> = inferProcedureInput< | ||
AppRouter["_def"]["queries"][TRouteKey] | ||
>; | ||
|
||
export type inferMutationInput<TRouteKey extends keyof AppRouter["_def"]["mutations"]> = inferProcedureInput< | ||
AppRouter["_def"]["mutations"][TRouteKey] | ||
>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* This file contains tRPC's HTTP response handler | ||
*/ | ||
import { createContext } from "@server/createContext"; | ||
import { appRouter } from "@server/routers/_app"; | ||
import * as trpcNext from "@trpc/server/adapters/next"; | ||
|
||
export default trpcNext.createNextApiHandler({ | ||
router: appRouter, | ||
/** | ||
* @link https://trpc.io/docs/context | ||
*/ | ||
createContext, | ||
/** | ||
* @link https://trpc.io/docs/error-handling | ||
*/ | ||
onError({ error }) { | ||
if (error.code === "INTERNAL_SERVER_ERROR") { | ||
// send to bug reporting | ||
console.error("Something went wrong", error); | ||
} | ||
}, | ||
/** | ||
* Enable query batching | ||
*/ | ||
batching: { | ||
enabled: true, | ||
}, | ||
/** | ||
* @link https://trpc.io/docs/caching#api-response-caching | ||
*/ | ||
// responseMeta() { | ||
// // ... | ||
// }, | ||
}); |
Oops, something went wrong.