Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: upgrade t3 stack to latest #118

Merged
merged 25 commits into from
Mar 31, 2024
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
288e751
fix: upgrade turbo to latest version
Security2431 Mar 9, 2024
da4a89c
fix: upgrade .github, .vscode to latest version
Security2431 Mar 9, 2024
ceeddf4
fix: add packages/validators
Security2431 Mar 9, 2024
3afb46b
fix: upgrade tooling folder to latest version
Security2431 Mar 9, 2024
95c81f8
fix: upgrade packages/ui to latest
Security2431 Mar 9, 2024
45a333e
fix: upgrade auth to latest version
Security2431 Mar 9, 2024
e978c2a
fix: upgrade trpc to latest version
Security2431 Mar 9, 2024
7d62dbe
fix: upgrade nextjs ui
Security2431 Mar 9, 2024
1a9f7dd
fix: configure theme UI
Security2431 Mar 9, 2024
bd2f4b0
fix: minor updates
Security2431 Mar 9, 2024
5ca507e
fix: add shadcn/ui library
Security2431 Mar 31, 2024
1a5a86f
fix: upgrade db
Security2431 Mar 31, 2024
1c3c2d4
fix: add zod schema validators
Security2431 Mar 31, 2024
6bfa69a
fix: upgrade packages/auth
Security2431 Mar 31, 2024
08a579c
fix: upgrade trpc endpoints
Security2431 Mar 31, 2024
db22ed0
fix: add images
Security2431 Mar 31, 2024
f6bb9dd
refactor: components
Security2431 Mar 31, 2024
e4d0a17
refactor: move hooks & utils to /src folder
Security2431 Mar 31, 2024
5865914
fix: upgrade nextjs common layout
Security2431 Mar 31, 2024
55c50b7
fix: delete migrated folders
Security2431 Mar 31, 2024
79d8a6b
fix: add public group routes
Security2431 Mar 31, 2024
7b2e81e
fix: upgrade workspaces structure
Security2431 Mar 31, 2024
ba302d1
fix: reactions hydration
Security2431 Mar 31, 2024
8a8a19b
fix: day report UI cards
Security2431 Mar 31, 2024
8038e83
fix: reload page on weekends switch
Security2431 Mar 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: upgrade trpc endpoints
Security2431 committed Mar 31, 2024
commit 08a579cd43f4fb00a283a9581f831ce59088cbfd
12 changes: 7 additions & 5 deletions packages/api/src/router/project.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import { z } from "zod";

import { createTRPCRouter, protectedProcedure, publicProcedure } from "../trpc";
import { Role } from "@acme/db";

import { createTRPCRouter, protectedProcedure } from "../trpc";

