diff --git a/apps/dashboard-app/app/(dashboard)/automations/_components/PublicWorkflows.tsx b/apps/dashboard-app/app/(dashboard)/automations/_components/PublicWorkflows.tsx index 50e64cf..6b564a2 100644 --- a/apps/dashboard-app/app/(dashboard)/automations/_components/PublicWorkflows.tsx +++ b/apps/dashboard-app/app/(dashboard)/automations/_components/PublicWorkflows.tsx @@ -11,11 +11,11 @@ const PublicWorkflows = () => { useEffect(()=>{ async function fetchWorkflows(){ const flows = await getPublicWorkflowsAction(); - console.log(flows) setWorkflows(flows); } fetchWorkflows() },[]) + return (
{workflows?.map((workflow:any) => ( diff --git a/apps/dashboard-app/app/(dashboard)/automations/_components/Template.tsx b/apps/dashboard-app/app/(dashboard)/automations/_components/Template.tsx new file mode 100644 index 0000000..2a72dcf --- /dev/null +++ b/apps/dashboard-app/app/(dashboard)/automations/_components/Template.tsx @@ -0,0 +1,117 @@ +'use client' + +import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from '@repo/ui/molecules/shadcn/Card' +import { ArrowRightIcon, CopyIcon } from 'lucide-react' +import DynamicIcon from '../../../../components/DynamicIcon' +import { useRouter } from 'next/navigation' +import { useSession } from 'next-auth/react' +import { useToast } from '../../../../hooks/useToast' +import { duplicateWorkflow, editFlow, makeFlowPublic } from '../../../actions/workflows/workflow' +import { Label } from '@repo/ui/atoms/shadcn/Label' +import { Switch } from '@repo/ui/molecules/shadcn/Switch' +import { useState } from 'react' +import { Input } from '@repo/ui/atoms/shadcn/Input' +import { Textarea } from '@repo/ui/atoms/shadcn/Textarea' + + +const Template = ({workflow}:any) => { + const router = useRouter(); + const session = useSession(); + const userId = session.data?.user?.id; + const [toggle,setToggle] = useState(workflow.shared || false) + const [name, setName] = useState(workflow.name); + const [description, setDescription] = useState(workflow.description); + const [showNameEdit,setShowNameEdit] = useState(false); + const [showDescriptionEdit,setShowDescriptionEdit] = useState(false); + + const onToggle = async () =>{ + setToggle(!toggle) + await makeFlowPublic(workflow.id,!toggle) + } + + const handleEditName = async () =>{ + if (showNameEdit) { + setName(name) + await editFlow(workflow.id,name,description); + } + setShowNameEdit(!showNameEdit); + // router.refresh(); + } + + const handleEditDescription = async () =>{ + if (showDescriptionEdit){ + setDescription(description) + await editFlow(workflow.id,name,description); + } + setShowDescriptionEdit(!showDescriptionEdit); + } + + return ( + + + +
+ {showNameEdit ? ( + setName(e.target.value)} + onBlur={handleEditName} // Exit edit mode when clicking outside the input + autoFocus // Automatically focus the input when entering edit mode + /> + ) : ( + // Add onDoubleClick to enable editing on double click +
+ {name} +
+ )} +
+
+ + +
+ +
+ +
+ {showDescriptionEdit ? ( +