Compare commits
20 Commits
fix/125
...
feat/dashb
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a7062f8cfb | ||
|
|
40f40a0329 | ||
|
|
4bc1cc1eda | ||
|
|
3743fcd88d | ||
|
|
8fb1da8224 | ||
|
|
a6946094f3 | ||
|
|
e3b25abccb | ||
|
|
74a0dc2fc0 | ||
|
|
6c6fd4bd32 | ||
|
|
09066fa47d | ||
|
|
089723d748 | ||
|
|
18c7faac19 | ||
|
|
076fe1d922 | ||
|
|
c58c8c753c | ||
|
|
789b48b715 | ||
|
|
9feb2d3d07 | ||
|
|
54479764f6 | ||
|
|
5c12221f09 | ||
|
|
b9c3ffe7ab | ||
|
|
63d948cc06 |
@@ -167,8 +167,7 @@ export function UpdateBoardSlugForm({
|
||||
!isDirty ||
|
||||
updateBoardSlug.isPending ||
|
||||
errors.slug?.message !== undefined ||
|
||||
isBoardSlugAvailable?.isReserved ||
|
||||
checkBoardSlugAvailability.isLoading
|
||||
isBoardSlugAvailable?.isReserved
|
||||
}
|
||||
>
|
||||
{t`Update`}
|
||||
|
||||
@@ -276,21 +276,6 @@ export const boardRouter = createTRPCRouter({
|
||||
|
||||
await assertUserInWorkspace(ctx.db, userId, board.workspaceId);
|
||||
|
||||
if (input.slug) {
|
||||
const isBoardSlugAvailable = await boardRepo.isBoardSlugAvailable(
|
||||
ctx.db,
|
||||
input.slug,
|
||||
board.workspaceId,
|
||||
);
|
||||
|
||||
if (!isBoardSlugAvailable) {
|
||||
throw new TRPCError({
|
||||
message: `Board slug ${input.slug} is not available`,
|
||||
code: "BAD_REQUEST",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const result = await boardRepo.update(ctx.db, {
|
||||
name: input.name,
|
||||
slug: input.slug,
|
||||
@@ -422,23 +407,11 @@ export const boardRouter = createTRPCRouter({
|
||||
}),
|
||||
)
|
||||
.query(async ({ ctx, input }) => {
|
||||
const board = await boardRepo.getWorkspaceAndBoardIdByBoardPublicId(
|
||||
ctx.db,
|
||||
input.boardPublicId,
|
||||
);
|
||||
|
||||
if (!board)
|
||||
throw new TRPCError({
|
||||
message: `Board with public ID ${input.boardPublicId} not found`,
|
||||
code: "NOT_FOUND",
|
||||
});
|
||||
|
||||
const isBoardSlugAvailable = await boardRepo.isBoardSlugAvailable(
|
||||
ctx.db,
|
||||
input.boardSlug,
|
||||
board.workspaceId,
|
||||
input.boardPublicId,
|
||||
);
|
||||
|
||||
return {
|
||||
isReserved: !isBoardSlugAvailable,
|
||||
};
|
||||
|
||||
@@ -166,19 +166,9 @@ export const initAuth = (db: dbClient) => {
|
||||
databaseHooks: {
|
||||
user: {
|
||||
create: {
|
||||
async before(user) {
|
||||
before() {
|
||||
if (env("NEXT_PUBLIC_DISABLE_SIGN_UP")?.toLowerCase() === "true") {
|
||||
const pendingInvitation = await memberRepo.getByEmailAndStatus(
|
||||
db,
|
||||
user.email,
|
||||
"invited",
|
||||
);
|
||||
|
||||
if (!pendingInvitation) {
|
||||
return Promise.resolve(false);
|
||||
}
|
||||
|
||||
return Promise.resolve(true);
|
||||
return Promise.resolve(false);
|
||||
}
|
||||
return Promise.resolve(true);
|
||||
},
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { and, asc, desc, eq, inArray, isNull, or } from "drizzle-orm";
|
||||
import { and, asc, desc, eq, exists, inArray, isNull, or, sql } from "drizzle-orm";
|
||||
|
||||
import type { dbClient } from "@kan/db/client";
|
||||
import type { BoardVisibilityStatus } from "@kan/db/schema";
|
||||
@@ -481,18 +481,30 @@ export const getWorkspaceAndBoardIdByBoardPublicId = async (
|
||||
export const isBoardSlugAvailable = async (
|
||||
db: dbClient,
|
||||
boardSlug: string,
|
||||
workspaceId: number,
|
||||
boardPublicId: string,
|
||||
) => {
|
||||
const result = await db.query.boards.findFirst({
|
||||
columns: {
|
||||
id: true,
|
||||
},
|
||||
where: and(
|
||||
eq(boards.slug, boardSlug),
|
||||
eq(boards.workspaceId, workspaceId),
|
||||
isNull(boards.deletedAt),
|
||||
),
|
||||
});
|
||||
const result = await db
|
||||
.select({ id: boards.id })
|
||||
.from(boards)
|
||||
.where(
|
||||
and(
|
||||
eq(boards.publicId, boardPublicId),
|
||||
exists(
|
||||
db
|
||||
.select({ id: boards.id })
|
||||
.from(boards)
|
||||
.where(
|
||||
and(
|
||||
eq(boards.slug, boardSlug),
|
||||
eq(boards.workspaceId, sql`${boards.workspaceId}`), // Reference outer query's workspaceId
|
||||
isNull(boards.deletedAt),
|
||||
),
|
||||
)
|
||||
.limit(1),
|
||||
),
|
||||
),
|
||||
)
|
||||
.limit(1);
|
||||
|
||||
return result === undefined;
|
||||
return result.length === 0;
|
||||
};
|
||||
|
||||
@@ -41,20 +41,6 @@ export const getByPublicId = async (db: dbClient, publicId: string) => {
|
||||
});
|
||||
};
|
||||
|
||||
export const getByEmailAndStatus = async (
|
||||
db: dbClient,
|
||||
email: string,
|
||||
status: MemberStatus,
|
||||
) => {
|
||||
return db.query.workspaceMembers.findFirst({
|
||||
where: and(
|
||||
eq(workspaceMembers.email, email),
|
||||
eq(workspaceMembers.status, status),
|
||||
isNull(workspaceMembers.deletedAt),
|
||||
),
|
||||
});
|
||||
};
|
||||
|
||||
export const acceptInvite = async (
|
||||
db: dbClient,
|
||||
args: { memberId: number; userId: string },
|
||||
|
||||
Reference in New Issue
Block a user