Skip to content

Commit

Permalink
frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
r4zendev committed Aug 29, 2024
1 parent b2ae3a0 commit 5c2c9f2
Show file tree
Hide file tree
Showing 20 changed files with 861 additions and 382 deletions.
34 changes: 34 additions & 0 deletions apps/backend/src/handlers/codemod-runs/codemod-runs.get.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import type { ApiResponse } from "@codemod-com/api-types";
import type { UserDataPopulatedRequest } from "@codemod-com/auth";
import { prisma } from "@codemod-com/database";
import type { CodemodRun } from "@codemod-com/database";
import type { RouteHandler } from "fastify";
import { parsePaginatedGetQuery } from "#schemata/schema.js";

export type GetCodemodRunsResponse = ApiResponse<{
total: number;
data: CodemodRun[];
}>;

export const getCodemodRunsHandler: RouteHandler<{
Reply: GetCodemodRunsResponse;
}> = async (request: UserDataPopulatedRequest) => {
const query = parsePaginatedGetQuery(request.query);

const userId = request.user?.id;
const [total, codemodRuns] = await Promise.all([
prisma.codemodRun.count({
where: { ownerId: userId },
}),
prisma.codemodRun.findMany({
where: { ownerId: userId },
take: query.size,
skip: query.size && query.page ? query.size * (query.page - 1) : 0,
}),
]);

return {
total,
data: codemodRuns,
};
};
20 changes: 9 additions & 11 deletions apps/backend/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ import {
type PutInsightResponse,
putInsightHandler,
} from "#handlers/insights/insight.put.js";
import {
type GetCodemodRunsResponse,
getCodemodRunsHandler,
} from "./handlers/codemod-runs/codemod-runs.get.js";
import { getCodemodsListHandler } from "./handlers/codemods/codemod-list.get.js";
import { getCodemodHandler } from "./handlers/codemods/codemod.get.js";
import {
Expand Down Expand Up @@ -394,17 +398,11 @@ const routes: FastifyPluginCallback = (instance, _opts, done) => {
putInsightHandler,
);

// instance.get<{ Reply: GetWidgetsResponse }>(
// "/widgets",
// { preHandler: [instance.getUserData] },
// getWidgetsHandler,
// );

// instance.get<{ Reply: GetWidgetResponse }>(
// "/widget/:id",
// { preHandler: [instance.getUserData] },
// getWidgetHandler,
// );
instance.get<{ Reply: GetCodemodRunsResponse }>(
"/codemod-runs",
{ preHandler: [instance.getUserData] },
getCodemodRunsHandler,
);

instance.put<{ Reply: PutWidgetResponse }>(
"/widget",
Expand Down
9 changes: 0 additions & 9 deletions apps/frontend/app/(website)/auth/layout.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function SignInPage() {
return (
<div className="flex h-screen w-screen items-center justify-center">
<SignIn
forceRedirectUrl={isStudio ? "/studio" : "/registry"}
fallbackRedirectUrl={isStudio ? "/studio" : "/registry"}
appearance={{ elements: { footer: { display: "none" } } }}
/>
</div>
Expand Down
Loading

0 comments on commit 5c2c9f2

Please sign in to comment.