mirror of
https://github.com/ahmadk953/tasko.git
synced 2025-05-04 04:33:10 +00:00
Formated Files
This commit is contained in:
parent
d5631b309a
commit
e768d9181f
138 changed files with 1829 additions and 1851 deletions
|
@ -1,20 +1,20 @@
|
|||
"use server";
|
||||
'use server';
|
||||
|
||||
import { auth } from "@clerk/nextjs";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { ACTION, ENTITY_TYPE } from "@prisma/client";
|
||||
import { auth } from '@clerk/nextjs';
|
||||
import { revalidatePath } from 'next/cache';
|
||||
import { ACTION, ENTITY_TYPE } from '@prisma/client';
|
||||
|
||||
import { db } from "@/lib/db";
|
||||
import { createAuditLog } from "@/lib/create-audit-log";
|
||||
import { createSafeAction } from "@/lib/create-safe-action";
|
||||
import { db } from '@/lib/db';
|
||||
import { createAuditLog } from '@/lib/create-audit-log';
|
||||
import { createSafeAction } from '@/lib/create-safe-action';
|
||||
|
||||
import { InputType, ReturnType } from "./types";
|
||||
import { CopyCard } from "./schema";
|
||||
import { InputType, ReturnType } from './types';
|
||||
import { CopyCard } from './schema';
|
||||
|
||||
const handler = async (data: InputType): Promise<ReturnType> => {
|
||||
const { userId, orgId } = auth();
|
||||
|
||||
if (!userId || !orgId) return { error: "Unauthorized" };
|
||||
if (!userId || !orgId) return { error: 'Unauthorized' };
|
||||
|
||||
const { id, boardId } = data;
|
||||
let card;
|
||||
|
@ -31,11 +31,11 @@ const handler = async (data: InputType): Promise<ReturnType> => {
|
|||
},
|
||||
});
|
||||
|
||||
if (!cardToCopy) return { error: "Card not found" };
|
||||
if (!cardToCopy) return { error: 'Card not found' };
|
||||
|
||||
const lastCard = await db.card.findFirst({
|
||||
where: { listId: cardToCopy.listId },
|
||||
orderBy: { order: "desc" },
|
||||
orderBy: { order: 'desc' },
|
||||
select: { order: true },
|
||||
});
|
||||
|
||||
|
@ -47,8 +47,8 @@ const handler = async (data: InputType): Promise<ReturnType> => {
|
|||
description: cardToCopy.description,
|
||||
order: newOrder,
|
||||
listId: cardToCopy.listId,
|
||||
}
|
||||
})
|
||||
},
|
||||
});
|
||||
|
||||
await createAuditLog({
|
||||
entityTitle: card.title,
|
||||
|
@ -58,7 +58,7 @@ const handler = async (data: InputType): Promise<ReturnType> => {
|
|||
});
|
||||
} catch (error) {
|
||||
return {
|
||||
error: "Failed to copy card",
|
||||
error: 'Failed to copy card',
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { z } from "zod";
|
||||
import { z } from 'zod';
|
||||
|
||||
export const CopyCard = z.object({
|
||||
id: z.string(),
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { z } from "zod";
|
||||
import { Card } from "@prisma/client";
|
||||
import { z } from 'zod';
|
||||
import { Card } from '@prisma/client';
|
||||
|
||||
import { ActionState } from "@/lib/create-safe-action";
|
||||
import { ActionState } from '@/lib/create-safe-action';
|
||||
|
||||
import { CopyCard } from "./schema";
|
||||
import { CopyCard } from './schema';
|
||||
|
||||
export type InputType = z.infer<typeof CopyCard>;
|
||||
export type ReturnType = ActionState<InputType, Card>;
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
"use server";
|
||||
'use server';
|
||||
|
||||
import { auth } from "@clerk/nextjs";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { ACTION, ENTITY_TYPE } from "@prisma/client";
|
||||
import { auth } from '@clerk/nextjs';
|
||||
import { revalidatePath } from 'next/cache';
|
||||
import { ACTION, ENTITY_TYPE } from '@prisma/client';
|
||||
|
||||
import { db } from "@/lib/db";
|
||||
import { createAuditLog } from "@/lib/create-audit-log";
|
||||
import { createSafeAction } from "@/lib/create-safe-action";
|
||||
import { db } from '@/lib/db';
|
||||
import { createAuditLog } from '@/lib/create-audit-log';
|
||||
import { createSafeAction } from '@/lib/create-safe-action';
|
||||
|
||||
import { InputType, ReturnType } from "./types";
|
||||
import { CopyList } from "./schema";
|
||||
import { InputType, ReturnType } from './types';
|
||||
import { CopyList } from './schema';
|
||||
|
||||
const handler = async (data: InputType): Promise<ReturnType> => {
|
||||
const { userId, orgId } = auth();
|
||||
|
||||
if (!userId || !orgId) return { error: "Unauthorized" };
|
||||
if (!userId || !orgId) return { error: 'Unauthorized' };
|
||||
|
||||
const { id, boardId } = data;
|
||||
let list;
|
||||
|
@ -33,11 +33,11 @@ const handler = async (data: InputType): Promise<ReturnType> => {
|
|||
},
|
||||
});
|
||||
|
||||
if (!listToCopy) return { error: "List not found" };
|
||||
if (!listToCopy) return { error: 'List not found' };
|
||||
|
||||
const lastList = await db.list.findFirst({
|
||||
where: { boardId },
|
||||
orderBy: { order: "desc" },
|
||||
orderBy: { order: 'desc' },
|
||||
select: { order: true },
|
||||
});
|
||||
|
||||
|
@ -71,7 +71,7 @@ const handler = async (data: InputType): Promise<ReturnType> => {
|
|||
});
|
||||
} catch (error) {
|
||||
return {
|
||||
error: "Failed to copy list",
|
||||
error: 'Failed to copy list',
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { z } from "zod";
|
||||
import { z } from 'zod';
|
||||
|
||||
export const CopyList = z.object({
|
||||
id: z.string(),
|
||||
boardId: z.string(),
|
||||
})
|
||||
});
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { z } from "zod";
|
||||
import { List } from "@prisma/client";
|
||||
import { z } from 'zod';
|
||||
import { List } from '@prisma/client';
|
||||
|
||||
import { ActionState } from "@/lib/create-safe-action";
|
||||
import { ActionState } from '@/lib/create-safe-action';
|
||||
|
||||
import { CopyList } from "./schema";
|
||||
import { CopyList } from './schema';
|
||||
|
||||
export type InputType = z.infer<typeof CopyList>;
|
||||
export type ReturnType = ActionState<InputType, List>;
|
||||
export type ReturnType = ActionState<InputType, List>;
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
"use server";
|
||||
'use server';
|
||||
|
||||
import { auth } from "@clerk/nextjs";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { auth } from '@clerk/nextjs';
|
||||
import { revalidatePath } from 'next/cache';
|
||||
|
||||
import { db } from "@/lib/db";
|
||||
import { createSafeAction } from "@/lib/create-safe-action";
|
||||
import { db } from '@/lib/db';
|
||||
import { createSafeAction } from '@/lib/create-safe-action';
|
||||
|
||||
import { InputType, ReturnType } from "./types";
|
||||
import { CreateBoard } from "./schema";
|
||||
import { createAuditLog } from "@/lib/create-audit-log";
|
||||
import { ACTION, ENTITY_TYPE } from "@prisma/client";
|
||||
import { incrementAvailableCount, hasAvailableCount } from "@/lib/org-limit";
|
||||
import { checkSubscription } from "@/lib/subscription";
|
||||
import { InputType, ReturnType } from './types';
|
||||
import { CreateBoard } from './schema';
|
||||
import { createAuditLog } from '@/lib/create-audit-log';
|
||||
import { ACTION, ENTITY_TYPE } from '@prisma/client';
|
||||
import { incrementAvailableCount, hasAvailableCount } from '@/lib/org-limit';
|
||||
import { checkSubscription } from '@/lib/subscription';
|
||||
|
||||
const handler = async (data: InputType): Promise<ReturnType> => {
|
||||
const { userId, orgId } = auth();
|
||||
|
||||
if (!userId || !orgId) {
|
||||
return {
|
||||
error: "Unauthorized",
|
||||
error: 'Unauthorized',
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -28,14 +28,14 @@ const handler = async (data: InputType): Promise<ReturnType> => {
|
|||
if (!canCreate && !isPro) {
|
||||
return {
|
||||
error:
|
||||
"You have reached your limit of free boards. Please upgrade to create more.",
|
||||
'You have reached your limit of free boards. Please upgrade to create more.',
|
||||
};
|
||||
}
|
||||
|
||||
const { title, image } = data;
|
||||
|
||||
const [imageId, imageThumbUrl, imageFullUrl, imageLinkHTML, imageUserName] =
|
||||
image.split("|");
|
||||
image.split('|');
|
||||
|
||||
if (
|
||||
!imageId ||
|
||||
|
@ -45,7 +45,7 @@ const handler = async (data: InputType): Promise<ReturnType> => {
|
|||
!imageLinkHTML
|
||||
) {
|
||||
return {
|
||||
error: "Missing fields. Failed to create board.",
|
||||
error: 'Missing fields. Failed to create board.',
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ const handler = async (data: InputType): Promise<ReturnType> => {
|
|||
});
|
||||
} catch (error) {
|
||||
return {
|
||||
error: "Failed to create board",
|
||||
error: 'Failed to create board',
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
import { z } from "zod";
|
||||
import { z } from 'zod';
|
||||
|
||||
export const CreateBoard = z.object({
|
||||
title: z.string({
|
||||
required_error: "Title is required",
|
||||
invalid_type_error: "Title must be a string",
|
||||
}).min(3, {
|
||||
message: "Title must be at least 3 characters",
|
||||
}),
|
||||
title: z
|
||||
.string({
|
||||
required_error: 'Title is required',
|
||||
invalid_type_error: 'Title must be a string',
|
||||
})
|
||||
.min(3, {
|
||||
message: 'Title must be at least 3 characters',
|
||||
}),
|
||||
image: z.string({
|
||||
required_error: "Image is required",
|
||||
invalid_type_error: "Image must be a string",
|
||||
})
|
||||
});
|
||||
required_error: 'Image is required',
|
||||
invalid_type_error: 'Image must be a string',
|
||||
}),
|
||||
});
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { z } from "zod";
|
||||
import { Board } from "@prisma/client";
|
||||
import { z } from 'zod';
|
||||
import { Board } from '@prisma/client';
|
||||
|
||||
import { ActionState } from "@/lib/create-safe-action";
|
||||
import { CreateBoard } from "./schema";
|
||||
import { ActionState } from '@/lib/create-safe-action';
|
||||
import { CreateBoard } from './schema';
|
||||
|
||||
export type InputType = z.infer<typeof CreateBoard>;
|
||||
export type ReturnType = ActionState<InputType, Board>;
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
"use server";
|
||||
'use server';
|
||||
|
||||
import { auth } from "@clerk/nextjs";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { ACTION, ENTITY_TYPE } from "@prisma/client";
|
||||
import { auth } from '@clerk/nextjs';
|
||||
import { revalidatePath } from 'next/cache';
|
||||
import { ACTION, ENTITY_TYPE } from '@prisma/client';
|
||||
|
||||
import { db } from "@/lib/db";
|
||||
import { createAuditLog } from "@/lib/create-audit-log";
|
||||
import { createSafeAction } from "@/lib/create-safe-action";
|
||||
import { db } from '@/lib/db';
|
||||
import { createAuditLog } from '@/lib/create-audit-log';
|
||||
import { createSafeAction } from '@/lib/create-safe-action';
|
||||
|
||||
import { InputType, ReturnType } from "./types";
|
||||
import { CreateCard } from "./schema";
|
||||
import { InputType, ReturnType } from './types';
|
||||
import { CreateCard } from './schema';
|
||||
|
||||
const handler = async (data: InputType): Promise<ReturnType> => {
|
||||
const { userId, orgId } = auth();
|
||||
|
||||
if (!userId || !orgId) return { error: "Unauthorized" };
|
||||
if (!userId || !orgId) return { error: 'Unauthorized' };
|
||||
|
||||
const { title, boardId, listId } = data;
|
||||
let card;
|
||||
|
@ -29,11 +29,11 @@ const handler = async (data: InputType): Promise<ReturnType> => {
|
|||
},
|
||||
});
|
||||
|
||||
if (!list) return { error: "List not found" };
|
||||
if (!list) return { error: 'List not found' };
|
||||
|
||||
const lastCard = await db.card.findFirst({
|
||||
where: { listId },
|
||||
orderBy: { order: "desc" },
|
||||
orderBy: { order: 'desc' },
|
||||
select: { order: true },
|
||||
});
|
||||
|
||||
|
@ -55,7 +55,7 @@ const handler = async (data: InputType): Promise<ReturnType> => {
|
|||
});
|
||||
} catch (error) {
|
||||
return {
|
||||
error: "Failed to create card",
|
||||
error: 'Failed to create card',
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
import { z } from "zod";
|
||||
import { z } from 'zod';
|
||||
|
||||
export const CreateCard = z.object({
|
||||
title: z.string({
|
||||
required_error: "Card title is required",
|
||||
invalid_type_error: "Card title must be a string",
|
||||
}).min(2, {
|
||||
message: "Card title must be at least 2 characters",
|
||||
}),
|
||||
title: z
|
||||
.string({
|
||||
required_error: 'Card title is required',
|
||||
invalid_type_error: 'Card title must be a string',
|
||||
})
|
||||
.min(2, {
|
||||
message: 'Card title must be at least 2 characters',
|
||||
}),
|
||||
boardId: z.string(),
|
||||
listId: z.string(),
|
||||
})
|
||||
});
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { z } from "zod";
|
||||
import { Card } from "@prisma/client";
|
||||
import { z } from 'zod';
|
||||
import { Card } from '@prisma/client';
|
||||
|
||||
import { ActionState } from "@/lib/create-safe-action";
|
||||
import { ActionState } from '@/lib/create-safe-action';
|
||||
|
||||
import { CreateCard } from "./schema";
|
||||
import { CreateCard } from './schema';
|
||||
|
||||
export type InputType = z.infer<typeof CreateCard>;
|
||||
export type ReturnType = ActionState<InputType, Card>;
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
"use server";
|
||||
'use server';
|
||||
|
||||
import { auth } from "@clerk/nextjs";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { ACTION, ENTITY_TYPE } from "@prisma/client";
|
||||
import { auth } from '@clerk/nextjs';
|
||||
import { revalidatePath } from 'next/cache';
|
||||
import { ACTION, ENTITY_TYPE } from '@prisma/client';
|
||||
|
||||
import { db } from "@/lib/db";
|
||||
import { createAuditLog } from "@/lib/create-audit-log";
|
||||
import { createSafeAction } from "@/lib/create-safe-action";
|
||||
import { db } from '@/lib/db';
|
||||
import { createAuditLog } from '@/lib/create-audit-log';
|
||||
import { createSafeAction } from '@/lib/create-safe-action';
|
||||
|
||||
import { InputType, ReturnType } from "./types";
|
||||
import { CreateList } from "./schema";
|
||||
import { InputType, ReturnType } from './types';
|
||||
import { CreateList } from './schema';
|
||||
|
||||
const handler = async (data: InputType): Promise<ReturnType> => {
|
||||
const { userId, orgId } = auth();
|
||||
|
||||
if (!userId || !orgId) return { error: "Unauthorized" };
|
||||
if (!userId || !orgId) return { error: 'Unauthorized' };
|
||||
|
||||
const { title, boardId } = data;
|
||||
let list;
|
||||
|
@ -27,11 +27,11 @@ const handler = async (data: InputType): Promise<ReturnType> => {
|
|||
},
|
||||
});
|
||||
|
||||
if (!board) return { error: "Board not found" };
|
||||
if (!board) return { error: 'Board not found' };
|
||||
|
||||
const lastList = await db.list.findFirst({
|
||||
where: { boardId: boardId },
|
||||
orderBy: { order: "desc" },
|
||||
orderBy: { order: 'desc' },
|
||||
select: { order: true },
|
||||
});
|
||||
|
||||
|
@ -53,7 +53,7 @@ const handler = async (data: InputType): Promise<ReturnType> => {
|
|||
});
|
||||
} catch (error) {
|
||||
return {
|
||||
error: "Failed to create list",
|
||||
error: 'Failed to create list',
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
import { z } from "zod";
|
||||
import { z } from 'zod';
|
||||
|
||||
export const CreateList = z.object({
|
||||
title: z.string({
|
||||
required_error: "List title is required",
|
||||
invalid_type_error: "List title must be a string",
|
||||
}).min(2, {
|
||||
message: "List title must be at least 2 characters",
|
||||
}),
|
||||
title: z
|
||||
.string({
|
||||
required_error: 'List title is required',
|
||||
invalid_type_error: 'List title must be a string',
|
||||
})
|
||||
.min(2, {
|
||||
message: 'List title must be at least 2 characters',
|
||||
}),
|
||||
boardId: z.string(),
|
||||
})
|
||||
});
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { z } from "zod";
|
||||
import { List } from "@prisma/client";
|
||||
import { z } from 'zod';
|
||||
import { List } from '@prisma/client';
|
||||
|
||||
import { ActionState } from "@/lib/create-safe-action";
|
||||
import { ActionState } from '@/lib/create-safe-action';
|
||||
|
||||
import { CreateList } from "./schema";
|
||||
import { CreateList } from './schema';
|
||||
|
||||
export type InputType = z.infer<typeof CreateList>;
|
||||
export type ReturnType = ActionState<InputType, List>;
|
||||
export type InputType = z.infer<typeof CreateList>;
|
||||
export type ReturnType = ActionState<InputType, List>;
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
"use server";
|
||||
'use server';
|
||||
|
||||
import { auth } from "@clerk/nextjs";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { redirect } from "next/navigation";
|
||||
import { ACTION, ENTITY_TYPE } from "@prisma/client";
|
||||
import { auth } from '@clerk/nextjs';
|
||||
import { revalidatePath } from 'next/cache';
|
||||
import { redirect } from 'next/navigation';
|
||||
import { ACTION, ENTITY_TYPE } from '@prisma/client';
|
||||
|
||||
import { db } from "@/lib/db";
|
||||
import { createAuditLog } from "@/lib/create-audit-log";
|
||||
import { createSafeAction } from "@/lib/create-safe-action";
|
||||
import { decreaseAvailableCount } from "@/lib/org-limit";
|
||||
import { checkSubscription } from "@/lib/subscription";
|
||||
import { db } from '@/lib/db';
|
||||
import { createAuditLog } from '@/lib/create-audit-log';
|
||||
import { createSafeAction } from '@/lib/create-safe-action';
|
||||
import { decreaseAvailableCount } from '@/lib/org-limit';
|
||||
import { checkSubscription } from '@/lib/subscription';
|
||||
|
||||
import { InputType, ReturnType } from "./types";
|
||||
import { DeleteBoard } from "./schema";
|
||||
import { InputType, ReturnType } from './types';
|
||||
import { DeleteBoard } from './schema';
|
||||
|
||||
const handler = async (data: InputType): Promise<ReturnType> => {
|
||||
const { userId, orgId } = auth();
|
||||
|
||||
if (!userId || !orgId) return { error: "Unauthorized" };
|
||||
if (!userId || !orgId) return { error: 'Unauthorized' };
|
||||
|
||||
const isPro = await checkSubscription();
|
||||
|
||||
|
@ -44,7 +44,7 @@ const handler = async (data: InputType): Promise<ReturnType> => {
|
|||
});
|
||||
} catch (error) {
|
||||
return {
|
||||
error: "Failed to delete board",
|
||||
error: 'Failed to delete board',
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { z } from "zod";
|
||||
import { z } from 'zod';
|
||||
|
||||
export const DeleteBoard = z.object({
|
||||
id: z.string(),
|
||||
})
|
||||
});
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { z } from "zod";
|
||||
import { Board } from "@prisma/client";
|
||||
import { z } from 'zod';
|
||||
import { Board } from '@prisma/client';
|
||||
|
||||
import { ActionState } from "@/lib/create-safe-action";
|
||||
import { ActionState } from '@/lib/create-safe-action';
|
||||
|
||||
import { DeleteBoard } from "./schema";
|
||||
import { DeleteBoard } from './schema';
|
||||
|
||||
export type InputType = z.infer<typeof DeleteBoard>;
|
||||
export type ReturnType = ActionState<InputType, Board>;
|
||||
export type ReturnType = ActionState<InputType, Board>;
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
"use server";
|
||||
'use server';
|
||||
|
||||
import { auth } from "@clerk/nextjs";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { ACTION, ENTITY_TYPE } from "@prisma/client";
|
||||
import { auth } from '@clerk/nextjs';
|
||||
import { revalidatePath } from 'next/cache';
|
||||
import { ACTION, ENTITY_TYPE } from '@prisma/client';
|
||||
|
||||
import { db } from "@/lib/db";
|
||||
import { createAuditLog } from "@/lib/create-audit-log";
|
||||
import { createSafeAction } from "@/lib/create-safe-action";
|
||||
import { db } from '@/lib/db';
|
||||
import { createAuditLog } from '@/lib/create-audit-log';
|
||||
import { createSafeAction } from '@/lib/create-safe-action';
|
||||
|
||||
import { InputType, ReturnType } from "./types";
|
||||
import { DeleteCard } from "./schema";
|
||||
import { InputType, ReturnType } from './types';
|
||||
import { DeleteCard } from './schema';
|
||||
|
||||
const handler = async (data: InputType): Promise<ReturnType> => {
|
||||
const { userId, orgId } = auth();
|
||||
|
||||
if (!userId || !orgId) return { error: "Unauthorized" };
|
||||
if (!userId || !orgId) return { error: 'Unauthorized' };
|
||||
|
||||
const { id, boardId } = data;
|
||||
let card;
|
||||
|
@ -39,7 +39,7 @@ const handler = async (data: InputType): Promise<ReturnType> => {
|
|||
});
|
||||
} catch (error) {
|
||||
return {
|
||||
error: "Failed to delete card",
|
||||
error: 'Failed to delete card',
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { z } from "zod";
|
||||
import { z } from 'zod';
|
||||
|
||||
export const DeleteCard = z.object({
|
||||
id: z.string(),
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { z } from "zod";
|
||||
import { Card } from "@prisma/client";
|
||||
import { z } from 'zod';
|
||||
import { Card } from '@prisma/client';
|
||||
|
||||
import { ActionState } from "@/lib/create-safe-action";
|
||||
import { ActionState } from '@/lib/create-safe-action';
|
||||
|
||||
import { DeleteCard } from "./schema";
|
||||
import { DeleteCard } from './schema';
|
||||
|
||||
export type InputType = z.infer<typeof DeleteCard>;
|
||||
export type ReturnType = ActionState<InputType, Card>;
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
"use server";
|
||||
'use server';
|
||||
|
||||
import { auth } from "@clerk/nextjs";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { ACTION, ENTITY_TYPE } from "@prisma/client";
|
||||
import { auth } from '@clerk/nextjs';
|
||||
import { revalidatePath } from 'next/cache';
|
||||
import { ACTION, ENTITY_TYPE } from '@prisma/client';
|
||||
|
||||
import { db } from "@/lib/db";
|
||||
import { createAuditLog } from "@/lib/create-audit-log";
|
||||
import { createSafeAction } from "@/lib/create-safe-action";
|
||||
import { db } from '@/lib/db';
|
||||
import { createAuditLog } from '@/lib/create-audit-log';
|
||||
import { createSafeAction } from '@/lib/create-safe-action';
|
||||
|
||||
import { InputType, ReturnType } from "./types";
|
||||
import { DeleteList } from "./schema";
|
||||
import { InputType, ReturnType } from './types';
|
||||
import { DeleteList } from './schema';
|
||||
|
||||
const handler = async (data: InputType): Promise<ReturnType> => {
|
||||
const { userId, orgId } = auth();
|
||||
|
||||
if (!userId || !orgId) return { error: "Unauthorized" };
|
||||
if (!userId || !orgId) return { error: 'Unauthorized' };
|
||||
|
||||
const { id, boardId } = data;
|
||||
let list;
|
||||
|
@ -38,7 +38,7 @@ const handler = async (data: InputType): Promise<ReturnType> => {
|
|||
});
|
||||
} catch (error) {
|
||||
return {
|
||||
error: "Failed to delete list",
|
||||
error: 'Failed to delete list',
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { z } from "zod";
|
||||
import { z } from 'zod';
|
||||
|
||||
export const DeleteList = z.object({
|
||||
id: z.string(),
|
||||
boardId: z.string(),
|
||||
})
|
||||
});
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { z } from "zod";
|
||||
import { List } from "@prisma/client";
|
||||
import { z } from 'zod';
|
||||
import { List } from '@prisma/client';
|
||||
|
||||
import { ActionState } from "@/lib/create-safe-action";
|
||||
import { ActionState } from '@/lib/create-safe-action';
|
||||
|
||||
import { DeleteList } from "./schema";
|
||||
import { DeleteList } from './schema';
|
||||
|
||||
export type InputType = z.infer<typeof DeleteList>;
|
||||
export type ReturnType = ActionState<InputType, List>;
|
||||
export type ReturnType = ActionState<InputType, List>;
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
"use server";
|
||||
'use server';
|
||||
|
||||
import { auth, currentUser } from "@clerk/nextjs";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { auth, currentUser } from '@clerk/nextjs';
|
||||
import { revalidatePath } from 'next/cache';
|
||||
|
||||
import { db } from "@/lib/db";
|
||||
import { createSafeAction } from "@/lib/create-safe-action";
|
||||
import { absoluteUrl } from "@/lib/utils";
|
||||
import { stripe } from "@/lib/stripe";
|
||||
import { db } from '@/lib/db';
|
||||
import { createSafeAction } from '@/lib/create-safe-action';
|
||||
import { absoluteUrl } from '@/lib/utils';
|
||||
import { stripe } from '@/lib/stripe';
|
||||
|
||||
import { InputType, ReturnType } from "./types";
|
||||
import { StripeRedirect } from "./schema";
|
||||
import { InputType, ReturnType } from './types';
|
||||
import { StripeRedirect } from './schema';
|
||||
|
||||
const handler = async (data: InputType): Promise<ReturnType> => {
|
||||
const { userId, orgId } = auth();
|
||||
const user = await currentUser();
|
||||
|
||||
if (!userId || !orgId || !user) return { error: "Unauthorized" };
|
||||
if (!userId || !orgId || !user) return { error: 'Unauthorized' };
|
||||
|
||||
const settingsUrl = absoluteUrl(`/organization/${orgId}`);
|
||||
|
||||
let url = "";
|
||||
let url = '';
|
||||
|
||||
try {
|
||||
const orgSubscription = await db.orgSubscription.findUnique({
|
||||
|
@ -37,20 +37,20 @@ const handler = async (data: InputType): Promise<ReturnType> => {
|
|||
const stripeSession = await stripe.checkout.sessions.create({
|
||||
success_url: settingsUrl,
|
||||
cancel_url: settingsUrl,
|
||||
payment_method_types: ["card", "paypal"],
|
||||
mode: "subscription",
|
||||
billing_address_collection: "auto",
|
||||
payment_method_types: ['card', 'paypal'],
|
||||
mode: 'subscription',
|
||||
billing_address_collection: 'auto',
|
||||
customer_email: user.emailAddresses[0].emailAddress,
|
||||
line_items: [
|
||||
{
|
||||
price_data: {
|
||||
currency: "usd",
|
||||
currency: 'usd',
|
||||
product_data: {
|
||||
name: "Tasko Pro",
|
||||
description: "Unlimited boards for your organization",
|
||||
name: 'Tasko Pro',
|
||||
description: 'Unlimited boards for your organization',
|
||||
},
|
||||
unit_amount: 2000,
|
||||
recurring: { interval: "month" },
|
||||
recurring: { interval: 'month' },
|
||||
},
|
||||
quantity: 1,
|
||||
},
|
||||
|
@ -60,11 +60,11 @@ const handler = async (data: InputType): Promise<ReturnType> => {
|
|||
},
|
||||
});
|
||||
|
||||
url = stripeSession.url ?? "";
|
||||
url = stripeSession.url ?? '';
|
||||
}
|
||||
} catch (error) {
|
||||
return {
|
||||
error: "Something went wrong",
|
||||
error: 'Something went wrong',
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
import { z } from "zod";
|
||||
import { z } from 'zod';
|
||||
|
||||
export const StripeRedirect = z.object({});
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { z } from "zod";
|
||||
import { z } from 'zod';
|
||||
|
||||
import { ActionState } from "@/lib/create-safe-action";
|
||||
import { ActionState } from '@/lib/create-safe-action';
|
||||
|
||||
import { StripeRedirect } from "./schema";
|
||||
import { StripeRedirect } from './schema';
|
||||
|
||||
export type InputType = z.infer<typeof StripeRedirect>;
|
||||
export type ReturnType = ActionState<InputType, string>;
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
"use server";
|
||||
'use server';
|
||||
|
||||
import { auth } from "@clerk/nextjs";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { ACTION, ENTITY_TYPE } from "@prisma/client";
|
||||
import { auth } from '@clerk/nextjs';
|
||||
import { revalidatePath } from 'next/cache';
|
||||
import { ACTION, ENTITY_TYPE } from '@prisma/client';
|
||||
|
||||
import { db } from "@/lib/db";
|
||||
import { createAuditLog } from "@/lib/create-audit-log";
|
||||
import { createSafeAction } from "@/lib/create-safe-action";
|
||||
import { db } from '@/lib/db';
|
||||
import { createAuditLog } from '@/lib/create-audit-log';
|
||||
import { createSafeAction } from '@/lib/create-safe-action';
|
||||
|
||||
import { InputType, ReturnType } from "./types";
|
||||
import { UpdateBoard } from "./schema";
|
||||
import { InputType, ReturnType } from './types';
|
||||
import { UpdateBoard } from './schema';
|
||||
|
||||
const handler = async (data: InputType): Promise<ReturnType> => {
|
||||
const { userId, orgId } = auth();
|
||||
|
||||
if (!userId || !orgId) return { error: "Unauthorized" };
|
||||
if (!userId || !orgId) return { error: 'Unauthorized' };
|
||||
|
||||
const { title, id } = data;
|
||||
let board;
|
||||
|
@ -38,7 +38,7 @@ const handler = async (data: InputType): Promise<ReturnType> => {
|
|||
});
|
||||
} catch (error) {
|
||||
return {
|
||||
error: "Failed to update board",
|
||||
error: 'Failed to update board',
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -46,4 +46,4 @@ const handler = async (data: InputType): Promise<ReturnType> => {
|
|||
return { data: board };
|
||||
};
|
||||
|
||||
export const updateBoard = createSafeAction(UpdateBoard, handler);
|
||||
export const updateBoard = createSafeAction(UpdateBoard, handler);
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
import { z } from "zod";
|
||||
import { z } from 'zod';
|
||||
|
||||
export const UpdateBoard = z.object({
|
||||
title: z.string({
|
||||
required_error: "Title is required",
|
||||
invalid_type_error: "Title must be a string",
|
||||
}).min(3, {
|
||||
message: "Title must be at least 3 characters",
|
||||
}),
|
||||
title: z
|
||||
.string({
|
||||
required_error: 'Title is required',
|
||||
invalid_type_error: 'Title must be a string',
|
||||
})
|
||||
.min(3, {
|
||||
message: 'Title must be at least 3 characters',
|
||||
}),
|
||||
id: z.string(),
|
||||
})
|
||||
});
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { z } from "zod";
|
||||
import { Board } from "@prisma/client";
|
||||
import { z } from 'zod';
|
||||
import { Board } from '@prisma/client';
|
||||
|
||||
import { ActionState } from "@/lib/create-safe-action";
|
||||
import { ActionState } from '@/lib/create-safe-action';
|
||||
|
||||
import { UpdateBoard } from "./schema";
|
||||
import { UpdateBoard } from './schema';
|
||||
|
||||
export type InputType = z.infer<typeof UpdateBoard>;
|
||||
export type ReturnType = ActionState<InputType, Board>;
|
||||
export type ReturnType = ActionState<InputType, Board>;
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
"use server";
|
||||
'use server';
|
||||
|
||||
import { auth } from "@clerk/nextjs";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { auth } from '@clerk/nextjs';
|
||||
import { revalidatePath } from 'next/cache';
|
||||
|
||||
import { db } from "@/lib/db";
|
||||
import { createSafeAction } from "@/lib/create-safe-action";
|
||||
import { db } from '@/lib/db';
|
||||
import { createSafeAction } from '@/lib/create-safe-action';
|
||||
|
||||
import { InputType, ReturnType } from "./types";
|
||||
import { UpdateCardOrder } from "./schema";
|
||||
import { InputType, ReturnType } from './types';
|
||||
import { UpdateCardOrder } from './schema';
|
||||
|
||||
const handler = async (data: InputType): Promise<ReturnType> => {
|
||||
const { userId, orgId } = auth();
|
||||
|
||||
if (!userId || !orgId) return { error: "Unauthorized" };
|
||||
if (!userId || !orgId) return { error: 'Unauthorized' };
|
||||
|
||||
const { items, boardId } = data;
|
||||
let updatedCards;
|
||||
|
@ -38,7 +38,7 @@ const handler = async (data: InputType): Promise<ReturnType> => {
|
|||
updatedCards = await db.$transaction(transaction);
|
||||
} catch (error) {
|
||||
return {
|
||||
error: "Failed to reorder list",
|
||||
error: 'Failed to reorder list',
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { z } from "zod";
|
||||
import { z } from 'zod';
|
||||
|
||||
export const UpdateCardOrder = z.object({
|
||||
items: z.array(
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { z } from "zod";
|
||||
import { Card } from "@prisma/client";
|
||||
import { z } from 'zod';
|
||||
import { Card } from '@prisma/client';
|
||||
|
||||
import { ActionState } from "@/lib/create-safe-action";
|
||||
import { ActionState } from '@/lib/create-safe-action';
|
||||
|
||||
import { UpdateCardOrder } from "./schema";
|
||||
import { UpdateCardOrder } from './schema';
|
||||
|
||||
export type InputType = z.infer<typeof UpdateCardOrder>;
|
||||
export type ReturnType = ActionState<InputType, Card[]>;
|
||||
export type InputType = z.infer<typeof UpdateCardOrder>;
|
||||
export type ReturnType = ActionState<InputType, Card[]>;
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
"use server";
|
||||
'use server';
|
||||
|
||||
import { auth } from "@clerk/nextjs";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { ACTION, ENTITY_TYPE } from "@prisma/client";
|
||||
import { auth } from '@clerk/nextjs';
|
||||
import { revalidatePath } from 'next/cache';
|
||||
import { ACTION, ENTITY_TYPE } from '@prisma/client';
|
||||
|
||||
import { db } from "@/lib/db";
|
||||
import { createAuditLog } from "@/lib/create-audit-log";
|
||||
import { createSafeAction } from "@/lib/create-safe-action";
|
||||
import { db } from '@/lib/db';
|
||||
import { createAuditLog } from '@/lib/create-audit-log';
|
||||
import { createSafeAction } from '@/lib/create-safe-action';
|
||||
|
||||
import { InputType, ReturnType } from "./types";
|
||||
import { UpdateCard } from "./schema";
|
||||
import { InputType, ReturnType } from './types';
|
||||
import { UpdateCard } from './schema';
|
||||
|
||||
const handler = async (data: InputType): Promise<ReturnType> => {
|
||||
const { userId, orgId } = auth();
|
||||
|
||||
if (!userId || !orgId) return { error: "Unauthorized" };
|
||||
if (!userId || !orgId) return { error: 'Unauthorized' };
|
||||
|
||||
const { id, boardId, ...values } = data;
|
||||
let card;
|
||||
|
@ -42,7 +42,7 @@ const handler = async (data: InputType): Promise<ReturnType> => {
|
|||
});
|
||||
} catch (error) {
|
||||
return {
|
||||
error: "Failed to update card",
|
||||
error: 'Failed to update card',
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
import { z } from "zod";
|
||||
import { z } from 'zod';
|
||||
|
||||
export const UpdateCard = z.object({
|
||||
boardId: z.string(),
|
||||
description: z.optional(
|
||||
z
|
||||
.string({
|
||||
invalid_type_error: "Description must be a string",
|
||||
required_error: "Description is required",
|
||||
invalid_type_error: 'Description must be a string',
|
||||
required_error: 'Description is required',
|
||||
})
|
||||
.min(3, {
|
||||
message: "Description must be at least 3 characters",
|
||||
message: 'Description must be at least 3 characters',
|
||||
})
|
||||
),
|
||||
title: z.optional(
|
||||
z
|
||||
.string({
|
||||
required_error: "Title is required",
|
||||
invalid_type_error: "Title must be a string",
|
||||
required_error: 'Title is required',
|
||||
invalid_type_error: 'Title must be a string',
|
||||
})
|
||||
.min(3, {
|
||||
message: "Title must be at least 3 characters",
|
||||
message: 'Title must be at least 3 characters',
|
||||
})
|
||||
),
|
||||
id: z.string(),
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { z } from "zod";
|
||||
import { Card } from "@prisma/client";
|
||||
import { z } from 'zod';
|
||||
import { Card } from '@prisma/client';
|
||||
|
||||
import { ActionState } from "@/lib/create-safe-action";
|
||||
import { ActionState } from '@/lib/create-safe-action';
|
||||
|
||||
import { UpdateCard } from "./schema";
|
||||
import { UpdateCard } from './schema';
|
||||
|
||||
export type InputType = z.infer<typeof UpdateCard>;
|
||||
export type ReturnType = ActionState<InputType, Card>;
|
||||
export type ReturnType = ActionState<InputType, Card>;
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
"use server";
|
||||
'use server';
|
||||
|
||||
import { auth } from "@clerk/nextjs";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { auth } from '@clerk/nextjs';
|
||||
import { revalidatePath } from 'next/cache';
|
||||
|
||||
import { db } from "@/lib/db";
|
||||
import { createSafeAction } from "@/lib/create-safe-action";
|
||||
import { db } from '@/lib/db';
|
||||
import { createSafeAction } from '@/lib/create-safe-action';
|
||||
|
||||
import { InputType, ReturnType } from "./types";
|
||||
import { UpdateListOrder } from "./schema";
|
||||
import { InputType, ReturnType } from './types';
|
||||
import { UpdateListOrder } from './schema';
|
||||
|
||||
const handler = async (data: InputType): Promise<ReturnType> => {
|
||||
const { userId, orgId } = auth();
|
||||
|
||||
if (!userId || !orgId) return { error: "Unauthorized" };
|
||||
if (!userId || !orgId) return { error: 'Unauthorized' };
|
||||
|
||||
const { items, boardId } = data;
|
||||
let lists;
|
||||
|
@ -35,7 +35,7 @@ const handler = async (data: InputType): Promise<ReturnType> => {
|
|||
lists = await db.$transaction(transaction);
|
||||
} catch (error) {
|
||||
return {
|
||||
error: "Failed to reorder list",
|
||||
error: 'Failed to reorder list',
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { z } from "zod";
|
||||
import { z } from 'zod';
|
||||
|
||||
export const UpdateListOrder = z.object({
|
||||
items: z.array(
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { z } from "zod";
|
||||
import { List } from "@prisma/client";
|
||||
import { z } from 'zod';
|
||||
import { List } from '@prisma/client';
|
||||
|
||||
import { ActionState } from "@/lib/create-safe-action";
|
||||
import { ActionState } from '@/lib/create-safe-action';
|
||||
|
||||
import { UpdateListOrder } from "./schema";
|
||||
import { UpdateListOrder } from './schema';
|
||||
|
||||
export type InputType = z.infer<typeof UpdateListOrder>;
|
||||
export type ReturnType = ActionState<InputType, List[]>;
|
||||
export type InputType = z.infer<typeof UpdateListOrder>;
|
||||
export type ReturnType = ActionState<InputType, List[]>;
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
"use server";
|
||||
'use server';
|
||||
|
||||
import { auth } from "@clerk/nextjs";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { ACTION, ENTITY_TYPE } from "@prisma/client";
|
||||
import { auth } from '@clerk/nextjs';
|
||||
import { revalidatePath } from 'next/cache';
|
||||
import { ACTION, ENTITY_TYPE } from '@prisma/client';
|
||||
|
||||
import { db } from "@/lib/db";
|
||||
import { createAuditLog } from "@/lib/create-audit-log";
|
||||
import { createSafeAction } from "@/lib/create-safe-action";
|
||||
import { db } from '@/lib/db';
|
||||
import { createAuditLog } from '@/lib/create-audit-log';
|
||||
import { createSafeAction } from '@/lib/create-safe-action';
|
||||
|
||||
import { InputType, ReturnType } from "./types";
|
||||
import { UpdateList } from "./schema";
|
||||
import { InputType, ReturnType } from './types';
|
||||
import { UpdateList } from './schema';
|
||||
|
||||
const handler = async (data: InputType): Promise<ReturnType> => {
|
||||
const { userId, orgId } = auth();
|
||||
|
||||
if (!userId || !orgId) return { error: "Unauthorized" };
|
||||
if (!userId || !orgId) return { error: 'Unauthorized' };
|
||||
|
||||
const { title, id, boardId } = data;
|
||||
let list;
|
||||
|
@ -41,7 +41,7 @@ const handler = async (data: InputType): Promise<ReturnType> => {
|
|||
});
|
||||
} catch (error) {
|
||||
return {
|
||||
error: "Failed to update list",
|
||||
error: 'Failed to update list',
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
import { z } from "zod";
|
||||
import { z } from 'zod';
|
||||
|
||||
export const UpdateList = z.object({
|
||||
title: z.string({
|
||||
required_error: "Title is required",
|
||||
invalid_type_error: "Title must be a string",
|
||||
}).min(2, {
|
||||
message: "Title must be at least 2 characters",
|
||||
}),
|
||||
title: z
|
||||
.string({
|
||||
required_error: 'Title is required',
|
||||
invalid_type_error: 'Title must be a string',
|
||||
})
|
||||
.min(2, {
|
||||
message: 'Title must be at least 2 characters',
|
||||
}),
|
||||
id: z.string(),
|
||||
boardId: z.string(),
|
||||
})
|
||||
});
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { z } from "zod";
|
||||
import { List } from "@prisma/client";
|
||||
import { z } from 'zod';
|
||||
import { List } from '@prisma/client';
|
||||
|
||||
import { ActionState } from "@/lib/create-safe-action";
|
||||
import { ActionState } from '@/lib/create-safe-action';
|
||||
|
||||
import { UpdateList } from "./schema";
|
||||
import { UpdateList } from './schema';
|
||||
|
||||
export type InputType = z.infer<typeof UpdateList>;
|
||||
export type ReturnType = ActionState<InputType, List>;
|
||||
export type ReturnType = ActionState<InputType, List>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue