Added Copy Board Feature

This commit is contained in:
Ahmad 2024-03-29 23:15:34 -04:00
parent b15a0fbac5
commit 993552226b
No known key found for this signature in database
GPG key ID: 8FD8A93530D182BF
8 changed files with 125 additions and 17 deletions

View file

@ -12,20 +12,37 @@ import {
PopoverContent,
PopoverTrigger,
} from '@/components/ui/popover';
import { copyBoard } from '@/actions/copy-board';
interface BoardOptionsProps {
id: string;
}
export const BoardOptions = ({ id }: BoardOptionsProps) => {
const { execute, isLoading } = useAction(deleteBoard, {
onError: (error) => {
toast.error(error);
},
});
const { execute: executeDelete, isLoading: isLoadingDelete } = useAction(
deleteBoard,
{
onError: (error) => {
toast.error(error);
},
}
);
const { execute: executeCopy, isLoading: isLoadingCopy } = useAction(
copyBoard,
{
onError: (error) => {
toast.error(error);
},
}
);
const onDelete = () => {
execute({ id });
executeDelete({ id });
};
const onCopy = () => {
executeCopy({ id });
};
return (
@ -47,10 +64,18 @@ export const BoardOptions = ({ id }: BoardOptionsProps) => {
<X className='h-4 w-4' />
</Button>
</PopoverClose>
<Button
variant='ghost'
onClick={onCopy}
disabled={isLoadingCopy}
className='h-auto w-full justify-start rounded-none p-2 px-5 text-sm font-normal text-neutral-600'
>
Copy this board
</Button>
<Button
variant='ghost'
onClick={onDelete}
disabled={isLoading}
disabled={isLoadingDelete}
className='h-auto w-full justify-start rounded-none p-2 px-5 text-sm font-normal text-destructive hover:text-destructive'
>
Delete this board