chore: fix types
This commit is contained in:
@@ -19,7 +19,7 @@ export function NewWorkspaceForm() {
|
|||||||
const createWorkspace = api.workspace.create.useMutation({
|
const createWorkspace = api.workspace.create.useMutation({
|
||||||
onSuccess: (values) => {
|
onSuccess: (values) => {
|
||||||
try {
|
try {
|
||||||
if (values?.publicId) {
|
if (values?.publicId && values.name) {
|
||||||
switchWorkspace({ publicId: values.publicId, name: values.name });
|
switchWorkspace({ publicId: values.publicId, name: values.name });
|
||||||
closeModal();
|
closeModal();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,7 @@
|
|||||||
import { redirect } from "next/navigation";
|
|
||||||
|
|
||||||
import SideNavigation from "./SideNavigation";
|
import SideNavigation from "./SideNavigation";
|
||||||
import FeedbackButton from "./FeedbackButton";
|
import FeedbackButton from "./FeedbackButton";
|
||||||
|
|
||||||
export default function Dashboard(props: { children: React.ReactNode }) {
|
export default function Dashboard(props: { children: React.ReactNode }) {
|
||||||
// const session = await auth();
|
|
||||||
|
|
||||||
// if (!session?.user) {
|
|
||||||
// redirect("/api/auth/signin");
|
|
||||||
// }
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex h-screen flex-col items-center bg-light-100 dark:bg-dark-50">
|
<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">
|
<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 { type NextApiRequest, type NextApiResponse } from "next";
|
||||||
import { createNextApiHandler, CreateNextContextOptions } from "@trpc/server/adapters/next";
|
import { createNextApiHandler } from "@trpc/server/adapters/next";
|
||||||
|
|
||||||
import { env } from "~/env.mjs";
|
import { env } from "~/env.mjs";
|
||||||
import { appRouter } from "~/server/api/root";
|
import { appRouter } from "~/server/api/root";
|
||||||
import { createTRPCContext } from "~/server/api/trpc";
|
import { createTRPCContext } from "~/server/api/trpc";
|
||||||
|
|
||||||
|
|
||||||
const nextApiHandler = createNextApiHandler({
|
const nextApiHandler = createNextApiHandler({
|
||||||
router: appRouter,
|
router: appRouter,
|
||||||
createContext: createTRPCContext,
|
createContext: createTRPCContext,
|
||||||
@@ -13,21 +12,16 @@ const nextApiHandler = createNextApiHandler({
|
|||||||
env.NODE_ENV === "development"
|
env.NODE_ENV === "development"
|
||||||
? ({ path, error }) => {
|
? ({ path, error }) => {
|
||||||
console.error(
|
console.error(
|
||||||
`❌ tRPC failed on ${path ?? "<no-path>"}: ${error.message}`
|
`❌ tRPC failed on ${path ?? "<no-path>"}: ${error.message}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
: undefined,
|
: undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
export default async function handler(
|
export default function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||||
req: NextApiRequest,
|
|
||||||
res: NextApiResponse,
|
|
||||||
) {
|
|
||||||
|
|
||||||
return nextApiHandler(req, res);
|
return nextApiHandler(req, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
// export const runtime = "edge";
|
// export const runtime = "edge";
|
||||||
// export const preferredRegion = 'lhr1';
|
// export const preferredRegion = 'lhr1';
|
||||||
// export const dynamic = 'force-dynamic'
|
// export const dynamic = 'force-dynamic'
|
||||||
|
|
||||||
|
|||||||
@@ -58,21 +58,27 @@ export const WorkspaceProvider: React.FC<{ children: ReactNode }> = ({
|
|||||||
localStorage.getItem("workspacePublicId");
|
localStorage.getItem("workspacePublicId");
|
||||||
|
|
||||||
if (data?.length) {
|
if (data?.length) {
|
||||||
const workspaces = data.map(({ workspace }) => ({
|
const workspaces = data
|
||||||
publicId: workspace.publicId,
|
.map(({ workspace }) => {
|
||||||
name: workspace.name,
|
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) {
|
if (storedWorkspaceId !== null) {
|
||||||
const newData = data;
|
const newData = data;
|
||||||
const selectedWorkspace = newData?.find(
|
const selectedWorkspace = newData?.find(
|
||||||
({ workspace }) => workspace.publicId === storedWorkspaceId,
|
({ workspace }) => workspace?.publicId === storedWorkspaceId,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!selectedWorkspace) return;
|
if (!selectedWorkspace?.workspace) return;
|
||||||
|
|
||||||
setWorkspace({
|
setWorkspace({
|
||||||
publicId: selectedWorkspace.workspace.publicId,
|
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 {
|
||||||
import { type NextApiRequest, type NextApiResponse } from 'next'
|
createServerClient,
|
||||||
|
type CookieOptions,
|
||||||
|
serialize,
|
||||||
|
} from "@supabase/ssr";
|
||||||
|
import { type NextApiRequest, type NextApiResponse } from "next";
|
||||||
import { type Database } from "~/types/database.types";
|
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>(
|
const supabase = createServerClient<Database>(
|
||||||
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
||||||
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
|
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
|
||||||
{
|
{
|
||||||
cookies: {
|
cookies: {
|
||||||
get(name: string) {
|
get(name: string) {
|
||||||
return req.cookies[name]
|
return req.cookies[name];
|
||||||
},
|
},
|
||||||
set(name: string, value: string, options: CookieOptions) {
|
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) {
|
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 { useForm } from "react-hook-form";
|
||||||
import { api } from "~/utils/api";
|
import { api } from "~/utils/api";
|
||||||
|
|
||||||
@@ -88,7 +88,7 @@ export function NewCardForm({ listPublicId }: NewCardFormProps) {
|
|||||||
const formattedMembers =
|
const formattedMembers =
|
||||||
boardData?.workspace?.members?.map((member) => ({
|
boardData?.workspace?.members?.map((member) => ({
|
||||||
key: member.publicId,
|
key: member.publicId,
|
||||||
value: member.user.name,
|
value: member.user?.name ?? "",
|
||||||
selected: memberPublicIds.includes(member.publicId),
|
selected: memberPublicIds.includes(member.publicId),
|
||||||
})) ?? [];
|
})) ?? [];
|
||||||
|
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ export default function CardPage() {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
...member,
|
...member,
|
||||||
|
user: member.user ?? { id: "", name: null },
|
||||||
selected: isSelected ?? false,
|
selected: isSelected ?? false,
|
||||||
};
|
};
|
||||||
}) ?? [];
|
}) ?? [];
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { NewWorkspaceForm } from "~/components/NewWorkspaceForm";
|
|||||||
import { api } from "~/utils/api";
|
import { api } from "~/utils/api";
|
||||||
|
|
||||||
export default function MembersPage() {
|
export default function MembersPage() {
|
||||||
const { openModal, modalContentType } = useModal();
|
const { modalContentType } = useModal();
|
||||||
const { workspace } = useWorkspace();
|
const { workspace } = useWorkspace();
|
||||||
|
|
||||||
const { data } = api.workspace.byId.useQuery(
|
const { data } = api.workspace.byId.useQuery(
|
||||||
@@ -68,7 +68,7 @@ export default function MembersPage() {
|
|||||||
<div className="flex-shrink-0">
|
<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="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">
|
<span className="text-sm font-medium leading-none text-white">
|
||||||
{member.user.name
|
{member.user?.name
|
||||||
?.split(" ")
|
?.split(" ")
|
||||||
.map((namePart) =>
|
.map((namePart) =>
|
||||||
namePart.charAt(0).toUpperCase(),
|
namePart.charAt(0).toUpperCase(),
|
||||||
@@ -81,11 +81,11 @@ export default function MembersPage() {
|
|||||||
<div>
|
<div>
|
||||||
<div className="flex items-center">
|
<div className="flex items-center">
|
||||||
<p className="mr-2 text-sm font-medium text-neutral-900 dark:text-dark-1000">
|
<p className="mr-2 text-sm font-medium text-neutral-900 dark:text-dark-1000">
|
||||||
{member.user.name}
|
{member.user?.name}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<p className="truncate text-sm text-dark-900">
|
<p className="truncate text-sm text-dark-900">
|
||||||
{member.user.email}
|
{member.user?.email}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import Modal from "~/components/modal";
|
|||||||
import { NewWorkspaceForm } from "~/components/NewWorkspaceForm";
|
import { NewWorkspaceForm } from "~/components/NewWorkspaceForm";
|
||||||
|
|
||||||
export default function SettingsPage() {
|
export default function SettingsPage() {
|
||||||
const { openModal, modalContentType } = useModal();
|
const { modalContentType } = useModal();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="px-28 py-12">
|
<div className="px-28 py-12">
|
||||||
|
|||||||
@@ -36,8 +36,10 @@
|
|||||||
"**/*.tsx",
|
"**/*.tsx",
|
||||||
"**/*.cjs",
|
"**/*.cjs",
|
||||||
"**/*.js",
|
"**/*.js",
|
||||||
".next/types/**/*.ts"
|
".next/types/**/*.ts",
|
||||||
, "src/env.mjs" ],
|
"src/env.mjs",
|
||||||
|
"types/**/*.d.ts"
|
||||||
|
],
|
||||||
"exclude": ["node_modules"]
|
"exclude": ["node_modules"]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user