Fixed Compile Issues

This commit is contained in:
Ahmad 2024-12-18 21:39:25 -05:00
parent 7578b189ef
commit e006da673e
No known key found for this signature in database
GPG key ID: 8FD8A93530D182BF
13 changed files with 1289 additions and 2620 deletions

View file

@ -77,17 +77,6 @@ const handler = async (data: InputType): Promise<ReturnType> => {
imageLinkHTML, imageLinkHTML,
imageDownloadUrl, imageDownloadUrl,
}, },
select: {
id: true,
title: true,
orgId: true,
imageId: true,
imageThumbUrl: true,
imageFullUrl: true,
imageUserName: true,
imageLinkHTML: true,
imageDownloadUrl: true,
},
}); });
if (!isPro) { if (!isPro) {

View file

@ -29,10 +29,6 @@ const handler = async (data: InputType): Promise<ReturnType> => {
}, },
}, },
}, },
select: {
id: true,
title: true,
},
}); });
await createAuditLog({ await createAuditLog({

View file

@ -28,10 +28,6 @@ const handler = async (data: InputType): Promise<ReturnType> => {
orgId, orgId,
}, },
}, },
select: {
id: true,
title: true,
},
}); });
await createAuditLog({ await createAuditLog({

View file

@ -60,17 +60,6 @@ const handler = async (data: InputType): Promise<ReturnType> => {
imageUserName, imageUserName,
imageDownloadUrl, imageDownloadUrl,
}, },
select: {
id: true,
title: true,
orgId: true,
imageId: true,
imageThumbUrl: true,
imageFullUrl: true,
imageUserName: true,
imageLinkHTML: true,
imageDownloadUrl: true,
},
}); });
await createAuditLog({ await createAuditLog({

View file

@ -32,11 +32,6 @@ const handler = async (data: InputType): Promise<ReturnType> => {
order: card.order, order: card.order,
listId: card.listId, listId: card.listId,
}, },
select: {
id: true,
order: true,
listId: true,
},
}) })
); );

View file

@ -34,15 +34,6 @@ const handler = async (data: InputType): Promise<ReturnType> => {
dueDate: dueDate, dueDate: dueDate,
startedAt: startedAt, startedAt: startedAt,
}, },
select: {
id: true,
title: true,
description: true,
order: true,
listId: true,
dueDate: true,
startedAt: true,
},
}); });
await createAuditLog({ await createAuditLog({

View file

@ -31,11 +31,6 @@ const handler = async (data: InputType): Promise<ReturnType> => {
data: { data: {
title, title,
}, },
select: {
id: true,
title: true,
boardId: true,
},
}); });
await createAuditLog({ await createAuditLog({

View file

@ -1,98 +1,78 @@
import { useState } from 'react'; import { X } from 'lucide-react';
import { useRouter } from 'next/navigation'; import { toast } from 'sonner';
import { zodResolver } from '@hookform/resolvers/zod'; import { useRef } from 'react';
import { useForm } from 'react-hook-form'; import Link from 'next/link';
import { z } from 'zod';
import { updateBoard } from '@/actions/update-board';
import { Button } from '@/components/ui/button'; import { Button } from '@/components/ui/button';
import { Form, FormControl, FormField, FormItem, FormLabel } from '@/components/ui/form'; import {
import { Input } from '@/components/ui/input'; Popover,
import { useToast } from '@/components/ui/use-toast'; PopoverClose,
import { cn } from '@/lib/utils'; PopoverContent,
import { images } from '@/constants/images'; PopoverTrigger,
} from '@/components/ui/popover';
const formSchema = z.object({ import { FormPicker } from '@/components/form/form-picker';
image: z.string().min(1, { import { FormSubmit } from '@/components/form/form-submit';
message: 'Image is required', import { useAction } from '@/hooks/use-action';
}), import { updateBoard } from '@/actions/update-board';
});
interface BoardUpdateImageProps { interface BoardUpdateImageProps {
boardId: string; boardId: string;
image: string;
} }
export function BoardUpdateImage({ boardId, image }: BoardUpdateImageProps) { export const BoardUpdateImage = ({ boardId }: BoardUpdateImageProps) => {
const [isLoading, setIsLoading] = useState(false); const closeRef = useRef<HTMLButtonElement>(null);
const { toast } = useToast();
const router = useRouter();
const form = useForm<z.infer<typeof formSchema>>({ const { execute, fieldErrors } = useAction(updateBoard, {
resolver: zodResolver(formSchema), onSuccess: (data) => {
defaultValues: { toast.success('Board image updated');
image, closeRef.current?.click();
},
onError: (error) => {
toast.error(error);
}, },
}); });
async function onSubmit(values: z.infer<typeof formSchema>) { const onSubmit = (formData: FormData) => {
setIsLoading(true); const image = formData.get('image') as string;
const response = await updateBoard({ execute({ id: boardId, image });
id: boardId, };
image: values.image,
});
setIsLoading(false);
if (response?.error) {
return toast({
title: 'Something went wrong.',
description: response.error,
variant: 'destructive',
});
}
toast({
description: 'Board image updated.',
});
router.refresh();
}
return ( return (
<Form {...form}> <Popover>
<form <PopoverTrigger asChild>
onSubmit={form.handleSubmit(onSubmit)} <Button
className="space-y-8" variant='ghost'
> className='h-auto w-full justify-start p-2 px-5 text-sm font-normal text-neutral-600'
<FormField >
control={form.control} Change Background Image
name="image"
render={({ field }) => (
<FormItem>
<FormLabel>Image</FormLabel>
<FormControl>
<div className="relative">
<Input {...field} />
<img
src={field.value}
alt="Board Image"
className="mt-4 w-full h-auto rounded-lg"
loading="lazy"
/>
</div>
</FormControl>
</FormItem>
)}
/>
<Button type="submit" disabled={isLoading}>
{isLoading && (
<span className="mr-2 h-4 w-4 animate-spin">🔄</span>
)}
Update Image
</Button> </Button>
</form> </PopoverTrigger>
</Form> <PopoverContent className='w-80 pt-3' side='left' align='start'>
<PopoverClose asChild>
<Button
className='absolute right-2 top-2 h-auto w-auto p-2 text-neutral-600'
variant='ghost'
>
<X className='h-4 w-4' />
</Button>
</PopoverClose>
<form action={onSubmit} className='space-y-4'>
<div className='space-y-4'>
<p className='text-center text-xs font-medium italic text-neutral-700'>
Images Provided by{' '}
<Link
className='text-sky-900 underline'
href='https://unsplash.com/'
>
Unsplash
</Link>
</p>
<FormPicker id='image' errors={fieldErrors} />
</div>
<FormSubmit className='w-full'>Update</FormSubmit>
</form>
</PopoverContent>
</Popover>
); );
} };

View file

@ -1,138 +1,76 @@
import { Card } from '@prisma/client'; 'use client';
import { useState } from 'react';
import { useRouter } from 'next/navigation';
import { useForm } from 'react-hook-form';
import { zodResolver } from '@hookform/resolvers/zod';
import { z } from 'zod';
import { LazyLoad } from 'react-lazyload';
import { updateCard } from '@/actions/update-card'; import { useRef, useState } from 'react';
import { deleteCard } from '@/actions/delete-card'; import { Draggable, Droppable } from '@hello-pangea/dnd';
import { Button } from '@/components/ui/button';
import { Form, FormControl, FormField, FormItem, FormLabel } from '@/components/ui/form'; import { ListWithCards } from '@/types';
import { Input } from '@/components/ui/input';
import { useToast } from '@/components/ui/use-toast';
import { cn } from '@/lib/utils'; import { cn } from '@/lib/utils';
const formSchema = z.object({ import { ListHeader } from './list-header';
title: z.string().min(1, { import { CardForm } from './card-form';
message: 'Title is required', import { CardItem } from './card-item';
}),
});
interface ListItemProps { interface ListItemProps {
card: Card; data: ListWithCards;
index: number;
} }
export function ListItem({ card }: ListItemProps) { export const ListItem = ({ index, data }: ListItemProps) => {
const textareaRef = useRef<HTMLTextAreaElement>(null);
const [isEditing, setIsEditing] = useState(false); const [isEditing, setIsEditing] = useState(false);
const [isLoading, setIsLoading] = useState(false);
const { toast } = useToast();
const router = useRouter();
const form = useForm<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema),
defaultValues: {
title: card.title,
},
});
async function onSubmit(values: z.infer<typeof formSchema>) {
setIsLoading(true);
const response = await updateCard({
id: card.id,
title: values.title,
boardId: card.boardId,
});
setIsLoading(false);
if (response?.error) {
return toast({
title: 'Something went wrong.',
description: response.error,
variant: 'destructive',
});
}
toast({
description: 'Card updated.',
});
const disableEditing = () => {
setIsEditing(false); setIsEditing(false);
router.refresh(); };
}
async function onDelete() { const enableEditing = () => {
setIsLoading(true); setIsEditing(true);
setTimeout(() => {
const response = await deleteCard({ textareaRef.current?.focus();
id: card.id,
boardId: card.boardId,
}); });
};
setIsLoading(false);
if (response?.error) {
return toast({
title: 'Something went wrong.',
description: response.error,
variant: 'destructive',
});
}
toast({
description: 'Card deleted.',
});
router.refresh();
}
return ( return (
<LazyLoad height={200} offset={100}> <Draggable draggableId={data.id} index={index}>
<div className="p-4 border rounded-lg shadow-sm"> {(provided) => (
{isEditing ? ( <li
<Form {...form}> {...provided.draggableProps}
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-4"> ref={provided.innerRef}
<FormField className='h-full w-[272px] shrink-0 select-none'
control={form.control} >
name="title" <div
render={({ field }) => ( {...provided.dragHandleProps}
<FormItem> className='w-full rounded-md bg-[#f1f2f4] pb-2 shadow-md'
<FormLabel>Title</FormLabel> >
<FormControl> <ListHeader onAddCard={enableEditing} data={data} />
<Input {...field} /> <Droppable droppableId={data.id} type='card'>
</FormControl> {(provided) => (
</FormItem> <ol
)} ref={provided.innerRef}
/> {...provided.droppableProps}
<div className="flex justify-end space-x-2"> className={cn(
<Button type="button" variant="outline" onClick={() => setIsEditing(false)}> 'mx-1 flex flex-col gap-y-2 px-1 py-0.5',
Cancel data.cards.length > 0 ? 'mt-2' : 'mt-0'
</Button> )}
<Button type="submit" disabled={isLoading}> >
{isLoading && <span className="mr-2 h-4 w-4 animate-spin">🔄</span>} {data.cards.map((card, index) => (
Save <CardItem index={index} key={card.id} data={card} />
</Button> ))}
</div> {provided.placeholder}
</form> </ol>
</Form> )}
) : ( </Droppable>
<div className="flex justify-between items-center"> <CardForm
<span>{card.title}</span> listId={data.id}
<div className="flex space-x-2"> ref={textareaRef}
<Button variant="outline" size="sm" onClick={() => setIsEditing(true)}> isEditing={isEditing}
Edit enableEditing={enableEditing}
</Button> disableEditing={disableEditing}
<Button variant="destructive" size="sm" onClick={onDelete} disabled={isLoading}> />
{isLoading && <span className="mr-2 h-4 w-4 animate-spin">🔄</span>}
Delete
</Button>
</div>
</div> </div>
)} </li>
</div> )}
</LazyLoad> </Draggable>
); );
} };

View file

@ -1,6 +1,6 @@
import Stripe from 'stripe'; import Stripe from 'stripe';
export const stripe = new Stripe(process.env.STRIPE_API_KEY!, { export const stripe = new Stripe(process.env.STRIPE_API_KEY!, {
apiVersion: '2024-11-20.acacia', apiVersion: '2024-12-18.acacia',
typescript: true, typescript: true,
}); });

View file

@ -25,9 +25,7 @@ const nextConfig: NextConfig = {
}, },
pageExtensions: ['ts', 'tsx', 'js', 'jsx', 'md', 'mdx'], pageExtensions: ['ts', 'tsx', 'js', 'jsx', 'md', 'mdx'],
compress: true, compress: true,
serverMiddleware: [ serverMiddleware: [compression()],
compression()
],
}; };
const withMDX = createMDX({}); const withMDX = createMDX({});

