feat: create and assign labels on trello import

This commit is contained in:
Henry
2025-01-29 18:00:44 +00:00
parent 34f8ad4def
commit 80067767ce
9 changed files with 1796 additions and 38 deletions

View File

@@ -284,8 +284,7 @@ export const isSlugUnique = async (
.eq("slug", args.slug)
.eq("workspaceId", args.workspaceId)
.is("deletedAt", null)
.limit(1)
.single();
.limit(1);
return !data;
return data?.length === 0;
};

View File

@@ -161,6 +161,18 @@ export const createCardLabelRelationship = async (
return data;
};
export const bulkCreateCardLabelRelationship = async (
db: SupabaseClient<Database>,
cardLabelRelationshipInput: { cardId: number; labelId: number }[],
) => {
const { data } = await db
.from("_card_labels")
.insert(cardLabelRelationshipInput)
.select();
return data;
};
export const getCardMemberRelationship = async (
db: SupabaseClient<Database>,
args: { cardId: number; memberId: number },

View File

@@ -1,7 +1,7 @@
import type { SupabaseClient } from "@supabase/supabase-js";
import type { Database } from "@kan/db/types/database.types";
import { generateUID } from "@kan/utils";
import { generateUID } from "@kan/shared/utils";
export const create = async (
db: SupabaseClient<Database>,

View File

@@ -1,7 +1,7 @@
import type { SupabaseClient } from "@supabase/supabase-js";
import type { Database } from "@kan/db/types/database.types";
import { generateUID } from "@kan/utils";
import { generateUID } from "@kan/shared/utils";
export const create = async (
db: SupabaseClient<Database>,
@@ -35,6 +35,21 @@ export const create = async (
return data;
};
export const bulkCreate = async (
db: SupabaseClient<Database>,
labels: {
publicId: string;
name: string;
colourCode: string;
boardId: number;
createdBy: string;
}[],
) => {
const { data } = await db.from("label").insert(labels).select(`id`);
return data;
};
export const getAllByPublicIds = async (
db: SupabaseClient<Database>,
labelPublicIds: string[],