export const projectRouter = createTRPCRouter({
all: publicProcedure.query(({ ctx }) => {
all: protectedProcedure.query(({ ctx }) => {
return ctx.db.project.findMany({ orderBy: { id: "desc" } });
}),
byId: publicProcedure
byId: protectedProcedure
.input(z.object({ id: z.string() }))
.query(({ ctx, input }) => {
return ctx.db.project.findFirst({ where: { id: input.id } });
}),
byWorkspaceId: publicProcedure
byWorkspaceId: protectedProcedure
.input(z.object({ id: z.string() }))
.query(({ ctx, input }) => {
return ctx.db.project.findMany({
@@ -23,7 +25,7 @@ export const projectRouter = createTRPCRouter({
},
});
}),
create: publicProcedure
create: protectedProcedure
.input(
z.object({
name: z.string().min(1),
8 changes: 4 additions & 4 deletions packages/api/src/router/report.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { z } from "zod";

import { createTRPCRouter, protectedProcedure, publicProcedure } from "../trpc";
import { createTRPCRouter, protectedProcedure } from "../trpc";

export const reportRouter = createTRPCRouter({
all: publicProcedure.query(({ ctx }) => {
all: protectedProcedure.query(({ ctx }) => {
return ctx.db.report.findMany({
orderBy: { id: "desc" },
});
}),
byId: publicProcedure
byId: protectedProcedure
.input(z.object({ id: z.string() }))
.query(({ ctx, input }) => {
return ctx.db.report.findFirst({ where: { id: input.id } });
}),
create: publicProcedure
create: protectedProcedure
.input(
z.object({
sprintId: z.string().min(1),
32 changes: 8 additions & 24 deletions packages/api/src/router/sprint.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { z } from "zod";

import { createTRPCRouter, protectedProcedure, publicProcedure } from "../trpc";
import { DayType } from "@acme/db";

import { createTRPCRouter, protectedProcedure } from "../trpc";

export const sprintRouter = createTRPCRouter({
all: publicProcedure.query(({ ctx }) => {
all: protectedProcedure.query(({ ctx }) => {
return ctx.db.sprint.findMany({
orderBy: { id: "desc" },
});
}),
byDateRange: publicProcedure
byDateRange: protectedProcedure
.input(z.object({ workspaceId: z.string(), from: z.date(), to: z.date() }))
.query(async ({ ctx, input }) => {
return await ctx.db.sprint.findMany({
@@ -50,7 +52,7 @@ export const sprintRouter = createTRPCRouter({
orderBy: [{ date: "asc" }],
});
}),
byId: publicProcedure
byId: protectedProcedure
.input(z.object({ id: z.string() }))
.query(({ ctx, input }) => {
return ctx.db.sprint.findFirst({ where: { id: input.id } });
@@ -62,16 +64,7 @@ export const sprintRouter = createTRPCRouter({
workspaceId: z.string().min(1),
userId: z.string().min(1),
date: z.date(),
type: z.enum([
"WORKING",
"HOME_OFFICE",
"NOT_WORKING",
"HALF_DAY_VACATION",
"VACATION",
"SICK_DAY",
"ILLNESS",
"TRAVELING",
]),
type: z.nativeEnum(DayType),
tomorrowsDescription: z.string().optional(),
reports: z
.array(
@@ -121,16 +114,7 @@ export const sprintRouter = createTRPCRouter({
workspaceId: z.string().min(1),
userId: z.string().min(1),
date: z.date(),
type: z.enum([
"WORKING",
"HOME_OFFICE",
"NOT_WORKING",
"HALF_DAY_VACATION",
"VACATION",
"SICK_DAY",
"ILLNESS",
"TRAVELING",
]),
type: z.nativeEnum(DayType),
tomorrowsDescription: z.string().optional(),
reports: z
.array(
6 changes: 3 additions & 3 deletions packages/api/src/router/user.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { z } from "zod";

import { createTRPCRouter, protectedProcedure, publicProcedure } from "../trpc";
import { createTRPCRouter, protectedProcedure } from "../trpc";

export const userRouter = createTRPCRouter({
all: protectedProcedure.query(({ ctx }) => {
@@ -26,7 +26,7 @@ export const userRouter = createTRPCRouter({
.query(({ ctx, input }) => {
return ctx.db.user.findFirst({ where: { id: input.id } });
}),
create: publicProcedure
create: protectedProcedure
.input(
z.object({
name: z.string().min(1),
@@ -41,7 +41,7 @@ export const userRouter = createTRPCRouter({
.mutation(({ ctx, input }) => {
return ctx.db.user.create({ data: input });
}),
update: publicProcedure
update: protectedProcedure
.input(
z
.object({
110 changes: 110 additions & 0 deletions packages/api/src/router/workspace.ts
Original file line number Diff line number Diff line change
@@ -106,14 +106,124 @@ export const workspaceRouter = createTRPCRouter({
delete: protectedProcedure
.input(z.string())
.mutation(async ({ ctx, input }) => {
const userRole = await ctx.db.workspacesMembers.findFirst({
where: {
workspaceId: input,
userId: ctx.session.user.id,
},
select: {
permissions: true,
},
});

if (!userRole?.permissions.includes(Role.ADMIN)) {
throw new TRPCError({
code: "FORBIDDEN",
message: "You must be an admin to delete a workspace",
});
}

const workspaceData = await ctx.db.workspace.findFirst({
where: {
id: input,
},
include: {
teams: true,
projects: true,
integrations: true,
invitations: true,
sprints: true,
},
});

const [, workspace] = await ctx.db.$transaction([
ctx.db.team.findMany({
where: {
id: { in: workspaceData?.teams.map((team) => team.id) },
},
}),
ctx.db.project.findMany({
where: {
id: { in: workspaceData?.projects.map((project) => project.id) },
},
}),
ctx.db.integration.findMany({
where: {
id: {
in: workspaceData?.integrations.map(
(integration) => integration.id,
),
},
},
}),
ctx.db.invitation.deleteMany({
where: {
id: {
in: workspaceData?.invitations.map((invitation) => invitation.id),
},
},
}),
ctx.db.sprint.deleteMany({
where: {
id: {
in: workspaceData?.sprints.map((sprint) => sprint.id),
},
},
}),
ctx.db.workspacesMembers.deleteMany({
where: {
workspaceId: input,
},
}),
// ctx.db.team.deleteMany({
// where: {
// workspaceId: input,
// },
// }),
// ctx.db.sprint.deleteMany({
// where: {
// workspaceId: input,
// },
// }),
// ctx.db.reaction.deleteMany({
// where: {
// workspaceId: input,
// },
// }),
ctx.db.workspace.delete({ where: { id: input } }),
]);
console.log("workspace", workspaceData);

// const reports = await ctx.db.$transaction(async (tx) => {
// return Promise.all(
// input.reports?.map((report) => {
// if (!report.reportId) {
// return tx.report.create({
// data: {
// description: report.description,
// hours: report.hours,
// sprintId: sprint.id,
// projectId: report.projectId,
// },
// });
// }

// return tx.report.update({
// where: { id: report.reportId },
// data: {
// description: report.description,
// hours: report.hours,
// },
// });
// }),
// );
// });

// const workspace = await ctx.db.workspace.deleteMany({
// where: {
// id: input,
// },
// });

return workspace;
}),