View file

@ -6,7 +6,7 @@
"dev": "next dev --turbo", "dev": "next dev --turbo",
"build": "next build", "build": "next build",
"start": "next start", "start": "next start",
"lint": "next lint", "lint": "next lint && tsc --noemit",
"postinstall": "prisma generate --no-engine", "postinstall": "prisma generate --no-engine",
"format": "prettier --check --ignore-path .prettierignore .", "format": "prettier --check --ignore-path .prettierignore .",
"format:fix": "prettier --write --ignore-path .prettierignore ." "format:fix": "prettier --write --ignore-path .prettierignore ."
@ -40,7 +40,7 @@
"@vercel/speed-insights": "^1.1.0", "@vercel/speed-insights": "^1.1.0",
"class-variance-authority": "^0.7.1", "class-variance-authority": "^0.7.1",
"clsx": "^2.1.1", "clsx": "^2.1.1",
"compression": "^1.7.4", "compression": "^1.7.5",
"date-fns": "^4.1.0", "date-fns": "^4.1.0",
"dompurify": "^3.2.3", "dompurify": "^3.2.3",
"lodash": "^4.17.21", "lodash": "^4.17.21",
@ -49,7 +49,6 @@
"react": "^19.0.0", "react": "^19.0.0",
"react-day-picker": "^9.4.4", "react-day-picker": "^9.4.4",
"react-dom": "^19.0.0", "react-dom": "^19.0.0",
"react-lazyload": "^3.2.0",
"sharp": "^0.33.5", "sharp": "^0.33.5",
"sonner": "^1.7.1", "sonner": "^1.7.1",
"stripe": "^17.4.0", "stripe": "^17.4.0",
@ -69,6 +68,7 @@
"@microsoft/eslint-formatter-sarif": "^3.1.0", "@microsoft/eslint-formatter-sarif": "^3.1.0",
"@next/eslint-plugin-next": "15.1.1", "@next/eslint-plugin-next": "15.1.1",
"@tailwindcss/typography": "^0.5.15", "@tailwindcss/typography": "^0.5.15",
"@types/compression": "^1.7.5",
"@types/dompurify": "^3", "@types/dompurify": "^3",
"@types/lodash": "^4.17.13", "@types/lodash": "^4.17.13",
"@types/node": "^22.10.2", "@types/node": "^22.10.2",

3522
yarn.lock

File diff suppressed because it is too large Load diff