diff --git a/app/[locale]/(routes)/crm/dashboard/_components/CRMKanban.tsx b/app/[locale]/(routes)/crm/dashboard/_components/CRMKanban.tsx index 9b57edb..f4d04f8 100644 --- a/app/[locale]/(routes)/crm/dashboard/_components/CRMKanban.tsx +++ b/app/[locale]/(routes)/crm/dashboard/_components/CRMKanban.tsx @@ -18,7 +18,7 @@ import { DragDropContext, Droppable, Draggable } from "react-beautiful-dnd"; import axios from "axios"; import { useRouter } from "next/navigation"; import { useToast } from "@/components/ui/use-toast"; -import LoadingComponent from "@/components/LoadingComponent"; + import { format } from "date-fns"; import LoadingModal from "@/components/modals/loading-modal"; import { @@ -164,7 +164,7 @@ const CRMKanban = ({ salesStages, opportunities: data }: CRMKanbanProps) => {
- + { - const [optimisticOpportunities, updateOptimisticOpportunities] = - useOptimistic(opportunities, (state) => [...state]); - - return ( -
-
{JSON.stringify(optimisticOpportunities, null, 2)}
-
- ); -}; - -export default CRMKanbanServer; diff --git a/app/[locale]/(routes)/invoice/data-table/data-table-row-actions.tsx b/app/[locale]/(routes)/invoice/data-table/data-table-row-actions.tsx index a27f473..3cad9c0 100644 --- a/app/[locale]/(routes)/invoice/data-table/data-table-row-actions.tsx +++ b/app/[locale]/(routes)/invoice/data-table/data-table-row-actions.tsx @@ -31,6 +31,8 @@ import RightViewModalNoTrigger from "@/components/modals/right-view-notrigger"; import RossumCockpit from "../components/RossumCockpit"; import Link from "next/link"; import LoadingModal from "@/components/modals/loading-modal"; +import { useAppStore } from "@/store/store"; +import { Edit } from "lucide-react"; interface DataTableRowActionsProps { row: Row; @@ -43,6 +45,9 @@ export function DataTableRowActions({ const [openView, setOpenView] = useState(false); const [openRossumView, setOpenRossumView] = useState(false); + //zustand + const { setIsOpen } = useAppStore(); + const router = useRouter(); const { toast } = useToast(); @@ -206,6 +211,14 @@ export function DataTableRowActions({ Preview invoice in new window + { + setIsOpen(true); + }} + > + + Create task from Notion + Rossum setOpenRossumView(true)}> diff --git a/app/[locale]/(routes)/invoice/dialogs/NewTask.tsx b/app/[locale]/(routes)/invoice/dialogs/NewTask.tsx new file mode 100644 index 0000000..e83a050 --- /dev/null +++ b/app/[locale]/(routes)/invoice/dialogs/NewTask.tsx @@ -0,0 +1,258 @@ +"use client"; + +import LoadingComponent from "@/components/LoadingComponent"; +import { Button } from "@/components/ui/button"; +import { + Dialog, + DialogContent, + DialogHeader, + DialogTrigger, + DialogTitle, + DialogDescription, + DialogFooter, +} from "@/components/ui/dialog"; +import { + Form, + FormControl, + FormField, + FormItem, + FormLabel, + FormMessage, +} from "@/components/ui/form"; +import { Input } from "@/components/ui/input"; +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from "@/components/ui/select"; +import { Textarea } from "@/components/ui/textarea"; +import { useToast } from "@/components/ui/use-toast"; +import { useAppStore } from "@/store/store"; +import { zodResolver } from "@hookform/resolvers/zod"; +import axios from "axios"; +import { useRouter } from "next/navigation"; + +import React, { useEffect, useState } from "react"; +import { useForm } from "react-hook-form"; +import { z } from "zod"; + +type Props = { + users: any; + boards: any; +}; + +const NewTaskDialog = ({ users, boards }: Props) => { + //const [open, setOpen] = useState(false); + const [isLoading, setIsLoading] = useState(false); + + const { isOpen, setIsOpen } = useAppStore(); + + const [isMounted, setIsMounted] = useState(false); + + const router = useRouter(); + const { toast } = useToast(); + + const formSchema = z.object({ + title: z.string().min(3).max(255), + user: z.string().min(3).max(255), + board: z.string().min(3).max(255), + priority: z.string().min(3).max(10), + content: z.string().min(3).max(500), + }); + + type NewAccountFormValues = z.infer; + + const form = useForm({ + resolver: zodResolver(formSchema), + }); + + useEffect(() => { + setIsMounted(true); + }, [form]); + + if (!isMounted) { + return null; + } + + //Actions + + const onSubmit = async (data: NewAccountFormValues) => { + setIsLoading(true); + + try { + await axios.post(`/api/projects/tasks/create-task`, data); + toast({ + title: "Success", + description: `New task: ${data.title}, created successfully`, + }); + } catch (error: any) { + toast({ + variant: "destructive", + title: "Error", + description: error?.response?.data, + }); + } finally { + setIsLoading(false); + setIsOpen(false); + } + setIsLoading(false); + setIsOpen(false); + }; + + return ( + + {/* + + */} + + + Create New Tas from Invoice + + + {isLoading ? ( + + ) : ( +
+ {/*
+              {JSON.stringify(form.getValues(), null, 2)}
+            
*/} +
+ +
+ ( + + New task name + + + + + + )} + /> + ( + + Task description + +