chore: fix types
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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 (
|
||||
<div className="flex h-screen flex-col items-center bg-light-100 dark:bg-dark-50">
|
||||
<div className="m-auto flex h-16 w-full justify-between border-b border-light-600 px-5 py-2 align-middle dark:border-dark-600">
|
||||
|
||||
@@ -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 ?? "<no-path>"}: ${error.message}`
|
||||
`❌ tRPC failed on ${path ?? "<no-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'
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
31
src/types/contenteditable.d.ts
vendored
Normal file
31
src/types/contenteditable.d.ts
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
declare module "react-contenteditable" {
|
||||
import React from "react";
|
||||
|
||||
type ChangeEventHandler<T = Element> = (event: React.ChangeEvent<T>) => void;
|
||||
type KeyUpHandler<T = Element> = (event: React.KeyboardEvent<T>) => void;
|
||||
type KeyDownHandler<T = Element> = (event: React.KeyboardEvent<T>) => void;
|
||||
|
||||
interface ContentEditableProps extends React.HTMLAttributes<HTMLDivElement> {
|
||||
html: string;
|
||||
onChange?: ChangeEventHandler<HTMLTextAreaElement | HTMLInputElement>;
|
||||
onBlur?: () => void;
|
||||
onKeyUp?: KeyUpHandler<HTMLTextAreaElement | HTMLInputElement>;
|
||||
onKeyDown?: KeyDownHandler<HTMLTextAreaElement | HTMLInputElement>;
|
||||
disabled?: boolean;
|
||||
tagName?: string;
|
||||
className?: string;
|
||||
style?: React.CSSProperties;
|
||||
innerRef?:
|
||||
| React.RefObject<HTMLElement>
|
||||
| ((instance: HTMLElement | null) => void);
|
||||
placeholder?: string;
|
||||
}
|
||||
|
||||
class ContentEditable extends React.Component<ContentEditableProps> {}
|
||||
|
||||
interface ContentEditableElement extends HTMLElement {
|
||||
value: string;
|
||||
}
|
||||
|
||||
export default ContentEditable;
|
||||
}
|
||||
@@ -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<Database>(
|
||||
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
|
||||
}
|
||||
return supabase;
|
||||
}
|
||||
|
||||
@@ -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),
|
||||
})) ?? [];
|
||||
|
||||
|
||||
@@ -69,6 +69,7 @@ export default function CardPage() {
|
||||
|
||||
return {
|
||||
...member,
|
||||
user: member.user ?? { id: "", name: null },
|
||||
selected: isSelected ?? false,
|
||||
};
|
||||
}) ?? [];
|
||||
|
||||
@@ -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() {
|
||||
<div className="flex-shrink-0">
|
||||
<span className="inline-flex h-9 w-9 items-center justify-center rounded-full bg-light-1000 dark:bg-dark-400">
|
||||
<span className="text-sm font-medium leading-none text-white">
|
||||
{member.user.name
|
||||
{member.user?.name
|
||||
?.split(" ")
|
||||
.map((namePart) =>
|
||||
namePart.charAt(0).toUpperCase(),
|
||||
@@ -81,11 +81,11 @@ export default function MembersPage() {
|
||||
<div>
|
||||
<div className="flex items-center">
|
||||
<p className="mr-2 text-sm font-medium text-neutral-900 dark:text-dark-1000">
|
||||
{member.user.name}
|
||||
{member.user?.name}
|
||||
</p>
|
||||
</div>
|
||||
<p className="truncate text-sm text-dark-900">
|
||||
{member.user.email}
|
||||
{member.user?.email}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -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 (
|
||||
<div className="px-28 py-12">
|
||||
|
||||
@@ -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"]
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user