diff --git a/src/components/NewWorkspaceForm.tsx b/src/components/NewWorkspaceForm.tsx index aba4af9e..a33a4e31 100644 --- a/src/components/NewWorkspaceForm.tsx +++ b/src/components/NewWorkspaceForm.tsx @@ -19,7 +19,7 @@ export function NewWorkspaceForm() { const createWorkspace = api.workspace.create.useMutation({ onSuccess: (values) => { try { - if (values?.publicId) { + if (values?.publicId && values.name) { switchWorkspace({ publicId: values.publicId, name: values.name }); closeModal(); } diff --git a/src/components/dashboard.tsx b/src/components/dashboard.tsx index 53e6bcf6..37769521 100644 --- a/src/components/dashboard.tsx +++ b/src/components/dashboard.tsx @@ -1,15 +1,7 @@ -import { redirect } from "next/navigation"; - import SideNavigation from "./SideNavigation"; import FeedbackButton from "./FeedbackButton"; export default function Dashboard(props: { children: React.ReactNode }) { - // const session = await auth(); - - // if (!session?.user) { - // redirect("/api/auth/signin"); - // } - return (
diff --git a/src/pages/api/trpc/[trpc].ts b/src/pages/api/trpc/[trpc].ts index 84c02f2a..7fc33a39 100644 --- a/src/pages/api/trpc/[trpc].ts +++ b/src/pages/api/trpc/[trpc].ts @@ -1,11 +1,10 @@ -import { NextApiRequest, NextApiResponse } from 'next'; -import { createNextApiHandler, CreateNextContextOptions } from "@trpc/server/adapters/next"; +import { type NextApiRequest, type NextApiResponse } from "next"; +import { createNextApiHandler } from "@trpc/server/adapters/next"; import { env } from "~/env.mjs"; import { appRouter } from "~/server/api/root"; import { createTRPCContext } from "~/server/api/trpc"; - const nextApiHandler = createNextApiHandler({ router: appRouter, createContext: createTRPCContext, @@ -13,21 +12,16 @@ const nextApiHandler = createNextApiHandler({ env.NODE_ENV === "development" ? ({ path, error }) => { console.error( - `❌ tRPC failed on ${path ?? ""}: ${error.message}` + `❌ tRPC failed on ${path ?? ""}: ${error.message}`, ); } : undefined, }); -export default async function handler( - req: NextApiRequest, - res: NextApiResponse, -) { - +export default function handler(req: NextApiRequest, res: NextApiResponse) { return nextApiHandler(req, res); } // export const runtime = "edge"; // export const preferredRegion = 'lhr1'; // export const dynamic = 'force-dynamic' - diff --git a/src/providers/workspace.tsx b/src/providers/workspace.tsx index e92a9b80..4691d1b8 100644 --- a/src/providers/workspace.tsx +++ b/src/providers/workspace.tsx @@ -58,21 +58,27 @@ export const WorkspaceProvider: React.FC<{ children: ReactNode }> = ({ localStorage.getItem("workspacePublicId"); if (data?.length) { - const workspaces = data.map(({ workspace }) => ({ - publicId: workspace.publicId, - name: workspace.name, - })); + const workspaces = data + .map(({ workspace }) => { + if (!workspace) return; - setAvailableWorkspaces(workspaces); + return { + publicId: workspace.publicId, + name: workspace.name, + }; + }) + .filter((workspace) => workspace !== null) as Workspace[]; + + if (workspaces.length) setAvailableWorkspaces(workspaces); } if (storedWorkspaceId !== null) { const newData = data; const selectedWorkspace = newData?.find( - ({ workspace }) => workspace.publicId === storedWorkspaceId, + ({ workspace }) => workspace?.publicId === storedWorkspaceId, ); - if (!selectedWorkspace) return; + if (!selectedWorkspace?.workspace) return; setWorkspace({ publicId: selectedWorkspace.workspace.publicId, diff --git a/src/types/contenteditable.d.ts b/src/types/contenteditable.d.ts new file mode 100644 index 00000000..3fddb0fe --- /dev/null +++ b/src/types/contenteditable.d.ts @@ -0,0 +1,31 @@ +declare module "react-contenteditable" { + import React from "react"; + + type ChangeEventHandler = (event: React.ChangeEvent) => void; + type KeyUpHandler = (event: React.KeyboardEvent) => void; + type KeyDownHandler = (event: React.KeyboardEvent) => void; + + interface ContentEditableProps extends React.HTMLAttributes { + html: string; + onChange?: ChangeEventHandler; + onBlur?: () => void; + onKeyUp?: KeyUpHandler; + onKeyDown?: KeyDownHandler; + disabled?: boolean; + tagName?: string; + className?: string; + style?: React.CSSProperties; + innerRef?: + | React.RefObject + | ((instance: HTMLElement | null) => void); + placeholder?: string; + } + + class ContentEditable extends React.Component {} + + interface ContentEditableElement extends HTMLElement { + value: string; + } + + export default ContentEditable; +} diff --git a/src/utils/supabase/api.ts b/src/utils/supabase/api.ts index aaa989d4..91b9e9fe 100644 --- a/src/utils/supabase/api.ts +++ b/src/utils/supabase/api.ts @@ -1,25 +1,34 @@ -import { createServerClient, type CookieOptions, serialize } from '@supabase/ssr' -import { type NextApiRequest, type NextApiResponse } from 'next' +import { + createServerClient, + type CookieOptions, + serialize, +} from "@supabase/ssr"; +import { type NextApiRequest, type NextApiResponse } from "next"; import { type Database } from "~/types/database.types"; -export default function createClient(req: NextApiRequest, res: NextApiResponse) { +export default function createClient( + req: NextApiRequest, + res: NextApiResponse, +) { const supabase = createServerClient( process.env.NEXT_PUBLIC_SUPABASE_URL!, process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!, { cookies: { get(name: string) { - return req.cookies[name] + return req.cookies[name]; }, set(name: string, value: string, options: CookieOptions) { - res.appendHeader('Set-Cookie', serialize(name, value, options)) + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call + res.appendHeader("Set-Cookie", serialize(name, value, options)); }, remove(name: string, options: CookieOptions) { - res.appendHeader('Set-Cookie', serialize(name, '', options)) + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call + res.appendHeader("Set-Cookie", serialize(name, "", options)); }, }, - } - ) + }, + ); - return supabase -} \ No newline at end of file + return supabase; +} diff --git a/src/views/board/components/NewCardForm.tsx b/src/views/board/components/NewCardForm.tsx index e94e45b3..cac35bfe 100644 --- a/src/views/board/components/NewCardForm.tsx +++ b/src/views/board/components/NewCardForm.tsx @@ -1,4 +1,4 @@ -import { useEffect, useState } from "react"; +import { useEffect } from "react"; import { useForm } from "react-hook-form"; import { api } from "~/utils/api"; @@ -88,7 +88,7 @@ export function NewCardForm({ listPublicId }: NewCardFormProps) { const formattedMembers = boardData?.workspace?.members?.map((member) => ({ key: member.publicId, - value: member.user.name, + value: member.user?.name ?? "", selected: memberPublicIds.includes(member.publicId), })) ?? []; diff --git a/src/views/card/index.tsx b/src/views/card/index.tsx index ada83f64..e0554ceb 100644 --- a/src/views/card/index.tsx +++ b/src/views/card/index.tsx @@ -69,6 +69,7 @@ export default function CardPage() { return { ...member, + user: member.user ?? { id: "", name: null }, selected: isSelected ?? false, }; }) ?? []; diff --git a/src/views/members/index.tsx b/src/views/members/index.tsx index a20407b5..5e5dc896 100644 --- a/src/views/members/index.tsx +++ b/src/views/members/index.tsx @@ -8,7 +8,7 @@ import { NewWorkspaceForm } from "~/components/NewWorkspaceForm"; import { api } from "~/utils/api"; export default function MembersPage() { - const { openModal, modalContentType } = useModal(); + const { modalContentType } = useModal(); const { workspace } = useWorkspace(); const { data } = api.workspace.byId.useQuery( @@ -68,7 +68,7 @@ export default function MembersPage() {
- {member.user.name + {member.user?.name ?.split(" ") .map((namePart) => namePart.charAt(0).toUpperCase(), @@ -81,11 +81,11 @@ export default function MembersPage() {

- {member.user.name} + {member.user?.name}

- {member.user.email} + {member.user?.email}

diff --git a/src/views/settings/index.tsx b/src/views/settings/index.tsx index cb4c9e02..1cdd6be1 100644 --- a/src/views/settings/index.tsx +++ b/src/views/settings/index.tsx @@ -4,7 +4,7 @@ import Modal from "~/components/modal"; import { NewWorkspaceForm } from "~/components/NewWorkspaceForm"; export default function SettingsPage() { - const { openModal, modalContentType } = useModal(); + const { modalContentType } = useModal(); return (
diff --git a/tsconfig.json b/tsconfig.json index 8f55caf2..3803209c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -36,8 +36,10 @@ "**/*.tsx", "**/*.cjs", "**/*.js", - ".next/types/**/*.ts" -, "src/env.mjs" ], + ".next/types/**/*.ts", + "src/env.mjs", + "types/**/*.d.ts" + ], "exclude": ["node_modules"] }