Flow.tsx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. 'use client';
  2. import React, { useCallback } from 'react'
  3. import { curStepAtom, stepsNodesAtom, viewedStepAtom } from '../store';
  4. import { useAtomValue } from 'jotai';
  5. import { twMerge } from 'tailwind-merge';
  6. import * as R from 'ramda'
  7. const Flow = () => {
  8. const stepsNodes = useAtomValue(stepsNodesAtom)
  9. const curStep = useAtomValue(curStepAtom)
  10. const viewedStep = useAtomValue(viewedStepAtom)
  11. const getNodeName = useCallback((node) => {
  12. return R.cond([
  13. // Form Node
  14. [R.propEq('form_card', 'type'), R.always('表单卡片')],
  15. // Agent Node
  16. [R.propEq('UserTask', 'type'), R.path(['properties', 'item', 'assistantName'])],
  17. [R.T, R.prop('type')]
  18. ])(node)
  19. }, [])
  20. return (
  21. <div className="flex justify-center items-center shadow-xl rounded-box min-h-[150px] p-2">
  22. <ul className="steps">
  23. {stepsNodes.map((stepNode, i) => (
  24. <li
  25. key={i}
  26. className={twMerge(
  27. "step",
  28. i <= curStep ? "step-primary" : '',
  29. )}
  30. {...(i === curStep ? { 'data-content': '★' } : {})}
  31. >
  32. {getNodeName(stepNode)}
  33. </li>
  34. ))}
  35. {/* <li className="step step-primary">Register</li>
  36. <li className="step step-primary">Choose plan</li>
  37. <li className="step">Purchase</li>
  38. <li className="step">Receive Product</li> */}
  39. </ul>
  40. </div>
  41. )
  42. }
  43. export default React.memo(React.forwardRef(Flow))