- {timeRecords?.map((timeRecord) => (
+ {timeRecords.map((timeRecord) => (
{displayTime({ date: timeRecord.time })}
diff --git a/apps/nextjs/src/app/team/[teamId]/_components/user-info.tsx b/apps/nextjs/src/app/team/[teamId]/_components/user-info.tsx
index aec2af9..2138bf3 100644
--- a/apps/nextjs/src/app/team/[teamId]/_components/user-info.tsx
+++ b/apps/nextjs/src/app/team/[teamId]/_components/user-info.tsx
@@ -1,4 +1,4 @@
-import { RouterOutputs } from "@acme/api";
+import type { RouterOutputs } from "@acme/api";
import dayjs, { displayTime } from "~/utils/dayjs";
@@ -6,11 +6,9 @@ type TeamMember = RouterOutputs["teamMember"]["get"];
type History = RouterOutputs["timeRecord"]["history"];
export function UserInfo({
- teamId,
teamMember,
history,
}: {
- teamId: string;
teamMember: TeamMember;
history: History;
}) {
@@ -44,7 +42,7 @@ export function UserInfo({
{displayTime({
- date: dayjs(teamMember?.createdAt),
+ date: dayjs(teamMember.createdAt),
format: "DD/MM/YYYY",
})}
@@ -59,7 +57,7 @@ export function UserInfo({
SALDO
ACUMULADO
- {history?.map((month, i) => (
+ {history.map((month, i) => (
{month.label}
diff --git a/apps/nextjs/src/app/team/join/page.tsx b/apps/nextjs/src/app/team/join/page.tsx
index 7df6cbc..c94c59f 100644
--- a/apps/nextjs/src/app/team/join/page.tsx
+++ b/apps/nextjs/src/app/team/join/page.tsx
@@ -35,8 +35,8 @@ export default function Page({
});
const createTeamMember = api.teamMember.create.useMutation({
- onSuccess: async (team) => {
- await router.push(`/team/${team.id}`);
+ onSuccess: (team) => {
+ router.push(`/team/${team.id}`);
},
onError: (err) => {
toast.error(err.message);
diff --git a/apps/nextjs/src/app/team/new/page.tsx b/apps/nextjs/src/app/team/new/page.tsx
index 890742b..dba94f2 100644
--- a/apps/nextjs/src/app/team/new/page.tsx
+++ b/apps/nextjs/src/app/team/new/page.tsx
@@ -29,8 +29,8 @@ export default function Page() {
});
const createTeam = api.team.create.useMutation({
- onSuccess: async (team) => {
- await router.push(`/team/${team.id}`);
+ onSuccess: (team) => {
+ router.push(`/team/${team.id}`);
},
onError: (err) => {
toast.error(
diff --git a/apps/nextjs/src/env.mjs b/apps/nextjs/src/env.ts
similarity index 100%
rename from apps/nextjs/src/env.mjs
rename to apps/nextjs/src/env.ts
diff --git a/apps/nextjs/src/trpc/react.tsx b/apps/nextjs/src/trpc/react.tsx
index 9921249..b9ac6f1 100644
--- a/apps/nextjs/src/trpc/react.tsx
+++ b/apps/nextjs/src/trpc/react.tsx
@@ -8,7 +8,7 @@ import SuperJSON from "superjson";
import type { AppRouter } from "@acme/api";
-import { env } from "~/env.mjs";
+import { env } from "~/env";
const createQueryClient = () =>
new QueryClient({
diff --git a/apps/nextjs/src/utils/dayjs.ts b/apps/nextjs/src/utils/dayjs.ts
index 27f3466..2d3ea9c 100644
--- a/apps/nextjs/src/utils/dayjs.ts
+++ b/apps/nextjs/src/utils/dayjs.ts
@@ -1,4 +1,5 @@
-import lib, { ConfigType, Dayjs, OptionType } from "dayjs";
+import type { ConfigType, OptionType } from "dayjs";
+import lib, { Dayjs } from "dayjs";
import ptbr from "dayjs/locale/pt-br";
import minMax from "dayjs/plugin/minMax";
import timezone from "dayjs/plugin/timezone";
diff --git a/apps/nextjs/tsconfig.json b/apps/nextjs/tsconfig.json
index 91fc90a..893effc 100644
--- a/apps/nextjs/tsconfig.json
+++ b/apps/nextjs/tsconfig.json
@@ -1,17 +1,11 @@
{
"extends": "@acme/tsconfig/base.json",
"compilerOptions": {
- "lib": [
- "es2022",
- "dom",
- "dom.iterable"
- ],
+ "lib": ["es2022", "dom", "dom.iterable"],
"jsx": "preserve",
"baseUrl": ".",
"paths": {
- "~/*": [
- "src/*"
- ]
+ "~/*": ["src/*"]
},
"plugins": [
{
@@ -22,11 +16,6 @@
"module": "esnext",
"strictNullChecks": true
},
- "include": [
- ".",
- ".next/types/**/*.ts"
- ],
- "exclude": [
- "node_modules"
- ]
-}
\ No newline at end of file
+ "include": [".", ".next/types/**/*.ts"],
+ "exclude": ["node_modules"]
+}
diff --git a/packages/api/src/root.ts b/packages/api/src/root.ts
index c4e3d5c..d10519c 100644
--- a/packages/api/src/root.ts
+++ b/packages/api/src/root.ts
@@ -1,4 +1,3 @@
-
import { authRouter } from "./router/auth";
import { teamRouter } from "./router/team";
import { teamMemberRouter } from "./router/team-member";
diff --git a/packages/api/src/router/team.ts b/packages/api/src/router/team.ts
index 39c2973..0d66bb8 100644
--- a/packages/api/src/router/team.ts
+++ b/packages/api/src/router/team.ts
@@ -1,3 +1,4 @@
+import { TRPCError } from "@trpc/server";
import { z } from "zod";
import { and, eq, schema } from "@acme/db";
@@ -55,7 +56,14 @@ export const teamRouter = {
})
.returning();
- const team = res[0]!;
+ const team = res[0];
+
+ if (!team) {
+ throw new TRPCError({
+ code: "BAD_REQUEST",
+ message: "Time não encontrado",
+ });
+ }
await ctx.db.insert(schema.teamMember).values({
teamId: team.id,
diff --git a/packages/api/src/router/time-record.ts b/packages/api/src/router/time-record.ts
index 79cfcf7..b499bf7 100644
--- a/packages/api/src/router/time-record.ts
+++ b/packages/api/src/router/time-record.ts
@@ -39,11 +39,6 @@ export const timeRecordRouter = {
userId: true,
time: true,
},
- // where: {
- // userId: input.userId ?? ctx.session.user.id,
- // time: { gte: input?.start, lte: input?.end },
- // teamId: input.teamId,
- // },
where: and(
eq(schema.timeRecord.teamId, input.teamId),
eq(schema.timeRecord.userId, input.userId ?? ctx.session.user.id),
@@ -125,22 +120,24 @@ export const timeRecordRouter = {
orderBy: schema.timeRecord.time,
});
- const groupByYearMonthDay =
- timeRecords?.reduce(
- (acc, timeRecord) => {
- const day = timeRecord.time.getDate();
- const month = timeRecord.time.getMonth();
- const year = timeRecord.time.getFullYear();
-
- if (!acc[year]) acc[year] = {};
- if (!acc[year]?.[month]) acc[year]![month] = {};
- if (!acc[year]?.[month]?.[day]) acc[year]![month]![day] = [];
-
- acc[year]![month]![day]!.push(timeRecord.time);
- return acc;
- },
- {} as Record>>,
- ) ?? {};
+ const groupByYearMonthDay = timeRecords.reduce(
+ (acc, timeRecord) => {
+ const day = timeRecord.time.getDate();
+ const month = timeRecord.time.getMonth();
+ const year = timeRecord.time.getFullYear();
+
+ if (!acc[year]) acc[year] = {};
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ if (!acc[year]?.[month]) acc[year]![month] = {};
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ if (!acc[year]?.[month]?.[day]) acc[year]![month]![day] = [];
+
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ acc[year]![month]![day]!.push(timeRecord.time);
+ return acc;
+ },
+ {} as Record>>,
+ );
const historyResult: {
label: string;
diff --git a/packages/auth/env.ts b/packages/auth/env.ts
index 627caa1..770c20d 100644
--- a/packages/auth/env.ts
+++ b/packages/auth/env.ts
@@ -1,3 +1,4 @@
+/* eslint-disable no-restricted-properties */
import { createEnv } from "@t3-oss/env-nextjs";
import { z } from "zod";
diff --git a/packages/ui/src/calendar.tsx b/packages/ui/src/calendar.tsx
index 175f779..38d9e32 100644
--- a/packages/ui/src/calendar.tsx
+++ b/packages/ui/src/calendar.tsx
@@ -61,8 +61,8 @@ function Calendar({
...classNames,
}}
components={{
- IconLeft: ({ ...props }) => ,
- IconRight: ({ ...props }) => ,
+ IconLeft: () => ,
+ IconRight: () => ,
}}
{...props}
/>