import axios from 'axios'; import React, { ReactNode, useEffect } from 'react'; import { FiUpload, FiEdit, FiFolder, FiArrowRight } from 'react-icons/fi'; import { useDispatch, useSelector } from 'react-redux'; import { useNavigate } from 'react-router-dom'; import { AppDispatch, RootState } from '../../store/store'; import api from '../../config/api'; import { setTransactionId, TRANSACTION_STATUS_ENUMS, updateTransactionStatus } from '../../store/slices/transactionSlice'; export interface StartCard { icon: ReactNode; title: string; description: string; buttonText?: string; bg: string; } const cards = [ { icon: , title: 'Start a Workflow', description: 'Begin by uploading a document and tagging fields.', buttonText: 'Start Now', bg: 'bg-white/60', }, { icon: , title: 'Sign an Agreement', description: 'Upload a document you need to sign and place your signature.', bg: 'bg-white/60', }, { icon: , title: 'Use a Template', description: 'Pick from ready-made templates for common agreements.', bg: 'bg-white/60', }, ]; const StartSection = () => { const navigate = useNavigate(); const dispatch = useDispatch() const user = useSelector((state: RootState) => state.user); if (!user.account || user.account === null) { window.location.href = "/login"; return; } const defaultAccountId = user.account.id; const handleStartSectionClick = (card: StartCard) => { if ("buttonText" in card && card.buttonText === "Start Now") { api.post(`/api/accounts/${defaultAccountId}/transactions`) .then(res => { if (res.status === 200 || res.status === 201) { dispatch(updateTransactionStatus(TRANSACTION_STATUS_ENUMS.TRANSACTION_INITIATED)); dispatch(setTransactionId(res.data)); setTimeout(() => navigate(`/process-step-one/${defaultAccountId}/${res.data.id}`), 0) } }) .catch(err => console.log(err)) } // navigate("/process-step-one"); } // useEffect(() => { // try { // axios.get(`${import.meta.env.VITE_BASE_URI}/api/dashboard`, {"withCredentials": true, "ngrok-skip-browser-warning": "69420"}).then((res) => { // console.log(res) // }) // } catch (error) { // console.log(error) // } // }, []) return (

Get Started

{cards.map((card, index) => (
handleStartSectionClick(card)} key={index} className={`${card.bg} cursor-pointer relative border border-gray-200 rounded-xl p-4 shadow-sm hover:shadow-md transition-all h-full flex flex-col justify-between min-h-[220px]`} > {/* Icon + Text */}
{card.icon}

{card.title}

{card.description}

{/* Bottom Area */}
{card.buttonText ? ( ) : (
)}
))}
); }; export default StartSection;