Formated Files

This commit is contained in:
Ahmad 2024-02-15 20:49:19 -05:00
parent d5631b309a
commit e768d9181f
No known key found for this signature in database
GPG key ID: 8FD8A93530D182BF
138 changed files with 1829 additions and 1851 deletions

View file

@ -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',
};
}

View file

@ -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',
}),
});

View file

@ -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>;