import { AnimatePresence } from 'framer-motion'; import { ComponentProps, FunctionComponent } from 'react'; import { Send, X } from 'lucide-react'; import { Button } from '../../../../common/components/atoms/Button/Button'; import { Input } from '../../../../common/components/atoms/Input/Input'; import { Select } from '../../../../common/components/atoms/Select/Select'; import { SelectContent } from '../../../../common/components/atoms/Select/Select.Content'; import { SelectItem } from '../../../../common/components/atoms/Select/Select.Item'; import { SelectTrigger } from '../../../../common/components/atoms/Select/Select.Trigger'; import { SelectValue } from '../../../../common/components/atoms/Select/Select.Value'; import { MotionButton } from '../../../../common/components/molecules/MotionButton/MotionButton'; import { Dialog } from '../../../../common/components/molecules/Dialog/Dialog'; import { capitalize } from '../../../../common/utils/capitalize/capitalize'; import { ctw } from '../../../../common/utils/ctw/ctw'; import { ICallToActionLegacyProps } from './interfaces'; import { useCallToActionLegacyLogic } from '@/lib/blocks/components/CallToActionLegacy/hooks/useCallToActionLegacyLogic/useCallToActionLegacyLogic'; const motionButtonProps = { exit: { opacity: 0, transition: { duration: 0.2 } }, initial: { y: 10, opacity: 0 }, transition: { type: 'spring', bounce: 0.3 }, animate: { y: 0, opacity: 1, transition: { duration: 0.2 } }, } satisfies ComponentProps; export const CallToActionLegacy: FunctionComponent = ({ value }) => { const { contextUpdateMethod, revisionReasons, rejectionReasons, onReuploadReset, onReuploadNeeded, isLoadingReuploadNeeded, onDialogClose, id, directorId, workflow, decision, disabled, dialog, } = value?.props || {}; const { onMutateTaskDecisionById, isLoadingTaskDecisionById, action, actions, onActionChange, reasons, reason, onReasonChange, comment, onCommentChange, noReasons, workflowLevelResolution, isReuploadResetable, handleDialogClose, DialogDescription, } = useCallToActionLegacyLogic({ contextUpdateMethod, revisionReasons, rejectionReasons, onDialogClose, onReuploadReset, workflow, onReuploadNeeded, isLoadingReuploadNeeded, dialog, }); if (value?.text === 'Reject') { return ( {value.text} } content={ <>
{!noReasons && (
)}
{ if (noReasons) { onReasonChange(event.target.value); return; } onCommentChange(event.target.value); }} value={noReasons ? reason : comment} id={noReasons ? `reason` : `comment`} />
} close={ } /> ); } if (value?.text === 'Re-upload needed') { return ( {value.text} {isReuploadResetable && ( { event.stopPropagation(); onReuploadReset?.(); }} /> )} } title={'Mark document for re-upload'} description={} content={ <> {!noReasons && (
)}
{ if (noReasons) { onReasonChange(event.target.value); return; } onCommentChange(event.target.value); }} value={noReasons ? reason : comment} id={noReasons ? `reason` : `comment`} />
} close={ } props={{ title: { className: `text-2xl`, }, content: { className: `mb-96`, }, description: { asChild: true, }, }} /> ); } return ( {value?.text} ); };